Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(richtext): text color pasting #17076

Merged
merged 1 commit into from May 15, 2024

Conversation

Rom1-B
Copy link
Contributor

@Rom1-B Rom1-B commented May 6, 2024

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets !32846

When copying text with layout (colors, size, bold, etc.). Depending on the browser, not everything was included.

For example, when copying from MS Word to GLPI, the color was pasted in Firefox, but not in Chrome.

Copy link
Member

@cedric-anne cedric-anne left a comment

Choose a reason for hiding this comment

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

I do not have time to valid this PR right now.

Last time I tried to change this kind of setting value, the result was that pasted HTML code was too verbose (see #15840 (comment)). I am not in favor of this change if the result is that every element of the pasted HTML contains all its computed styles.

@trasher trasher added the javascript Pull requests that update Javascript code label May 13, 2024
@Rom1-B
Copy link
Contributor Author

Rom1-B commented May 13, 2024

I am not in favor of this change if the result is that every element of the pasted HTML contains all its computed styles.

Instead of "all", can we be more specific, would color and font size be enough?

paste_webkit_styles: 'color font-size',

Copy link
Member

@cedric-anne cedric-anne left a comment

Choose a reason for hiding this comment

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

I made some tests and I changed my mind.

Using paste_webkit_styles: 'all', will unify behaviour between webkit browsers (Chrome, Edge, ...) and Firefox. Indeed, for now, the computed styles are cleaned on webkit browsers, but are preserved on Firefox.

Here is the result of a copy/paste of the previous comment of this PR:

<blockquote style="box-sizing: border-box; padding: 0px 1em; color: var(--fgcolor-muted, var(--color-fg-muted)); border-left: .25em solid var(--borderColor-default, var(--color-border-default)); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: #0d1117; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; margin: 0px !important 0px 16px 0px;">
  <p dir="auto" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px;">I am not in favor of this change if the result is that every element of the pasted HTML contains all its computed styles.</p>
</blockquote>
<p dir="auto" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #e6edf3; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: #0d1117; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Instead of "all", can we be more specific, would color and font size be enough?</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" style="box-sizing: border-box; position: relative !important; overflow: auto !important; margin-bottom: 0px !important; color: #e6edf3; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: #0d1117; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
  <pre class="notranslate" style="box-sizing: border-box; font-family: var(--fontStack-monospace, ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace); font-size: 11.9px; margin-top: 0px; margin-bottom: 16px; overflow-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; color: var(--fgcolor-default, var(--color-fg-default)); background-color: var(--bgcolor-muted, var(--color-canvas-subtle)); border-radius: 6px;">
		<code class="notranslate" style="box-sizing: border-box; font-family: var(--fontStack-monospace, ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace); font-size: 11.9px; padding: 0px; margin: 0px; white-space: pre; background: #000000; border-radius: 6px; word-break: normal; border: 0px; display: inline; overflow: visible; line-height: inherit; overflow-wrap: normal;">paste_webkit_styles: 'color font-size',</code>
	</pre>
</div>

The styles attributes will consume some more space in DB, but I guess it is acceptable, as we are using longtext fields for most of the DB fields that contains rich text. Also, I guess that copy/paste operations in rich text editor are often limited to small pieces of content, so the overload will not be that big.

@AdrienClairembault
Copy link
Contributor

I am not able to reproduce the issue on my side but I agree with @cedric-anne last comment.

If you think this deserves a test, a todo could be added for GLPI 11 (as e2e are not available on the bugfix branch).

@cedric-anne cedric-anne merged commit a360e6d into glpi-project:10.0/bugfixes May 15, 2024
13 checks passed
@Rom1-B Rom1-B deleted the support_32846 branch May 15, 2024 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants