@edifice.io/tiptap-extensions 1.5.16-develop-rc.3 → 1.7.4-develop-pedago.20241211162226
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 +12 -12
- 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 +6 -6
- 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 +13 -17
- 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 +13 -13
- 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 +12 -10
- 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 +24 -27
- 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 +14 -12
- 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 +17 -17
- 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 +12 -12
- 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 +9 -9
- 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.d.ts +1 -4
- package/dist/transform/html-to-json/html-to-json.js +4 -2
- package/dist/transform/json-to-html/json-to-html.cjs +1 -4
- package/dist/transform/json-to-html/json-to-html.js +4 -2
- package/dist/video/video.cjs +2 -111
- package/dist/video/video.cjs.map +1 -1
- package/dist/video/video.d.ts +19 -28
- 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
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
9
|
declare module '@tiptap/core' {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 '@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,
|
|
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 '@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,
|
|
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 '@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,
|
|
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 '@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,
|
|
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 '@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,
|
|
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;"}
|
|
@@ -1,77 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
-
const core = require('@tiptap/core');
|
|
4
|
-
class SR_Node extends core.Node {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(), (this.isStarted = !1);
|
|
7
|
-
}
|
|
8
|
-
static create(config) {
|
|
9
|
-
return core.Node.create(config);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const SpeechRecognition = SR_Node.create({
|
|
13
|
-
name: 'SpeechRecognition',
|
|
14
|
-
addOptions() {
|
|
15
|
-
return { lang: 'fr-FR' };
|
|
16
|
-
},
|
|
17
|
-
onCreate() {
|
|
18
|
-
'SpeechRecognition' in window ||
|
|
19
|
-
'webkitSpeechRecognition' in window ||
|
|
20
|
-
console.warn(
|
|
21
|
-
'"speechrecognition extension from @edifice.io/tiptap-extensions" requires a browser supporting the SpeechRecognition API".',
|
|
22
|
-
);
|
|
23
|
-
},
|
|
24
|
-
addCommands() {
|
|
25
|
-
return {
|
|
26
|
-
startSpeechRecognition:
|
|
27
|
-
() =>
|
|
28
|
-
({ commands }) => {
|
|
29
|
-
const SpeechRecognition2 =
|
|
30
|
-
window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
31
|
-
(this.recognition = new SpeechRecognition2()),
|
|
32
|
-
(this.recognition.lang = this.options.lang),
|
|
33
|
-
(this.recognition.interimResults = !0),
|
|
34
|
-
(this.recognition.maxAlternatives = 1),
|
|
35
|
-
(this.recognition.continuous = !0),
|
|
36
|
-
this.recognition.start();
|
|
37
|
-
let { from, to } = this.editor.state.selection;
|
|
38
|
-
return (
|
|
39
|
-
(this.recognition.onresult = (event) => {
|
|
40
|
-
let currentResult = '';
|
|
41
|
-
for (let i = event.resultIndex; i < event.results.length; i++)
|
|
42
|
-
currentResult += event.results[i][0].transcript;
|
|
43
|
-
const isFinal = event.results[event.results.length - 1].isFinal;
|
|
44
|
-
this.editor.commands.deleteRange({ from, to }),
|
|
45
|
-
this.editor.commands.insertContentAt(
|
|
46
|
-
from,
|
|
47
|
-
isFinal ? currentResult : `<code>${currentResult}</code>`,
|
|
48
|
-
{ updateSelection: !isFinal },
|
|
49
|
-
),
|
|
50
|
-
(to = this.editor.state.selection.to),
|
|
51
|
-
isFinal && (from = to);
|
|
52
|
-
}),
|
|
53
|
-
(this.recognition.onerror = (event) => {
|
|
54
|
-
console.log(
|
|
55
|
-
`[speechrecognition from @edifice.io/tiptap-extensions][error][${event.error}]: ${event.message}`,
|
|
56
|
-
);
|
|
57
|
-
}),
|
|
58
|
-
(this.recognition.onstart = () => {
|
|
59
|
-
this.isStarted = !0;
|
|
60
|
-
}),
|
|
61
|
-
(this.recognition.onend = () => {
|
|
62
|
-
this.isStarted = !1;
|
|
63
|
-
}),
|
|
64
|
-
commands
|
|
65
|
-
);
|
|
66
|
-
},
|
|
67
|
-
stopSpeechRecognition:
|
|
68
|
-
() =>
|
|
69
|
-
({ commands }) => (
|
|
70
|
-
this.recognition.stop(), this.editor.commands.focus(), commands
|
|
71
|
-
),
|
|
72
|
-
isSpeechRecognitionStarted: () => () => this.isStarted,
|
|
73
|
-
};
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
exports.SpeechRecognition = SpeechRecognition;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@tiptap/core");class SR_Node extends core.Node{constructor(){super(),this.isStarted=!1}static create(config){return core.Node.create(config)}}const SpeechRecognition=SR_Node.create({name:"SpeechRecognition",addOptions(){return{lang:"fr-FR"}},onCreate(){"SpeechRecognition"in window||"webkitSpeechRecognition"in window||console.warn('"@edifice.io/tiptap-extensions/speechrecognition" requires a browser supporting the SpeechRecognition API".')},addCommands(){return{startSpeechRecognition:()=>({commands})=>{const SpeechRecognition2=window.SpeechRecognition||window.webkitSpeechRecognition;this.recognition=new SpeechRecognition2,this.recognition.lang=this.options.lang,this.recognition.interimResults=!0,this.recognition.maxAlternatives=1,this.recognition.continuous=!0,this.recognition.start();let{from,to}=this.editor.state.selection;return this.recognition.onresult=event=>{let currentResult="";for(let i=event.resultIndex;i<event.results.length;i++)currentResult+=event.results[i][0].transcript;const isFinal=event.results[event.results.length-1].isFinal;this.editor.commands.deleteRange({from,to}),this.editor.commands.insertContentAt(from,isFinal?currentResult:`<code>${currentResult}</code>`,{updateSelection:!isFinal}),to=this.editor.state.selection.to,isFinal&&(from=to)},this.recognition.onerror=event=>{console.log(`[@edifice.io/tiptap-extensions/speech-recognition][error][${event.error}]: ${event.message}`)},this.recognition.onstart=()=>{this.isStarted=!0},this.recognition.onend=()=>{this.isStarted=!1},commands},stopSpeechRecognition:()=>({commands})=>(this.recognition.stop(),this.editor.commands.focus(),commands),isSpeechRecognitionStarted:()=>()=>this.isStarted}}});exports.SpeechRecognition=SpeechRecognition;
|
|
77
2
|
//# sourceMappingURL=speech-recognition.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speech-recognition.cjs","sources":["../../src/speech-recognition/speech-recognition.ts"],"sourcesContent":["import { Node } from '@tiptap/core';\n\nexport interface SpeechRecognitionOptions {\n lang: string;\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n SpeechRecognition: {\n startSpeechRecognition: () => ReturnType;\n stopSpeechRecognition: () => ReturnType;\n isSpeechRecognitionStarted: () => boolean;\n };\n }\n}\n\nclass SR_Node<O = any, S = any> extends Node<O, S> {\n protected constructor() {\n super();\n }\n\n recognition: SpeechRecognition | undefined;\n readonly isStarted: boolean = false;\n\n static create<O = any, S = any>(config?: any) {\n return Node.create(config) as SR_Node<O, S>;\n }\n}\n\nexport const SpeechRecognition = SR_Node.create<SpeechRecognitionOptions>({\n name: 'SpeechRecognition',\n\n addOptions() {\n return {\n lang: 'fr-FR',\n };\n },\n\n onCreate() {\n if (\n !('SpeechRecognition' in window || 'webkitSpeechRecognition' in window)\n ) {\n console.warn(\n '\"
|
|
1
|
+
{"version":3,"file":"speech-recognition.cjs","sources":["../../src/speech-recognition/speech-recognition.ts"],"sourcesContent":["import { Node } from '@tiptap/core';\n\nexport interface SpeechRecognitionOptions {\n lang: string;\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n SpeechRecognition: {\n startSpeechRecognition: () => ReturnType;\n stopSpeechRecognition: () => ReturnType;\n isSpeechRecognitionStarted: () => boolean;\n };\n }\n}\n\nclass SR_Node<O = any, S = any> extends Node<O, S> {\n protected constructor() {\n super();\n }\n\n recognition: SpeechRecognition | undefined;\n readonly isStarted: boolean = false;\n\n static create<O = any, S = any>(config?: any) {\n return Node.create(config) as SR_Node<O, S>;\n }\n}\n\nexport const SpeechRecognition = SR_Node.create<SpeechRecognitionOptions>({\n name: 'SpeechRecognition',\n\n addOptions() {\n return {\n lang: 'fr-FR',\n };\n },\n\n onCreate() {\n if (\n !('SpeechRecognition' in window || 'webkitSpeechRecognition' in window)\n ) {\n console.warn(\n '\"@edifice.io/tiptap-extensions/speechrecognition\" requires a browser supporting the SpeechRecognition API\".',\n );\n }\n },\n\n addCommands() {\n return {\n startSpeechRecognition:\n () =>\n ({ commands }) => {\n const SpeechRecognition =\n window.SpeechRecognition || window.webkitSpeechRecognition;\n this.recognition = new SpeechRecognition();\n\n this.recognition.lang = this.options.lang;\n this.recognition.interimResults = true;\n this.recognition.maxAlternatives = 1;\n this.recognition.continuous = true;\n\n this.recognition.start();\n\n // Memoize initial caret positions\n let { from, to } = this.editor.state.selection;\n\n this.recognition.onresult = (event: SpeechRecognitionEvent) => {\n let currentResult = '';\n\n // Add to the currentResult variable the content of the last recognized sentence\n for (let i = event.resultIndex; i < event.results.length; i++) {\n currentResult += event.results[i][0].transcript;\n }\n\n // Is this the final recognition ?\n const isFinal = event.results[event.results.length - 1].isFinal;\n\n // Replace selection by the last recognized sentence (+ style and select, if not final)\n this.editor.commands.deleteRange({ from, to });\n this.editor.commands.insertContentAt(\n from,\n isFinal ? currentResult : `<code>${currentResult}</code>`,\n { updateSelection: !isFinal },\n );\n to = this.editor.state.selection.to;\n\n if (isFinal) {\n // Next content will go after last insertion\n from = to;\n }\n };\n\n this.recognition.onerror = (event: SpeechRecognitionErrorEvent) => {\n // TODO create a \"feedback\" tiptap extension, to display user friendly error messages ?\n console.log(\n `[@edifice.io/tiptap-extensions/speech-recognition][error][${event.error}]: ${event.message}`,\n );\n };\n\n this.recognition.onstart = () => {\n this.isStarted = true;\n };\n\n this.recognition.onend = () => {\n this.isStarted = false;\n };\n\n return commands;\n },\n\n stopSpeechRecognition:\n () =>\n ({ commands }) => {\n this.recognition.stop();\n this.editor.commands.focus();\n return commands;\n },\n\n isSpeechRecognitionStarted: () => () => this.isStarted,\n };\n },\n});\n"],"names":["Node","SpeechRecognition"],"mappings":"mHAgBA,MAAM,gBAAkCA,KAAAA,IAAW,CACvC,aAAc,CAChB,MAAA,EAIR,KAAS,UAAqB,EAAA,CAE9B,OAAO,OAAyB,OAAc,CACrC,OAAAA,KAAA,KAAK,OAAO,MAAM,CAAA,CAE7B,CAEa,MAAA,kBAAoB,QAAQ,OAAiC,CACxE,KAAM,oBAEN,YAAa,CACJ,MAAA,CACL,KAAM,OACR,CACF,EAEA,UAAW,CAEL,sBAAuB,QAAU,4BAA6B,QAExD,QAAA,KACN,6GACF,CAEJ,EAEA,aAAc,CACL,MAAA,CACL,uBACE,IACA,CAAC,CAAE,YAAe,CACVC,MAAAA,mBACJ,OAAO,mBAAqB,OAAO,wBAChC,KAAA,YAAc,IAAIA,mBAElB,KAAA,YAAY,KAAO,KAAK,QAAQ,KACrC,KAAK,YAAY,eAAiB,GAClC,KAAK,YAAY,gBAAkB,EACnC,KAAK,YAAY,WAAa,GAE9B,KAAK,YAAY,MAAM,EAGvB,GAAI,CAAE,KAAM,EAAA,EAAO,KAAK,OAAO,MAAM,UAEhC,YAAA,YAAY,SAAY,OAAkC,CAC7D,IAAI,cAAgB,GAGpB,QAAS,EAAI,MAAM,YAAa,EAAI,MAAM,QAAQ,OAAQ,IACxD,eAAiB,MAAM,QAAQ,CAAC,EAAE,CAAC,EAAE,WAIvC,MAAM,QAAU,MAAM,QAAQ,MAAM,QAAQ,OAAS,CAAC,EAAE,QAGxD,KAAK,OAAO,SAAS,YAAY,CAAE,KAAM,GAAI,EAC7C,KAAK,OAAO,SAAS,gBACnB,KACA,QAAU,cAAgB,SAAS,aAAa,UAChD,CAAE,gBAAiB,CAAC,OAAQ,CAC9B,EACK,GAAA,KAAK,OAAO,MAAM,UAAU,GAE7B,UAEK,KAAA,GAEX,EAEK,KAAA,YAAY,QAAW,OAAuC,CAEzD,QAAA,IACN,6DAA6D,MAAM,KAAK,MAAM,MAAM,OAAO,EAC7F,CACF,EAEK,KAAA,YAAY,QAAU,IAAM,CAC/B,KAAK,UAAY,EACnB,EAEK,KAAA,YAAY,MAAQ,IAAM,CAC7B,KAAK,UAAY,EACnB,EAEO,QACT,EAEF,sBACE,IACA,CAAC,CAAE,aACD,KAAK,YAAY,KAAK,EACjB,KAAA,OAAO,SAAS,MAAM,EACpB,UAGX,2BAA4B,IAAM,IAAM,KAAK,SAC/C,CAAA,CAEJ,CAAC"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { Node } from '@tiptap/core';
|
|
2
2
|
export interface SpeechRecognitionOptions {
|
|
3
|
-
|
|
3
|
+
lang: string;
|
|
4
4
|
}
|
|
5
5
|
declare module '@tiptap/core' {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
interface Commands<ReturnType> {
|
|
7
|
+
SpeechRecognition: {
|
|
8
|
+
startSpeechRecognition: () => ReturnType;
|
|
9
|
+
stopSpeechRecognition: () => ReturnType;
|
|
10
|
+
isSpeechRecognitionStarted: () => boolean;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
13
|
}
|
|
14
14
|
declare class SR_Node<O = any, S = any> extends Node<O, S> {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
protected constructor();
|
|
16
|
+
recognition: SpeechRecognition | undefined;
|
|
17
|
+
readonly isStarted: boolean;
|
|
18
|
+
static create<O = any, S = any>(config?: any): SR_Node<O, S>;
|
|
19
19
|
}
|
|
20
20
|
export declare const SpeechRecognition: SR_Node<SpeechRecognitionOptions, any>;
|
|
21
21
|
export {};
|