Sha256: f99459a7cfd7cf4ca31dfd96458530032027f439f72b66cf362cd6fd7a97d198

Contents?: true

Size: 1.28 KB

Versions: 24

Compression:

Stored size: 1.28 KB

Contents

import { Link } from 'tiptap-extensions'

export default class MaglevLink extends Link {
  get name() {
    return 'link'
  }

  get schema() {
    return {
      attrs: {
        href: {
          default: null,
        },
        target: {
          default: null,
        },
        linkType: {
          default: null,
        },
        linkId: {
          default: null,
        },
        sectionId: {
          default: null,
        },
      },
      inclusive: false,
      parseDOM: [
        {
          tag: 'a[href]',
          getAttrs: (dom) => ({
            href: dom.getAttribute('href'),
            target: dom.getAttribute('target'),
            linkType: dom.getAttribute('maglev-link-type'),
            linkId: dom.getAttribute('maglev-link-id'),
            sectionId: dom.getAttribute('maglev-section-id'),
          }),
        },
      ],
      toDOM: (node) => {
        const { linkType, linkId, sectionId, ...attrs } = node.attrs
        return [
          'a',
          {
            ...attrs,
            rel: 'noopener noreferrer nofollow',
            target: attrs.target || this.options.target,
            'maglev-link-type': linkType,
            'maglev-link-id': linkId,
            'maglev-section-id': sectionId,
          },
          0,
        ]
      },
    }
  }
}

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
maglevcms-1.7.3 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.7.2 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.7.1 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.7.0 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.6.1 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.6.0 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.5.1 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.4.0 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.3.0 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.2.2 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.2.1 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.2.0 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.1.7 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.1.6 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.1.5 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.1.4 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.1.3 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.1.2 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.1.1 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js
maglevcms-1.1.0 app/frontend/editor/components/kit/rich-text-input/extensions/marks/Link.js