@edifice.io/tiptap-extensions 2.0.0-develop-rc.13 → 2.0.0-develop-rc.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/dist/abbr/abbr.cjs +1 -32
- package/dist/abbr/abbr.cjs.map +1 -1
- package/dist/abbr/abbr.d.ts +13 -13
- package/dist/abbr/abbr.js +13 -17
- package/dist/abbr/abbr.js.map +1 -1
- package/dist/alert/alert.cjs +1 -32
- package/dist/alert/alert.cjs.map +1 -1
- package/dist/alert/alert.js +22 -20
- package/dist/alert/alert.js.map +1 -1
- package/dist/attachment/attachment-transformer.cjs +2 -0
- package/dist/attachment/attachment-transformer.cjs.map +1 -0
- package/dist/attachment/attachment-transformer.d.ts +12 -0
- package/dist/attachment/attachment-transformer.js +76 -0
- package/dist/attachment/attachment-transformer.js.map +1 -0
- package/dist/attachment/attachment.cjs +1 -73
- package/dist/attachment/attachment.cjs.map +1 -1
- package/dist/attachment/attachment.d.ts +7 -7
- package/dist/attachment/attachment.js +29 -40
- package/dist/attachment/attachment.js.map +1 -1
- package/dist/attachment/index.d.ts +1 -0
- package/dist/audio/audio.cjs +2 -52
- package/dist/audio/audio.cjs.map +1 -1
- package/dist/audio/audio.d.ts +14 -18
- package/dist/audio/audio.js +25 -28
- package/dist/audio/audio.js.map +1 -1
- package/dist/font-size/font-size.cjs +1 -48
- package/dist/font-size/font-size.cjs.map +1 -1
- package/dist/font-size/font-size.d.ts +14 -14
- package/dist/font-size/font-size.js +17 -29
- package/dist/font-size/font-size.js.map +1 -1
- package/dist/heading/heading.cjs +1 -61
- package/dist/heading/heading.cjs.map +1 -1
- package/dist/heading/heading.d.ts +13 -11
- package/dist/heading/heading.js +25 -39
- package/dist/heading/heading.js.map +1 -1
- package/dist/highlight/highlight.cjs +1 -25
- package/dist/highlight/highlight.cjs.map +1 -1
- package/dist/highlight/highlight.d.ts +1 -4
- package/dist/highlight/highlight.js +13 -11
- package/dist/highlight/highlight.js.map +1 -1
- package/dist/hyperlink/hyperlink.cjs +1 -47
- package/dist/hyperlink/hyperlink.cjs.map +1 -1
- package/dist/hyperlink/hyperlink.d.ts +25 -28
- package/dist/hyperlink/hyperlink.js +19 -21
- package/dist/hyperlink/hyperlink.js.map +1 -1
- package/dist/iframe/iframe.cjs +1 -69
- package/dist/iframe/iframe.cjs.map +1 -1
- package/dist/iframe/iframe.d.ts +15 -13
- package/dist/iframe/iframe.js +32 -48
- package/dist/iframe/iframe.js.map +1 -1
- package/dist/image/image.cjs +2 -0
- package/dist/image/image.cjs.map +1 -0
- package/dist/image/image.d.ts +26 -0
- package/dist/image/image.js +178 -0
- package/dist/image/image.js.map +1 -0
- package/dist/image/index.d.ts +3 -3
- package/dist/index.cjs +1 -43
- package/dist/index.js +24 -22
- package/dist/index.js.map +1 -1
- package/dist/line-height/line-height.cjs +1 -33
- package/dist/line-height/line-height.cjs.map +1 -1
- package/dist/line-height/line-height.js +15 -18
- package/dist/line-height/line-height.js.map +1 -1
- package/dist/linker/linker.cjs +1 -95
- package/dist/linker/linker.cjs.map +1 -1
- package/dist/linker/linker.d.ts +18 -18
- package/dist/linker/linker.js +49 -57
- package/dist/linker/linker.js.map +1 -1
- package/dist/mathjax/mathjax.cjs +1 -47
- package/dist/mathjax/mathjax.cjs.map +1 -1
- package/dist/mathjax/mathjax.js +20 -30
- package/dist/mathjax/mathjax.js.map +1 -1
- package/dist/paragraph/paragraph.cjs +1 -13
- package/dist/paragraph/paragraph.cjs.map +1 -1
- package/dist/paragraph/paragraph.d.ts +1 -4
- package/dist/paragraph/paragraph.js +8 -6
- package/dist/paragraph/paragraph.js.map +1 -1
- package/dist/speech-recognition/speech-recognition.cjs +1 -76
- package/dist/speech-recognition/speech-recognition.cjs.map +1 -1
- package/dist/speech-recognition/speech-recognition.d.ts +13 -13
- package/dist/speech-recognition/speech-recognition.js +36 -57
- package/dist/speech-recognition/speech-recognition.js.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.cjs +1 -32
- package/dist/speech-synthesis/speech-synthesis.cjs.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.d.ts +10 -10
- package/dist/speech-synthesis/speech-synthesis.js +10 -19
- package/dist/speech-synthesis/speech-synthesis.js.map +1 -1
- package/dist/table-cell/table-cell.cjs +1 -27
- package/dist/table-cell/table-cell.cjs.map +1 -1
- package/dist/table-cell/table-cell.d.ts +1 -4
- package/dist/table-cell/table-cell.js +12 -17
- package/dist/table-cell/table-cell.js.map +1 -1
- package/dist/transform/html-to-json/html-to-json.cjs +1 -4
- package/dist/transform/html-to-json/html-to-json.cjs.map +1 -1
- package/dist/transform/html-to-json/html-to-json.d.ts +1 -4
- package/dist/transform/html-to-json/html-to-json.js +4 -2
- package/dist/transform/html-to-json/html-to-json.js.map +1 -1
- package/dist/transform/json-to-html/json-to-html.cjs +1 -4
- package/dist/transform/json-to-html/json-to-html.cjs.map +1 -1
- package/dist/transform/json-to-html/json-to-html.js +4 -2
- package/dist/transform/json-to-html/json-to-html.js.map +1 -1
- package/dist/video/video.cjs +2 -111
- package/dist/video/video.cjs.map +1 -1
- package/dist/video/video.d.ts +20 -29
- package/dist/video/video.js +90 -114
- package/dist/video/video.js.map +1 -1
- package/package.json +24 -16
- package/dist/image/custom-image.cjs +0 -163
- package/dist/image/custom-image.cjs.map +0 -1
- package/dist/image/custom-image.d.ts +0 -27
- package/dist/image/custom-image.js +0 -181
- package/dist/image/custom-image.js.map +0 -1
|
@@ -1,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
|
|
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
|
-
declare module
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
declare module "@tiptap/core" {
|
|
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,77 +1,56 @@
|
|
|
1
|
-
import { Node } from
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
2
|
class SR_Node extends Node {
|
|
3
3
|
constructor() {
|
|
4
|
-
super(),
|
|
4
|
+
super(), this.isStarted = !1;
|
|
5
5
|
}
|
|
6
6
|
static create(config) {
|
|
7
7
|
return Node.create(config);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
const SpeechRecognition = SR_Node.create({
|
|
11
|
-
name:
|
|
11
|
+
name: "SpeechRecognition",
|
|
12
12
|
addOptions() {
|
|
13
13
|
return {
|
|
14
|
-
lang:
|
|
14
|
+
lang: "fr-FR"
|
|
15
15
|
};
|
|
16
16
|
},
|
|
17
17
|
onCreate() {
|
|
18
|
-
|
|
19
|
-
'
|
|
20
|
-
|
|
21
|
-
'"speechrecognition extension from @edifice.io/tiptap-extensions" requires a browser supporting the SpeechRecognition API".',
|
|
22
|
-
);
|
|
18
|
+
"SpeechRecognition" in window || "webkitSpeechRecognition" in window || console.warn(
|
|
19
|
+
'"@edifice.io/tiptap-extensions/speechrecognition" requires a browser supporting the SpeechRecognition API".'
|
|
20
|
+
);
|
|
23
21
|
},
|
|
24
22
|
addCommands() {
|
|
25
23
|
return {
|
|
26
|
-
startSpeechRecognition:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
24
|
+
startSpeechRecognition: () => ({ commands }) => {
|
|
25
|
+
const SpeechRecognition2 = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
26
|
+
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();
|
|
27
|
+
let { from, to } = this.editor.state.selection;
|
|
28
|
+
return this.recognition.onresult = (event) => {
|
|
29
|
+
let currentResult = "";
|
|
30
|
+
for (let i = event.resultIndex; i < event.results.length; i++)
|
|
31
|
+
currentResult += event.results[i][0].transcript;
|
|
32
|
+
const isFinal = event.results[event.results.length - 1].isFinal;
|
|
33
|
+
this.editor.commands.deleteRange({ from, to }), this.editor.commands.insertContentAt(
|
|
34
|
+
from,
|
|
35
|
+
isFinal ? currentResult : `<code>${currentResult}</code>`,
|
|
36
|
+
{ updateSelection: !isFinal }
|
|
37
|
+
), to = this.editor.state.selection.to, isFinal && (from = to);
|
|
38
|
+
}, this.recognition.onerror = (event) => {
|
|
39
|
+
console.log(
|
|
40
|
+
`[@edifice.io/tiptap-extensions/speech-recognition][error][${event.error}]: ${event.message}`
|
|
65
41
|
);
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
() =>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
42
|
+
}, this.recognition.onstart = () => {
|
|
43
|
+
this.isStarted = !0;
|
|
44
|
+
}, this.recognition.onend = () => {
|
|
45
|
+
this.isStarted = !1;
|
|
46
|
+
}, commands;
|
|
47
|
+
},
|
|
48
|
+
stopSpeechRecognition: () => ({ commands }) => (this.recognition.stop(), this.editor.commands.focus(), commands),
|
|
49
|
+
isSpeechRecognitionStarted: () => () => this.isStarted
|
|
73
50
|
};
|
|
74
|
-
}
|
|
51
|
+
}
|
|
75
52
|
});
|
|
76
|
-
export {
|
|
53
|
+
export {
|
|
54
|
+
SpeechRecognition
|
|
55
|
+
};
|
|
77
56
|
//# 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
|
|
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 '\"@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":["SpeechRecognition"],"mappings":";AAgBA,MAAM,gBAAkC,KAAW;AAAA,EACvC,cAAc;AAChB,UAAA,GAIR,KAAS,YAAqB;AAAA,EAAA;AAAA,EAE9B,OAAO,OAAyB,QAAc;AACrC,WAAA,KAAK,OAAO,MAAM;AAAA,EAAA;AAE7B;AAEa,MAAA,oBAAoB,QAAQ,OAAiC;AAAA,EACxE,MAAM;AAAA,EAEN,aAAa;AACJ,WAAA;AAAA,MACL,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEA,WAAW;AACT,IACI,uBAAuB,UAAU,6BAA6B,UAExD,QAAA;AAAA,MACN;AAAA,IACF;AAAA,EAEJ;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,wBACE,MACA,CAAC,EAAE,eAAe;AACVA,cAAAA,qBACJ,OAAO,qBAAqB,OAAO;AAChC,aAAA,cAAc,IAAIA,mBAAkB,GAEpC,KAAA,YAAY,OAAO,KAAK,QAAQ,MACrC,KAAK,YAAY,iBAAiB,IAClC,KAAK,YAAY,kBAAkB,GACnC,KAAK,YAAY,aAAa,IAE9B,KAAK,YAAY,MAAM;AAGvB,YAAI,EAAE,MAAM,GAAA,IAAO,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,UAC9B,GACK,KAAA,KAAK,OAAO,MAAM,UAAU,IAE7B,YAEK,OAAA;AAAA,QAEX,GAEK,KAAA,YAAY,UAAU,CAAC,UAAuC;AAEzD,kBAAA;AAAA,YACN,6DAA6D,MAAM,KAAK,MAAM,MAAM,OAAO;AAAA,UAC7F;AAAA,QACF,GAEK,KAAA,YAAY,UAAU,MAAM;AAC/B,eAAK,YAAY;AAAA,QACnB,GAEK,KAAA,YAAY,QAAQ,MAAM;AAC7B,eAAK,YAAY;AAAA,QACnB,GAEO;AAAA,MACT;AAAA,MAEF,uBACE,MACA,CAAC,EAAE,gBACD,KAAK,YAAY,KAAK,GACjB,KAAA,OAAO,SAAS,MAAM,GACpB;AAAA,MAGX,4BAA4B,MAAM,MAAM,KAAK;AAAA,IAC/C;AAAA,EAAA;AAEJ,CAAC;"}
|
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
|
|
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;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@tiptap/core");class SS_Node extends core.Node{static create(config){return core.Node.create(config)}}const SpeechSynthesis=SS_Node.create({name:"speechSynthesis",addOptions(){return{lang:"fr-FR",pitch:1}},addCommands(){return{startSpeechSynthesis:()=>({commands})=>(this.speechSynthesis=new SpeechSynthesisUtterance,this.speechSynthesis.lang=this.options.lang,this.speechSynthesis.pitch=this.options.pitch,this.speechSynthesis.text=this.editor.getText(),window.speechSynthesis.speak(this.speechSynthesis),commands),stopSpeechSynthesis:()=>({commands})=>(window.speechSynthesis.cancel(),commands)}}});exports.SpeechSynthesis=SpeechSynthesis;
|
|
33
2
|
//# 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
|
|
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,CAAA,CAE7B,CAEa,MAAA,gBAAkB,QAAQ,OAA+B,CACpE,KAAM,kBACN,YAAa,CACJ,MAAA,CACL,KAAM,QACN,MAAO,CACT,CACF,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,OAAO,EACvB,SAEb,CAAA,CAEJ,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
|
-
declare module
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
declare module "@tiptap/core" {
|
|
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 {};
|
|
@@ -1,34 +1,25 @@
|
|
|
1
|
-
import { Node } from
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
2
|
class SS_Node extends Node {
|
|
3
3
|
static create(config) {
|
|
4
4
|
return Node.create(config);
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
const SpeechSynthesis = SS_Node.create({
|
|
8
|
-
name:
|
|
8
|
+
name: "speechSynthesis",
|
|
9
9
|
addOptions() {
|
|
10
10
|
return {
|
|
11
|
-
lang:
|
|
12
|
-
pitch: 1
|
|
11
|
+
lang: "fr-FR",
|
|
12
|
+
pitch: 1
|
|
13
13
|
};
|
|
14
14
|
},
|
|
15
15
|
addCommands() {
|
|
16
16
|
return {
|
|
17
|
-
startSpeechSynthesis:
|
|
18
|
-
|
|
19
|
-
({ commands }) => (
|
|
20
|
-
(this.speechSynthesis = new SpeechSynthesisUtterance()),
|
|
21
|
-
(this.speechSynthesis.lang = this.options.lang),
|
|
22
|
-
(this.speechSynthesis.pitch = this.options.pitch),
|
|
23
|
-
(this.speechSynthesis.text = this.editor.getText()),
|
|
24
|
-
window.speechSynthesis.speak(this.speechSynthesis),
|
|
25
|
-
commands
|
|
26
|
-
),
|
|
27
|
-
stopSpeechSynthesis:
|
|
28
|
-
() =>
|
|
29
|
-
({ commands }) => (window.speechSynthesis.cancel(), commands),
|
|
17
|
+
startSpeechSynthesis: () => ({ commands }) => (this.speechSynthesis = new SpeechSynthesisUtterance(), this.speechSynthesis.lang = this.options.lang, this.speechSynthesis.pitch = this.options.pitch, this.speechSynthesis.text = this.editor.getText(), window.speechSynthesis.speak(this.speechSynthesis), commands),
|
|
18
|
+
stopSpeechSynthesis: () => ({ commands }) => (window.speechSynthesis.cancel(), commands)
|
|
30
19
|
};
|
|
31
|
-
}
|
|
20
|
+
}
|
|
32
21
|
});
|
|
33
|
-
export {
|
|
22
|
+
export {
|
|
23
|
+
SpeechSynthesis
|
|
24
|
+
};
|
|
34
25
|
//# sourceMappingURL=speech-synthesis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speech-synthesis.js","sources":["../../src/speech-synthesis/speech-synthesis.ts"],"sourcesContent":["import { Node } from
|
|
1
|
+
{"version":3,"file":"speech-synthesis.js","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":[],"mappings":";AAgBA,MAAM,gBAAkC,KAAW;AAAA,EACjD,OAAO,OAAyB,QAAc;AACrC,WAAA,KAAK,OAAO,MAAM;AAAA,EAAA;AAE7B;AAEa,MAAA,kBAAkB,QAAQ,OAA+B;AAAA,EACpE,MAAM;AAAA,EACN,aAAa;AACJ,WAAA;AAAA,MACL,MAAM;AAAA,MACN,OAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,cAAc;AACL,WAAA;AAAA,MACL,sBACE,MACA,CAAC,EAAE,gBACI,KAAA,kBAAkB,IAAI,yBAAyB,GAC/C,KAAA,gBAAgB,OAAO,KAAK,QAAQ,MACpC,KAAA,gBAAgB,QAAQ,KAAK,QAAQ,OAC1C,KAAK,gBAAgB,OAAO,KAAK,OAAO,QAAQ,GAEzC,OAAA,gBAAgB,MAAM,KAAK,eAAe,GAC1C;AAAA,MAEX,qBACE,MACA,CAAC,EAAE,gBACD,OAAO,gBAAgB,OAAO,GACvB;AAAA,IAEb;AAAA,EAAA;AAEJ,CAAC;"}
|
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
-
const extensionTableCell = require('@tiptap/extension-table-cell'),
|
|
4
|
-
TableCell = extensionTableCell.TableCell.extend({
|
|
5
|
-
addAttributes() {
|
|
6
|
-
var _a;
|
|
7
|
-
return {
|
|
8
|
-
...((_a = this.parent) == null ? void 0 : _a.call(this)),
|
|
9
|
-
backgroundColor: {
|
|
10
|
-
default: null,
|
|
11
|
-
renderHTML: (attributes) =>
|
|
12
|
-
attributes.backgroundColor
|
|
13
|
-
? { style: `background-color: ${attributes.backgroundColor}` }
|
|
14
|
-
: {},
|
|
15
|
-
parseHTML: (element) => {
|
|
16
|
-
var _a2, _b;
|
|
17
|
-
return (_b =
|
|
18
|
-
(_a2 = element.style) == null ? void 0 : _a2.backgroundColor) ==
|
|
19
|
-
null
|
|
20
|
-
? void 0
|
|
21
|
-
: _b.replace(/['"]+/g, '');
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
exports.TableCell = TableCell;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const extensionTableCell=require("@tiptap/extension-table-cell"),TableCell=extensionTableCell.TableCell.extend({addAttributes(){var _a;return{...(_a=this.parent)==null?void 0:_a.call(this),backgroundColor:{default:null,renderHTML:attributes=>attributes.backgroundColor?{style:`background-color: ${attributes.backgroundColor}`}:{},parseHTML:element=>{var _a2,_b;return(_b=(_a2=element.style)==null?void 0:_a2.backgroundColor)==null?void 0:_b.replace(/['"]+/g,"")}}}}});exports.TableCell=TableCell;
|
|
28
2
|
//# sourceMappingURL=table-cell.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-cell.cjs","sources":["../../src/table-cell/table-cell.ts"],"sourcesContent":["import { TableCell as TipTapTableCell } from
|
|
1
|
+
{"version":3,"file":"table-cell.cjs","sources":["../../src/table-cell/table-cell.ts"],"sourcesContent":["import { TableCell as TipTapTableCell } from \"@tiptap/extension-table-cell\";\n\n/**\n * This custom extension allows setting a background-color to table cells.\n * Apply with ̀`editor.chain().focus().setCellAttribute(\"backgroundColor\", color).run()`\n */\nexport const TableCell = TipTapTableCell.extend({\n addAttributes() {\n return {\n ...this.parent?.(),\n backgroundColor: {\n default: null,\n renderHTML: (attributes: { backgroundColor?: string }) => {\n if (!attributes.backgroundColor) {\n return {};\n }\n\n return {\n style: `background-color: ${attributes.backgroundColor}`,\n };\n },\n parseHTML: (element: { style?: { backgroundColor: string } }) => {\n return element.style?.backgroundColor?.replace(/['\"]+/g, \"\");\n },\n },\n };\n },\n});\n"],"names":["TipTapTableCell","_a"],"mappings":"iJAMa,UAAYA,6BAAgB,OAAO,CAC9C,eAAgB,QACP,MAAA,CACL,IAAG,QAAK,SAAL,0BACH,gBAAiB,CACf,QAAS,KACT,WAAa,YACN,WAAW,gBAIT,CACL,MAAO,qBAAqB,WAAW,eAAe,EACxD,EALS,CAAC,EAOZ,UAAY,SAAqD,YAC/D,OAAO,IAAAC,IAAA,QAAQ,QAAR,YAAAA,IAAe,kBAAf,eAAgC,QAAQ,SAAU,GAAE,CAC7D,CAEJ,CAAA,CAEJ,CAAC"}
|
|
@@ -2,7 +2,4 @@
|
|
|
2
2
|
* This custom extension allows setting a background-color to table cells.
|
|
3
3
|
* Apply with ̀`editor.chain().focus().setCellAttribute("backgroundColor", color).run()`
|
|
4
4
|
*/
|
|
5
|
-
export declare const TableCell: import('@tiptap/core').Node<
|
|
6
|
-
import('@tiptap/extension-table-cell').TableCellOptions,
|
|
7
|
-
any
|
|
8
|
-
>;
|
|
5
|
+
export declare const TableCell: import('@tiptap/core').Node<import('@tiptap/extension-table-cell').TableCellOptions, any>;
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
import { TableCell as TableCell$1 } from
|
|
1
|
+
import { TableCell as TableCell$1 } from "@tiptap/extension-table-cell";
|
|
2
2
|
const TableCell = TableCell$1.extend({
|
|
3
3
|
addAttributes() {
|
|
4
4
|
var _a;
|
|
5
5
|
return {
|
|
6
|
-
...(
|
|
6
|
+
...(_a = this.parent) == null ? void 0 : _a.call(this),
|
|
7
7
|
backgroundColor: {
|
|
8
8
|
default: null,
|
|
9
|
-
renderHTML: (attributes) =>
|
|
10
|
-
attributes.backgroundColor
|
|
11
|
-
|
|
12
|
-
style: `background-color: ${attributes.backgroundColor}`,
|
|
13
|
-
}
|
|
14
|
-
: {},
|
|
9
|
+
renderHTML: (attributes) => attributes.backgroundColor ? {
|
|
10
|
+
style: `background-color: ${attributes.backgroundColor}`
|
|
11
|
+
} : {},
|
|
15
12
|
parseHTML: (element) => {
|
|
16
13
|
var _a2, _b;
|
|
17
|
-
return (_b =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
? void 0
|
|
21
|
-
: _b.replace(/['"]+/g, '');
|
|
22
|
-
},
|
|
23
|
-
},
|
|
14
|
+
return (_b = (_a2 = element.style) == null ? void 0 : _a2.backgroundColor) == null ? void 0 : _b.replace(/['"]+/g, "");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
24
17
|
};
|
|
25
|
-
}
|
|
18
|
+
}
|
|
26
19
|
});
|
|
27
|
-
export {
|
|
20
|
+
export {
|
|
21
|
+
TableCell
|
|
22
|
+
};
|
|
28
23
|
//# sourceMappingURL=table-cell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-cell.js","sources":["../../src/table-cell/table-cell.ts"],"sourcesContent":["import { TableCell as TipTapTableCell } from
|
|
1
|
+
{"version":3,"file":"table-cell.js","sources":["../../src/table-cell/table-cell.ts"],"sourcesContent":["import { TableCell as TipTapTableCell } from \"@tiptap/extension-table-cell\";\n\n/**\n * This custom extension allows setting a background-color to table cells.\n * Apply with ̀`editor.chain().focus().setCellAttribute(\"backgroundColor\", color).run()`\n */\nexport const TableCell = TipTapTableCell.extend({\n addAttributes() {\n return {\n ...this.parent?.(),\n backgroundColor: {\n default: null,\n renderHTML: (attributes: { backgroundColor?: string }) => {\n if (!attributes.backgroundColor) {\n return {};\n }\n\n return {\n style: `background-color: ${attributes.backgroundColor}`,\n };\n },\n parseHTML: (element: { style?: { backgroundColor: string } }) => {\n return element.style?.backgroundColor?.replace(/['\"]+/g, \"\");\n },\n },\n };\n },\n});\n"],"names":["TipTapTableCell","_a"],"mappings":";AAMa,MAAA,YAAYA,YAAgB,OAAO;AAAA,EAC9C,gBAAgB;;AACP,WAAA;AAAA,MACL,IAAG,UAAK,WAAL;AAAA,MACH,iBAAiB;AAAA,QACf,SAAS;AAAA,QACT,YAAY,CAAC,eACN,WAAW,kBAIT;AAAA,UACL,OAAO,qBAAqB,WAAW,eAAe;AAAA,QACxD,IALS,CAAC;AAAA,QAOZ,WAAW,CAAC,YAAqD;;AAC/D,kBAAO,MAAAC,MAAA,QAAQ,UAAR,gBAAAA,IAAe,oBAAf,mBAAgC,QAAQ,UAAU;AAAA,QAAE;AAAA,MAC7D;AAAA,IAEJ;AAAA,EAAA;AAEJ,CAAC;"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
const core = require('@tiptap/core'),
|
|
3
|
-
htmlToJson = (html, extensions) => core.generateJSON(html, extensions);
|
|
4
|
-
module.exports = htmlToJson;
|
|
1
|
+
"use strict";const core=require("@tiptap/core"),htmlToJson=(html,extensions)=>core.generateJSON(html,extensions);module.exports=htmlToJson;
|
|
5
2
|
//# sourceMappingURL=html-to-json.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-to-json.cjs","sources":["../../../src/transform/html-to-json/html-to-json.ts"],"sourcesContent":["import { Extensions, HTMLContent, generateJSON } from
|
|
1
|
+
{"version":3,"file":"html-to-json.cjs","sources":["../../../src/transform/html-to-json/html-to-json.ts"],"sourcesContent":["import { Extensions, HTMLContent, generateJSON } from \"@tiptap/core\";\n\nexport default (html: HTMLContent, extensions: Extensions) => {\n return generateJSON(html, extensions);\n};\n"],"names":["generateJSON"],"mappings":"gDAEA,WAAe,CAAC,KAAmB,aAC1BA,KAAA,aAAa,KAAM,UAAU"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { Extensions, HTMLContent } from '@tiptap/core';
|
|
2
|
-
declare const _default: (
|
|
3
|
-
html: HTMLContent,
|
|
4
|
-
extensions: Extensions,
|
|
5
|
-
) => Record<string, any>;
|
|
2
|
+
declare const _default: (html: HTMLContent, extensions: Extensions) => Record<string, any>;
|
|
6
3
|
export default _default;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { generateJSON } from
|
|
1
|
+
import { generateJSON } from "@tiptap/core";
|
|
2
2
|
const htmlToJson = (html, extensions) => generateJSON(html, extensions);
|
|
3
|
-
export {
|
|
3
|
+
export {
|
|
4
|
+
htmlToJson as default
|
|
5
|
+
};
|
|
4
6
|
//# sourceMappingURL=html-to-json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-to-json.js","sources":["../../../src/transform/html-to-json/html-to-json.ts"],"sourcesContent":["import { Extensions, HTMLContent, generateJSON } from
|
|
1
|
+
{"version":3,"file":"html-to-json.js","sources":["../../../src/transform/html-to-json/html-to-json.ts"],"sourcesContent":["import { Extensions, HTMLContent, generateJSON } from \"@tiptap/core\";\n\nexport default (html: HTMLContent, extensions: Extensions) => {\n return generateJSON(html, extensions);\n};\n"],"names":[],"mappings":";AAEA,MAAA,aAAe,CAAC,MAAmB,eAC1B,aAAa,MAAM,UAAU;"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
const core = require('@tiptap/core'),
|
|
3
|
-
jsonToHtml = (json, extensions) => core.generateHTML(json, extensions);
|
|
4
|
-
module.exports = jsonToHtml;
|
|
1
|
+
"use strict";const core=require("@tiptap/core"),jsonToHtml=(json,extensions)=>core.generateHTML(json,extensions);module.exports=jsonToHtml;
|
|
5
2
|
//# sourceMappingURL=json-to-html.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-to-html.cjs","sources":["../../../src/transform/json-to-html/json-to-html.ts"],"sourcesContent":["import { Extensions, JSONContent, generateHTML } from
|
|
1
|
+
{"version":3,"file":"json-to-html.cjs","sources":["../../../src/transform/json-to-html/json-to-html.ts"],"sourcesContent":["import { Extensions, JSONContent, generateHTML } from \"@tiptap/core\";\n\nexport default (json: JSONContent, extensions: Extensions) => {\n return generateHTML(json, extensions);\n};\n"],"names":["generateHTML"],"mappings":"gDAEA,WAAe,CAAC,KAAmB,aAC1BA,KAAA,aAAa,KAAM,UAAU"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { generateHTML } from
|
|
1
|
+
import { generateHTML } from "@tiptap/core";
|
|
2
2
|
const jsonToHtml = (json, extensions) => generateHTML(json, extensions);
|
|
3
|
-
export {
|
|
3
|
+
export {
|
|
4
|
+
jsonToHtml as default
|
|
5
|
+
};
|
|
4
6
|
//# sourceMappingURL=json-to-html.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-to-html.js","sources":["../../../src/transform/json-to-html/json-to-html.ts"],"sourcesContent":["import { Extensions, JSONContent, generateHTML } from
|
|
1
|
+
{"version":3,"file":"json-to-html.js","sources":["../../../src/transform/json-to-html/json-to-html.ts"],"sourcesContent":["import { Extensions, JSONContent, generateHTML } from \"@tiptap/core\";\n\nexport default (json: JSONContent, extensions: Extensions) => {\n return generateHTML(json, extensions);\n};\n"],"names":[],"mappings":";AAEA,MAAA,aAAe,CAAC,MAAmB,eAC1B,aAAa,MAAM,UAAU;"}
|