@edifice.io/tiptap-extensions 2.0.0-develop-rc.13 → 2.0.0-develop-rc.15
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/README.md +8 -5
- package/dist/abbr/abbr.cjs +1 -32
- package/dist/abbr/abbr.cjs.map +1 -1
- package/dist/abbr/abbr.d.ts +13 -13
- package/dist/abbr/abbr.js +13 -17
- package/dist/abbr/abbr.js.map +1 -1
- package/dist/alert/alert.cjs +1 -32
- package/dist/alert/alert.cjs.map +1 -1
- package/dist/alert/alert.js +22 -20
- package/dist/alert/alert.js.map +1 -1
- package/dist/attachment/attachment-transformer.cjs +2 -0
- package/dist/attachment/attachment-transformer.cjs.map +1 -0
- package/dist/attachment/attachment-transformer.d.ts +12 -0
- package/dist/attachment/attachment-transformer.js +76 -0
- package/dist/attachment/attachment-transformer.js.map +1 -0
- package/dist/attachment/attachment.cjs +1 -73
- package/dist/attachment/attachment.cjs.map +1 -1
- package/dist/attachment/attachment.d.ts +7 -7
- package/dist/attachment/attachment.js +29 -40
- package/dist/attachment/attachment.js.map +1 -1
- package/dist/attachment/index.d.ts +1 -0
- package/dist/audio/audio.cjs +2 -52
- package/dist/audio/audio.cjs.map +1 -1
- package/dist/audio/audio.d.ts +14 -18
- package/dist/audio/audio.js +25 -28
- package/dist/audio/audio.js.map +1 -1
- package/dist/font-size/font-size.cjs +1 -48
- package/dist/font-size/font-size.cjs.map +1 -1
- package/dist/font-size/font-size.d.ts +14 -14
- package/dist/font-size/font-size.js +17 -29
- package/dist/font-size/font-size.js.map +1 -1
- package/dist/heading/heading.cjs +1 -61
- package/dist/heading/heading.cjs.map +1 -1
- package/dist/heading/heading.d.ts +13 -11
- package/dist/heading/heading.js +25 -39
- package/dist/heading/heading.js.map +1 -1
- package/dist/highlight/highlight.cjs +1 -25
- package/dist/highlight/highlight.cjs.map +1 -1
- package/dist/highlight/highlight.d.ts +1 -4
- package/dist/highlight/highlight.js +13 -11
- package/dist/highlight/highlight.js.map +1 -1
- package/dist/hyperlink/hyperlink.cjs +1 -47
- package/dist/hyperlink/hyperlink.cjs.map +1 -1
- package/dist/hyperlink/hyperlink.d.ts +25 -28
- package/dist/hyperlink/hyperlink.js +19 -21
- package/dist/hyperlink/hyperlink.js.map +1 -1
- package/dist/iframe/iframe.cjs +1 -69
- package/dist/iframe/iframe.cjs.map +1 -1
- package/dist/iframe/iframe.d.ts +15 -13
- package/dist/iframe/iframe.js +32 -48
- package/dist/iframe/iframe.js.map +1 -1
- package/dist/image/image.cjs +2 -0
- package/dist/image/image.cjs.map +1 -0
- package/dist/image/image.d.ts +26 -0
- package/dist/image/image.js +178 -0
- package/dist/image/image.js.map +1 -0
- package/dist/image/index.d.ts +3 -3
- package/dist/index.cjs +1 -43
- package/dist/index.js +24 -22
- package/dist/index.js.map +1 -1
- package/dist/line-height/line-height.cjs +1 -33
- package/dist/line-height/line-height.cjs.map +1 -1
- package/dist/line-height/line-height.js +15 -18
- package/dist/line-height/line-height.js.map +1 -1
- package/dist/linker/linker.cjs +1 -95
- package/dist/linker/linker.cjs.map +1 -1
- package/dist/linker/linker.d.ts +18 -18
- package/dist/linker/linker.js +49 -57
- package/dist/linker/linker.js.map +1 -1
- package/dist/mathjax/mathjax.cjs +1 -47
- package/dist/mathjax/mathjax.cjs.map +1 -1
- package/dist/mathjax/mathjax.js +20 -30
- package/dist/mathjax/mathjax.js.map +1 -1
- package/dist/paragraph/paragraph.cjs +1 -13
- package/dist/paragraph/paragraph.cjs.map +1 -1
- package/dist/paragraph/paragraph.d.ts +1 -4
- package/dist/paragraph/paragraph.js +8 -6
- package/dist/paragraph/paragraph.js.map +1 -1
- package/dist/speech-recognition/speech-recognition.cjs +1 -76
- package/dist/speech-recognition/speech-recognition.cjs.map +1 -1
- package/dist/speech-recognition/speech-recognition.d.ts +13 -13
- package/dist/speech-recognition/speech-recognition.js +36 -57
- package/dist/speech-recognition/speech-recognition.js.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.cjs +1 -32
- package/dist/speech-synthesis/speech-synthesis.cjs.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.d.ts +10 -10
- package/dist/speech-synthesis/speech-synthesis.js +10 -19
- package/dist/speech-synthesis/speech-synthesis.js.map +1 -1
- package/dist/table-cell/table-cell.cjs +1 -27
- package/dist/table-cell/table-cell.cjs.map +1 -1
- package/dist/table-cell/table-cell.d.ts +1 -4
- package/dist/table-cell/table-cell.js +12 -17
- package/dist/table-cell/table-cell.js.map +1 -1
- package/dist/transform/html-to-json/html-to-json.cjs +1 -4
- package/dist/transform/html-to-json/html-to-json.cjs.map +1 -1
- package/dist/transform/html-to-json/html-to-json.d.ts +1 -4
- package/dist/transform/html-to-json/html-to-json.js +4 -2
- package/dist/transform/html-to-json/html-to-json.js.map +1 -1
- package/dist/transform/json-to-html/json-to-html.cjs +1 -4
- package/dist/transform/json-to-html/json-to-html.cjs.map +1 -1
- package/dist/transform/json-to-html/json-to-html.js +4 -2
- package/dist/transform/json-to-html/json-to-html.js.map +1 -1
- package/dist/video/video.cjs +2 -111
- package/dist/video/video.cjs.map +1 -1
- package/dist/video/video.d.ts +20 -29
- package/dist/video/video.js +90 -114
- package/dist/video/video.js.map +1 -1
- package/package.json +24 -16
- package/dist/image/custom-image.cjs +0 -163
- package/dist/image/custom-image.cjs.map +0 -1
- package/dist/image/custom-image.d.ts +0 -27
- package/dist/image/custom-image.js +0 -181
- package/dist/image/custom-image.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Extension } from
|
|
1
|
+
import "@tiptap/extension-text-style";
|
|
2
|
+
import { Extension } from "@tiptap/core";
|
|
3
3
|
const LineHeight = Extension.create({
|
|
4
|
-
name:
|
|
4
|
+
name: "lineHeight",
|
|
5
5
|
addOptions() {
|
|
6
6
|
return {
|
|
7
|
-
types: [
|
|
7
|
+
types: ["textStyle"]
|
|
8
8
|
};
|
|
9
9
|
},
|
|
10
10
|
addGlobalAttributes() {
|
|
@@ -16,21 +16,18 @@ const LineHeight = Extension.create({
|
|
|
16
16
|
default: null,
|
|
17
17
|
parseHTML: (element) => {
|
|
18
18
|
var _a;
|
|
19
|
-
return (_a = element.style.lineHeight) == null
|
|
20
|
-
? void 0
|
|
21
|
-
: _a.replace(/['"]+/g, '');
|
|
19
|
+
return (_a = element.style.lineHeight) == null ? void 0 : _a.replace(/['"]+/g, "");
|
|
22
20
|
},
|
|
23
|
-
renderHTML: (attributes) =>
|
|
24
|
-
attributes.lineHeight
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
21
|
+
renderHTML: (attributes) => attributes.lineHeight ? {
|
|
22
|
+
style: `line-height: ${attributes.lineHeight}`
|
|
23
|
+
} : {}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
32
27
|
];
|
|
33
|
-
}
|
|
28
|
+
}
|
|
34
29
|
});
|
|
35
|
-
export {
|
|
30
|
+
export {
|
|
31
|
+
LineHeight
|
|
32
|
+
};
|
|
36
33
|
//# sourceMappingURL=line-height.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-height.js","sources":["../../src/line-height/line-height.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"line-height.js","sources":["../../src/line-height/line-height.ts"],"sourcesContent":["import \"@tiptap/extension-text-style\";\n\nimport { Extension } from \"@tiptap/core\";\n\nexport const LineHeight = Extension.create({\n name: \"lineHeight\",\n\n addOptions() {\n return {\n types: [\"textStyle\"],\n };\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n lineHeight: {\n default: null,\n parseHTML: (element) =>\n element.style.lineHeight?.replace(/['\"]+/g, \"\"),\n renderHTML: (attributes) => {\n if (!attributes.lineHeight) {\n return {};\n }\n\n return {\n style: `line-height: ${attributes.lineHeight}`,\n };\n },\n },\n },\n },\n ];\n },\n});\n"],"names":[],"mappings":";;AAIa,MAAA,aAAa,UAAU,OAAO;AAAA,EACzC,MAAM;AAAA,EAEN,aAAa;AACJ,WAAA;AAAA,MACL,OAAO,CAAC,WAAW;AAAA,IACrB;AAAA,EACF;AAAA,EAEA,sBAAsB;AACb,WAAA;AAAA,MACL;AAAA,QACE,OAAO,KAAK,QAAQ;AAAA,QACpB,YAAY;AAAA,UACV,YAAY;AAAA,YACV,SAAS;AAAA,YACT,WAAW,CAAC,YACV;;AAAA,mCAAQ,MAAM,eAAd,mBAA0B,QAAQ,UAAU;AAAA;AAAA,YAC9C,YAAY,CAAC,eACN,WAAW,aAIT;AAAA,cACL,OAAO,gBAAgB,WAAW,UAAU;AAAA,YAC9C,IALS,CAAC;AAAA,UAMZ;AAAA,QACF;AAAA,MACF;AAAA,IAEJ;AAAA,EAAA;AAEJ,CAAC;"}
|
package/dist/linker/linker.cjs
CHANGED
|
@@ -1,96 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
-
const core = require('@tiptap/core'),
|
|
4
|
-
Linker = core.Node.create({
|
|
5
|
-
name: 'linker',
|
|
6
|
-
content: 'text*',
|
|
7
|
-
marks: '',
|
|
8
|
-
group: 'inline',
|
|
9
|
-
inline: !0,
|
|
10
|
-
selectable: !0,
|
|
11
|
-
atom: !0,
|
|
12
|
-
draggable: !0,
|
|
13
|
-
isolating: !0,
|
|
14
|
-
allowGapCursor: !1,
|
|
15
|
-
priority: 1100,
|
|
16
|
-
keepOnSplit: !1,
|
|
17
|
-
addOptions() {
|
|
18
|
-
return {
|
|
19
|
-
openOnClick: !0,
|
|
20
|
-
HTMLAttributes: {
|
|
21
|
-
target: null,
|
|
22
|
-
title: null,
|
|
23
|
-
class: null,
|
|
24
|
-
'data-id': null,
|
|
25
|
-
'data-app-prefix': null,
|
|
26
|
-
},
|
|
27
|
-
validate: void 0,
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
addAttributes() {
|
|
31
|
-
return {
|
|
32
|
-
href: { default: null },
|
|
33
|
-
class: { default: this.options.HTMLAttributes.class },
|
|
34
|
-
target: {
|
|
35
|
-
default: this.options.HTMLAttributes.target,
|
|
36
|
-
parseHTML: (element) =>
|
|
37
|
-
element.getAttribute('target') !== '_blank' ? null : '_blank',
|
|
38
|
-
},
|
|
39
|
-
title: { default: this.options.HTMLAttributes.title },
|
|
40
|
-
'data-id': { default: this.options.HTMLAttributes['data-id'] },
|
|
41
|
-
'data-app-prefix': {
|
|
42
|
-
default: this.options.HTMLAttributes['data-app-prefix'],
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
parseHTML() {
|
|
47
|
-
return [
|
|
48
|
-
{
|
|
49
|
-
tag: 'a[href]:not([href *= "javascript:" i])[data-id][data-app-prefix]',
|
|
50
|
-
},
|
|
51
|
-
];
|
|
52
|
-
},
|
|
53
|
-
renderHTML({ HTMLAttributes }) {
|
|
54
|
-
var _a;
|
|
55
|
-
return (_a = HTMLAttributes.href) != null && _a.startsWith('javascript:')
|
|
56
|
-
? [
|
|
57
|
-
'a',
|
|
58
|
-
core.mergeAttributes(this.options.HTMLAttributes, {
|
|
59
|
-
...HTMLAttributes,
|
|
60
|
-
href: '',
|
|
61
|
-
}),
|
|
62
|
-
0,
|
|
63
|
-
]
|
|
64
|
-
: [
|
|
65
|
-
'a',
|
|
66
|
-
core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
67
|
-
0,
|
|
68
|
-
];
|
|
69
|
-
},
|
|
70
|
-
addCommands() {
|
|
71
|
-
return {
|
|
72
|
-
setLinker:
|
|
73
|
-
(attrs) =>
|
|
74
|
-
({ commands }) => (
|
|
75
|
-
commands.insertContent({
|
|
76
|
-
type: this.name,
|
|
77
|
-
attrs,
|
|
78
|
-
content: [{ type: 'text', text: attrs.title }],
|
|
79
|
-
}),
|
|
80
|
-
!0
|
|
81
|
-
),
|
|
82
|
-
unsetLinker:
|
|
83
|
-
() =>
|
|
84
|
-
({ state, tr }) => {
|
|
85
|
-
const { node, from, to } = state.selection;
|
|
86
|
-
return (
|
|
87
|
-
(node == null ? void 0 : node.type.name) === 'linker' &&
|
|
88
|
-
tr.delete(from, to).scrollIntoView(),
|
|
89
|
-
!0
|
|
90
|
-
);
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
exports.Linker = Linker;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@tiptap/core"),Linker=core.Node.create({name:"linker",content:"text*",marks:"",group:"inline",inline:!0,selectable:!0,atom:!0,draggable:!0,isolating:!0,allowGapCursor:!1,priority:1100,keepOnSplit:!1,addOptions(){return{openOnClick:!0,HTMLAttributes:{target:null,title:null,class:null,"data-id":null,"data-app-prefix":null},validate:void 0}},addAttributes(){return{href:{default:null},class:{default:this.options.HTMLAttributes.class},target:{default:this.options.HTMLAttributes.target,parseHTML:element=>element.getAttribute("target")!=="_blank"?null:"_blank"},title:{default:this.options.HTMLAttributes.title},"data-id":{default:this.options.HTMLAttributes["data-id"]},"data-app-prefix":{default:this.options.HTMLAttributes["data-app-prefix"]}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])[data-id][data-app-prefix]'}]},renderHTML({HTMLAttributes}){var _a;return(_a=HTMLAttributes.href)!=null&&_a.startsWith("javascript:")?["a",core.mergeAttributes(this.options.HTMLAttributes,{...HTMLAttributes,href:""}),0]:["a",core.mergeAttributes(this.options.HTMLAttributes,HTMLAttributes),0]},addCommands(){return{setLinker:attrs=>({commands})=>(commands.insertContent({type:this.name,attrs,content:[{type:"text",text:attrs.title}]}),!0),unsetLinker:()=>({state,tr})=>{const{node,from,to}=state.selection;return(node==null?void 0:node.type.name)==="linker"&&tr.delete(from,to).scrollIntoView(),!0}}}});exports.Linker=Linker;
|
|
96
2
|
//# sourceMappingURL=linker.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linker.cjs","sources":["../../src/linker/linker.ts"],"sourcesContent":["import { Node, mergeAttributes } from
|
|
1
|
+
{"version":3,"file":"linker.cjs","sources":["../../src/linker/linker.ts"],"sourcesContent":["import { Node, mergeAttributes } from \"@tiptap/core\";\nimport { NodeSelection } from \"@tiptap/pm/state\";\n\n/* Our own model of a link in a rich document. */\nexport type LinkerAttributes = {\n \"href\": string | null;\n \"target\": \"_blank\" | null;\n \"title\": string | null;\n \"data-id\": string | null;\n \"data-app-prefix\": string | null;\n};\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n linker: {\n /**\n * Set a linker node\n */\n setLinker: (attributes: LinkerAttributes) => ReturnType;\n /**\n * Unset a linker node\n */\n unsetLinker: () => ReturnType;\n };\n }\n}\n\n/**\n * Internal links extension.\n * Reproduces the legacy angularJs \"linker\" directive.\n *\n * Links to internal resources MAY have a `title` and MUST HAVE `data-id` and `data-app-prefix` attributes :\n * `<a href=\"/blog#/view/35fa4198-blog_id/5e654c71-article_id\" data-app-prefix=\"blog\" data-id=\"35fa4198-blog_id\" target=\"_blank\" title=\"Voir ce billet de blog\" class=\"ng-scope\">/blog#/view/35fa4198-57fe-45eb-94f4-a5e4defff305/5e654c71-1e61-4f84-86dc-6fcfaf33f513</a>`\n */\nexport const Linker = Node.create({\n name: \"linker\",\n content: \"text*\",\n marks: \"\",\n group: \"inline\",\n\n inline: true,\n selectable: true,\n atom: true,\n draggable: true,\n isolating: true,\n allowGapCursor: false,\n\n priority: 1100,\n keepOnSplit: false,\n\n addOptions() {\n return {\n openOnClick: true,\n HTMLAttributes: {\n \"target\": null,\n \"title\": null,\n \"class\": null,\n \"data-id\": null,\n \"data-app-prefix\": null,\n },\n validate: undefined,\n };\n },\n\n addAttributes() {\n return {\n \"href\": {\n default: null,\n },\n \"class\": {\n default: this.options.HTMLAttributes.class,\n },\n \"target\": {\n default: this.options.HTMLAttributes.target,\n // Sanitize target value\n parseHTML: (element) =>\n element.getAttribute(\"target\") !== \"_blank\" ? null : \"_blank\",\n },\n \"title\": {\n default: this.options.HTMLAttributes.title,\n },\n \"data-id\": {\n default: this.options.HTMLAttributes[\"data-id\"],\n },\n \"data-app-prefix\": {\n default: this.options.HTMLAttributes[\"data-app-prefix\"],\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'a[href]:not([href *= \"javascript:\" i])[data-id][data-app-prefix]',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n if (HTMLAttributes.href?.startsWith(\"javascript:\")) {\n return [\n \"a\",\n mergeAttributes(this.options.HTMLAttributes, {\n ...HTMLAttributes,\n href: \"\",\n }),\n 0,\n ];\n }\n return [\n \"a\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setLinker:\n (attrs) =>\n ({ commands }) => {\n // Insert a Linker node with inner text node\n commands.insertContent({\n type: this.name,\n attrs,\n content: [\n {\n type: \"text\",\n text: attrs.title,\n },\n ],\n });\n return true;\n },\n\n unsetLinker:\n () =>\n ({ state, tr }) => {\n // Which Linker node is actually selected ?\n const { node, from, to } = state.selection as NodeSelection;\n // Delete any selected Linker node\n if (node?.type.name === \"linker\") {\n /* The following does not work as one would expected.\n commands.deleteNode(this.name);\n commands.deleteCurrentNode();\n * Replaced by : */\n tr.delete(from, to).scrollIntoView();\n }\n return true;\n },\n };\n },\n});\n"],"names":["Node","mergeAttributes"],"mappings":"mHAkCa,OAASA,UAAK,OAAO,CAChC,KAAM,SACN,QAAS,QACT,MAAO,GACP,MAAO,SAEP,OAAQ,GACR,WAAY,GACZ,KAAM,GACN,UAAW,GACX,UAAW,GACX,eAAgB,GAEhB,SAAU,KACV,YAAa,GAEb,YAAa,CACJ,MAAA,CACL,YAAa,GACb,eAAgB,CACd,OAAU,KACV,MAAS,KACT,MAAS,KACT,UAAW,KACX,kBAAmB,IACrB,EACA,SAAU,MACZ,CACF,EAEA,eAAgB,CACP,MAAA,CACL,KAAQ,CACN,QAAS,IACX,EACA,MAAS,CACP,QAAS,KAAK,QAAQ,eAAe,KACvC,EACA,OAAU,CACR,QAAS,KAAK,QAAQ,eAAe,OAErC,UAAY,SACV,QAAQ,aAAa,QAAQ,IAAM,SAAW,KAAO,QACzD,EACA,MAAS,CACP,QAAS,KAAK,QAAQ,eAAe,KACvC,EACA,UAAW,CACT,QAAS,KAAK,QAAQ,eAAe,SAAS,CAChD,EACA,kBAAmB,CACjB,QAAS,KAAK,QAAQ,eAAe,iBAAiB,CAAA,CAE1D,CACF,EAEA,WAAY,CACH,MAAA,CACL,CACE,IAAK,kEAAA,CAET,CACF,EAEA,WAAW,CAAE,gBAAkB,QAC7B,OAAI,kBAAe,OAAf,SAAqB,WAAW,eAC3B,CACL,IACAC,qBAAgB,KAAK,QAAQ,eAAgB,CAC3C,GAAG,eACH,KAAM,EAAA,CACP,EACD,CACF,EAEK,CACL,IACAA,KAAAA,gBAAgB,KAAK,QAAQ,eAAgB,cAAc,EAC3D,CACF,CACF,EAEA,aAAc,CACL,MAAA,CACL,UACG,OACD,CAAC,CAAE,aAED,SAAS,cAAc,CACrB,KAAM,KAAK,KACX,MACA,QAAS,CACP,CACE,KAAM,OACN,KAAM,MAAM,KAAA,CACd,CACF,CACD,EACM,IAGX,YACE,IACA,CAAC,CAAE,MAAO,MAAS,CAEjB,KAAM,CAAE,KAAM,KAAM,IAAO,MAAM,UAE7B,OAAA,uBAAM,KAAK,QAAS,UAKtB,GAAG,OAAO,KAAM,EAAE,EAAE,eAAe,EAE9B,EAAA,CAEb,CAAA,CAEJ,CAAC"}
|
package/dist/linker/linker.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { Node } from '@tiptap/core';
|
|
2
2
|
export type LinkerAttributes = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
"href": string | null;
|
|
4
|
+
"target": "_blank" | null;
|
|
5
|
+
"title": string | null;
|
|
6
|
+
"data-id": string | null;
|
|
7
|
+
"data-app-prefix": string | null;
|
|
8
8
|
};
|
|
9
|
-
declare module
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
declare module "@tiptap/core" {
|
|
10
|
+
interface Commands<ReturnType> {
|
|
11
|
+
linker: {
|
|
12
|
+
/**
|
|
13
|
+
* Set a linker node
|
|
14
|
+
*/
|
|
15
|
+
setLinker: (attributes: LinkerAttributes) => ReturnType;
|
|
16
|
+
/**
|
|
17
|
+
* Unset a linker node
|
|
18
|
+
*/
|
|
19
|
+
unsetLinker: () => ReturnType;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Internal links extension.
|
package/dist/linker/linker.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Node, mergeAttributes } from
|
|
1
|
+
import { Node, mergeAttributes } from "@tiptap/core";
|
|
2
2
|
const Linker = Node.create({
|
|
3
|
-
name:
|
|
4
|
-
content:
|
|
5
|
-
marks:
|
|
6
|
-
group:
|
|
3
|
+
name: "linker",
|
|
4
|
+
content: "text*",
|
|
5
|
+
marks: "",
|
|
6
|
+
group: "inline",
|
|
7
7
|
inline: !0,
|
|
8
8
|
selectable: !0,
|
|
9
9
|
atom: !0,
|
|
@@ -19,86 +19,78 @@ const Linker = Node.create({
|
|
|
19
19
|
target: null,
|
|
20
20
|
title: null,
|
|
21
21
|
class: null,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
"data-id": null,
|
|
23
|
+
"data-app-prefix": null
|
|
24
24
|
},
|
|
25
|
-
validate: void 0
|
|
25
|
+
validate: void 0
|
|
26
26
|
};
|
|
27
27
|
},
|
|
28
28
|
addAttributes() {
|
|
29
29
|
return {
|
|
30
30
|
href: {
|
|
31
|
-
default: null
|
|
31
|
+
default: null
|
|
32
32
|
},
|
|
33
33
|
class: {
|
|
34
|
-
default: this.options.HTMLAttributes.class
|
|
34
|
+
default: this.options.HTMLAttributes.class
|
|
35
35
|
},
|
|
36
36
|
target: {
|
|
37
37
|
default: this.options.HTMLAttributes.target,
|
|
38
38
|
// Sanitize target value
|
|
39
|
-
parseHTML: (element) =>
|
|
40
|
-
element.getAttribute('target') !== '_blank' ? null : '_blank',
|
|
39
|
+
parseHTML: (element) => element.getAttribute("target") !== "_blank" ? null : "_blank"
|
|
41
40
|
},
|
|
42
41
|
title: {
|
|
43
|
-
default: this.options.HTMLAttributes.title
|
|
42
|
+
default: this.options.HTMLAttributes.title
|
|
44
43
|
},
|
|
45
|
-
|
|
46
|
-
default: this.options.HTMLAttributes[
|
|
47
|
-
},
|
|
48
|
-
'data-app-prefix': {
|
|
49
|
-
default: this.options.HTMLAttributes['data-app-prefix'],
|
|
44
|
+
"data-id": {
|
|
45
|
+
default: this.options.HTMLAttributes["data-id"]
|
|
50
46
|
},
|
|
47
|
+
"data-app-prefix": {
|
|
48
|
+
default: this.options.HTMLAttributes["data-app-prefix"]
|
|
49
|
+
}
|
|
51
50
|
};
|
|
52
51
|
},
|
|
53
52
|
parseHTML() {
|
|
54
53
|
return [
|
|
55
54
|
{
|
|
56
|
-
tag: 'a[href]:not([href *= "javascript:" i])[data-id][data-app-prefix]'
|
|
57
|
-
}
|
|
55
|
+
tag: 'a[href]:not([href *= "javascript:" i])[data-id][data-app-prefix]'
|
|
56
|
+
}
|
|
58
57
|
];
|
|
59
58
|
},
|
|
60
59
|
renderHTML({ HTMLAttributes }) {
|
|
61
60
|
var _a;
|
|
62
|
-
return (_a = HTMLAttributes.href) != null && _a.startsWith(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
return (_a = HTMLAttributes.href) != null && _a.startsWith("javascript:") ? [
|
|
62
|
+
"a",
|
|
63
|
+
mergeAttributes(this.options.HTMLAttributes, {
|
|
64
|
+
...HTMLAttributes,
|
|
65
|
+
href: ""
|
|
66
|
+
}),
|
|
67
|
+
0
|
|
68
|
+
] : [
|
|
69
|
+
"a",
|
|
70
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
71
|
+
0
|
|
72
|
+
];
|
|
72
73
|
},
|
|
73
74
|
addCommands() {
|
|
74
75
|
return {
|
|
75
|
-
setLinker:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
),
|
|
90
|
-
unsetLinker:
|
|
91
|
-
() =>
|
|
92
|
-
({ state, tr }) => {
|
|
93
|
-
const { node, from, to } = state.selection;
|
|
94
|
-
return (
|
|
95
|
-
(node == null ? void 0 : node.type.name) === 'linker' &&
|
|
96
|
-
tr.delete(from, to).scrollIntoView(),
|
|
97
|
-
!0
|
|
98
|
-
);
|
|
99
|
-
},
|
|
76
|
+
setLinker: (attrs) => ({ commands }) => (commands.insertContent({
|
|
77
|
+
type: this.name,
|
|
78
|
+
attrs,
|
|
79
|
+
content: [
|
|
80
|
+
{
|
|
81
|
+
type: "text",
|
|
82
|
+
text: attrs.title
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}), !0),
|
|
86
|
+
unsetLinker: () => ({ state, tr }) => {
|
|
87
|
+
const { node, from, to } = state.selection;
|
|
88
|
+
return (node == null ? void 0 : node.type.name) === "linker" && tr.delete(from, to).scrollIntoView(), !0;
|
|
89
|
+
}
|
|
100
90
|
};
|
|
101
|
-
}
|
|
91
|
+
}
|
|
102
92
|
});
|
|
103
|
-
export {
|
|
93
|
+
export {
|
|
94
|
+
Linker
|
|
95
|
+
};
|
|
104
96
|
//# sourceMappingURL=linker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linker.js","sources":["../../src/linker/linker.ts"],"sourcesContent":["import { Node, mergeAttributes } from
|
|
1
|
+
{"version":3,"file":"linker.js","sources":["../../src/linker/linker.ts"],"sourcesContent":["import { Node, mergeAttributes } from \"@tiptap/core\";\nimport { NodeSelection } from \"@tiptap/pm/state\";\n\n/* Our own model of a link in a rich document. */\nexport type LinkerAttributes = {\n \"href\": string | null;\n \"target\": \"_blank\" | null;\n \"title\": string | null;\n \"data-id\": string | null;\n \"data-app-prefix\": string | null;\n};\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n linker: {\n /**\n * Set a linker node\n */\n setLinker: (attributes: LinkerAttributes) => ReturnType;\n /**\n * Unset a linker node\n */\n unsetLinker: () => ReturnType;\n };\n }\n}\n\n/**\n * Internal links extension.\n * Reproduces the legacy angularJs \"linker\" directive.\n *\n * Links to internal resources MAY have a `title` and MUST HAVE `data-id` and `data-app-prefix` attributes :\n * `<a href=\"/blog#/view/35fa4198-blog_id/5e654c71-article_id\" data-app-prefix=\"blog\" data-id=\"35fa4198-blog_id\" target=\"_blank\" title=\"Voir ce billet de blog\" class=\"ng-scope\">/blog#/view/35fa4198-57fe-45eb-94f4-a5e4defff305/5e654c71-1e61-4f84-86dc-6fcfaf33f513</a>`\n */\nexport const Linker = Node.create({\n name: \"linker\",\n content: \"text*\",\n marks: \"\",\n group: \"inline\",\n\n inline: true,\n selectable: true,\n atom: true,\n draggable: true,\n isolating: true,\n allowGapCursor: false,\n\n priority: 1100,\n keepOnSplit: false,\n\n addOptions() {\n return {\n openOnClick: true,\n HTMLAttributes: {\n \"target\": null,\n \"title\": null,\n \"class\": null,\n \"data-id\": null,\n \"data-app-prefix\": null,\n },\n validate: undefined,\n };\n },\n\n addAttributes() {\n return {\n \"href\": {\n default: null,\n },\n \"class\": {\n default: this.options.HTMLAttributes.class,\n },\n \"target\": {\n default: this.options.HTMLAttributes.target,\n // Sanitize target value\n parseHTML: (element) =>\n element.getAttribute(\"target\") !== \"_blank\" ? null : \"_blank\",\n },\n \"title\": {\n default: this.options.HTMLAttributes.title,\n },\n \"data-id\": {\n default: this.options.HTMLAttributes[\"data-id\"],\n },\n \"data-app-prefix\": {\n default: this.options.HTMLAttributes[\"data-app-prefix\"],\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'a[href]:not([href *= \"javascript:\" i])[data-id][data-app-prefix]',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n if (HTMLAttributes.href?.startsWith(\"javascript:\")) {\n return [\n \"a\",\n mergeAttributes(this.options.HTMLAttributes, {\n ...HTMLAttributes,\n href: \"\",\n }),\n 0,\n ];\n }\n return [\n \"a\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setLinker:\n (attrs) =>\n ({ commands }) => {\n // Insert a Linker node with inner text node\n commands.insertContent({\n type: this.name,\n attrs,\n content: [\n {\n type: \"text\",\n text: attrs.title,\n },\n ],\n });\n return true;\n },\n\n unsetLinker:\n () =>\n ({ state, tr }) => {\n // Which Linker node is actually selected ?\n const { node, from, to } = state.selection as NodeSelection;\n // Delete any selected Linker node\n if (node?.type.name === \"linker\") {\n /* The following does not work as one would expected.\n commands.deleteNode(this.name);\n commands.deleteCurrentNode();\n * Replaced by : */\n tr.delete(from, to).scrollIntoView();\n }\n return true;\n },\n };\n },\n});\n"],"names":[],"mappings":";AAkCa,MAAA,SAAS,KAAK,OAAO;AAAA,EAChC,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,EAEP,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,WAAW;AAAA,EACX,WAAW;AAAA,EACX,gBAAgB;AAAA,EAEhB,UAAU;AAAA,EACV,aAAa;AAAA,EAEb,aAAa;AACJ,WAAA;AAAA,MACL,aAAa;AAAA,MACb,gBAAgB;AAAA,QACd,QAAU;AAAA,QACV,OAAS;AAAA,QACT,OAAS;AAAA,QACT,WAAW;AAAA,QACX,mBAAmB;AAAA,MACrB;AAAA,MACA,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EAEA,gBAAgB;AACP,WAAA;AAAA,MACL,MAAQ;AAAA,QACN,SAAS;AAAA,MACX;AAAA,MACA,OAAS;AAAA,QACP,SAAS,KAAK,QAAQ,eAAe;AAAA,MACvC;AAAA,MACA,QAAU;AAAA,QACR,SAAS,KAAK,QAAQ,eAAe;AAAA;AAAA,QAErC,WAAW,CAAC,YACV,QAAQ,aAAa,QAAQ,MAAM,WAAW,OAAO;AAAA,MACzD;AAAA,MACA,OAAS;AAAA,QACP,SAAS,KAAK,QAAQ,eAAe;AAAA,MACvC;AAAA,MACA,WAAW;AAAA,QACT,SAAS,KAAK,QAAQ,eAAe,SAAS;AAAA,MAChD;AAAA,MACA,mBAAmB;AAAA,QACjB,SAAS,KAAK,QAAQ,eAAe,iBAAiB;AAAA,MAAA;AAAA,IAE1D;AAAA,EACF;AAAA,EAEA,YAAY;AACH,WAAA;AAAA,MACL;AAAA,QACE,KAAK;AAAA,MAAA;AAAA,IAET;AAAA,EACF;AAAA,EAEA,WAAW,EAAE,kBAAkB;;AAC7B,YAAI,oBAAe,SAAf,WAAqB,WAAW,iBAC3B;AAAA,MACL;AAAA,MACA,gBAAgB,KAAK,QAAQ,gBAAgB;AAAA,QAC3C,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACP;AAAA,MACD;AAAA,IACF,IAEK;AAAA,MACL;AAAA,MACA,gBAAgB,KAAK,QAAQ,gBAAgB,cAAc;AAAA,MAC3D;AAAA,IACF;AAAA,EACF;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,WACE,CAAC,UACD,CAAC,EAAE,gBAED,SAAS,cAAc;AAAA,QACrB,MAAM,KAAK;AAAA,QACX;AAAA,QACA,SAAS;AAAA,UACP;AAAA,YACE,MAAM;AAAA,YACN,MAAM,MAAM;AAAA,UAAA;AAAA,QACd;AAAA,MACF,CACD,GACM;AAAA,MAGX,aACE,MACA,CAAC,EAAE,OAAO,SAAS;AAEjB,cAAM,EAAE,MAAM,MAAM,OAAO,MAAM;AAE7B,gBAAA,6BAAM,KAAK,UAAS,YAKtB,GAAG,OAAO,MAAM,EAAE,EAAE,eAAe,GAE9B;AAAA,MAAA;AAAA,IAEb;AAAA,EAAA;AAEJ,CAAC;"}
|
package/dist/mathjax/mathjax.cjs
CHANGED
|
@@ -1,48 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
-
const core = require('@tiptap/core'),
|
|
4
|
-
MathJax = core.Node.create({
|
|
5
|
-
name: 'mathjaxnode',
|
|
6
|
-
group: 'inline',
|
|
7
|
-
inline: !0,
|
|
8
|
-
atom: !1,
|
|
9
|
-
selectable: !0,
|
|
10
|
-
parseHTML() {
|
|
11
|
-
return [{ tag: 'mathjax' }];
|
|
12
|
-
},
|
|
13
|
-
addAttributes() {
|
|
14
|
-
return {
|
|
15
|
-
equation: {
|
|
16
|
-
default: null,
|
|
17
|
-
parseHTML: (element) => {
|
|
18
|
-
const textNodes = [...element.childNodes].filter(
|
|
19
|
-
(child) => child.nodeType === 3,
|
|
20
|
-
);
|
|
21
|
-
return textNodes.length > 0
|
|
22
|
-
? textNodes[textNodes.length - 1].nodeValue
|
|
23
|
-
: null;
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
renderHTML({ HTMLAttributes }) {
|
|
29
|
-
let equation = (HTMLAttributes.equation || '')
|
|
30
|
-
.replaceAll(
|
|
31
|
-
/(?:\\)?begin{equation}\s*\n?\s*{(.+?)}\n?\s*?(?:\\)?end{equation}/gm,
|
|
32
|
-
'$$$1$$',
|
|
33
|
-
)
|
|
34
|
-
.replaceAll(
|
|
35
|
-
/(?:\\)?begin{equation}\s*\n?\s*(.+?)\n?\s*?(?:\\)?end{equation}/gm,
|
|
36
|
-
'$$$1$$',
|
|
37
|
-
);
|
|
38
|
-
return (
|
|
39
|
-
equation.length > 0 &&
|
|
40
|
-
(equation.charAt(0) !== '$' && (equation = `$${equation}`),
|
|
41
|
-
equation.charAt(equation.length - 1) !== '$' &&
|
|
42
|
-
(equation = `${equation}$`)),
|
|
43
|
-
['span', {}, equation]
|
|
44
|
-
);
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
exports.MathJax = MathJax;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@tiptap/core"),MathJax=core.Node.create({name:"mathjaxnode",group:"inline",inline:!0,atom:!1,selectable:!0,parseHTML(){return[{tag:"mathjax"}]},addAttributes(){return{equation:{default:null,parseHTML:element=>{const textNodes=[...element.childNodes].filter(child=>child.nodeType===3);return textNodes.length>0?textNodes[textNodes.length-1].nodeValue:null}}}},renderHTML({HTMLAttributes}){let equation=(HTMLAttributes.equation||"").replaceAll(/(?:\\)?begin{equation}\s*\n?\s*{(.+?)}\n?\s*?(?:\\)?end{equation}/gm,"$$$1$$").replaceAll(/(?:\\)?begin{equation}\s*\n?\s*(.+?)\n?\s*?(?:\\)?end{equation}/gm,"$$$1$$");return equation.length>0&&(equation.charAt(0)!=="$"&&(equation=`$${equation}`),equation.charAt(equation.length-1)!=="$"&&(equation=`${equation}$`)),["span",{},equation]}});exports.MathJax=MathJax;
|
|
48
2
|
//# sourceMappingURL=mathjax.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mathjax.cjs","sources":["../../src/mathjax/mathjax.ts"],"sourcesContent":["import { Node } from
|
|
1
|
+
{"version":3,"file":"mathjax.cjs","sources":["../../src/mathjax/mathjax.ts"],"sourcesContent":["import { Node } from \"@tiptap/core\";\n\nexport const MathJax = Node.create({\n name: \"mathjaxnode\",\n group: \"inline\",\n inline: true,\n atom: false,\n selectable: true,\n\n parseHTML() {\n return [\n {\n tag: \"mathjax\",\n },\n ];\n },\n\n addAttributes() {\n return {\n equation: {\n default: null,\n parseHTML: (element: any) => {\n const children = [...element.childNodes];\n const textNodes = children.filter((child) => child.nodeType === 3);\n return textNodes.length > 0\n ? textNodes[textNodes.length - 1].nodeValue\n : null;\n },\n },\n };\n },\n\n renderHTML({ HTMLAttributes }) {\n let equation = (HTMLAttributes.equation || \"\")\n // Get what is between \\begin{equation}{... ...}\\end{equation}\n // Or between \\begin{equation}... ...\\end{equation} without enclosing brackets\n .replaceAll(\n /(?:\\\\)?begin{equation}\\s*\\n?\\s*{(.+?)}\\n?\\s*?(?:\\\\)?end{equation}/gm,\n \"$$$1$$\",\n )\n .replaceAll(\n /(?:\\\\)?begin{equation}\\s*\\n?\\s*(.+?)\\n?\\s*?(?:\\\\)?end{equation}/gm,\n \"$$$1$$\",\n );\n if (equation.length > 0) {\n if (equation.charAt(0) !== \"$\") {\n equation = `$${equation}`;\n }\n if (equation.charAt(equation.length - 1) !== \"$\") {\n equation = `${equation}$`;\n }\n }\n return [\"span\", {}, equation];\n },\n});\n"],"names":["Node"],"mappings":"mHAEa,QAAUA,UAAK,OAAO,CACjC,KAAM,cACN,MAAO,SACP,OAAQ,GACR,KAAM,GACN,WAAY,GAEZ,WAAY,CACH,MAAA,CACL,CACE,IAAK,SAAA,CAET,CACF,EAEA,eAAgB,CACP,MAAA,CACL,SAAU,CACR,QAAS,KACT,UAAY,SAAiB,CAE3B,MAAM,UADW,CAAC,GAAG,QAAQ,UAAU,EACZ,OAAQ,OAAU,MAAM,WAAa,CAAC,EAC1D,OAAA,UAAU,OAAS,EACtB,UAAU,UAAU,OAAS,CAAC,EAAE,UAChC,IAAA,CACN,CAEJ,CACF,EAEA,WAAW,CAAE,gBAAkB,CACzB,IAAA,UAAY,eAAe,UAAY,IAGxC,WACC,sEACA,QAAA,EAED,WACC,oEACA,QACF,EACE,OAAA,SAAS,OAAS,IAChB,SAAS,OAAO,CAAC,IAAM,MACzB,SAAW,IAAI,QAAQ,IAErB,SAAS,OAAO,SAAS,OAAS,CAAC,IAAM,MAC3C,SAAW,GAAG,QAAQ,MAGnB,CAAC,OAAQ,CAAC,EAAG,QAAQ,CAAA,CAEhC,CAAC"}
|
package/dist/mathjax/mathjax.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Node } from
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
2
|
const MathJax = Node.create({
|
|
3
|
-
name:
|
|
4
|
-
group:
|
|
3
|
+
name: "mathjaxnode",
|
|
4
|
+
group: "inline",
|
|
5
5
|
inline: !0,
|
|
6
6
|
atom: !1,
|
|
7
7
|
selectable: !0,
|
|
8
8
|
parseHTML() {
|
|
9
9
|
return [
|
|
10
10
|
{
|
|
11
|
-
tag:
|
|
12
|
-
}
|
|
11
|
+
tag: "mathjax"
|
|
12
|
+
}
|
|
13
13
|
];
|
|
14
14
|
},
|
|
15
15
|
addAttributes() {
|
|
@@ -17,34 +17,24 @@ const MathJax = Node.create({
|
|
|
17
17
|
equation: {
|
|
18
18
|
default: null,
|
|
19
19
|
parseHTML: (element) => {
|
|
20
|
-
const textNodes = [...element.childNodes].filter(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
? textNodes[textNodes.length - 1].nodeValue
|
|
25
|
-
: null;
|
|
26
|
-
},
|
|
27
|
-
},
|
|
20
|
+
const textNodes = [...element.childNodes].filter((child) => child.nodeType === 3);
|
|
21
|
+
return textNodes.length > 0 ? textNodes[textNodes.length - 1].nodeValue : null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
28
24
|
};
|
|
29
25
|
},
|
|
30
26
|
renderHTML({ HTMLAttributes }) {
|
|
31
|
-
let equation = (HTMLAttributes.equation ||
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
/(?:\\)?begin{equation}\s*\n?\s*(.+?)\n?\s*?(?:\\)?end{equation}/gm,
|
|
38
|
-
'$$$1$$',
|
|
39
|
-
);
|
|
40
|
-
return (
|
|
41
|
-
equation.length > 0 &&
|
|
42
|
-
(equation.charAt(0) !== '$' && (equation = `$${equation}`),
|
|
43
|
-
equation.charAt(equation.length - 1) !== '$' &&
|
|
44
|
-
(equation = `${equation}$`)),
|
|
45
|
-
['span', {}, equation]
|
|
27
|
+
let equation = (HTMLAttributes.equation || "").replaceAll(
|
|
28
|
+
/(?:\\)?begin{equation}\s*\n?\s*{(.+?)}\n?\s*?(?:\\)?end{equation}/gm,
|
|
29
|
+
"$$$1$$"
|
|
30
|
+
).replaceAll(
|
|
31
|
+
/(?:\\)?begin{equation}\s*\n?\s*(.+?)\n?\s*?(?:\\)?end{equation}/gm,
|
|
32
|
+
"$$$1$$"
|
|
46
33
|
);
|
|
47
|
-
|
|
34
|
+
return equation.length > 0 && (equation.charAt(0) !== "$" && (equation = `$${equation}`), equation.charAt(equation.length - 1) !== "$" && (equation = `${equation}$`)), ["span", {}, equation];
|
|
35
|
+
}
|
|
48
36
|
});
|
|
49
|
-
export {
|
|
37
|
+
export {
|
|
38
|
+
MathJax
|
|
39
|
+
};
|
|
50
40
|
//# sourceMappingURL=mathjax.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mathjax.js","sources":["../../src/mathjax/mathjax.ts"],"sourcesContent":["import { Node } from
|
|
1
|
+
{"version":3,"file":"mathjax.js","sources":["../../src/mathjax/mathjax.ts"],"sourcesContent":["import { Node } from \"@tiptap/core\";\n\nexport const MathJax = Node.create({\n name: \"mathjaxnode\",\n group: \"inline\",\n inline: true,\n atom: false,\n selectable: true,\n\n parseHTML() {\n return [\n {\n tag: \"mathjax\",\n },\n ];\n },\n\n addAttributes() {\n return {\n equation: {\n default: null,\n parseHTML: (element: any) => {\n const children = [...element.childNodes];\n const textNodes = children.filter((child) => child.nodeType === 3);\n return textNodes.length > 0\n ? textNodes[textNodes.length - 1].nodeValue\n : null;\n },\n },\n };\n },\n\n renderHTML({ HTMLAttributes }) {\n let equation = (HTMLAttributes.equation || \"\")\n // Get what is between \\begin{equation}{... ...}\\end{equation}\n // Or between \\begin{equation}... ...\\end{equation} without enclosing brackets\n .replaceAll(\n /(?:\\\\)?begin{equation}\\s*\\n?\\s*{(.+?)}\\n?\\s*?(?:\\\\)?end{equation}/gm,\n \"$$$1$$\",\n )\n .replaceAll(\n /(?:\\\\)?begin{equation}\\s*\\n?\\s*(.+?)\\n?\\s*?(?:\\\\)?end{equation}/gm,\n \"$$$1$$\",\n );\n if (equation.length > 0) {\n if (equation.charAt(0) !== \"$\") {\n equation = `$${equation}`;\n }\n if (equation.charAt(equation.length - 1) !== \"$\") {\n equation = `${equation}$`;\n }\n }\n return [\"span\", {}, equation];\n },\n});\n"],"names":[],"mappings":";AAEa,MAAA,UAAU,KAAK,OAAO;AAAA,EACjC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,YAAY;AAAA,EAEZ,YAAY;AACH,WAAA;AAAA,MACL;AAAA,QACE,KAAK;AAAA,MAAA;AAAA,IAET;AAAA,EACF;AAAA,EAEA,gBAAgB;AACP,WAAA;AAAA,MACL,UAAU;AAAA,QACR,SAAS;AAAA,QACT,WAAW,CAAC,YAAiB;AAE3B,gBAAM,YADW,CAAC,GAAG,QAAQ,UAAU,EACZ,OAAO,CAAC,UAAU,MAAM,aAAa,CAAC;AAC1D,iBAAA,UAAU,SAAS,IACtB,UAAU,UAAU,SAAS,CAAC,EAAE,YAChC;AAAA,QAAA;AAAA,MACN;AAAA,IAEJ;AAAA,EACF;AAAA,EAEA,WAAW,EAAE,kBAAkB;AACzB,QAAA,YAAY,eAAe,YAAY,IAGxC;AAAA,MACC;AAAA,MACA;AAAA,IAAA,EAED;AAAA,MACC;AAAA,MACA;AAAA,IACF;AACE,WAAA,SAAS,SAAS,MAChB,SAAS,OAAO,CAAC,MAAM,QACzB,WAAW,IAAI,QAAQ,KAErB,SAAS,OAAO,SAAS,SAAS,CAAC,MAAM,QAC3C,WAAW,GAAG,QAAQ,OAGnB,CAAC,QAAQ,CAAC,GAAG,QAAQ;AAAA,EAAA;AAEhC,CAAC;"}
|
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
-
const extensionParagraph = require('@tiptap/extension-paragraph'),
|
|
4
|
-
Paragraph = extensionParagraph.Paragraph.extend({
|
|
5
|
-
parseHTML() {
|
|
6
|
-
var _a;
|
|
7
|
-
return [
|
|
8
|
-
...(((_a = this.parent) == null ? void 0 : _a.call(this)) ?? []),
|
|
9
|
-
{ tag: 'div[style]:has(> span)' },
|
|
10
|
-
];
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
exports.Paragraph = Paragraph;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const extensionParagraph=require("@tiptap/extension-paragraph"),Paragraph=extensionParagraph.Paragraph.extend({parseHTML(){var _a;return[...((_a=this.parent)==null?void 0:_a.call(this))??[],{tag:"div[style]:has(> span)"}]}});exports.Paragraph=Paragraph;
|
|
14
2
|
//# sourceMappingURL=paragraph.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paragraph.cjs","sources":["../../src/paragraph/paragraph.ts"],"sourcesContent":["import { Paragraph as TiptapParagraph } from
|
|
1
|
+
{"version":3,"file":"paragraph.cjs","sources":["../../src/paragraph/paragraph.ts"],"sourcesContent":["import { Paragraph as TiptapParagraph } from \"@tiptap/extension-paragraph\";\n\n/**\n * Extends `Paragraph` extension from TipTap.\n *\n * This extension is used to parse documents in old-format (version 0),\n * where text alignments were applied on a <div> wrapping a <span>.\n * The new format is a <p> with style attributes.\n *\n * For example :\n * `<div style=\"text-align: right;\"><span style=\"font-size: 20pt;\">A right-aligned text</span></div>`\n * is now parsed and rendered as\n * `<p style=\"text-align: right;\"><span style=\"font-size: 20pt;\">A right-aligned text</span></p>`\n */\nexport const Paragraph = TiptapParagraph.extend({\n parseHTML() {\n const parentRules = this.parent?.() ?? [];\n return [\n ...parentRules,\n {\n tag: \"div[style]:has(> span)\",\n },\n ];\n },\n});\n"],"names":["TiptapParagraph"],"mappings":"gJAca,UAAYA,6BAAgB,OAAO,CAC9C,WAAY,QAEH,MAAA,CACL,KAFkB,QAAK,SAAL,4BAAmB,CAAC,EAGtC,CACE,IAAK,wBAAA,CAET,CAAA,CAEJ,CAAC"}
|
|
@@ -10,7 +10,4 @@
|
|
|
10
10
|
* is now parsed and rendered as
|
|
11
11
|
* `<p style="text-align: right;"><span style="font-size: 20pt;">A right-aligned text</span></p>`
|
|
12
12
|
*/
|
|
13
|
-
export declare const Paragraph: import('@tiptap/core').Node<
|
|
14
|
-
import('@tiptap/extension-paragraph').ParagraphOptions,
|
|
15
|
-
any
|
|
16
|
-
>;
|
|
13
|
+
export declare const Paragraph: import('@tiptap/core').Node<import('@tiptap/extension-paragraph').ParagraphOptions, any>;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { Paragraph as Paragraph$1 } from
|
|
1
|
+
import { Paragraph as Paragraph$1 } from "@tiptap/extension-paragraph";
|
|
2
2
|
const Paragraph = Paragraph$1.extend({
|
|
3
3
|
parseHTML() {
|
|
4
4
|
var _a;
|
|
5
5
|
return [
|
|
6
|
-
...((
|
|
6
|
+
...((_a = this.parent) == null ? void 0 : _a.call(this)) ?? [],
|
|
7
7
|
{
|
|
8
|
-
tag:
|
|
9
|
-
}
|
|
8
|
+
tag: "div[style]:has(> span)"
|
|
9
|
+
}
|
|
10
10
|
];
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
12
|
});
|
|
13
|
-
export {
|
|
13
|
+
export {
|
|
14
|
+
Paragraph
|
|
15
|
+
};
|
|
14
16
|
//# sourceMappingURL=paragraph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paragraph.js","sources":["../../src/paragraph/paragraph.ts"],"sourcesContent":["import { Paragraph as TiptapParagraph } from
|
|
1
|
+
{"version":3,"file":"paragraph.js","sources":["../../src/paragraph/paragraph.ts"],"sourcesContent":["import { Paragraph as TiptapParagraph } from \"@tiptap/extension-paragraph\";\n\n/**\n * Extends `Paragraph` extension from TipTap.\n *\n * This extension is used to parse documents in old-format (version 0),\n * where text alignments were applied on a <div> wrapping a <span>.\n * The new format is a <p> with style attributes.\n *\n * For example :\n * `<div style=\"text-align: right;\"><span style=\"font-size: 20pt;\">A right-aligned text</span></div>`\n * is now parsed and rendered as\n * `<p style=\"text-align: right;\"><span style=\"font-size: 20pt;\">A right-aligned text</span></p>`\n */\nexport const Paragraph = TiptapParagraph.extend({\n parseHTML() {\n const parentRules = this.parent?.() ?? [];\n return [\n ...parentRules,\n {\n tag: \"div[style]:has(> span)\",\n },\n ];\n },\n});\n"],"names":["TiptapParagraph"],"mappings":";AAca,MAAA,YAAYA,YAAgB,OAAO;AAAA,EAC9C,YAAY;;AAEH,WAAA;AAAA,MACL,KAFkB,UAAK,WAAL,kCAAmB,CAAC;AAAA,MAGtC;AAAA,QACE,KAAK;AAAA,MAAA;AAAA,IAET;AAAA,EAAA;AAEJ,CAAC;"}
|