πŸ‡ΊπŸ‡ΈUnited States @matthew.page

Account created on 7 December 2020, over 3 years ago
#

Recent comments

πŸ‡ΊπŸ‡ΈUnited States matthew.page

I'm facing a similar problem with ckeditor5. I've created a function intended to eliminate the data-entity-type and data-entity-uuid upon clicking. However, it currently only detaches the text, leaving the data attributes unchanged. I'm in the process of developing a converter to address this issue by removing the attributes while preserving the text, if that clarifies my approach.

// Method to handle unlinking a file
  unlinkFileCommand() {
    const { editor } = this;
    const { model } = this.editor;
    const { selection } = model.document;
  
    let isUnlinkingInProgress = false;
  
    // Execute the 'unlink' command to remove the link from the selected text.
    editor.execute('unlink');
  
    // This single block wraps all changes that should be in a single undo step.
    model.change(() => {
      // Now, in this single "undo block" let the unlink command flow naturally.
      isUnlinkingInProgress = true;
  
      // Do the unlinking within a single undo step.
      editor.execute('unlink');
  
      // Let's make sure the next unlinking will also be handled.
      isUnlinkingInProgress = false;
  
      // The actual integration that removes the extra attribute.
      model.change((writer) => {
        // Get ranges to unlink.
        let ranges;
  
        const attributeNames = ['data-entity-type', 'data-entity-uuid'];
  
        if (selection.isCollapsed) {
          ranges = [
            findAttributeRange(
              selection.getFirstPosition(),
              attributeNames,
              selection.getAttribute(attributeNames[0]), // Assuming both attributes have the same value.
              model,
            ),
          ];
        } else {
          ranges = model.schema.getValidRanges(
            selection.getRanges(),
            attributeNames,
          );
        }

        // Remove the extra attribute from specified ranges.
        for (const range of ranges) {
           attributeNames.forEach((attr) => {
             writer.removeAttribute(attr, range);
           });
         }

      });
    });
  }
πŸ‡ΊπŸ‡ΈUnited States matthew.page

I'm on Drupal 10.1.8, Ckeditor5. It looks like editor_file and edit_advanced_link modules are sharing this editor_file_dialog window. But the advanced attributes do not work. I noticed Ckeditor5 is actually using their tooltip, balloon (whatever you want to call this tooltip) to add these fields for the edit_advanced_link module. Hence, I'm wondering why this editor_file_dialog is even needed. Was this used for the for Ckeditor4 - 5 conversion?

πŸ‡ΊπŸ‡ΈUnited States matthew.page

Here's the patch. This unsets the advanced attribute fields. That way when you use editor_file module, these fields will be hidden since they do not work.

Production build 0.69.0 2024