Skip to content

Conversation

@z-of-nz
Copy link

@z-of-nz z-of-nz commented Nov 3, 2025

As mentioned before, my task was to create a commenting feature in lexxy: My approach is to use Lexicals MarkNode.
Details:

ActionTextAttachmentMarkNode

  • This model references meta elements (like comments) in rich texts. The actual meta content will be saved and updated in RoR backend
  • MarkNode from lexical is used to spread meta references over multiple html nodes of the rich text
  • Adds an attribute (data-selection-group) for grouping selection before rails creates instance
  • Adds an attribute (data-create-meta-content) for triggering the creation and storage of the meta user input as some ActiveStorage instance in backend
  • Adds an attribute (data-delete-meta-content) for triggering the deletion of the referenced ActiveStorage instance in backend
  • After creation the sgid is used for identification
  • Updating of the meta content (UX and storage) should be provided by the parent application

@jorgemanrubia what is your take on my concept?

Dispatcher Commands for MarkNodes

The command for creating ActionTextAttachmentMarkNode(s) makes sure that all selections (could be several dom elements) are collected and marked by a selectionGroup - this ensures that the backend associates the multiple parts of the comment.

  dispatchInsertMarkNodeOnSelection(metaContent) {
    const selection = $getSelection();
    this.editor.update(() => {
      if ($isRangeSelection(selection)) {
        const isBackward = selection.isBackward();
        let i = 0
        const selectionGroupId = [...Array(8)].map(() => Math.floor(Math.random() * 16).toString(16)).join('');
        $wrapSelectionInMarkNode(selection, isBackward, "", ([]) => {
          let dataset = { selectionGroup: selectionGroupId }
          if (i === 0) { dataset.createMetaContent = metaContent; i++; }
          return new ActionTextAttachmentMarkNode([], dataset)
        });
        dispatch(this.editorElement, "lexxy:addMarkNodeOnSelection", { selectionGroupId: selectionGroupId })
      }
    })
  }
  
  dispatchInsertMarkNodeDeletionTrigger(sgid) {
    this.editor.update(() => {
      const rootNode = $getRoot();
      const traverse = (node) => {
        if (node.getType() === 'action_text_attachment_mark_node' && node.sgid && node.sgid === sgid) {
          const writableNode = node.getWritable();
          writableNode.__dataset.deleteMetaContent = true;
        }
        if ($isElementNode(node)) {
          node.getChildren().forEach(traverse);
        }
      };
      traverse(rootNode);
    })
  }

z-of-nz and others added 30 commits October 21, 2025 19:46
…n" to ALLOWED_HTML_TAGS - adds "style" to ALLOWED_HTML_ATTRIBUTES
Render them as not-previeable attachments
Bumps [turbo-rails](https://github.com/hotwired/turbo-rails) from 2.0.16 to 2.0.20.
- [Release notes](https://github.com/hotwired/turbo-rails/releases)
- [Commits](hotwired/turbo-rails@v2.0.16...v2.0.20)

---
updated-dependencies:
- dependency-name: turbo-rails
  dependency-version: 2.0.20
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [selenium-webdriver](https://github.com/SeleniumHQ/selenium) from 4.35.0 to 4.38.0.
- [Release notes](https://github.com/SeleniumHQ/selenium/releases)
- [Changelog](https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES)
- [Commits](SeleniumHQ/selenium@selenium-4.35.0...selenium-4.38.0)

---
updated-dependencies:
- dependency-name: selenium-webdriver
  dependency-version: 4.38.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [puma](https://github.com/puma/puma) from 7.0.3 to 7.1.0.
- [Release notes](https://github.com/puma/puma/releases)
- [Changelog](https://github.com/puma/puma/blob/main/History.md)
- [Commits](puma/puma@v7.0.3...v7.1.0)

---
updated-dependencies:
- dependency-name: puma
  dependency-version: 7.1.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Otherwise, when there are multiple Lexxy instances on the page, it
always opens the first.
jorgemanrubia and others added 30 commits November 5, 2025 09:19
This will reposition the prompt on every change, so that the content is always
correctly positioned regarding the cursor.
Lexical won´t handle these automatically
…n" to ALLOWED_HTML_TAGS - adds "style" to ALLOWED_HTML_ATTRIBUTES
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.

7 participants