Skip to content

Conversation

@rrahir
Copy link
Collaborator

@rrahir rrahir commented Dec 12, 2025

Currently, we apply a custom style to the cells that contain a content similar to a hyper/markdown link during the rendering process. This means that this style disappears once we export the spreadsheet to other formats (.xlsx for instance ). Furthermore, the detection depends on the elements added to urlRegistry.

In some cases (specifically when loading a spreadsheet in a public page in Odoo) we might populate this registry differently, which leads to a difference of behaviour between renderers of the same raw content.

Since the style was computed during the rendering process, it means that you could not just "get rid" of that style, you had to define a dedicated style to override it, so 'clear format' would never work.

This revision changes our strategy and tries to explicitely apply a specific style when adding a content detected as a hyperlink/markdownling. This way, we ensure that the style is hardcoded in the data and will be consistent when we export it in .xslx files or if we show it on a public page in Odoo.

Task: 5410289

Description:

description of this task, what is implemented and why it is implemented that way.

Task: 5410289

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Collaborator

robodoo commented Dec 12, 2025

Pull request status dashboard

fdamhaut

This comment was marked as resolved.

Copy link
Contributor

@fdamhaut fdamhaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🇫🇷 commentaires en Alexispeech 🇫🇷 et bug avec le reload cf task pad

for (const xc in sheet.cells || {}) {
const content = sheet.cells[xc];
if (content && (isMarkdownLink(content) || isWebLink(content))) {
// debugger;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up

const label = this.link.label
? canonicalizeNumberContent(this.link.label, locale)
: this.link.url;
// TODORAR add this feature to UPDATE_CELL in the composr as well ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO ?

@rrahir rrahir force-pushed the master-force-link-color-as-a-true-style-rar branch from 152e2cb to 36f5691 Compare December 24, 2025 09:50
@rrahir rrahir force-pushed the master-force-link-color-as-a-true-style-rar branch from 36f5691 to 11f3ceb Compare January 12, 2026 07:05
for (const xc in sheet.cells || {}) {
const content = sheet.cells[xc];
if (content && (isMarkdownLink(content) || isWebLink(content))) {
// debugger;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up

@rrahir rrahir force-pushed the master-force-link-color-as-a-true-style-rar branch from 11f3ceb to 557d17a Compare January 14, 2026 06:33
Currently, we apply a custom style to the cells that contain a content
similar to a hyper/markdown link during the rendering process. This
means that this style disappears once we export the spreadsheet to other
formats (.xlsx for instance ). Furthermore, the detection depends on the
elements added to `urlRegistry`.

In some cases (specifically when loading a spreadsheet in a public page
in Odoo) we might populate this registry differently, which leads to a
difference of behaviour between renderers of the same raw content.

Since the style was computed during the rendering process, it means that
you could not just "get rid" of that style, you had to define a
dedicated style to override it, so 'clear format' would never work.

This revision changes our strategy and tries to explicitely apply a
specific style when adding a content detected as a
hyperlink/markdownling. This way, we ensure that the style is hardcoded
in the data and will be consistent when we export it in .xslx files or
if we show it on a public page in Odoo.

Task: 5410289
@rrahir rrahir force-pushed the master-force-link-color-as-a-true-style-rar branch from 557d17a to 7b0aec2 Compare January 14, 2026 06:50
Copy link
Contributor

@hokolomopo hokolomopo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋

Not 100% sure:

  • Evaluated links (eg. =CONCAT("www.google" , ".com"), =If(A1, HYPERLINK(...)) don't work ATM, but with this strategy we have the guarantee that they will never work.
  • We should change every place where we can insert cell content (so also the clipboard), not just the composer.
  • (not sure I understood your commit message correctly) if the urlRegistry is wrong for odoo public spreadsheet, your fix is not enough. The urlRegistry is also used to know if we should display a link popup/what happen on cell click, and those should also work in public spreadsheet.

Maybe its not worth, but I'd add a LinkUIPlugin if we really want to improve the handling of links. It could handle xlsx export/CLEAR_FORMATTING handling, and return a computed style based on the evaluation. I'm not sure links should be mentioned in core at all.

To discuss

})
.add("19.2.0", {
migrate(data: WorkbookData): any {
return addHyperlinkStyle(data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'd also have to do an odoo migration PR if we want to be correct

for (const sheet of data.sheets || []) {
for (const xc in sheet.cells || {}) {
const content = sheet.cells[xc];
if (content && (isMarkdownLink(content) || isWebLink(content))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasHyperlinkContent ?

}

export function hasHyperlinkContent(content: string): boolean {
return isMarkdownLink(content) || isWebLink(content) || content.startsWith("=HYPERLINK(");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it doens't work anymore for =IF(A1, HYPERLINK(...))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: oh it never worked in the first place. Probably it should work ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does work but requires the protocol prefix ^^
=IF(TRUE, CONCAT("https://", "google.com")) works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants