Skip to content

Conversation

@DavidAkkerman
Copy link
Contributor

Review:

  • Commits are atomic
  • Commits have the correct type for the changes made
  • Commits with breaking changes are marked as such

Browsers tested:

(Check any that applies, it's ok to leave boxes unchecked if testing something didn't seem relevant.)

Windows:

  • Chrome
  • Edge
  • Firefox

Linux:

  • Chrome
  • Firefox

macOS:

  • Chrome
  • Firefox
  • Safari

Mobile:

  • Chrome on Android
  • iOS

@DavidAkkerman DavidAkkerman force-pushed the poc-prosemirror-tables branch 2 times, most recently from 4bbe3f8 to e0714ef Compare October 15, 2024 13:46
@DavidAkkerman DavidAkkerman changed the title Poc prosemirror tables [WIP] prosemirror tables Oct 15, 2024
@john-traas john-traas assigned john-traas and unassigned john-traas Oct 22, 2024
@adrianschmidt
Copy link
Contributor

@DavidAkkerman, just an FYI: I've assigned you to this, because it's on the Feature Team board, and we have the workflow that the person that made the PR remains assigned when the PR is put in review, in order to keep some sense of ownership from the developer who made the PR. Then the reviewer also assigns themself to the issue.

So, in the review column (on our board), one assignee means it's ready for review, two assignees means it's being reviewed 😊

setDOMAttr: (value: string, attrs: Record<string, string>) => {
if (value) {
attrs.style =
(attrs.style || '') + `background-color: ${value};`;
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably need to check that we aren't opening up a vulnerability to script injection here. We might need to sanitise the value before using it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did a quick test, and it seems like any tags are encoded if not explicitly allowed
image

Also tried to research a bit, and it seems that the prosemirror developers are generally quite on top of protecting against these kind of things, such as discussed in this forum post https://discuss.prosemirror.net/t/heads-up-xss-risk-in-domserializer/6572.

I do feel a bit out of my comfort zone with this topic though, so I would appreciate a second opinion :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it sounds very reasonable that prosemirror would come with good protections built-in, or at least possible to easily enable (in which case I hope we've done so). What I'm concerned about is if directly manipulating DOM attributes like this, in a plugin, bypasses the built-in protections? I'm a bit unsure where the value of the value parameter comes from? It from the pasted content originally, of course, but has that all first gone through sanitising first, or are we reading it straight from the raw input?

You don't have to be the one who can answer these questions @DavidAkkerman. I'm guessing that @john-traas may have already looked into stuff like this in his previous work on the text editor, and if not, I, John, or someone else from our team can look it up 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

⚡ See comment below about updating the prosemirror-model version.

},
setDOMAttr: (value: string, attrs: Record<string, string>) => {
if (value) {
attrs.style = (attrs.style || '') + `color: ${value};`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, we need to consider injection attacks.

Copy link
Contributor

@john-traas john-traas Nov 14, 2024

Choose a reason for hiding this comment

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

⚡ Just adding this for clarity in case anyone is reading in future. We have updated prosemirror-model to version 1.22.1 as per this thread here

import { createImageRemoverPlugin } from './plugins/image-remover-plugin';
import { createMenuStateTrackingPlugin } from './plugins/menu-state-tracking-plugin';
import { createActionBarInteractionPlugin } from './plugins/menu-action-interaction-plugin';
import { getTableNodes, tableEditingPlugin } from './plugins/table-plugin';
Copy link
Contributor

@adrianschmidt adrianschmidt Oct 29, 2024

Choose a reason for hiding this comment

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

From what I've seen so far, this looks like a very lightweight and well-made addition.

What I'm a little concerned over is whether hardcoding in this plugin might prove problematic as we go forward with making limel-text-editor pluggable. Since this would add a very rudimentary support for tables, it seems fairly likely that, if we make it possible to use your own plugins with limel-text-editor, someone will eventually want to use a plugin that gives more comprehensive support for tables.

  • Do we have any idea if this plugin might be causing conflicts in a scenario like that?
  • Will it be possible to make the use of this plugin the default, will still making it possible to disable it to avoid conflicts with a consumer-provided plugin?

Since adding this now would provide this support by default from that point on. That means that if we need to later make it non-default, and have consumers register the plugin, that would be a breaking change, which we want to avoid if possible.

I don't view this as a total show-stopper, but I want to lift the concern, so we will at least considered it before moving ahead.

@john-traas Your input would be valuable here 🙏

Copy link
Contributor

@john-traas john-traas Oct 31, 2024

Choose a reason for hiding this comment

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

@DavidAkkerman @adrianschmidt I'll take another look at the start of cooldown.

I'm focused on the cycle work at the moment.

@adrianschmidt adrianschmidt self-assigned this Oct 29, 2024
@adrianschmidt adrianschmidt force-pushed the poc-prosemirror-tables branch from 5211671 to 151b20f Compare October 29, 2024 14:57
@john-traas john-traas force-pushed the poc-prosemirror-tables branch from 151b20f to 4ed1c9d Compare November 13, 2024 15:04
@civing civing requested a review from john-traas November 14, 2024 08:16
@john-traas john-traas force-pushed the poc-prosemirror-tables branch 2 times, most recently from c027904 to 78c6aba Compare November 14, 2024 09:15
@john-traas john-traas requested a review from a team as a code owner November 14, 2024 09:15
@john-traas john-traas force-pushed the poc-prosemirror-tables branch from 78c6aba to cfb3135 Compare November 14, 2024 09:27
@anderssonjohan
Copy link
Contributor

FYI - SonarCloud Scan will fail as long as the PR is created in a fork of this repo. We don't allow that (sharing the SONARCLOUD_TOKEN with the fork). I suggest recreating the branch in this repo instead.

Screenshot 2024-11-14 at 11 43 17

@DavidAkkerman
Copy link
Contributor Author

@john-traas I don't have permission to create a branch in this repo, could you do this? Then we can merge to that branch instead

@john-traas john-traas changed the base branch from main to add-tables-plugin-to-text-editor November 14, 2024 12:56
@john-traas john-traas merged commit 705a049 into Lundalogik:add-tables-plugin-to-text-editor Nov 14, 2024
8 of 9 checks passed
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