@edifice.io/tiptap-extensions 2.0.0-develop-rc.8 → 2.0.0-develop-rc.13
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 +1 -1
- package/dist/abbr/abbr.cjs +32 -1
- package/dist/abbr/abbr.cjs.map +1 -1
- package/dist/abbr/abbr.d.ts +12 -12
- package/dist/abbr/abbr.js +20 -16
- package/dist/abbr/abbr.js.map +1 -1
- package/dist/alert/alert.cjs +32 -1
- package/dist/alert/alert.cjs.map +1 -1
- package/dist/alert/alert.js +22 -24
- package/dist/alert/alert.js.map +1 -1
- package/dist/attachment/attachment.cjs +73 -1
- package/dist/attachment/attachment.cjs.map +1 -1
- package/dist/attachment/attachment.d.ts +6 -6
- package/dist/attachment/attachment.js +58 -47
- package/dist/attachment/attachment.js.map +1 -1
- package/dist/audio/audio.cjs +53 -3
- package/dist/audio/audio.cjs.map +1 -1
- package/dist/audio/audio.d.ts +17 -13
- package/dist/audio/audio.js +33 -30
- package/dist/audio/audio.js.map +1 -1
- package/dist/font-size/font-size.cjs +48 -1
- 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 +32 -20
- package/dist/font-size/font-size.js.map +1 -1
- package/dist/heading/heading.cjs +61 -1
- package/dist/heading/heading.cjs.map +1 -1
- package/dist/heading/heading.d.ts +10 -12
- package/dist/heading/heading.js +45 -31
- package/dist/heading/heading.js.map +1 -1
- package/dist/highlight/highlight.cjs +25 -1
- package/dist/highlight/highlight.cjs.map +1 -1
- package/dist/highlight/highlight.d.ts +4 -1
- package/dist/highlight/highlight.js +15 -17
- package/dist/highlight/highlight.js.map +1 -1
- package/dist/hyperlink/hyperlink.cjs +47 -1
- package/dist/hyperlink/hyperlink.cjs.map +1 -1
- package/dist/hyperlink/hyperlink.d.ts +27 -24
- package/dist/hyperlink/hyperlink.js +26 -24
- package/dist/hyperlink/hyperlink.js.map +1 -1
- package/dist/iframe/iframe.cjs +69 -1
- package/dist/iframe/iframe.cjs.map +1 -1
- package/dist/iframe/iframe.d.ts +12 -14
- package/dist/iframe/iframe.js +50 -34
- package/dist/iframe/iframe.js.map +1 -1
- package/dist/image/custom-image.cjs +162 -1
- package/dist/image/custom-image.cjs.map +1 -1
- package/dist/image/custom-image.d.ts +19 -16
- package/dist/image/custom-image.js +179 -130
- package/dist/image/custom-image.js.map +1 -1
- package/dist/index.cjs +43 -1
- package/dist/index.js +41 -41
- package/dist/line-height/line-height.cjs +33 -1
- package/dist/line-height/line-height.cjs.map +1 -1
- package/dist/line-height/line-height.js +21 -18
- package/dist/line-height/line-height.js.map +1 -1
- package/dist/linker/linker.cjs +95 -1
- package/dist/linker/linker.cjs.map +1 -1
- package/dist/linker/linker.d.ts +17 -17
- package/dist/linker/linker.js +60 -52
- package/dist/linker/linker.js.map +1 -1
- package/dist/mathjax/mathjax.cjs +47 -1
- package/dist/mathjax/mathjax.cjs.map +1 -1
- package/dist/mathjax/mathjax.js +33 -23
- package/dist/mathjax/mathjax.js.map +1 -1
- package/dist/paragraph/paragraph.cjs +13 -1
- package/dist/paragraph/paragraph.cjs.map +1 -1
- package/dist/paragraph/paragraph.d.ts +4 -1
- package/dist/paragraph/paragraph.js +8 -10
- package/dist/paragraph/paragraph.js.map +1 -1
- package/dist/speech-recognition/speech-recognition.cjs +76 -1
- 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 +61 -45
- package/dist/speech-recognition/speech-recognition.js.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.cjs +32 -1
- 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 +23 -14
- package/dist/speech-synthesis/speech-synthesis.js.map +1 -1
- package/dist/table-cell/table-cell.cjs +27 -1
- package/dist/table-cell/table-cell.cjs.map +1 -1
- package/dist/table-cell/table-cell.d.ts +4 -1
- package/dist/table-cell/table-cell.js +21 -16
- package/dist/table-cell/table-cell.js.map +1 -1
- package/dist/transform/html-to-json/html-to-json.cjs +4 -1
- package/dist/transform/html-to-json/html-to-json.cjs.map +1 -1
- package/dist/transform/html-to-json/html-to-json.d.ts +4 -1
- package/dist/transform/html-to-json/html-to-json.js +3 -5
- package/dist/transform/html-to-json/html-to-json.js.map +1 -1
- package/dist/transform/json-to-html/json-to-html.cjs +4 -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 -5
- package/dist/transform/json-to-html/json-to-html.js.map +1 -1
- package/dist/video/video.cjs +118 -9
- package/dist/video/video.cjs.map +1 -1
- package/dist/video/video.d.ts +28 -19
- package/dist/video/video.js +121 -97
- package/dist/video/video.js.map +1 -1
- package/package.json +36 -47
package/dist/mathjax/mathjax.cjs
CHANGED
|
@@ -1,2 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
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;
|
|
2
48
|
//# 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":["
|
|
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,SACP,CAAA,CAEJ,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,IACN,CACF,CAAA,CAEJ,EAEA,WAAW,CAAE,gBAAkB,CACzB,IAAA,UAAY,eAAe,UAAY,IAGxC,WACC,sEACA,QAAA,EAED,WACC,oEACA,QAAA,EAEA,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,GAAI,QAAQ,CAC9B,CACF,CAAC"}
|
package/dist/mathjax/mathjax.js
CHANGED
|
@@ -1,40 +1,50 @@
|
|
|
1
|
-
import { Node
|
|
2
|
-
const
|
|
3
|
-
name:
|
|
4
|
-
group:
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
const MathJax = Node.create({
|
|
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() {
|
|
16
16
|
return {
|
|
17
17
|
equation: {
|
|
18
18
|
default: null,
|
|
19
|
-
parseHTML: (
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
parseHTML: (element) => {
|
|
20
|
+
const textNodes = [...element.childNodes].filter(
|
|
21
|
+
(child) => child.nodeType === 3,
|
|
22
|
+
);
|
|
23
|
+
return textNodes.length > 0
|
|
24
|
+
? textNodes[textNodes.length - 1].nodeValue
|
|
25
|
+
: null;
|
|
26
|
+
},
|
|
27
|
+
},
|
|
24
28
|
};
|
|
25
29
|
},
|
|
26
|
-
renderHTML({ HTMLAttributes
|
|
27
|
-
let
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
renderHTML({ HTMLAttributes }) {
|
|
31
|
+
let equation = (HTMLAttributes.equation || '')
|
|
32
|
+
.replaceAll(
|
|
33
|
+
/(?:\\)?begin{equation}\s*\n?\s*{(.+?)}\n?\s*?(?:\\)?end{equation}/gm,
|
|
34
|
+
'$$$1$$',
|
|
35
|
+
)
|
|
36
|
+
.replaceAll(
|
|
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]
|
|
33
46
|
);
|
|
34
|
-
|
|
35
|
-
}
|
|
47
|
+
},
|
|
36
48
|
});
|
|
37
|
-
export {
|
|
38
|
-
i as MathJax
|
|
39
|
-
};
|
|
49
|
+
export { MathJax };
|
|
40
50
|
//# 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":[
|
|
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,MACP;AAAA,IAAA;AAAA,EAEJ;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,QACN;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,WAAW,EAAE,kBAAkB;AACzB,QAAA,YAAY,eAAe,YAAY,IAGxC;AAAA,MACC;AAAA,MACA;AAAA,IAAA,EAED;AAAA,MACC;AAAA,MACA;AAAA,IAAA;AAEA,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,IAAI,QAAQ;AAAA,EAC9B;AACF,CAAC;"}
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
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;
|
|
2
14
|
//# 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":["
|
|
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,CAAA,EAGrC,CACE,IAAK,wBACP,CAAA,CAEJ,CACF,CAAC"}
|
|
@@ -10,4 +10,7 @@
|
|
|
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<
|
|
13
|
+
export declare const Paragraph: import('@tiptap/core').Node<
|
|
14
|
+
import('@tiptap/extension-paragraph').ParagraphOptions,
|
|
15
|
+
any
|
|
16
|
+
>;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { Paragraph as
|
|
2
|
-
const
|
|
1
|
+
import { Paragraph as Paragraph$1 } from '@tiptap/extension-paragraph';
|
|
2
|
+
const Paragraph = Paragraph$1.extend({
|
|
3
3
|
parseHTML() {
|
|
4
|
-
var
|
|
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 {
|
|
14
|
-
p as Paragraph
|
|
15
|
-
};
|
|
13
|
+
export { Paragraph };
|
|
16
14
|
//# 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":["
|
|
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,CAAA;AAAA,MAGrC;AAAA,QACE,KAAK;AAAA,MACP;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;"}
|
|
@@ -1,2 +1,77 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
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;
|
|
2
77
|
//# 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 '\"speechrecognition extension from @edifice.io/tiptap-extensions\" 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 `[speechrecognition from @edifice.io/tiptap-extensions][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":["
|
|
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 '\"speechrecognition extension from @edifice.io/tiptap-extensions\" 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 `[speechrecognition from @edifice.io/tiptap-extensions][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,QAIR,KAAS,UAAqB,EAH9B,CAKA,OAAO,OAAyB,OAAc,CACrC,OAAAA,KAAA,KAAK,OAAO,MAAM,CAC3B,CACF,CAEa,MAAA,kBAAoB,QAAQ,OAAiC,CACxE,KAAM,oBAEN,YAAa,CACJ,MAAA,CACL,KAAM,OAAA,CAEV,EAEA,UAAW,CAEL,sBAAuB,QAAU,4BAA6B,QAExD,QAAA,KACN,4HAAA,CAGN,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,QAGjB,GAAI,CAAE,KAAM,EAAO,EAAA,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,CAAA,EAEzB,GAAA,KAAK,OAAO,MAAM,UAAU,GAE7B,UAEK,KAAA,GACT,EAGG,KAAA,YAAY,QAAW,OAAuC,CAEzD,QAAA,IACN,iEAAiE,MAAM,KAAK,MAAM,MAAM,OAAO,EAAA,CACjG,EAGG,KAAA,YAAY,QAAU,IAAM,CAC/B,KAAK,UAAY,EAAA,EAGd,KAAA,YAAY,MAAQ,IAAM,CAC7B,KAAK,UAAY,EAAA,EAGZ,QACT,EAEF,sBACE,IACA,CAAC,CAAE,aACD,KAAK,YAAY,OACZ,KAAA,OAAO,SAAS,QACd,UAGX,2BAA4B,IAAM,IAAM,KAAK,SAAA,CAEjD,CACF,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 {};
|
|
@@ -1,61 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var a = (e, t, i) => d(e, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
-
import { Node as h } from "@tiptap/core";
|
|
5
|
-
class l extends h {
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
class SR_Node extends Node {
|
|
6
3
|
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
a(this, "recognition");
|
|
9
|
-
a(this, "isStarted", !1);
|
|
4
|
+
super(), (this.isStarted = !1);
|
|
10
5
|
}
|
|
11
|
-
static create(
|
|
12
|
-
return
|
|
6
|
+
static create(config) {
|
|
7
|
+
return Node.create(config);
|
|
13
8
|
}
|
|
14
9
|
}
|
|
15
|
-
const
|
|
16
|
-
name:
|
|
10
|
+
const SpeechRecognition = SR_Node.create({
|
|
11
|
+
name: 'SpeechRecognition',
|
|
17
12
|
addOptions() {
|
|
18
13
|
return {
|
|
19
|
-
lang:
|
|
14
|
+
lang: 'fr-FR',
|
|
20
15
|
};
|
|
21
16
|
},
|
|
22
17
|
onCreate() {
|
|
23
|
-
|
|
24
|
-
'
|
|
25
|
-
|
|
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
|
+
);
|
|
26
23
|
},
|
|
27
24
|
addCommands() {
|
|
28
25
|
return {
|
|
29
|
-
startSpeechRecognition:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
|
46
65
|
);
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
isSpeechRecognitionStarted: () => () => this.isStarted
|
|
66
|
+
},
|
|
67
|
+
stopSpeechRecognition:
|
|
68
|
+
() =>
|
|
69
|
+
({ commands }) => (
|
|
70
|
+
this.recognition.stop(), this.editor.commands.focus(), commands
|
|
71
|
+
),
|
|
72
|
+
isSpeechRecognitionStarted: () => () => this.isStarted,
|
|
55
73
|
};
|
|
56
|
-
}
|
|
74
|
+
},
|
|
57
75
|
});
|
|
58
|
-
export {
|
|
59
|
-
S as SpeechRecognition
|
|
60
|
-
};
|
|
76
|
+
export { SpeechRecognition };
|
|
61
77
|
//# sourceMappingURL=speech-recognition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speech-recognition.js","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 '\"speechrecognition extension from @edifice.io/tiptap-extensions\" 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 `[speechrecognition from @edifice.io/tiptap-extensions][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":["
|
|
1
|
+
{"version":3,"file":"speech-recognition.js","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 '\"speechrecognition extension from @edifice.io/tiptap-extensions\" 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 `[speechrecognition from @edifice.io/tiptap-extensions][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":["SpeechRecognition"],"mappings":";AAgBA,MAAM,gBAAkC,KAAW;AAAA,EACvC,cAAc;AAChB,aAIR,KAAS,YAAqB;AAAA,EAH9B;AAAA,EAKA,OAAO,OAAyB,QAAc;AACrC,WAAA,KAAK,OAAO,MAAM;AAAA,EAC3B;AACF;AAEa,MAAA,oBAAoB,QAAQ,OAAiC;AAAA,EACxE,MAAM;AAAA,EAEN,aAAa;AACJ,WAAA;AAAA,MACL,MAAM;AAAA,IAAA;AAAA,EAEV;AAAA,EAEA,WAAW;AACT,IACI,uBAAuB,UAAU,6BAA6B,UAExD,QAAA;AAAA,MACN;AAAA,IAAA;AAAA,EAGN;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,wBACE,MACA,CAAC,EAAE,eAAe;AACVA,cAAAA,qBACJ,OAAO,qBAAqB,OAAO;AAChC,aAAA,cAAc,IAAIA,sBAElB,KAAA,YAAY,OAAO,KAAK,QAAQ,MACrC,KAAK,YAAY,iBAAiB,IAClC,KAAK,YAAY,kBAAkB,GACnC,KAAK,YAAY,aAAa,IAE9B,KAAK,YAAY;AAGjB,YAAI,EAAE,MAAM,GAAO,IAAA,KAAK,OAAO,MAAM;AAEhC,oBAAA,YAAY,WAAW,CAAC,UAAkC;AAC7D,cAAI,gBAAgB;AAGpB,mBAAS,IAAI,MAAM,aAAa,IAAI,MAAM,QAAQ,QAAQ;AACxD,6BAAiB,MAAM,QAAQ,CAAC,EAAE,CAAC,EAAE;AAIvC,gBAAM,UAAU,MAAM,QAAQ,MAAM,QAAQ,SAAS,CAAC,EAAE;AAGxD,eAAK,OAAO,SAAS,YAAY,EAAE,MAAM,IAAI,GAC7C,KAAK,OAAO,SAAS;AAAA,YACnB;AAAA,YACA,UAAU,gBAAgB,SAAS,aAAa;AAAA,YAChD,EAAE,iBAAiB,CAAC,QAAQ;AAAA,UAAA,GAEzB,KAAA,KAAK,OAAO,MAAM,UAAU,IAE7B,YAEK,OAAA;AAAA,QACT,GAGG,KAAA,YAAY,UAAU,CAAC,UAAuC;AAEzD,kBAAA;AAAA,YACN,iEAAiE,MAAM,KAAK,MAAM,MAAM,OAAO;AAAA,UAAA;AAAA,QACjG,GAGG,KAAA,YAAY,UAAU,MAAM;AAC/B,eAAK,YAAY;AAAA,QAAA,GAGd,KAAA,YAAY,QAAQ,MAAM;AAC7B,eAAK,YAAY;AAAA,QAAA,GAGZ;AAAA,MACT;AAAA,MAEF,uBACE,MACA,CAAC,EAAE,gBACD,KAAK,YAAY,QACZ,KAAA,OAAO,SAAS,SACd;AAAA,MAGX,4BAA4B,MAAM,MAAM,KAAK;AAAA,IAAA;AAAA,EAEjD;AACF,CAAC;"}
|
|
@@ -1,2 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const core = require('@tiptap/core');
|
|
4
|
+
class SS_Node extends core.Node {
|
|
5
|
+
static create(config) {
|
|
6
|
+
return core.Node.create(config);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
const SpeechSynthesis = SS_Node.create({
|
|
10
|
+
name: 'speechSynthesis',
|
|
11
|
+
addOptions() {
|
|
12
|
+
return { lang: 'fr-FR', pitch: 1 };
|
|
13
|
+
},
|
|
14
|
+
addCommands() {
|
|
15
|
+
return {
|
|
16
|
+
startSpeechSynthesis:
|
|
17
|
+
() =>
|
|
18
|
+
({ commands }) => (
|
|
19
|
+
(this.speechSynthesis = new SpeechSynthesisUtterance()),
|
|
20
|
+
(this.speechSynthesis.lang = this.options.lang),
|
|
21
|
+
(this.speechSynthesis.pitch = this.options.pitch),
|
|
22
|
+
(this.speechSynthesis.text = this.editor.getText()),
|
|
23
|
+
window.speechSynthesis.speak(this.speechSynthesis),
|
|
24
|
+
commands
|
|
25
|
+
),
|
|
26
|
+
stopSpeechSynthesis:
|
|
27
|
+
() =>
|
|
28
|
+
({ commands }) => (window.speechSynthesis.cancel(), commands),
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
exports.SpeechSynthesis = SpeechSynthesis;
|
|
2
33
|
//# sourceMappingURL=speech-synthesis.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speech-synthesis.cjs","sources":["../../src/speech-synthesis/speech-synthesis.ts"],"sourcesContent":["import { Node } from '@tiptap/core';\n\nexport interface SpeechSynthesisOptions {\n lang: string;\n pitch: number;\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n speechSynthesis: {\n startSpeechSynthesis: () => ReturnType;\n stopSpeechSynthesis: () => ReturnType;\n };\n }\n}\n\nclass SS_Node<O = any, S = any> extends Node<O, S> {\n static create<O = any, S = any>(config?: any) {\n return Node.create(config) as SS_Node<O, S>;\n }\n}\n\nexport const SpeechSynthesis = SS_Node.create<SpeechSynthesisOptions>({\n name: 'speechSynthesis',\n addOptions() {\n return {\n lang: 'fr-FR',\n pitch: 1,\n };\n },\n addCommands() {\n return {\n startSpeechSynthesis:\n () =>\n ({ commands }) => {\n this.speechSynthesis = new SpeechSynthesisUtterance();\n this.speechSynthesis.lang = this.options.lang;\n this.speechSynthesis.pitch = this.options.pitch;\n this.speechSynthesis.text = this.editor.getText();\n\n window.speechSynthesis.speak(this.speechSynthesis);\n return commands;\n },\n stopSpeechSynthesis:\n () =>\n ({ commands }) => {\n window.speechSynthesis.cancel();\n return commands;\n },\n };\n },\n});\n"],"names":["
|
|
1
|
+
{"version":3,"file":"speech-synthesis.cjs","sources":["../../src/speech-synthesis/speech-synthesis.ts"],"sourcesContent":["import { Node } from '@tiptap/core';\n\nexport interface SpeechSynthesisOptions {\n lang: string;\n pitch: number;\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n speechSynthesis: {\n startSpeechSynthesis: () => ReturnType;\n stopSpeechSynthesis: () => ReturnType;\n };\n }\n}\n\nclass SS_Node<O = any, S = any> extends Node<O, S> {\n static create<O = any, S = any>(config?: any) {\n return Node.create(config) as SS_Node<O, S>;\n }\n}\n\nexport const SpeechSynthesis = SS_Node.create<SpeechSynthesisOptions>({\n name: 'speechSynthesis',\n addOptions() {\n return {\n lang: 'fr-FR',\n pitch: 1,\n };\n },\n addCommands() {\n return {\n startSpeechSynthesis:\n () =>\n ({ commands }) => {\n this.speechSynthesis = new SpeechSynthesisUtterance();\n this.speechSynthesis.lang = this.options.lang;\n this.speechSynthesis.pitch = this.options.pitch;\n this.speechSynthesis.text = this.editor.getText();\n\n window.speechSynthesis.speak(this.speechSynthesis);\n return commands;\n },\n stopSpeechSynthesis:\n () =>\n ({ commands }) => {\n window.speechSynthesis.cancel();\n return commands;\n },\n };\n },\n});\n"],"names":["Node"],"mappings":"mHAgBA,MAAM,gBAAkCA,KAAAA,IAAW,CACjD,OAAO,OAAyB,OAAc,CACrC,OAAAA,KAAA,KAAK,OAAO,MAAM,CAC3B,CACF,CAEa,MAAA,gBAAkB,QAAQ,OAA+B,CACpE,KAAM,kBACN,YAAa,CACJ,MAAA,CACL,KAAM,QACN,MAAO,CAAA,CAEX,EACA,aAAc,CACL,MAAA,CACL,qBACE,IACA,CAAC,CAAE,aACI,KAAA,gBAAkB,IAAI,yBACtB,KAAA,gBAAgB,KAAO,KAAK,QAAQ,KACpC,KAAA,gBAAgB,MAAQ,KAAK,QAAQ,MAC1C,KAAK,gBAAgB,KAAO,KAAK,OAAO,QAAQ,EAEzC,OAAA,gBAAgB,MAAM,KAAK,eAAe,EAC1C,UAEX,oBACE,IACA,CAAC,CAAE,aACD,OAAO,gBAAgB,SAChB,SACT,CAEN,CACF,CAAC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Node } from '@tiptap/core';
|
|
2
2
|
export interface SpeechSynthesisOptions {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
lang: string;
|
|
4
|
+
pitch: number;
|
|
5
5
|
}
|
|
6
6
|
declare module '@tiptap/core' {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
interface Commands<ReturnType> {
|
|
8
|
+
speechSynthesis: {
|
|
9
|
+
startSpeechSynthesis: () => ReturnType;
|
|
10
|
+
stopSpeechSynthesis: () => ReturnType;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
13
|
}
|
|
14
14
|
declare class SS_Node<O = any, S = any> extends Node<O, S> {
|
|
15
|
-
|
|
15
|
+
static create<O = any, S = any>(config?: any): SS_Node<O, S>;
|
|
16
16
|
}
|
|
17
17
|
export declare const SpeechSynthesis: SS_Node<SpeechSynthesisOptions, any>;
|
|
18
18
|
export {};
|