|
|
@@ -1,4 +1,4 @@
|
|
|
-import { Attrs, DOMParser, DOMSerializer, Node, NodeSpec } from 'prosemirror-model';
|
|
|
+import { Attrs, DOMParser, DOMSerializer, Node, NodeSpec, Mark, MarkSpec } from 'prosemirror-model';
|
|
|
import { NodeViewConstructor } from 'prosemirror-view';
|
|
|
|
|
|
export const iframeNode: NodeSpec = {
|
|
|
@@ -58,3 +58,42 @@ export const iframeNodeView: NodeViewConstructor = (node, view, getPos, decorati
|
|
|
dom: wrapper,
|
|
|
};
|
|
|
};
|
|
|
+
|
|
|
+export const linkMark: MarkSpec = {
|
|
|
+ attrs: {
|
|
|
+ href: {},
|
|
|
+ title: { default: null },
|
|
|
+ target: { default: null },
|
|
|
+ rel: { default: null },
|
|
|
+ download: { default: null },
|
|
|
+ type: { default: null },
|
|
|
+ },
|
|
|
+ inclusive: false,
|
|
|
+ parseDOM: [
|
|
|
+ {
|
|
|
+ tag: 'a[href]',
|
|
|
+ getAttrs(dom: HTMLElement | string) {
|
|
|
+ if (typeof dom !== 'string') {
|
|
|
+ return {
|
|
|
+ href: dom.getAttribute('href'),
|
|
|
+ title: dom.getAttribute('title'),
|
|
|
+ target: dom.getAttribute('target'),
|
|
|
+ rel: dom.getAttribute('rel'),
|
|
|
+ download: dom.getAttribute('download'),
|
|
|
+ type: dom.getAttribute('type'),
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ toDOM(node) {
|
|
|
+ const { href, title, target, rel, download, type } = node.attrs;
|
|
|
+ const attrs = { href, title, rel, download, type };
|
|
|
+ if (target) {
|
|
|
+ attrs['target'] = target;
|
|
|
+ }
|
|
|
+ return ['a', attrs, 0];
|
|
|
+ },
|
|
|
+};
|