@edifice.io/tiptap-extensions 2.0.0-develop-rc.7 → 2.0.0-develop-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abbr/abbr.cjs +1 -1
- package/dist/abbr/abbr.cjs.map +1 -1
- package/dist/abbr/abbr.js +7 -7
- package/dist/abbr/abbr.js.map +1 -1
- package/dist/alert/alert.cjs +1 -1
- package/dist/alert/alert.cjs.map +1 -1
- package/dist/alert/alert.js +6 -6
- package/dist/alert/alert.js.map +1 -1
- package/dist/attachment/attachment.cjs +1 -1
- package/dist/attachment/attachment.cjs.map +1 -1
- package/dist/attachment/attachment.js +29 -29
- package/dist/attachment/attachment.js.map +1 -1
- package/dist/audio/audio.cjs +3 -3
- package/dist/audio/audio.cjs.map +1 -1
- package/dist/audio/audio.js +16 -16
- package/dist/audio/audio.js.map +1 -1
- package/dist/font-size/font-size.cjs +1 -1
- package/dist/font-size/font-size.cjs.map +1 -1
- package/dist/font-size/font-size.js +10 -10
- package/dist/font-size/font-size.js.map +1 -1
- package/dist/heading/heading.cjs +1 -1
- package/dist/heading/heading.cjs.map +1 -1
- package/dist/heading/heading.js +20 -20
- package/dist/heading/heading.js.map +1 -1
- package/dist/highlight/highlight.cjs +1 -1
- package/dist/highlight/highlight.cjs.map +1 -1
- package/dist/highlight/highlight.js +9 -9
- package/dist/highlight/highlight.js.map +1 -1
- package/dist/hyperlink/hyperlink.cjs +1 -1
- package/dist/hyperlink/hyperlink.cjs.map +1 -1
- package/dist/hyperlink/hyperlink.js +13 -13
- package/dist/hyperlink/hyperlink.js.map +1 -1
- package/dist/iframe/iframe.cjs +1 -1
- package/dist/iframe/iframe.cjs.map +1 -1
- package/dist/iframe/iframe.js +17 -17
- package/dist/iframe/iframe.js.map +1 -1
- package/dist/image/custom-image.cjs +1 -1
- package/dist/image/custom-image.cjs.map +1 -1
- package/dist/image/custom-image.js +51 -51
- package/dist/image/custom-image.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +41 -41
- package/dist/line-height/line-height.cjs +1 -1
- package/dist/line-height/line-height.cjs.map +1 -1
- package/dist/line-height/line-height.js +8 -8
- package/dist/line-height/line-height.js.map +1 -1
- package/dist/linker/linker.cjs +1 -1
- package/dist/linker/linker.cjs.map +1 -1
- package/dist/linker/linker.js +16 -16
- package/dist/linker/linker.js.map +1 -1
- package/dist/mathjax/mathjax.cjs +1 -1
- package/dist/mathjax/mathjax.cjs.map +1 -1
- package/dist/mathjax/mathjax.js +9 -9
- package/dist/mathjax/mathjax.js.map +1 -1
- package/dist/paragraph/paragraph.cjs +1 -1
- package/dist/paragraph/paragraph.cjs.map +1 -1
- package/dist/paragraph/paragraph.js +5 -5
- package/dist/paragraph/paragraph.js.map +1 -1
- package/dist/speech-recognition/speech-recognition.cjs +1 -1
- package/dist/speech-recognition/speech-recognition.cjs.map +1 -1
- package/dist/speech-recognition/speech-recognition.js +29 -29
- package/dist/speech-recognition/speech-recognition.js.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.cjs +1 -1
- package/dist/speech-synthesis/speech-synthesis.cjs.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.js +8 -8
- package/dist/speech-synthesis/speech-synthesis.js.map +1 -1
- package/dist/table-cell/table-cell.cjs +1 -1
- package/dist/table-cell/table-cell.cjs.map +1 -1
- package/dist/table-cell/table-cell.js +10 -10
- package/dist/table-cell/table-cell.js.map +1 -1
- package/dist/transform/html-to-json/html-to-json.cjs +1 -1
- package/dist/transform/html-to-json/html-to-json.cjs.map +1 -1
- package/dist/transform/html-to-json/html-to-json.js +3 -3
- package/dist/transform/html-to-json/html-to-json.js.map +1 -1
- package/dist/transform/json-to-html/json-to-html.cjs +1 -1
- package/dist/transform/json-to-html/json-to-html.cjs.map +1 -1
- package/dist/transform/json-to-html/json-to-html.js +3 -3
- package/dist/transform/json-to-html/json-to-html.js.map +1 -1
- package/dist/video/video.cjs +9 -9
- package/dist/video/video.cjs.map +1 -1
- package/dist/video/video.js +40 -40
- package/dist/video/video.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading.js","sources":["../../src/heading/heading.ts"],"sourcesContent":["import { mergeAttributes } from '@tiptap/core';\nimport { Heading } from '@tiptap/extension-heading';\nimport '@tiptap/extension-text-style';\n\nexport declare type Level = 1 | 2;\n\ninterface Options {\n levels: Level[];\n HTMLAttributes: Record<string, any>;\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n customHeading: {\n /**\n * Apply Heading Level\n */\n setCustomHeading: (attributes: { level: Level }) => ReturnType;\n };\n }\n}\n\nexport const CustomHeading = Heading.extend<Options>({\n name: 'customHeading',\n\n addOptions() {\n return {\n ...this.parent?.(),\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return this.options.levels.map((level: Level) => ({\n tag: `h${level}`,\n attrs: { level },\n }));\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const hasLevel = this.options.levels.includes(node.attrs.level);\n const level = hasLevel ? node.attrs.level : this.options.levels[0];\n\n return [\n `h${level}`,\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setCustomHeading:\n (attributes) =>\n ({ tr, dispatch, commands }) => {\n if (!this.options.levels.includes(attributes.level)) {\n return false;\n }\n\n const { selection } = tr;\n const { from, to } = selection;\n\n tr.doc.nodesBetween(from, to, (node, pos) => {\n if (node.isBlock && from >= pos && to <= pos + node.nodeSize) {\n /* get node content and iterate through */\n node.content.forEach((content) => {\n /* get content marks and iterate through */\n content.marks.forEach((mark) => {\n /* find textStyle mark and if has fontSize attrs */\n if (\n mark.type.name === 'textStyle' &&\n mark.attrs['fontSize'] &&\n mark.attrs['fontSize'] !== null\n ) {\n /* remove any fontSize attr to reset heading style */\n tr = tr.removeMark(pos, pos + node.nodeSize, mark.type);\n }\n });\n });\n }\n });\n\n if (dispatch) {\n dispatch(tr);\n }\n return commands.setHeading({ level: attributes.level });\n },\n };\n },\n});\n"],"names":[],"mappings":";;;AAsBa,
|
|
1
|
+
{"version":3,"file":"heading.js","sources":["../../src/heading/heading.ts"],"sourcesContent":["import { mergeAttributes } from '@tiptap/core';\nimport { Heading } from '@tiptap/extension-heading';\nimport '@tiptap/extension-text-style';\n\nexport declare type Level = 1 | 2;\n\ninterface Options {\n levels: Level[];\n HTMLAttributes: Record<string, any>;\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n customHeading: {\n /**\n * Apply Heading Level\n */\n setCustomHeading: (attributes: { level: Level }) => ReturnType;\n };\n }\n}\n\nexport const CustomHeading = Heading.extend<Options>({\n name: 'customHeading',\n\n addOptions() {\n return {\n ...this.parent?.(),\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return this.options.levels.map((level: Level) => ({\n tag: `h${level}`,\n attrs: { level },\n }));\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const hasLevel = this.options.levels.includes(node.attrs.level);\n const level = hasLevel ? node.attrs.level : this.options.levels[0];\n\n return [\n `h${level}`,\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setCustomHeading:\n (attributes) =>\n ({ tr, dispatch, commands }) => {\n if (!this.options.levels.includes(attributes.level)) {\n return false;\n }\n\n const { selection } = tr;\n const { from, to } = selection;\n\n tr.doc.nodesBetween(from, to, (node, pos) => {\n if (node.isBlock && from >= pos && to <= pos + node.nodeSize) {\n /* get node content and iterate through */\n node.content.forEach((content) => {\n /* get content marks and iterate through */\n content.marks.forEach((mark) => {\n /* find textStyle mark and if has fontSize attrs */\n if (\n mark.type.name === 'textStyle' &&\n mark.attrs['fontSize'] &&\n mark.attrs['fontSize'] !== null\n ) {\n /* remove any fontSize attr to reset heading style */\n tr = tr.removeMark(pos, pos + node.nodeSize, mark.type);\n }\n });\n });\n }\n });\n\n if (dispatch) {\n dispatch(tr);\n }\n return commands.setHeading({ level: attributes.level });\n },\n };\n },\n});\n"],"names":["CustomHeading","Heading","_a","level","node","HTMLAttributes","mergeAttributes","attributes","tr","dispatch","commands","selection","from","to","pos","content","mark"],"mappings":";;;AAsBa,MAAAA,IAAgBC,EAAQ,OAAgB;AAAA,EACnD,MAAM;AAAA,EAEN,aAAa;;AACJ,WAAA;AAAA,MACL,IAAGC,IAAA,KAAK,WAAL,gBAAAA,EAAA;AAAA,MACH,gBAAgB,CAAC;AAAA,IAAA;AAAA,EAErB;AAAA,EAEA,YAAY;AACV,WAAO,KAAK,QAAQ,OAAO,IAAI,CAACC,OAAkB;AAAA,MAChD,KAAK,IAAIA,CAAK;AAAA,MACd,OAAO,EAAE,OAAAA,EAAM;AAAA,IACf,EAAA;AAAA,EACJ;AAAA,EAEA,WAAW,EAAE,MAAAC,GAAM,gBAAAC,KAAkB;AAI5B,WAAA;AAAA,MACL,IAJe,KAAK,QAAQ,OAAO,SAASD,EAAK,MAAM,KAAK,IACrCA,EAAK,MAAM,QAAQ,KAAK,QAAQ,OAAO,CAAC,CAGtD;AAAA,MACTE,EAAgB,KAAK,QAAQ,gBAAgBD,CAAc;AAAA,MAC3D;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,kBACE,CAACE,MACD,CAAC,EAAE,IAAAC,GAAI,UAAAC,GAAU,UAAAC,QAAe;AAC9B,YAAI,CAAC,KAAK,QAAQ,OAAO,SAASH,EAAW,KAAK;AACzC,iBAAA;AAGH,cAAA,EAAE,WAAAI,EAAc,IAAAH,GAChB,EAAE,MAAAI,GAAM,IAAAC,EAAO,IAAAF;AAErB,eAAAH,EAAG,IAAI,aAAaI,GAAMC,GAAI,CAACT,GAAMU,MAAQ;AAC3C,UAAIV,EAAK,WAAWQ,KAAQE,KAAOD,KAAMC,IAAMV,EAAK,YAE7CA,EAAA,QAAQ,QAAQ,CAACW,MAAY;AAExB,YAAAA,EAAA,MAAM,QAAQ,CAACC,MAAS;AAE9B,cACEA,EAAK,KAAK,SAAS,eACnBA,EAAK,MAAM,YACXA,EAAK,MAAM,aAAgB,SAG3BR,IAAKA,EAAG,WAAWM,GAAKA,IAAMV,EAAK,UAAUY,EAAK,IAAI;AAAA,YACxD,CACD;AAAA,UAAA,CACF;AAAA,QACH,CACD,GAEGP,KACFA,EAASD,CAAE,GAENE,EAAS,WAAW,EAAE,OAAOH,EAAW,OAAO;AAAA,MACxD;AAAA,IAAA;AAAA,EAEN;AACF,CAAC;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@tiptap/extension-highlight"),i=r.extend({name:"customHighlight",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),multicolor:!0,HTMLAttributes:{}}},parseHTML(){var t;return[{...(t=this.parent)==null?void 0:t.call(this),style:"background-color",getAttrs:e=>({color:e})}]}});exports.CustomHighlight=i;
|
|
2
2
|
//# sourceMappingURL=highlight.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight.cjs","sources":["../../src/highlight/highlight.ts"],"sourcesContent":["import Highlight from '@tiptap/extension-highlight';\n\nexport const CustomHighlight = Highlight.extend({\n name: 'customHighlight',\n\n addOptions() {\n return {\n ...this.parent?.(),\n multicolor: true,\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return [\n {\n ...this.parent?.(),\n style: 'background-color',\n getAttrs: (style) => {\n return {\n color: style,\n };\n },\n },\n ];\n },\n});\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"highlight.cjs","sources":["../../src/highlight/highlight.ts"],"sourcesContent":["import Highlight from '@tiptap/extension-highlight';\n\nexport const CustomHighlight = Highlight.extend({\n name: 'customHighlight',\n\n addOptions() {\n return {\n ...this.parent?.(),\n multicolor: true,\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return [\n {\n ...this.parent?.(),\n style: 'background-color',\n getAttrs: (style) => {\n return {\n color: style,\n };\n },\n },\n ];\n },\n});\n"],"names":["CustomHighlight","Highlight","_a","style"],"mappings":"+HAEaA,EAAkBC,EAAU,OAAO,CAC9C,KAAM,kBAEN,YAAa,OACJ,MAAA,CACL,IAAGC,EAAA,KAAK,SAAL,YAAAA,EAAA,WACH,WAAY,GACZ,eAAgB,CAAC,CAAA,CAErB,EAEA,WAAY,OACH,MAAA,CACL,CACE,IAAGA,EAAA,KAAK,SAAL,YAAAA,EAAA,WACH,MAAO,mBACP,SAAWC,IACF,CACL,MAAOA,CAAA,EAGb,CAAA,CAEJ,CACF,CAAC"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
1
|
+
import e from "@tiptap/extension-highlight";
|
|
2
|
+
const i = e.extend({
|
|
3
3
|
name: "customHighlight",
|
|
4
4
|
addOptions() {
|
|
5
|
-
var
|
|
5
|
+
var t;
|
|
6
6
|
return {
|
|
7
|
-
...(
|
|
7
|
+
...(t = this.parent) == null ? void 0 : t.call(this),
|
|
8
8
|
multicolor: !0,
|
|
9
9
|
HTMLAttributes: {}
|
|
10
10
|
};
|
|
11
11
|
},
|
|
12
12
|
parseHTML() {
|
|
13
|
-
var
|
|
13
|
+
var t;
|
|
14
14
|
return [
|
|
15
15
|
{
|
|
16
|
-
...(
|
|
16
|
+
...(t = this.parent) == null ? void 0 : t.call(this),
|
|
17
17
|
style: "background-color",
|
|
18
|
-
getAttrs: (
|
|
19
|
-
color:
|
|
18
|
+
getAttrs: (r) => ({
|
|
19
|
+
color: r
|
|
20
20
|
})
|
|
21
21
|
}
|
|
22
22
|
];
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
export {
|
|
26
|
-
CustomHighlight
|
|
26
|
+
i as CustomHighlight
|
|
27
27
|
};
|
|
28
28
|
//# sourceMappingURL=highlight.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight.js","sources":["../../src/highlight/highlight.ts"],"sourcesContent":["import Highlight from '@tiptap/extension-highlight';\n\nexport const CustomHighlight = Highlight.extend({\n name: 'customHighlight',\n\n addOptions() {\n return {\n ...this.parent?.(),\n multicolor: true,\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return [\n {\n ...this.parent?.(),\n style: 'background-color',\n getAttrs: (style) => {\n return {\n color: style,\n };\n },\n },\n ];\n },\n});\n"],"names":[],"mappings":";AAEa,
|
|
1
|
+
{"version":3,"file":"highlight.js","sources":["../../src/highlight/highlight.ts"],"sourcesContent":["import Highlight from '@tiptap/extension-highlight';\n\nexport const CustomHighlight = Highlight.extend({\n name: 'customHighlight',\n\n addOptions() {\n return {\n ...this.parent?.(),\n multicolor: true,\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return [\n {\n ...this.parent?.(),\n style: 'background-color',\n getAttrs: (style) => {\n return {\n color: style,\n };\n },\n },\n ];\n },\n});\n"],"names":["CustomHighlight","Highlight","_a","style"],"mappings":";AAEa,MAAAA,IAAkBC,EAAU,OAAO;AAAA,EAC9C,MAAM;AAAA,EAEN,aAAa;;AACJ,WAAA;AAAA,MACL,IAAGC,IAAA,KAAK,WAAL,gBAAAA,EAAA;AAAA,MACH,YAAY;AAAA,MACZ,gBAAgB,CAAC;AAAA,IAAA;AAAA,EAErB;AAAA,EAEA,YAAY;;AACH,WAAA;AAAA,MACL;AAAA,QACE,IAAGA,IAAA,KAAK,WAAL,gBAAAA,EAAA;AAAA,QACH,OAAO;AAAA,QACP,UAAU,CAACC,OACF;AAAA,UACL,OAAOA;AAAA,QAAA;AAAA,MAGb;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@tiptap/extension-link"),i=r.Link.extend({name:"hyperlink",parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])',getAttrs:t=>{if(t.getAttribute("data-id")&&t.getAttribute("data-app-prefix"))return!1}}]},addOptions(){var t,e;return{...(t=this.parent)==null?void 0:t.call(this),openOnClick:!1,HTMLAttributes:{...(e=this.parent)==null?void 0:e.call(this).HTMLAttributes,target:null}}},addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),target:{default:this.options.HTMLAttributes.target,parseHTML:e=>e.getAttribute("target")!=="_blank"?null:"_blank",renderHTML:e=>({target:e.target})},title:{default:this.options.HTMLAttributes.title}}}});exports.Hyperlink=i;
|
|
2
2
|
//# sourceMappingURL=hyperlink.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hyperlink.cjs","sources":["../../src/hyperlink/hyperlink.ts"],"sourcesContent":["import { Link } from '@tiptap/extension-link';\n\n/** Our own model of an hyperlink in a rich document. */\nexport type HyperlinkAttributes = {\n href: string | null;\n target: '_blank' | null;\n title: string | null;\n text: string | null;\n};\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n hyperlink: {\n /**\n * Set an hyperlink mark\n */\n setLink: (attributes: Partial<HyperlinkAttributes>) => ReturnType;\n /**\n * Toggle an hyperlink mark\n */\n toggleLink: (attributes: {\n href: string;\n target?: string | null;\n }) => ReturnType;\n /**\n * Unset an hyperlink mark\n */\n unsetLink: () => ReturnType;\n };\n }\n}\n\n/**\n * Hyperlink (external links), extends `Link` extension from TipTap.\n *\n * Links to external resources MUST NOT have a `data-id` nor a `data-app-prefix` attribute.\n * The `target` attribute has to be sanitized, so it is overriden.\n */\nexport const Hyperlink = Link.extend({\n name: 'hyperlink',\n\n parseHTML() {\n return [\n {\n tag: 'a[href]:not([href *= \"javascript:\" i])',\n // Be sure no data-id and data-app-prefix attribute exists :\n // it would then be an Linker, not an Hyperlink !\n getAttrs: (node: HTMLAnchorElement) => {\n // See https://prosemirror.net/docs/ref/version/0.18.0.html#model.ParseRule.getAttrs\n if (\n node.getAttribute('data-id') &&\n node.getAttribute('data-app-prefix')\n )\n return false;\n },\n },\n ];\n },\n\n addOptions() {\n return {\n ...this.parent?.(),\n openOnClick: false,\n HTMLAttributes: {\n ...this.parent?.().HTMLAttributes,\n target: null,\n },\n };\n },\n\n /* Manage `title` and `target` attributes. */\n addAttributes() {\n return {\n // Preserve attributes of parent extension...\n ...this.parent?.(),\n // ...then add or override the following :\n //------------------\n target: {\n default: this.options.HTMLAttributes.target,\n // Sanitize target value\n parseHTML: (element) =>\n element.getAttribute('target') !== '_blank' ? null : '_blank',\n renderHTML: (attributes) => ({\n target: attributes['target'],\n }),\n },\n title: {\n default: this.options.HTMLAttributes.title,\n },\n };\n },\n});\n"],"names":["Link"],"mappings":"
|
|
1
|
+
{"version":3,"file":"hyperlink.cjs","sources":["../../src/hyperlink/hyperlink.ts"],"sourcesContent":["import { Link } from '@tiptap/extension-link';\n\n/** Our own model of an hyperlink in a rich document. */\nexport type HyperlinkAttributes = {\n href: string | null;\n target: '_blank' | null;\n title: string | null;\n text: string | null;\n};\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n hyperlink: {\n /**\n * Set an hyperlink mark\n */\n setLink: (attributes: Partial<HyperlinkAttributes>) => ReturnType;\n /**\n * Toggle an hyperlink mark\n */\n toggleLink: (attributes: {\n href: string;\n target?: string | null;\n }) => ReturnType;\n /**\n * Unset an hyperlink mark\n */\n unsetLink: () => ReturnType;\n };\n }\n}\n\n/**\n * Hyperlink (external links), extends `Link` extension from TipTap.\n *\n * Links to external resources MUST NOT have a `data-id` nor a `data-app-prefix` attribute.\n * The `target` attribute has to be sanitized, so it is overriden.\n */\nexport const Hyperlink = Link.extend({\n name: 'hyperlink',\n\n parseHTML() {\n return [\n {\n tag: 'a[href]:not([href *= \"javascript:\" i])',\n // Be sure no data-id and data-app-prefix attribute exists :\n // it would then be an Linker, not an Hyperlink !\n getAttrs: (node: HTMLAnchorElement) => {\n // See https://prosemirror.net/docs/ref/version/0.18.0.html#model.ParseRule.getAttrs\n if (\n node.getAttribute('data-id') &&\n node.getAttribute('data-app-prefix')\n )\n return false;\n },\n },\n ];\n },\n\n addOptions() {\n return {\n ...this.parent?.(),\n openOnClick: false,\n HTMLAttributes: {\n ...this.parent?.().HTMLAttributes,\n target: null,\n },\n };\n },\n\n /* Manage `title` and `target` attributes. */\n addAttributes() {\n return {\n // Preserve attributes of parent extension...\n ...this.parent?.(),\n // ...then add or override the following :\n //------------------\n target: {\n default: this.options.HTMLAttributes.target,\n // Sanitize target value\n parseHTML: (element) =>\n element.getAttribute('target') !== '_blank' ? null : '_blank',\n renderHTML: (attributes) => ({\n target: attributes['target'],\n }),\n },\n title: {\n default: this.options.HTMLAttributes.title,\n },\n };\n },\n});\n"],"names":["Hyperlink","Link","node","_a","_b","element","attributes"],"mappings":"0HAsCaA,EAAYC,OAAK,OAAO,CACnC,KAAM,YAEN,WAAY,CACH,MAAA,CACL,CACE,IAAK,yCAGL,SAAWC,GAA4B,CAErC,GACEA,EAAK,aAAa,SAAS,GAC3BA,EAAK,aAAa,iBAAiB,EAE5B,MAAA,EACX,CACF,CAAA,CAEJ,EAEA,YAAa,SACJ,MAAA,CACL,IAAGC,EAAA,KAAK,SAAL,YAAAA,EAAA,WACH,YAAa,GACb,eAAgB,CACd,IAAGC,EAAA,KAAK,SAAL,YAAAA,EAAA,WAAgB,eACnB,OAAQ,IACV,CAAA,CAEJ,EAGA,eAAgB,OACP,MAAA,CAEL,IAAGD,EAAA,KAAK,SAAL,YAAAA,EAAA,WAGH,OAAQ,CACN,QAAS,KAAK,QAAQ,eAAe,OAErC,UAAYE,GACVA,EAAQ,aAAa,QAAQ,IAAM,SAAW,KAAO,SACvD,WAAaC,IAAgB,CAC3B,OAAQA,EAAW,MAAQ,EAE/B,EACA,MAAO,CACL,QAAS,KAAK,QAAQ,eAAe,KACvC,CAAA,CAEJ,CACF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Link } from "@tiptap/extension-link";
|
|
2
|
-
const
|
|
1
|
+
import { Link as r } from "@tiptap/extension-link";
|
|
2
|
+
const i = r.extend({
|
|
3
3
|
name: "hyperlink",
|
|
4
4
|
parseHTML() {
|
|
5
5
|
return [
|
|
@@ -7,38 +7,38 @@ const Hyperlink = Link.extend({
|
|
|
7
7
|
tag: 'a[href]:not([href *= "javascript:" i])',
|
|
8
8
|
// Be sure no data-id and data-app-prefix attribute exists :
|
|
9
9
|
// it would then be an Linker, not an Hyperlink !
|
|
10
|
-
getAttrs: (
|
|
11
|
-
if (
|
|
10
|
+
getAttrs: (t) => {
|
|
11
|
+
if (t.getAttribute("data-id") && t.getAttribute("data-app-prefix"))
|
|
12
12
|
return !1;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
];
|
|
16
16
|
},
|
|
17
17
|
addOptions() {
|
|
18
|
-
var
|
|
18
|
+
var t, e;
|
|
19
19
|
return {
|
|
20
|
-
...(
|
|
20
|
+
...(t = this.parent) == null ? void 0 : t.call(this),
|
|
21
21
|
openOnClick: !1,
|
|
22
22
|
HTMLAttributes: {
|
|
23
|
-
...(
|
|
23
|
+
...(e = this.parent) == null ? void 0 : e.call(this).HTMLAttributes,
|
|
24
24
|
target: null
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
},
|
|
28
28
|
/* Manage `title` and `target` attributes. */
|
|
29
29
|
addAttributes() {
|
|
30
|
-
var
|
|
30
|
+
var t;
|
|
31
31
|
return {
|
|
32
32
|
// Preserve attributes of parent extension...
|
|
33
|
-
...(
|
|
33
|
+
...(t = this.parent) == null ? void 0 : t.call(this),
|
|
34
34
|
// ...then add or override the following :
|
|
35
35
|
//------------------
|
|
36
36
|
target: {
|
|
37
37
|
default: this.options.HTMLAttributes.target,
|
|
38
38
|
// Sanitize target value
|
|
39
|
-
parseHTML: (
|
|
40
|
-
renderHTML: (
|
|
41
|
-
target:
|
|
39
|
+
parseHTML: (e) => e.getAttribute("target") !== "_blank" ? null : "_blank",
|
|
40
|
+
renderHTML: (e) => ({
|
|
41
|
+
target: e.target
|
|
42
42
|
})
|
|
43
43
|
},
|
|
44
44
|
title: {
|
|
@@ -48,6 +48,6 @@ const Hyperlink = Link.extend({
|
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
export {
|
|
51
|
-
Hyperlink
|
|
51
|
+
i as Hyperlink
|
|
52
52
|
};
|
|
53
53
|
//# sourceMappingURL=hyperlink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hyperlink.js","sources":["../../src/hyperlink/hyperlink.ts"],"sourcesContent":["import { Link } from '@tiptap/extension-link';\n\n/** Our own model of an hyperlink in a rich document. */\nexport type HyperlinkAttributes = {\n href: string | null;\n target: '_blank' | null;\n title: string | null;\n text: string | null;\n};\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n hyperlink: {\n /**\n * Set an hyperlink mark\n */\n setLink: (attributes: Partial<HyperlinkAttributes>) => ReturnType;\n /**\n * Toggle an hyperlink mark\n */\n toggleLink: (attributes: {\n href: string;\n target?: string | null;\n }) => ReturnType;\n /**\n * Unset an hyperlink mark\n */\n unsetLink: () => ReturnType;\n };\n }\n}\n\n/**\n * Hyperlink (external links), extends `Link` extension from TipTap.\n *\n * Links to external resources MUST NOT have a `data-id` nor a `data-app-prefix` attribute.\n * The `target` attribute has to be sanitized, so it is overriden.\n */\nexport const Hyperlink = Link.extend({\n name: 'hyperlink',\n\n parseHTML() {\n return [\n {\n tag: 'a[href]:not([href *= \"javascript:\" i])',\n // Be sure no data-id and data-app-prefix attribute exists :\n // it would then be an Linker, not an Hyperlink !\n getAttrs: (node: HTMLAnchorElement) => {\n // See https://prosemirror.net/docs/ref/version/0.18.0.html#model.ParseRule.getAttrs\n if (\n node.getAttribute('data-id') &&\n node.getAttribute('data-app-prefix')\n )\n return false;\n },\n },\n ];\n },\n\n addOptions() {\n return {\n ...this.parent?.(),\n openOnClick: false,\n HTMLAttributes: {\n ...this.parent?.().HTMLAttributes,\n target: null,\n },\n };\n },\n\n /* Manage `title` and `target` attributes. */\n addAttributes() {\n return {\n // Preserve attributes of parent extension...\n ...this.parent?.(),\n // ...then add or override the following :\n //------------------\n target: {\n default: this.options.HTMLAttributes.target,\n // Sanitize target value\n parseHTML: (element) =>\n element.getAttribute('target') !== '_blank' ? null : '_blank',\n renderHTML: (attributes) => ({\n target: attributes['target'],\n }),\n },\n title: {\n default: this.options.HTMLAttributes.title,\n },\n };\n },\n});\n"],"names":[],"mappings":";AAsCa,
|
|
1
|
+
{"version":3,"file":"hyperlink.js","sources":["../../src/hyperlink/hyperlink.ts"],"sourcesContent":["import { Link } from '@tiptap/extension-link';\n\n/** Our own model of an hyperlink in a rich document. */\nexport type HyperlinkAttributes = {\n href: string | null;\n target: '_blank' | null;\n title: string | null;\n text: string | null;\n};\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n hyperlink: {\n /**\n * Set an hyperlink mark\n */\n setLink: (attributes: Partial<HyperlinkAttributes>) => ReturnType;\n /**\n * Toggle an hyperlink mark\n */\n toggleLink: (attributes: {\n href: string;\n target?: string | null;\n }) => ReturnType;\n /**\n * Unset an hyperlink mark\n */\n unsetLink: () => ReturnType;\n };\n }\n}\n\n/**\n * Hyperlink (external links), extends `Link` extension from TipTap.\n *\n * Links to external resources MUST NOT have a `data-id` nor a `data-app-prefix` attribute.\n * The `target` attribute has to be sanitized, so it is overriden.\n */\nexport const Hyperlink = Link.extend({\n name: 'hyperlink',\n\n parseHTML() {\n return [\n {\n tag: 'a[href]:not([href *= \"javascript:\" i])',\n // Be sure no data-id and data-app-prefix attribute exists :\n // it would then be an Linker, not an Hyperlink !\n getAttrs: (node: HTMLAnchorElement) => {\n // See https://prosemirror.net/docs/ref/version/0.18.0.html#model.ParseRule.getAttrs\n if (\n node.getAttribute('data-id') &&\n node.getAttribute('data-app-prefix')\n )\n return false;\n },\n },\n ];\n },\n\n addOptions() {\n return {\n ...this.parent?.(),\n openOnClick: false,\n HTMLAttributes: {\n ...this.parent?.().HTMLAttributes,\n target: null,\n },\n };\n },\n\n /* Manage `title` and `target` attributes. */\n addAttributes() {\n return {\n // Preserve attributes of parent extension...\n ...this.parent?.(),\n // ...then add or override the following :\n //------------------\n target: {\n default: this.options.HTMLAttributes.target,\n // Sanitize target value\n parseHTML: (element) =>\n element.getAttribute('target') !== '_blank' ? null : '_blank',\n renderHTML: (attributes) => ({\n target: attributes['target'],\n }),\n },\n title: {\n default: this.options.HTMLAttributes.title,\n },\n };\n },\n});\n"],"names":["Hyperlink","Link","node","_a","_b","element","attributes"],"mappings":";AAsCa,MAAAA,IAAYC,EAAK,OAAO;AAAA,EACnC,MAAM;AAAA,EAEN,YAAY;AACH,WAAA;AAAA,MACL;AAAA,QACE,KAAK;AAAA;AAAA;AAAA,QAGL,UAAU,CAACC,MAA4B;AAErC,cACEA,EAAK,aAAa,SAAS,KAC3BA,EAAK,aAAa,iBAAiB;AAE5B,mBAAA;AAAA,QACX;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,aAAa;;AACJ,WAAA;AAAA,MACL,IAAGC,IAAA,KAAK,WAAL,gBAAAA,EAAA;AAAA,MACH,aAAa;AAAA,MACb,gBAAgB;AAAA,QACd,IAAGC,IAAA,KAAK,WAAL,gBAAAA,EAAA,WAAgB;AAAA,QACnB,QAAQ;AAAA,MACV;AAAA,IAAA;AAAA,EAEJ;AAAA;AAAA,EAGA,gBAAgB;;AACP,WAAA;AAAA;AAAA,MAEL,IAAGD,IAAA,KAAK,WAAL,gBAAAA,EAAA;AAAA;AAAA;AAAA,MAGH,QAAQ;AAAA,QACN,SAAS,KAAK,QAAQ,eAAe;AAAA;AAAA,QAErC,WAAW,CAACE,MACVA,EAAQ,aAAa,QAAQ,MAAM,WAAW,OAAO;AAAA,QACvD,YAAY,CAACC,OAAgB;AAAA,UAC3B,QAAQA,EAAW;AAAA,QAAQ;AAAA,MAE/B;AAAA,MACA,OAAO;AAAA,QACL,SAAS,KAAK,QAAQ,eAAe;AAAA,MACvC;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;"}
|
package/dist/iframe/iframe.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@tiptap/core"),l=s.Node.create({name:"iframe",group:"block",atom:!0,draggable:!0,addOptions(){return{allowFullscreen:!0,HTMLAttributes:{class:"iframe-wrapper"}}},addAttributes(){return{src:{default:null},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen},width:{renderHTML:e=>e.width?{width:e.width==="100%"?"100%":parseInt(e.width)}:{},parseHTML:e=>e.getAttribute("width")},height:{renderHTML:e=>e.height?{height:parseInt(e.height)}:{},parseHTML:e=>e.getAttribute("height")},style:{renderHTML:e=>e.style?{style:e.style}:{},parseHTML:e=>e.getAttribute("style")}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:e}){return["div",this.options.HTMLAttributes,["iframe",e]]},addCommands(){return{setIframe:e=>({tr:t,dispatch:a})=>{const{selection:r}=t,n=this.type.create(e);return a&&t.replaceRangeWith(r.from,r.to,n),!0}}}});exports.Iframe=l;
|
|
2
2
|
//# sourceMappingURL=iframe.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframe.cjs","sources":["../../src/iframe/iframe.ts"],"sourcesContent":["import { Node } from '@tiptap/core';\n\nexport interface IframeOptions {\n allowFullscreen: boolean;\n HTMLAttributes: {\n [key: string]: any;\n };\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n iframe: {\n /**\n * Add an iframe\n */\n setIframe: (options: { src: string }) => ReturnType;\n };\n }\n}\n\nexport const Iframe = Node.create<IframeOptions>({\n name: 'iframe',\n group: 'block',\n atom: true,\n draggable: true,\n\n addOptions() {\n return {\n allowFullscreen: true,\n HTMLAttributes: {\n class: 'iframe-wrapper',\n },\n };\n },\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n frameborder: {\n default: 0,\n },\n allowfullscreen: {\n default: this.options.allowFullscreen,\n parseHTML: () => this.options.allowFullscreen,\n },\n width: {\n renderHTML: (attributes) => {\n return attributes.width\n ? {\n width:\n attributes.width === '100%'\n ? '100%'\n : parseInt(attributes.width),\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('width'),\n },\n height: {\n renderHTML: (attributes) => {\n return attributes.height\n ? {\n height: parseInt(attributes.height),\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('height'),\n },\n style: {\n renderHTML: (attributes) => {\n return attributes.style\n ? {\n style: attributes.style,\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('style'),\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'iframe',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['div', this.options.HTMLAttributes, ['iframe', HTMLAttributes]];\n },\n\n addCommands() {\n return {\n setIframe:\n (options: { src: string }) =>\n ({ tr, dispatch }) => {\n const { selection } = tr;\n const node = this.type.create(options);\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node);\n }\n\n return true;\n },\n };\n },\n});\n"],"names":["Node"],"mappings":"
|
|
1
|
+
{"version":3,"file":"iframe.cjs","sources":["../../src/iframe/iframe.ts"],"sourcesContent":["import { Node } from '@tiptap/core';\n\nexport interface IframeOptions {\n allowFullscreen: boolean;\n HTMLAttributes: {\n [key: string]: any;\n };\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n iframe: {\n /**\n * Add an iframe\n */\n setIframe: (options: { src: string }) => ReturnType;\n };\n }\n}\n\nexport const Iframe = Node.create<IframeOptions>({\n name: 'iframe',\n group: 'block',\n atom: true,\n draggable: true,\n\n addOptions() {\n return {\n allowFullscreen: true,\n HTMLAttributes: {\n class: 'iframe-wrapper',\n },\n };\n },\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n frameborder: {\n default: 0,\n },\n allowfullscreen: {\n default: this.options.allowFullscreen,\n parseHTML: () => this.options.allowFullscreen,\n },\n width: {\n renderHTML: (attributes) => {\n return attributes.width\n ? {\n width:\n attributes.width === '100%'\n ? '100%'\n : parseInt(attributes.width),\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('width'),\n },\n height: {\n renderHTML: (attributes) => {\n return attributes.height\n ? {\n height: parseInt(attributes.height),\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('height'),\n },\n style: {\n renderHTML: (attributes) => {\n return attributes.style\n ? {\n style: attributes.style,\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('style'),\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'iframe',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['div', this.options.HTMLAttributes, ['iframe', HTMLAttributes]];\n },\n\n addCommands() {\n return {\n setIframe:\n (options: { src: string }) =>\n ({ tr, dispatch }) => {\n const { selection } = tr;\n const node = this.type.create(options);\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node);\n }\n\n return true;\n },\n };\n },\n});\n"],"names":["Iframe","Node","attributes","element","HTMLAttributes","options","tr","dispatch","selection","node"],"mappings":"gHAoBaA,EAASC,OAAK,OAAsB,CAC/C,KAAM,SACN,MAAO,QACP,KAAM,GACN,UAAW,GAEX,YAAa,CACJ,MAAA,CACL,gBAAiB,GACjB,eAAgB,CACd,MAAO,gBACT,CAAA,CAEJ,EAEA,eAAgB,CACP,MAAA,CACL,IAAK,CACH,QAAS,IACX,EACA,YAAa,CACX,QAAS,CACX,EACA,gBAAiB,CACf,QAAS,KAAK,QAAQ,gBACtB,UAAW,IAAM,KAAK,QAAQ,eAChC,EACA,MAAO,CACL,WAAaC,GACJA,EAAW,MACd,CACE,MACEA,EAAW,QAAU,OACjB,OACA,SAASA,EAAW,KAAK,GAEjC,GAEN,UAAYC,GAAYA,EAAQ,aAAa,OAAO,CACtD,EACA,OAAQ,CACN,WAAaD,GACJA,EAAW,OACd,CACE,OAAQ,SAASA,EAAW,MAAM,GAEpC,GAEN,UAAYC,GAAYA,EAAQ,aAAa,QAAQ,CACvD,EACA,MAAO,CACL,WAAaD,GACJA,EAAW,MACd,CACE,MAAOA,EAAW,OAEpB,GAEN,UAAYC,GAAYA,EAAQ,aAAa,OAAO,CACtD,CAAA,CAEJ,EAEA,WAAY,CACH,MAAA,CACL,CACE,IAAK,QACP,CAAA,CAEJ,EAEA,WAAW,CAAE,eAAAC,GAAkB,CACtB,MAAA,CAAC,MAAO,KAAK,QAAQ,eAAgB,CAAC,SAAUA,CAAc,CAAC,CACxE,EAEA,aAAc,CACL,MAAA,CACL,UACGC,GACD,CAAC,CAAE,GAAAC,EAAI,SAAAC,KAAe,CACd,KAAA,CAAE,UAAAC,CAAc,EAAAF,EAChBG,EAAO,KAAK,KAAK,OAAOJ,CAAO,EAErC,OAAIE,GACFD,EAAG,iBAAiBE,EAAU,KAAMA,EAAU,GAAIC,CAAI,EAGjD,EACT,CAAA,CAEN,CACF,CAAC"}
|
package/dist/iframe/iframe.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Node } from "@tiptap/core";
|
|
2
|
-
const
|
|
1
|
+
import { Node as s } from "@tiptap/core";
|
|
2
|
+
const i = s.create({
|
|
3
3
|
name: "iframe",
|
|
4
4
|
group: "block",
|
|
5
5
|
atom: !0,
|
|
@@ -25,22 +25,22 @@ const Iframe = Node.create({
|
|
|
25
25
|
parseHTML: () => this.options.allowFullscreen
|
|
26
26
|
},
|
|
27
27
|
width: {
|
|
28
|
-
renderHTML: (
|
|
29
|
-
width:
|
|
28
|
+
renderHTML: (e) => e.width ? {
|
|
29
|
+
width: e.width === "100%" ? "100%" : parseInt(e.width)
|
|
30
30
|
} : {},
|
|
31
|
-
parseHTML: (
|
|
31
|
+
parseHTML: (e) => e.getAttribute("width")
|
|
32
32
|
},
|
|
33
33
|
height: {
|
|
34
|
-
renderHTML: (
|
|
35
|
-
height: parseInt(
|
|
34
|
+
renderHTML: (e) => e.height ? {
|
|
35
|
+
height: parseInt(e.height)
|
|
36
36
|
} : {},
|
|
37
|
-
parseHTML: (
|
|
37
|
+
parseHTML: (e) => e.getAttribute("height")
|
|
38
38
|
},
|
|
39
39
|
style: {
|
|
40
|
-
renderHTML: (
|
|
41
|
-
style:
|
|
40
|
+
renderHTML: (e) => e.style ? {
|
|
41
|
+
style: e.style
|
|
42
42
|
} : {},
|
|
43
|
-
parseHTML: (
|
|
43
|
+
parseHTML: (e) => e.getAttribute("style")
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
},
|
|
@@ -51,19 +51,19 @@ const Iframe = Node.create({
|
|
|
51
51
|
}
|
|
52
52
|
];
|
|
53
53
|
},
|
|
54
|
-
renderHTML({ HTMLAttributes }) {
|
|
55
|
-
return ["div", this.options.HTMLAttributes, ["iframe",
|
|
54
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
55
|
+
return ["div", this.options.HTMLAttributes, ["iframe", e]];
|
|
56
56
|
},
|
|
57
57
|
addCommands() {
|
|
58
58
|
return {
|
|
59
|
-
setIframe: (
|
|
60
|
-
const { selection } =
|
|
61
|
-
return
|
|
59
|
+
setIframe: (e) => ({ tr: t, dispatch: a }) => {
|
|
60
|
+
const { selection: r } = t, n = this.type.create(e);
|
|
61
|
+
return a && t.replaceRangeWith(r.from, r.to, n), !0;
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
export {
|
|
67
|
-
Iframe
|
|
67
|
+
i as Iframe
|
|
68
68
|
};
|
|
69
69
|
//# sourceMappingURL=iframe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframe.js","sources":["../../src/iframe/iframe.ts"],"sourcesContent":["import { Node } from '@tiptap/core';\n\nexport interface IframeOptions {\n allowFullscreen: boolean;\n HTMLAttributes: {\n [key: string]: any;\n };\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n iframe: {\n /**\n * Add an iframe\n */\n setIframe: (options: { src: string }) => ReturnType;\n };\n }\n}\n\nexport const Iframe = Node.create<IframeOptions>({\n name: 'iframe',\n group: 'block',\n atom: true,\n draggable: true,\n\n addOptions() {\n return {\n allowFullscreen: true,\n HTMLAttributes: {\n class: 'iframe-wrapper',\n },\n };\n },\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n frameborder: {\n default: 0,\n },\n allowfullscreen: {\n default: this.options.allowFullscreen,\n parseHTML: () => this.options.allowFullscreen,\n },\n width: {\n renderHTML: (attributes) => {\n return attributes.width\n ? {\n width:\n attributes.width === '100%'\n ? '100%'\n : parseInt(attributes.width),\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('width'),\n },\n height: {\n renderHTML: (attributes) => {\n return attributes.height\n ? {\n height: parseInt(attributes.height),\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('height'),\n },\n style: {\n renderHTML: (attributes) => {\n return attributes.style\n ? {\n style: attributes.style,\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('style'),\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'iframe',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['div', this.options.HTMLAttributes, ['iframe', HTMLAttributes]];\n },\n\n addCommands() {\n return {\n setIframe:\n (options: { src: string }) =>\n ({ tr, dispatch }) => {\n const { selection } = tr;\n const node = this.type.create(options);\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node);\n }\n\n return true;\n },\n };\n },\n});\n"],"names":[],"mappings":";AAoBa,
|
|
1
|
+
{"version":3,"file":"iframe.js","sources":["../../src/iframe/iframe.ts"],"sourcesContent":["import { Node } from '@tiptap/core';\n\nexport interface IframeOptions {\n allowFullscreen: boolean;\n HTMLAttributes: {\n [key: string]: any;\n };\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n iframe: {\n /**\n * Add an iframe\n */\n setIframe: (options: { src: string }) => ReturnType;\n };\n }\n}\n\nexport const Iframe = Node.create<IframeOptions>({\n name: 'iframe',\n group: 'block',\n atom: true,\n draggable: true,\n\n addOptions() {\n return {\n allowFullscreen: true,\n HTMLAttributes: {\n class: 'iframe-wrapper',\n },\n };\n },\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n frameborder: {\n default: 0,\n },\n allowfullscreen: {\n default: this.options.allowFullscreen,\n parseHTML: () => this.options.allowFullscreen,\n },\n width: {\n renderHTML: (attributes) => {\n return attributes.width\n ? {\n width:\n attributes.width === '100%'\n ? '100%'\n : parseInt(attributes.width),\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('width'),\n },\n height: {\n renderHTML: (attributes) => {\n return attributes.height\n ? {\n height: parseInt(attributes.height),\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('height'),\n },\n style: {\n renderHTML: (attributes) => {\n return attributes.style\n ? {\n style: attributes.style,\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('style'),\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'iframe',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['div', this.options.HTMLAttributes, ['iframe', HTMLAttributes]];\n },\n\n addCommands() {\n return {\n setIframe:\n (options: { src: string }) =>\n ({ tr, dispatch }) => {\n const { selection } = tr;\n const node = this.type.create(options);\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node);\n }\n\n return true;\n },\n };\n },\n});\n"],"names":["Iframe","Node","attributes","element","HTMLAttributes","options","tr","dispatch","selection","node"],"mappings":";AAoBa,MAAAA,IAASC,EAAK,OAAsB;AAAA,EAC/C,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,WAAW;AAAA,EAEX,aAAa;AACJ,WAAA;AAAA,MACL,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,QACd,OAAO;AAAA,MACT;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,gBAAgB;AACP,WAAA;AAAA,MACL,KAAK;AAAA,QACH,SAAS;AAAA,MACX;AAAA,MACA,aAAa;AAAA,QACX,SAAS;AAAA,MACX;AAAA,MACA,iBAAiB;AAAA,QACf,SAAS,KAAK,QAAQ;AAAA,QACtB,WAAW,MAAM,KAAK,QAAQ;AAAA,MAChC;AAAA,MACA,OAAO;AAAA,QACL,YAAY,CAACC,MACJA,EAAW,QACd;AAAA,UACE,OACEA,EAAW,UAAU,SACjB,SACA,SAASA,EAAW,KAAK;AAAA,YAEjC;QAEN,WAAW,CAACC,MAAYA,EAAQ,aAAa,OAAO;AAAA,MACtD;AAAA,MACA,QAAQ;AAAA,QACN,YAAY,CAACD,MACJA,EAAW,SACd;AAAA,UACE,QAAQ,SAASA,EAAW,MAAM;AAAA,YAEpC;QAEN,WAAW,CAACC,MAAYA,EAAQ,aAAa,QAAQ;AAAA,MACvD;AAAA,MACA,OAAO;AAAA,QACL,YAAY,CAACD,MACJA,EAAW,QACd;AAAA,UACE,OAAOA,EAAW;AAAA,YAEpB;QAEN,WAAW,CAACC,MAAYA,EAAQ,aAAa,OAAO;AAAA,MACtD;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,YAAY;AACH,WAAA;AAAA,MACL;AAAA,QACE,KAAK;AAAA,MACP;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,WAAW,EAAE,gBAAAC,KAAkB;AACtB,WAAA,CAAC,OAAO,KAAK,QAAQ,gBAAgB,CAAC,UAAUA,CAAc,CAAC;AAAA,EACxE;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,WACE,CAACC,MACD,CAAC,EAAE,IAAAC,GAAI,UAAAC,QAAe;AACd,cAAA,EAAE,WAAAC,EAAc,IAAAF,GAChBG,IAAO,KAAK,KAAK,OAAOJ,CAAO;AAErC,eAAIE,KACFD,EAAG,iBAAiBE,EAAU,MAAMA,EAAU,IAAIC,CAAI,GAGjD;AAAA,MACT;AAAA,IAAA;AAAA,EAEN;AACF,CAAC;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@tiptap/core"),h=require("@tiptap/extension-image"),a=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,c=h.extend({name:"custom-image",draggable:!0,selectable:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),inline:!0,content:"inline*",sizes:["small","medium","large"],HTMLAttributes:{class:"custom-image"}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),size:{default:"medium",rendered:!1},alt:{renderHTML:t=>({alt:t.alt}),parseHTML:t=>t.getAttribute("alt")},title:{renderHTML:t=>({title:t.title}),parseHTML:t=>t.getAttribute("title")},width:{default:"350",renderHTML:t=>t.width!==null&&t.width!==void 0&&!Number.isNaN(t.width)?{width:parseInt(t.width)}:{},parseHTML:t=>t.getAttribute("width")},height:{renderHTML:t=>t.height!==null&&t.height!==void 0&&!Number.isNaN(t.height)?{height:parseInt(t.height)}:{},parseHTML:t=>t.getAttribute("height")},style:{renderHTML:t=>t.style?{style:t.style}:{},parseHTML:t=>{const r=t.getAttribute("style");return r&&typeof r=="string"&&r.length>0?{}:null}}}},parseHTML(){return[{tag:'img[src]:not([src^="data:"])',getAttrs:e=>{var n,i,s,l,d;const t={src:e.getAttribute("src")};return(n=e.parentElement)!=null&&n.className.includes("image-container")&&(i=e.parentElement.style)!=null&&i.width&&(t.width=e.parentElement.style.width),(s=e.style)!=null&&s.width&&(t.width=e.style.width),["happy","proud","dreamy","love","tired","angry","worried","sick","joker","sad"].filter(u=>t.src.includes(u+".png")).length>0&&(t.style={width:"1.5em",height:"1.5em",fontSize:(d=(l=e.parentElement)==null?void 0:l.style)==null?void 0:d.fontSize},t.width="null",t.height="null"),t}}]},renderHTML({HTMLAttributes:e}){return["img",o.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){return[o.nodeInputRule({find:a,type:this.type,getAttributes:e=>{const[,,t,r,n]=e;return{src:r,alt:t,title:n}}})]},addCommands(){return{setNewImage:e=>({tr:t,dispatch:r})=>{const{selection:n}=t,i=this.type.create(e);return r&&t.replaceRangeWith(n.from,n.to,i),!0},setAttributes:e=>({tr:t,dispatch:r})=>{const{selection:n}=t,s={...t.doc.nodeAt(t.selection.from).attrs,...e},l=this.type.create(s);return r&&t.replaceRangeWith(n.from,n.to,l),!0}}}});exports.CustomImage=c;exports.IMAGE_INPUT_REGEX=a;
|
|
2
2
|
//# sourceMappingURL=custom-image.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-image.cjs","sources":["../../src/image/custom-image.ts"],"sourcesContent":["import { mergeAttributes, nodeInputRule } from '@tiptap/core';\nimport Image from '@tiptap/extension-image';\n\nexport const IMAGE_INPUT_REGEX =\n /(?:^|\\s)(!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\))$/;\n\nexport interface CustomImageOptions {\n HTMLAttributes: Record<string, string>;\n sizes: string[];\n}\n\ninterface AttributesProps {\n width: number | string;\n height: number | string;\n size: string;\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n customImage: {\n setAttributes: (options: AttributesProps) => ReturnType;\n setNewImage: (options: {\n src: string;\n alt?: string;\n title?: string;\n }) => ReturnType;\n };\n }\n}\n\nexport const CustomImage = Image.extend<CustomImageOptions>({\n name: 'custom-image',\n draggable: true,\n selectable: true,\n\n addOptions() {\n return {\n ...this.parent?.(),\n inline: true,\n content: 'inline*',\n sizes: ['small', 'medium', 'large'],\n HTMLAttributes: {\n class: 'custom-image',\n },\n };\n },\n\n addAttributes() {\n return {\n ...this.parent?.(),\n size: {\n default: 'medium',\n rendered: false,\n },\n alt: {\n renderHTML: (attributes) => {\n return {\n alt: attributes.alt,\n };\n },\n parseHTML: (element) => element.getAttribute('alt'),\n },\n title: {\n renderHTML: (attributes) => {\n return {\n title: attributes.title,\n };\n },\n parseHTML: (element) => element.getAttribute('title'),\n },\n width: {\n default: '350',\n renderHTML: (attributes) => {\n if (\n attributes.width !== null &&\n attributes.width !== undefined &&\n !Number.isNaN(attributes.width)\n ) {\n return {\n width: parseInt(attributes.width),\n };\n }\n return {};\n },\n parseHTML: (element) => element.getAttribute('width'),\n },\n height: {\n renderHTML: (attributes) => {\n if (\n attributes.height !== null &&\n attributes.height !== undefined &&\n !Number.isNaN(attributes.height)\n ) {\n return {\n height: parseInt(attributes.height),\n };\n }\n return {};\n },\n parseHTML: (element) => element.getAttribute('height'),\n },\n style: {\n renderHTML: (attributes) => {\n return attributes.style\n ? {\n style: attributes.style,\n }\n : {};\n },\n parseHTML: (element) => {\n const style = element.getAttribute('style');\n return style && typeof style === 'string' && style.length > 0\n ? {}\n : null;\n },\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'img[src]:not([src^=\"data:\"])',\n getAttrs: (el: HTMLImageElement) => {\n const attr = { src: el.getAttribute('src') };\n // Check old content format and get the width from the parent element\n if (el.parentElement?.className.includes('image-container')) {\n if (el.parentElement.style?.width) {\n attr['width'] = el.parentElement.style.width;\n }\n }\n if (el.style?.width) {\n attr['width'] = el.style.width;\n }\n\n // Check old content smiley\n const oldSmileyList = [\n 'happy',\n 'proud',\n 'dreamy',\n 'love',\n 'tired',\n 'angry',\n 'worried',\n 'sick',\n 'joker',\n 'sad',\n ];\n if (\n oldSmileyList.filter((smiley) => attr.src.includes(smiley + '.png'))\n .length > 0\n ) {\n attr['style'] = {\n width: '1.5em',\n height: '1.5em',\n fontSize: el.parentElement?.style?.fontSize,\n };\n attr['width'] = 'null';\n attr['height'] = 'null';\n }\n return attr;\n },\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n 'img',\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n ];\n },\n\n addInputRules() {\n return [\n nodeInputRule({\n find: IMAGE_INPUT_REGEX,\n type: this.type,\n getAttributes: (match) => {\n const [, , alt, src, title] = match;\n\n return {\n src,\n alt,\n title,\n };\n },\n }),\n ];\n },\n\n addCommands() {\n return {\n setNewImage:\n (attrs) =>\n ({ tr, dispatch }) => {\n const { selection } = tr;\n const node = this.type.create(attrs);\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node);\n }\n\n return true;\n },\n setAttributes:\n (attributes) =>\n ({ tr, dispatch }) => {\n const { selection } = tr;\n\n const nodeAttrs = tr.doc.nodeAt(tr.selection.from);\n const options = {\n ...nodeAttrs.attrs,\n ...attributes,\n };\n const node = this.type.create(options);\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node);\n }\n\n return true;\n },\n };\n },\n});\n"],"names":["mergeAttributes","nodeInputRule"],"mappings":"
|
|
1
|
+
{"version":3,"file":"custom-image.cjs","sources":["../../src/image/custom-image.ts"],"sourcesContent":["import { mergeAttributes, nodeInputRule } from '@tiptap/core';\nimport Image from '@tiptap/extension-image';\n\nexport const IMAGE_INPUT_REGEX =\n /(?:^|\\s)(!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\))$/;\n\nexport interface CustomImageOptions {\n HTMLAttributes: Record<string, string>;\n sizes: string[];\n}\n\ninterface AttributesProps {\n width: number | string;\n height: number | string;\n size: string;\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n customImage: {\n setAttributes: (options: AttributesProps) => ReturnType;\n setNewImage: (options: {\n src: string;\n alt?: string;\n title?: string;\n }) => ReturnType;\n };\n }\n}\n\nexport const CustomImage = Image.extend<CustomImageOptions>({\n name: 'custom-image',\n draggable: true,\n selectable: true,\n\n addOptions() {\n return {\n ...this.parent?.(),\n inline: true,\n content: 'inline*',\n sizes: ['small', 'medium', 'large'],\n HTMLAttributes: {\n class: 'custom-image',\n },\n };\n },\n\n addAttributes() {\n return {\n ...this.parent?.(),\n size: {\n default: 'medium',\n rendered: false,\n },\n alt: {\n renderHTML: (attributes) => {\n return {\n alt: attributes.alt,\n };\n },\n parseHTML: (element) => element.getAttribute('alt'),\n },\n title: {\n renderHTML: (attributes) => {\n return {\n title: attributes.title,\n };\n },\n parseHTML: (element) => element.getAttribute('title'),\n },\n width: {\n default: '350',\n renderHTML: (attributes) => {\n if (\n attributes.width !== null &&\n attributes.width !== undefined &&\n !Number.isNaN(attributes.width)\n ) {\n return {\n width: parseInt(attributes.width),\n };\n }\n return {};\n },\n parseHTML: (element) => element.getAttribute('width'),\n },\n height: {\n renderHTML: (attributes) => {\n if (\n attributes.height !== null &&\n attributes.height !== undefined &&\n !Number.isNaN(attributes.height)\n ) {\n return {\n height: parseInt(attributes.height),\n };\n }\n return {};\n },\n parseHTML: (element) => element.getAttribute('height'),\n },\n style: {\n renderHTML: (attributes) => {\n return attributes.style\n ? {\n style: attributes.style,\n }\n : {};\n },\n parseHTML: (element) => {\n const style = element.getAttribute('style');\n return style && typeof style === 'string' && style.length > 0\n ? {}\n : null;\n },\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'img[src]:not([src^=\"data:\"])',\n getAttrs: (el: HTMLImageElement) => {\n const attr = { src: el.getAttribute('src') };\n // Check old content format and get the width from the parent element\n if (el.parentElement?.className.includes('image-container')) {\n if (el.parentElement.style?.width) {\n attr['width'] = el.parentElement.style.width;\n }\n }\n if (el.style?.width) {\n attr['width'] = el.style.width;\n }\n\n // Check old content smiley\n const oldSmileyList = [\n 'happy',\n 'proud',\n 'dreamy',\n 'love',\n 'tired',\n 'angry',\n 'worried',\n 'sick',\n 'joker',\n 'sad',\n ];\n if (\n oldSmileyList.filter((smiley) => attr.src.includes(smiley + '.png'))\n .length > 0\n ) {\n attr['style'] = {\n width: '1.5em',\n height: '1.5em',\n fontSize: el.parentElement?.style?.fontSize,\n };\n attr['width'] = 'null';\n attr['height'] = 'null';\n }\n return attr;\n },\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n 'img',\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n ];\n },\n\n addInputRules() {\n return [\n nodeInputRule({\n find: IMAGE_INPUT_REGEX,\n type: this.type,\n getAttributes: (match) => {\n const [, , alt, src, title] = match;\n\n return {\n src,\n alt,\n title,\n };\n },\n }),\n ];\n },\n\n addCommands() {\n return {\n setNewImage:\n (attrs) =>\n ({ tr, dispatch }) => {\n const { selection } = tr;\n const node = this.type.create(attrs);\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node);\n }\n\n return true;\n },\n setAttributes:\n (attributes) =>\n ({ tr, dispatch }) => {\n const { selection } = tr;\n\n const nodeAttrs = tr.doc.nodeAt(tr.selection.from);\n const options = {\n ...nodeAttrs.attrs,\n ...attributes,\n };\n const node = this.type.create(options);\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node);\n }\n\n return true;\n },\n };\n },\n});\n"],"names":["IMAGE_INPUT_REGEX","CustomImage","Image","_a","attributes","element","style","el","attr","_b","_c","smiley","_e","_d","HTMLAttributes","mergeAttributes","nodeInputRule","match","alt","src","title","attrs","tr","dispatch","selection","node","options"],"mappings":"qJAGaA,EACX,2DA0BWC,EAAcC,EAAM,OAA2B,CAC1D,KAAM,eACN,UAAW,GACX,WAAY,GAEZ,YAAa,OACJ,MAAA,CACL,IAAGC,EAAA,KAAK,SAAL,YAAAA,EAAA,WACH,OAAQ,GACR,QAAS,UACT,MAAO,CAAC,QAAS,SAAU,OAAO,EAClC,eAAgB,CACd,MAAO,cACT,CAAA,CAEJ,EAEA,eAAgB,OACP,MAAA,CACL,IAAGA,EAAA,KAAK,SAAL,YAAAA,EAAA,WACH,KAAM,CACJ,QAAS,SACT,SAAU,EACZ,EACA,IAAK,CACH,WAAaC,IACJ,CACL,IAAKA,EAAW,GAAA,GAGpB,UAAYC,GAAYA,EAAQ,aAAa,KAAK,CACpD,EACA,MAAO,CACL,WAAaD,IACJ,CACL,MAAOA,EAAW,KAAA,GAGtB,UAAYC,GAAYA,EAAQ,aAAa,OAAO,CACtD,EACA,MAAO,CACL,QAAS,MACT,WAAaD,GAETA,EAAW,QAAU,MACrBA,EAAW,QAAU,QACrB,CAAC,OAAO,MAAMA,EAAW,KAAK,EAEvB,CACL,MAAO,SAASA,EAAW,KAAK,CAAA,EAG7B,GAET,UAAYC,GAAYA,EAAQ,aAAa,OAAO,CACtD,EACA,OAAQ,CACN,WAAaD,GAETA,EAAW,SAAW,MACtBA,EAAW,SAAW,QACtB,CAAC,OAAO,MAAMA,EAAW,MAAM,EAExB,CACL,OAAQ,SAASA,EAAW,MAAM,CAAA,EAG/B,GAET,UAAYC,GAAYA,EAAQ,aAAa,QAAQ,CACvD,EACA,MAAO,CACL,WAAaD,GACJA,EAAW,MACd,CACE,MAAOA,EAAW,OAEpB,GAEN,UAAYC,GAAY,CAChB,MAAAC,EAAQD,EAAQ,aAAa,OAAO,EACnC,OAAAC,GAAS,OAAOA,GAAU,UAAYA,EAAM,OAAS,EACxD,CACA,EAAA,IACN,CACF,CAAA,CAEJ,EAEA,WAAY,CACH,MAAA,CACL,CACE,IAAK,+BACL,SAAWC,GAAyB,eAClC,MAAMC,EAAO,CAAE,IAAKD,EAAG,aAAa,KAAK,GAEzC,OAAIJ,EAAAI,EAAG,gBAAH,MAAAJ,EAAkB,UAAU,SAAS,qBACnCM,EAAAF,EAAG,cAAc,QAAjB,MAAAE,EAAwB,QAC1BD,EAAK,MAAWD,EAAG,cAAc,MAAM,QAGvCG,EAAAH,EAAG,QAAH,MAAAG,EAAU,QACPF,EAAA,MAAWD,EAAG,MAAM,OAIL,CACpB,QACA,QACA,SACA,OACA,QACA,QACA,UACA,OACA,QACA,KAAA,EAGc,OAAQI,GAAWH,EAAK,IAAI,SAASG,EAAS,MAAM,CAAC,EAChE,OAAS,IAEZH,EAAK,MAAW,CACd,MAAO,QACP,OAAQ,QACR,UAAUI,GAAAC,EAAAN,EAAG,gBAAH,YAAAM,EAAkB,QAAlB,YAAAD,EAAyB,QAAA,EAErCJ,EAAK,MAAW,OAChBA,EAAK,OAAY,QAEZA,CACT,CACF,CAAA,CAEJ,EAEA,WAAW,CAAE,eAAAM,GAAkB,CACtB,MAAA,CACL,MACAC,EAAAA,gBAAgB,KAAK,QAAQ,eAAgBD,CAAc,CAAA,CAE/D,EAEA,eAAgB,CACP,MAAA,CACLE,gBAAc,CACZ,KAAMhB,EACN,KAAM,KAAK,KACX,cAAgBiB,GAAU,CACxB,KAAM,CAAK,CAAA,CAAAC,EAAKC,EAAKC,CAAK,EAAIH,EAEvB,MAAA,CACL,IAAAE,EACA,IAAAD,EACA,MAAAE,CAAA,CAEJ,CAAA,CACD,CAAA,CAEL,EAEA,aAAc,CACL,MAAA,CACL,YACGC,GACD,CAAC,CAAE,GAAAC,EAAI,SAAAC,KAAe,CACd,KAAA,CAAE,UAAAC,CAAc,EAAAF,EAChBG,EAAO,KAAK,KAAK,OAAOJ,CAAK,EAEnC,OAAIE,GACFD,EAAG,iBAAiBE,EAAU,KAAMA,EAAU,GAAIC,CAAI,EAGjD,EACT,EACF,cACGrB,GACD,CAAC,CAAE,GAAAkB,EAAI,SAAAC,KAAe,CACd,KAAA,CAAE,UAAAC,CAAc,EAAAF,EAGhBI,EAAU,CACd,GAFgBJ,EAAG,IAAI,OAAOA,EAAG,UAAU,IAAI,EAElC,MACb,GAAGlB,CAAA,EAECqB,EAAO,KAAK,KAAK,OAAOC,CAAO,EAErC,OAAIH,GACFD,EAAG,iBAAiBE,EAAU,KAAMA,EAAU,GAAIC,CAAI,EAGjD,EACT,CAAA,CAEN,CACF,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { mergeAttributes, nodeInputRule } from "@tiptap/core";
|
|
2
|
-
import
|
|
3
|
-
const
|
|
1
|
+
import { mergeAttributes as a, nodeInputRule as u } from "@tiptap/core";
|
|
2
|
+
import h from "@tiptap/extension-image";
|
|
3
|
+
const m = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/, p = h.extend({
|
|
4
4
|
name: "custom-image",
|
|
5
5
|
draggable: !0,
|
|
6
6
|
selectable: !0,
|
|
7
7
|
addOptions() {
|
|
8
|
-
var
|
|
8
|
+
var e;
|
|
9
9
|
return {
|
|
10
|
-
...(
|
|
10
|
+
...(e = this.parent) == null ? void 0 : e.call(this),
|
|
11
11
|
inline: !0,
|
|
12
12
|
content: "inline*",
|
|
13
13
|
sizes: ["small", "medium", "large"],
|
|
@@ -17,45 +17,45 @@ const IMAGE_INPUT_REGEX = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\
|
|
|
17
17
|
};
|
|
18
18
|
},
|
|
19
19
|
addAttributes() {
|
|
20
|
-
var
|
|
20
|
+
var e;
|
|
21
21
|
return {
|
|
22
|
-
...(
|
|
22
|
+
...(e = this.parent) == null ? void 0 : e.call(this),
|
|
23
23
|
size: {
|
|
24
24
|
default: "medium",
|
|
25
25
|
rendered: !1
|
|
26
26
|
},
|
|
27
27
|
alt: {
|
|
28
|
-
renderHTML: (
|
|
29
|
-
alt:
|
|
28
|
+
renderHTML: (t) => ({
|
|
29
|
+
alt: t.alt
|
|
30
30
|
}),
|
|
31
|
-
parseHTML: (
|
|
31
|
+
parseHTML: (t) => t.getAttribute("alt")
|
|
32
32
|
},
|
|
33
33
|
title: {
|
|
34
|
-
renderHTML: (
|
|
35
|
-
title:
|
|
34
|
+
renderHTML: (t) => ({
|
|
35
|
+
title: t.title
|
|
36
36
|
}),
|
|
37
|
-
parseHTML: (
|
|
37
|
+
parseHTML: (t) => t.getAttribute("title")
|
|
38
38
|
},
|
|
39
39
|
width: {
|
|
40
40
|
default: "350",
|
|
41
|
-
renderHTML: (
|
|
42
|
-
width: parseInt(
|
|
41
|
+
renderHTML: (t) => t.width !== null && t.width !== void 0 && !Number.isNaN(t.width) ? {
|
|
42
|
+
width: parseInt(t.width)
|
|
43
43
|
} : {},
|
|
44
|
-
parseHTML: (
|
|
44
|
+
parseHTML: (t) => t.getAttribute("width")
|
|
45
45
|
},
|
|
46
46
|
height: {
|
|
47
|
-
renderHTML: (
|
|
48
|
-
height: parseInt(
|
|
47
|
+
renderHTML: (t) => t.height !== null && t.height !== void 0 && !Number.isNaN(t.height) ? {
|
|
48
|
+
height: parseInt(t.height)
|
|
49
49
|
} : {},
|
|
50
|
-
parseHTML: (
|
|
50
|
+
parseHTML: (t) => t.getAttribute("height")
|
|
51
51
|
},
|
|
52
52
|
style: {
|
|
53
|
-
renderHTML: (
|
|
54
|
-
style:
|
|
53
|
+
renderHTML: (t) => t.style ? {
|
|
54
|
+
style: t.style
|
|
55
55
|
} : {},
|
|
56
|
-
parseHTML: (
|
|
57
|
-
const
|
|
58
|
-
return
|
|
56
|
+
parseHTML: (t) => {
|
|
57
|
+
const r = t.getAttribute("style");
|
|
58
|
+
return r && typeof r == "string" && r.length > 0 ? {} : null;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
};
|
|
@@ -64,10 +64,10 @@ const IMAGE_INPUT_REGEX = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\
|
|
|
64
64
|
return [
|
|
65
65
|
{
|
|
66
66
|
tag: 'img[src]:not([src^="data:"])',
|
|
67
|
-
getAttrs: (
|
|
68
|
-
var
|
|
69
|
-
const
|
|
70
|
-
return (
|
|
67
|
+
getAttrs: (e) => {
|
|
68
|
+
var n, i, s, l, d;
|
|
69
|
+
const t = { src: e.getAttribute("src") };
|
|
70
|
+
return (n = e.parentElement) != null && n.className.includes("image-container") && (i = e.parentElement.style) != null && i.width && (t.width = e.parentElement.style.width), (s = e.style) != null && s.width && (t.width = e.style.width), [
|
|
71
71
|
"happy",
|
|
72
72
|
"proud",
|
|
73
73
|
"dreamy",
|
|
@@ -78,32 +78,32 @@ const IMAGE_INPUT_REGEX = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\
|
|
|
78
78
|
"sick",
|
|
79
79
|
"joker",
|
|
80
80
|
"sad"
|
|
81
|
-
].filter((
|
|
81
|
+
].filter((o) => t.src.includes(o + ".png")).length > 0 && (t.style = {
|
|
82
82
|
width: "1.5em",
|
|
83
83
|
height: "1.5em",
|
|
84
|
-
fontSize: (
|
|
85
|
-
},
|
|
84
|
+
fontSize: (d = (l = e.parentElement) == null ? void 0 : l.style) == null ? void 0 : d.fontSize
|
|
85
|
+
}, t.width = "null", t.height = "null"), t;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
];
|
|
89
89
|
},
|
|
90
|
-
renderHTML({ HTMLAttributes }) {
|
|
90
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
91
91
|
return [
|
|
92
92
|
"img",
|
|
93
|
-
|
|
93
|
+
a(this.options.HTMLAttributes, e)
|
|
94
94
|
];
|
|
95
95
|
},
|
|
96
96
|
addInputRules() {
|
|
97
97
|
return [
|
|
98
|
-
|
|
99
|
-
find:
|
|
98
|
+
u({
|
|
99
|
+
find: m,
|
|
100
100
|
type: this.type,
|
|
101
|
-
getAttributes: (
|
|
102
|
-
const [, ,
|
|
101
|
+
getAttributes: (e) => {
|
|
102
|
+
const [, , t, r, n] = e;
|
|
103
103
|
return {
|
|
104
|
-
src,
|
|
105
|
-
alt,
|
|
106
|
-
title
|
|
104
|
+
src: r,
|
|
105
|
+
alt: t,
|
|
106
|
+
title: n
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
})
|
|
@@ -111,22 +111,22 @@ const IMAGE_INPUT_REGEX = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\
|
|
|
111
111
|
},
|
|
112
112
|
addCommands() {
|
|
113
113
|
return {
|
|
114
|
-
setNewImage: (
|
|
115
|
-
const { selection } =
|
|
116
|
-
return
|
|
114
|
+
setNewImage: (e) => ({ tr: t, dispatch: r }) => {
|
|
115
|
+
const { selection: n } = t, i = this.type.create(e);
|
|
116
|
+
return r && t.replaceRangeWith(n.from, n.to, i), !0;
|
|
117
117
|
},
|
|
118
|
-
setAttributes: (
|
|
119
|
-
const { selection } =
|
|
120
|
-
...
|
|
121
|
-
...
|
|
122
|
-
},
|
|
123
|
-
return
|
|
118
|
+
setAttributes: (e) => ({ tr: t, dispatch: r }) => {
|
|
119
|
+
const { selection: n } = t, s = {
|
|
120
|
+
...t.doc.nodeAt(t.selection.from).attrs,
|
|
121
|
+
...e
|
|
122
|
+
}, l = this.type.create(s);
|
|
123
|
+
return r && t.replaceRangeWith(n.from, n.to, l), !0;
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
128
|
export {
|
|
129
|
-
CustomImage,
|
|
130
|
-
IMAGE_INPUT_REGEX
|
|
129
|
+
p as CustomImage,
|
|
130
|
+
m as IMAGE_INPUT_REGEX
|
|
131
131
|
};
|
|
132
132
|
//# sourceMappingURL=custom-image.js.map
|