Sha256: 130cc24dd90f5f52e2a9ba51ca08086e4b7dcf117a168b22b67b0c1601577430

Contents?: true

Size: 1.28 KB

Versions: 13

Compression:

Stored size: 1.28 KB

Contents

import { PluginKey } from "prosemirror-state";

import { getDictionary } from "src/decidim/i18n";
import BubbleMenu from "src/decidim/editor/common/bubble_menu";

class LinkBubbleMenu extends BubbleMenu {
  shouldDisplay() {
    return this.editor.isActive("link");
  }

  display() {
    const { href } = this.editor.getAttributes("link");
    this.element.querySelector("[data-linkbubble-value]").textContent = href;
  }

  handleAction(action) {
    if (action === "remove") {
      this.editor.chain().focus(null, { scrollIntoView: false }).unsetLink().run();
    } else {
      this.editor.commands.linkDialog();
    }
  }
}

const createElement = () => {
  const i18n = getDictionary("editor.extensions.link.bubbleMenu");

  const element = document.createElement("div");
  element.dataset.linkbubble = "";
  element.innerHTML = `
    <span data-linkbubble-content>
      ${i18n.url}:
      <span data-linkbubble-value></span>
    </span>
    <span data-linkbubble-actions>
      <button type="button" data-action="edit">${i18n.edit}</button>
      <button type="button" data-action="remove">${i18n.remove}</button>
    </span>
  `;

  return element;
};

export default (editor) => {
  return new LinkBubbleMenu({
    editor,
    element: createElement(),
    pluginKey: new PluginKey("LinkBubble")
  });
};

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/packs/src/decidim/editor/extensions/link/bubble_menu.js
decidim-core-0.28.4 app/packs/src/decidim/editor/extensions/link/bubble_menu.js
decidim-core-0.29.0 app/packs/src/decidim/editor/extensions/link/bubble_menu.js
decidim-core-0.28.3 app/packs/src/decidim/editor/extensions/link/bubble_menu.js
decidim-core-0.29.0.rc4 app/packs/src/decidim/editor/extensions/link/bubble_menu.js
decidim-core-0.29.0.rc3 app/packs/src/decidim/editor/extensions/link/bubble_menu.js
decidim-core-0.29.0.rc2 app/packs/src/decidim/editor/extensions/link/bubble_menu.js
decidim-core-0.29.0.rc1 app/packs/src/decidim/editor/extensions/link/bubble_menu.js
decidim-core-0.28.2 app/packs/src/decidim/editor/extensions/link/bubble_menu.js
decidim-core-0.28.1 app/packs/src/decidim/editor/extensions/link/bubble_menu.js
decidim-core-0.28.0 app/packs/src/decidim/editor/extensions/link/bubble_menu.js
decidim-core-0.28.0.rc5 app/packs/src/decidim/editor/extensions/link/bubble_menu.js
decidim-core-0.28.0.rc4 app/packs/src/decidim/editor/extensions/link/bubble_menu.js