@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/index.cjs
CHANGED
|
@@ -1,2 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const abbr = require('./abbr/abbr.cjs'),
|
|
4
|
+
alert = require('./alert/alert.cjs'),
|
|
5
|
+
attachment = require('./attachment/attachment.cjs'),
|
|
6
|
+
audio = require('./audio/audio.cjs'),
|
|
7
|
+
fontSize = require('./font-size/font-size.cjs'),
|
|
8
|
+
heading = require('./heading/heading.cjs'),
|
|
9
|
+
highlight = require('./highlight/highlight.cjs'),
|
|
10
|
+
hyperlink = require('./hyperlink/hyperlink.cjs'),
|
|
11
|
+
iframe = require('./iframe/iframe.cjs'),
|
|
12
|
+
customImage = require('./image/custom-image.cjs'),
|
|
13
|
+
lineHeight = require('./line-height/line-height.cjs'),
|
|
14
|
+
linker = require('./linker/linker.cjs'),
|
|
15
|
+
mathjax = require('./mathjax/mathjax.cjs'),
|
|
16
|
+
paragraph = require('./paragraph/paragraph.cjs'),
|
|
17
|
+
speechRecognition = require('./speech-recognition/speech-recognition.cjs'),
|
|
18
|
+
speechSynthesis = require('./speech-synthesis/speech-synthesis.cjs'),
|
|
19
|
+
tableCell = require('./table-cell/table-cell.cjs'),
|
|
20
|
+
htmlToJson = require('./transform/html-to-json/html-to-json.cjs'),
|
|
21
|
+
jsonToHtml = require('./transform/json-to-html/json-to-html.cjs'),
|
|
22
|
+
video = require('./video/video.cjs');
|
|
23
|
+
exports.Abbr = abbr.Abbr;
|
|
24
|
+
exports.Alert = alert.Alert;
|
|
25
|
+
exports.Attachment = attachment.Attachment;
|
|
26
|
+
exports.Audio = audio.Audio;
|
|
27
|
+
exports.FontSize = fontSize.FontSize;
|
|
28
|
+
exports.CustomHeading = heading.CustomHeading;
|
|
29
|
+
exports.CustomHighlight = highlight.CustomHighlight;
|
|
30
|
+
exports.Hyperlink = hyperlink.Hyperlink;
|
|
31
|
+
exports.Iframe = iframe.Iframe;
|
|
32
|
+
exports.CustomImage = customImage.CustomImage;
|
|
33
|
+
exports.IMAGE_INPUT_REGEX = customImage.IMAGE_INPUT_REGEX;
|
|
34
|
+
exports.LineHeight = lineHeight.LineHeight;
|
|
35
|
+
exports.Linker = linker.Linker;
|
|
36
|
+
exports.MathJax = mathjax.MathJax;
|
|
37
|
+
exports.Paragraph = paragraph.Paragraph;
|
|
38
|
+
exports.SpeechRecognition = speechRecognition.SpeechRecognition;
|
|
39
|
+
exports.SpeechSynthesis = speechSynthesis.SpeechSynthesis;
|
|
40
|
+
exports.TableCell = tableCell.TableCell;
|
|
41
|
+
exports.htmlToJson = htmlToJson;
|
|
42
|
+
exports.jsonToHtml = jsonToHtml;
|
|
43
|
+
exports.Video = video.Video;
|
|
2
44
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { Abbr
|
|
2
|
-
import { Alert
|
|
3
|
-
import { Attachment
|
|
4
|
-
import { Audio
|
|
5
|
-
import { FontSize
|
|
6
|
-
import { CustomHeading
|
|
7
|
-
import { CustomHighlight
|
|
8
|
-
import { Hyperlink
|
|
9
|
-
import { Iframe
|
|
10
|
-
import { CustomImage
|
|
11
|
-
import { LineHeight
|
|
12
|
-
import { Linker
|
|
13
|
-
import { MathJax
|
|
14
|
-
import { Paragraph
|
|
15
|
-
import { SpeechRecognition
|
|
16
|
-
import { SpeechSynthesis
|
|
17
|
-
import { TableCell
|
|
18
|
-
import { default as
|
|
19
|
-
import { default as
|
|
20
|
-
import { Video
|
|
1
|
+
import { Abbr } from './abbr/abbr.js';
|
|
2
|
+
import { Alert } from './alert/alert.js';
|
|
3
|
+
import { Attachment } from './attachment/attachment.js';
|
|
4
|
+
import { Audio } from './audio/audio.js';
|
|
5
|
+
import { FontSize } from './font-size/font-size.js';
|
|
6
|
+
import { CustomHeading } from './heading/heading.js';
|
|
7
|
+
import { CustomHighlight } from './highlight/highlight.js';
|
|
8
|
+
import { Hyperlink } from './hyperlink/hyperlink.js';
|
|
9
|
+
import { Iframe } from './iframe/iframe.js';
|
|
10
|
+
import { CustomImage, IMAGE_INPUT_REGEX } from './image/custom-image.js';
|
|
11
|
+
import { LineHeight } from './line-height/line-height.js';
|
|
12
|
+
import { Linker } from './linker/linker.js';
|
|
13
|
+
import { MathJax } from './mathjax/mathjax.js';
|
|
14
|
+
import { Paragraph } from './paragraph/paragraph.js';
|
|
15
|
+
import { SpeechRecognition } from './speech-recognition/speech-recognition.js';
|
|
16
|
+
import { SpeechSynthesis } from './speech-synthesis/speech-synthesis.js';
|
|
17
|
+
import { TableCell } from './table-cell/table-cell.js';
|
|
18
|
+
import { default as default2 } from './transform/html-to-json/html-to-json.js';
|
|
19
|
+
import { default as default3 } from './transform/json-to-html/json-to-html.js';
|
|
20
|
+
import { Video } from './video/video.js';
|
|
21
21
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
22
|
+
Abbr,
|
|
23
|
+
Alert,
|
|
24
|
+
Attachment,
|
|
25
|
+
Audio,
|
|
26
|
+
CustomHeading,
|
|
27
|
+
CustomHighlight,
|
|
28
|
+
CustomImage,
|
|
29
|
+
FontSize,
|
|
30
|
+
Hyperlink,
|
|
31
|
+
IMAGE_INPUT_REGEX,
|
|
32
|
+
Iframe,
|
|
33
|
+
LineHeight,
|
|
34
|
+
Linker,
|
|
35
|
+
MathJax,
|
|
36
|
+
Paragraph,
|
|
37
|
+
SpeechRecognition,
|
|
38
|
+
SpeechSynthesis,
|
|
39
|
+
TableCell,
|
|
40
|
+
Video,
|
|
41
|
+
default2 as htmlToJson,
|
|
42
|
+
default3 as jsonToHtml,
|
|
43
43
|
};
|
|
44
44
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
require('@tiptap/extension-text-style');
|
|
4
|
+
const core = require('@tiptap/core'),
|
|
5
|
+
LineHeight = core.Extension.create({
|
|
6
|
+
name: 'lineHeight',
|
|
7
|
+
addOptions() {
|
|
8
|
+
return { types: ['textStyle'] };
|
|
9
|
+
},
|
|
10
|
+
addGlobalAttributes() {
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
types: this.options.types,
|
|
14
|
+
attributes: {
|
|
15
|
+
lineHeight: {
|
|
16
|
+
default: null,
|
|
17
|
+
parseHTML: (element) => {
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = element.style.lineHeight) == null
|
|
20
|
+
? void 0
|
|
21
|
+
: _a.replace(/['"]+/g, '');
|
|
22
|
+
},
|
|
23
|
+
renderHTML: (attributes) =>
|
|
24
|
+
attributes.lineHeight
|
|
25
|
+
? { style: `line-height: ${attributes.lineHeight}` }
|
|
26
|
+
: {},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
exports.LineHeight = LineHeight;
|
|
2
34
|
//# sourceMappingURL=line-height.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-height.cjs","sources":["../../src/line-height/line-height.ts"],"sourcesContent":["import '@tiptap/extension-text-style';\n\nimport { Extension } from '@tiptap/core';\n\nexport const LineHeight = Extension.create({\n name: 'lineHeight',\n\n addOptions() {\n return {\n types: ['textStyle'],\n };\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n lineHeight: {\n default: null,\n parseHTML: (element) =>\n element.style.lineHeight?.replace(/['\"]+/g, ''),\n renderHTML: (attributes) => {\n if (!attributes.lineHeight) {\n return {};\n }\n\n return {\n style: `line-height: ${attributes.lineHeight}`,\n };\n },\n },\n },\n },\n ];\n },\n});\n"],"names":["
|
|
1
|
+
{"version":3,"file":"line-height.cjs","sources":["../../src/line-height/line-height.ts"],"sourcesContent":["import '@tiptap/extension-text-style';\n\nimport { Extension } from '@tiptap/core';\n\nexport const LineHeight = Extension.create({\n name: 'lineHeight',\n\n addOptions() {\n return {\n types: ['textStyle'],\n };\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n lineHeight: {\n default: null,\n parseHTML: (element) =>\n element.style.lineHeight?.replace(/['\"]+/g, ''),\n renderHTML: (attributes) => {\n if (!attributes.lineHeight) {\n return {};\n }\n\n return {\n style: `line-height: ${attributes.lineHeight}`,\n };\n },\n },\n },\n },\n ];\n },\n});\n"],"names":["Extension"],"mappings":"2JAIa,WAAaA,eAAU,OAAO,CACzC,KAAM,aAEN,YAAa,CACJ,MAAA,CACL,MAAO,CAAC,WAAW,CAAA,CAEvB,EAEA,qBAAsB,CACb,MAAA,CACL,CACE,MAAO,KAAK,QAAQ,MACpB,WAAY,CACV,WAAY,CACV,QAAS,KACT,UAAY,SACV,QAAA,kBAAQ,MAAM,aAAd,eAA0B,QAAQ,SAAU,KAC9C,WAAa,YACN,WAAW,WAIT,CACL,MAAO,gBAAgB,WAAW,UAAU,EAAA,EAJrC,EAOb,CACF,CACF,CAAA,CAEJ,CACF,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Extension
|
|
3
|
-
const
|
|
4
|
-
name:
|
|
1
|
+
import '@tiptap/extension-text-style';
|
|
2
|
+
import { Extension } from '@tiptap/core';
|
|
3
|
+
const LineHeight = Extension.create({
|
|
4
|
+
name: 'lineHeight',
|
|
5
5
|
addOptions() {
|
|
6
6
|
return {
|
|
7
|
-
types: [
|
|
7
|
+
types: ['textStyle'],
|
|
8
8
|
};
|
|
9
9
|
},
|
|
10
10
|
addGlobalAttributes() {
|
|
@@ -14,20 +14,23 @@ const l = i.create({
|
|
|
14
14
|
attributes: {
|
|
15
15
|
lineHeight: {
|
|
16
16
|
default: null,
|
|
17
|
-
parseHTML: (
|
|
18
|
-
var
|
|
19
|
-
return (
|
|
17
|
+
parseHTML: (element) => {
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = element.style.lineHeight) == null
|
|
20
|
+
? void 0
|
|
21
|
+
: _a.replace(/['"]+/g, '');
|
|
20
22
|
},
|
|
21
|
-
renderHTML: (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
renderHTML: (attributes) =>
|
|
24
|
+
attributes.lineHeight
|
|
25
|
+
? {
|
|
26
|
+
style: `line-height: ${attributes.lineHeight}`,
|
|
27
|
+
}
|
|
28
|
+
: {},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
27
32
|
];
|
|
28
|
-
}
|
|
33
|
+
},
|
|
29
34
|
});
|
|
30
|
-
export {
|
|
31
|
-
l as LineHeight
|
|
32
|
-
};
|
|
35
|
+
export { LineHeight };
|
|
33
36
|
//# sourceMappingURL=line-height.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-height.js","sources":["../../src/line-height/line-height.ts"],"sourcesContent":["import '@tiptap/extension-text-style';\n\nimport { Extension } from '@tiptap/core';\n\nexport const LineHeight = Extension.create({\n name: 'lineHeight',\n\n addOptions() {\n return {\n types: ['textStyle'],\n };\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n lineHeight: {\n default: null,\n parseHTML: (element) =>\n element.style.lineHeight?.replace(/['\"]+/g, ''),\n renderHTML: (attributes) => {\n if (!attributes.lineHeight) {\n return {};\n }\n\n return {\n style: `line-height: ${attributes.lineHeight}`,\n };\n },\n },\n },\n },\n ];\n },\n});\n"],"names":[
|
|
1
|
+
{"version":3,"file":"line-height.js","sources":["../../src/line-height/line-height.ts"],"sourcesContent":["import '@tiptap/extension-text-style';\n\nimport { Extension } from '@tiptap/core';\n\nexport const LineHeight = Extension.create({\n name: 'lineHeight',\n\n addOptions() {\n return {\n types: ['textStyle'],\n };\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n lineHeight: {\n default: null,\n parseHTML: (element) =>\n element.style.lineHeight?.replace(/['\"]+/g, ''),\n renderHTML: (attributes) => {\n if (!attributes.lineHeight) {\n return {};\n }\n\n return {\n style: `line-height: ${attributes.lineHeight}`,\n };\n },\n },\n },\n },\n ];\n },\n});\n"],"names":[],"mappings":";;AAIa,MAAA,aAAa,UAAU,OAAO;AAAA,EACzC,MAAM;AAAA,EAEN,aAAa;AACJ,WAAA;AAAA,MACL,OAAO,CAAC,WAAW;AAAA,IAAA;AAAA,EAEvB;AAAA,EAEA,sBAAsB;AACb,WAAA;AAAA,MACL;AAAA,QACE,OAAO,KAAK,QAAQ;AAAA,QACpB,YAAY;AAAA,UACV,YAAY;AAAA,YACV,SAAS;AAAA,YACT,WAAW,CAAC,YACV;;AAAA,mCAAQ,MAAM,eAAd,mBAA0B,QAAQ,UAAU;AAAA;AAAA,YAC9C,YAAY,CAAC,eACN,WAAW,aAIT;AAAA,cACL,OAAO,gBAAgB,WAAW,UAAU;AAAA,YAAA,IAJrC;UAOb;AAAA,QACF;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;"}
|
package/dist/linker/linker.cjs
CHANGED
|
@@ -1,2 +1,96 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const core = require('@tiptap/core'),
|
|
4
|
+
Linker = core.Node.create({
|
|
5
|
+
name: 'linker',
|
|
6
|
+
content: 'text*',
|
|
7
|
+
marks: '',
|
|
8
|
+
group: 'inline',
|
|
9
|
+
inline: !0,
|
|
10
|
+
selectable: !0,
|
|
11
|
+
atom: !0,
|
|
12
|
+
draggable: !0,
|
|
13
|
+
isolating: !0,
|
|
14
|
+
allowGapCursor: !1,
|
|
15
|
+
priority: 1100,
|
|
16
|
+
keepOnSplit: !1,
|
|
17
|
+
addOptions() {
|
|
18
|
+
return {
|
|
19
|
+
openOnClick: !0,
|
|
20
|
+
HTMLAttributes: {
|
|
21
|
+
target: null,
|
|
22
|
+
title: null,
|
|
23
|
+
class: null,
|
|
24
|
+
'data-id': null,
|
|
25
|
+
'data-app-prefix': null,
|
|
26
|
+
},
|
|
27
|
+
validate: void 0,
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
addAttributes() {
|
|
31
|
+
return {
|
|
32
|
+
href: { default: null },
|
|
33
|
+
class: { default: this.options.HTMLAttributes.class },
|
|
34
|
+
target: {
|
|
35
|
+
default: this.options.HTMLAttributes.target,
|
|
36
|
+
parseHTML: (element) =>
|
|
37
|
+
element.getAttribute('target') !== '_blank' ? null : '_blank',
|
|
38
|
+
},
|
|
39
|
+
title: { default: this.options.HTMLAttributes.title },
|
|
40
|
+
'data-id': { default: this.options.HTMLAttributes['data-id'] },
|
|
41
|
+
'data-app-prefix': {
|
|
42
|
+
default: this.options.HTMLAttributes['data-app-prefix'],
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
parseHTML() {
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
tag: 'a[href]:not([href *= "javascript:" i])[data-id][data-app-prefix]',
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
},
|
|
53
|
+
renderHTML({ HTMLAttributes }) {
|
|
54
|
+
var _a;
|
|
55
|
+
return (_a = HTMLAttributes.href) != null && _a.startsWith('javascript:')
|
|
56
|
+
? [
|
|
57
|
+
'a',
|
|
58
|
+
core.mergeAttributes(this.options.HTMLAttributes, {
|
|
59
|
+
...HTMLAttributes,
|
|
60
|
+
href: '',
|
|
61
|
+
}),
|
|
62
|
+
0,
|
|
63
|
+
]
|
|
64
|
+
: [
|
|
65
|
+
'a',
|
|
66
|
+
core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
|
|
67
|
+
0,
|
|
68
|
+
];
|
|
69
|
+
},
|
|
70
|
+
addCommands() {
|
|
71
|
+
return {
|
|
72
|
+
setLinker:
|
|
73
|
+
(attrs) =>
|
|
74
|
+
({ commands }) => (
|
|
75
|
+
commands.insertContent({
|
|
76
|
+
type: this.name,
|
|
77
|
+
attrs,
|
|
78
|
+
content: [{ type: 'text', text: attrs.title }],
|
|
79
|
+
}),
|
|
80
|
+
!0
|
|
81
|
+
),
|
|
82
|
+
unsetLinker:
|
|
83
|
+
() =>
|
|
84
|
+
({ state, tr }) => {
|
|
85
|
+
const { node, from, to } = state.selection;
|
|
86
|
+
return (
|
|
87
|
+
(node == null ? void 0 : node.type.name) === 'linker' &&
|
|
88
|
+
tr.delete(from, to).scrollIntoView(),
|
|
89
|
+
!0
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
exports.Linker = Linker;
|
|
2
96
|
//# sourceMappingURL=linker.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linker.cjs","sources":["../../src/linker/linker.ts"],"sourcesContent":["import { Node, mergeAttributes } from '@tiptap/core';\nimport { NodeSelection } from '@tiptap/pm/state';\n\n/* Our own model of a link in a rich document. */\nexport type LinkerAttributes = {\n href: string | null;\n target: '_blank' | null;\n title: string | null;\n 'data-id': string | null;\n 'data-app-prefix': string | null;\n};\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n linker: {\n /**\n * Set a linker node\n */\n setLinker: (attributes: LinkerAttributes) => ReturnType;\n /**\n * Unset a linker node\n */\n unsetLinker: () => ReturnType;\n };\n }\n}\n\n/**\n * Internal links extension.\n * Reproduces the legacy angularJs \"linker\" directive.\n *\n * Links to internal resources MAY have a `title` and MUST HAVE `data-id` and `data-app-prefix` attributes :\n * `<a href=\"/blog#/view/35fa4198-blog_id/5e654c71-article_id\" data-app-prefix=\"blog\" data-id=\"35fa4198-blog_id\" target=\"_blank\" title=\"Voir ce billet de blog\" class=\"ng-scope\">/blog#/view/35fa4198-57fe-45eb-94f4-a5e4defff305/5e654c71-1e61-4f84-86dc-6fcfaf33f513</a>`\n */\nexport const Linker = Node.create({\n name: 'linker',\n content: 'text*',\n marks: '',\n group: 'inline',\n\n inline: true,\n selectable: true,\n atom: true,\n draggable: true,\n isolating: true,\n allowGapCursor: false,\n\n priority: 1100,\n keepOnSplit: false,\n\n addOptions() {\n return {\n openOnClick: true,\n HTMLAttributes: {\n target: null,\n title: null,\n class: null,\n 'data-id': null,\n 'data-app-prefix': null,\n },\n validate: undefined,\n };\n },\n\n addAttributes() {\n return {\n href: {\n default: null,\n },\n class: {\n default: this.options.HTMLAttributes.class,\n },\n target: {\n default: this.options.HTMLAttributes.target,\n // Sanitize target value\n parseHTML: (element) =>\n element.getAttribute('target') !== '_blank' ? null : '_blank',\n },\n title: {\n default: this.options.HTMLAttributes.title,\n },\n 'data-id': {\n default: this.options.HTMLAttributes['data-id'],\n },\n 'data-app-prefix': {\n default: this.options.HTMLAttributes['data-app-prefix'],\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'a[href]:not([href *= \"javascript:\" i])[data-id][data-app-prefix]',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n if (HTMLAttributes.href?.startsWith('javascript:')) {\n return [\n 'a',\n mergeAttributes(this.options.HTMLAttributes, {\n ...HTMLAttributes,\n href: '',\n }),\n 0,\n ];\n }\n return [\n 'a',\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setLinker:\n (attrs) =>\n ({ commands }) => {\n // Insert a Linker node with inner text node\n commands.insertContent({\n type: this.name,\n attrs,\n content: [\n {\n type: 'text',\n text: attrs.title,\n },\n ],\n });\n return true;\n },\n\n unsetLinker:\n () =>\n ({ state, tr }) => {\n // Which Linker node is actually selected ?\n const { node, from, to } = state.selection as NodeSelection;\n // Delete any selected Linker node\n if (node?.type.name === 'linker') {\n /* The following does not work as one would expected.\n commands.deleteNode(this.name);\n commands.deleteCurrentNode();\n * Replaced by : */\n tr.delete(from, to).scrollIntoView();\n }\n return true;\n },\n };\n },\n});\n"],"names":["
|
|
1
|
+
{"version":3,"file":"linker.cjs","sources":["../../src/linker/linker.ts"],"sourcesContent":["import { Node, mergeAttributes } from '@tiptap/core';\nimport { NodeSelection } from '@tiptap/pm/state';\n\n/* Our own model of a link in a rich document. */\nexport type LinkerAttributes = {\n href: string | null;\n target: '_blank' | null;\n title: string | null;\n 'data-id': string | null;\n 'data-app-prefix': string | null;\n};\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n linker: {\n /**\n * Set a linker node\n */\n setLinker: (attributes: LinkerAttributes) => ReturnType;\n /**\n * Unset a linker node\n */\n unsetLinker: () => ReturnType;\n };\n }\n}\n\n/**\n * Internal links extension.\n * Reproduces the legacy angularJs \"linker\" directive.\n *\n * Links to internal resources MAY have a `title` and MUST HAVE `data-id` and `data-app-prefix` attributes :\n * `<a href=\"/blog#/view/35fa4198-blog_id/5e654c71-article_id\" data-app-prefix=\"blog\" data-id=\"35fa4198-blog_id\" target=\"_blank\" title=\"Voir ce billet de blog\" class=\"ng-scope\">/blog#/view/35fa4198-57fe-45eb-94f4-a5e4defff305/5e654c71-1e61-4f84-86dc-6fcfaf33f513</a>`\n */\nexport const Linker = Node.create({\n name: 'linker',\n content: 'text*',\n marks: '',\n group: 'inline',\n\n inline: true,\n selectable: true,\n atom: true,\n draggable: true,\n isolating: true,\n allowGapCursor: false,\n\n priority: 1100,\n keepOnSplit: false,\n\n addOptions() {\n return {\n openOnClick: true,\n HTMLAttributes: {\n target: null,\n title: null,\n class: null,\n 'data-id': null,\n 'data-app-prefix': null,\n },\n validate: undefined,\n };\n },\n\n addAttributes() {\n return {\n href: {\n default: null,\n },\n class: {\n default: this.options.HTMLAttributes.class,\n },\n target: {\n default: this.options.HTMLAttributes.target,\n // Sanitize target value\n parseHTML: (element) =>\n element.getAttribute('target') !== '_blank' ? null : '_blank',\n },\n title: {\n default: this.options.HTMLAttributes.title,\n },\n 'data-id': {\n default: this.options.HTMLAttributes['data-id'],\n },\n 'data-app-prefix': {\n default: this.options.HTMLAttributes['data-app-prefix'],\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'a[href]:not([href *= \"javascript:\" i])[data-id][data-app-prefix]',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n if (HTMLAttributes.href?.startsWith('javascript:')) {\n return [\n 'a',\n mergeAttributes(this.options.HTMLAttributes, {\n ...HTMLAttributes,\n href: '',\n }),\n 0,\n ];\n }\n return [\n 'a',\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setLinker:\n (attrs) =>\n ({ commands }) => {\n // Insert a Linker node with inner text node\n commands.insertContent({\n type: this.name,\n attrs,\n content: [\n {\n type: 'text',\n text: attrs.title,\n },\n ],\n });\n return true;\n },\n\n unsetLinker:\n () =>\n ({ state, tr }) => {\n // Which Linker node is actually selected ?\n const { node, from, to } = state.selection as NodeSelection;\n // Delete any selected Linker node\n if (node?.type.name === 'linker') {\n /* The following does not work as one would expected.\n commands.deleteNode(this.name);\n commands.deleteCurrentNode();\n * Replaced by : */\n tr.delete(from, to).scrollIntoView();\n }\n return true;\n },\n };\n },\n});\n"],"names":["Node","mergeAttributes"],"mappings":"mHAkCa,OAASA,UAAK,OAAO,CAChC,KAAM,SACN,QAAS,QACT,MAAO,GACP,MAAO,SAEP,OAAQ,GACR,WAAY,GACZ,KAAM,GACN,UAAW,GACX,UAAW,GACX,eAAgB,GAEhB,SAAU,KACV,YAAa,GAEb,YAAa,CACJ,MAAA,CACL,YAAa,GACb,eAAgB,CACd,OAAQ,KACR,MAAO,KACP,MAAO,KACP,UAAW,KACX,kBAAmB,IACrB,EACA,SAAU,MAAA,CAEd,EAEA,eAAgB,CACP,MAAA,CACL,KAAM,CACJ,QAAS,IACX,EACA,MAAO,CACL,QAAS,KAAK,QAAQ,eAAe,KACvC,EACA,OAAQ,CACN,QAAS,KAAK,QAAQ,eAAe,OAErC,UAAY,SACV,QAAQ,aAAa,QAAQ,IAAM,SAAW,KAAO,QACzD,EACA,MAAO,CACL,QAAS,KAAK,QAAQ,eAAe,KACvC,EACA,UAAW,CACT,QAAS,KAAK,QAAQ,eAAe,SAAS,CAChD,EACA,kBAAmB,CACjB,QAAS,KAAK,QAAQ,eAAe,iBAAiB,CACxD,CAAA,CAEJ,EAEA,WAAY,CACH,MAAA,CACL,CACE,IAAK,kEACP,CAAA,CAEJ,EAEA,WAAW,CAAE,gBAAkB,QAC7B,OAAI,kBAAe,OAAf,SAAqB,WAAW,eAC3B,CACL,IACAC,qBAAgB,KAAK,QAAQ,eAAgB,CAC3C,GAAG,eACH,KAAM,EAAA,CACP,EACD,CAAA,EAGG,CACL,IACAA,KAAAA,gBAAgB,KAAK,QAAQ,eAAgB,cAAc,EAC3D,CAAA,CAEJ,EAEA,aAAc,CACL,MAAA,CACL,UACG,OACD,CAAC,CAAE,aAED,SAAS,cAAc,CACrB,KAAM,KAAK,KACX,MACA,QAAS,CACP,CACE,KAAM,OACN,KAAM,MAAM,KACd,CACF,CAAA,CACD,EACM,IAGX,YACE,IACA,CAAC,CAAE,MAAO,MAAS,CAEjB,KAAM,CAAE,KAAM,KAAM,EAAA,EAAO,MAAM,UAE7B,OAAA,uBAAM,KAAK,QAAS,UAKtB,GAAG,OAAO,KAAM,EAAE,EAAE,eAAe,EAE9B,EACT,CAAA,CAEN,CACF,CAAC"}
|
package/dist/linker/linker.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { Node } from '@tiptap/core';
|
|
2
2
|
export type LinkerAttributes = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
href: string | null;
|
|
4
|
+
target: '_blank' | null;
|
|
5
|
+
title: string | null;
|
|
6
|
+
'data-id': string | null;
|
|
7
|
+
'data-app-prefix': string | null;
|
|
8
8
|
};
|
|
9
9
|
declare module '@tiptap/core' {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
interface Commands<ReturnType> {
|
|
11
|
+
linker: {
|
|
12
|
+
/**
|
|
13
|
+
* Set a linker node
|
|
14
|
+
*/
|
|
15
|
+
setLinker: (attributes: LinkerAttributes) => ReturnType;
|
|
16
|
+
/**
|
|
17
|
+
* Unset a linker node
|
|
18
|
+
*/
|
|
19
|
+
unsetLinker: () => ReturnType;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Internal links extension.
|
package/dist/linker/linker.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Node
|
|
2
|
-
const
|
|
3
|
-
name:
|
|
4
|
-
content:
|
|
5
|
-
marks:
|
|
6
|
-
group:
|
|
1
|
+
import { Node, mergeAttributes } from '@tiptap/core';
|
|
2
|
+
const Linker = Node.create({
|
|
3
|
+
name: 'linker',
|
|
4
|
+
content: 'text*',
|
|
5
|
+
marks: '',
|
|
6
|
+
group: 'inline',
|
|
7
7
|
inline: !0,
|
|
8
8
|
selectable: !0,
|
|
9
9
|
atom: !0,
|
|
@@ -19,78 +19,86 @@ const u = s.create({
|
|
|
19
19
|
target: null,
|
|
20
20
|
title: null,
|
|
21
21
|
class: null,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
'data-id': null,
|
|
23
|
+
'data-app-prefix': null,
|
|
24
24
|
},
|
|
25
|
-
validate: void 0
|
|
25
|
+
validate: void 0,
|
|
26
26
|
};
|
|
27
27
|
},
|
|
28
28
|
addAttributes() {
|
|
29
29
|
return {
|
|
30
30
|
href: {
|
|
31
|
-
default: null
|
|
31
|
+
default: null,
|
|
32
32
|
},
|
|
33
33
|
class: {
|
|
34
|
-
default: this.options.HTMLAttributes.class
|
|
34
|
+
default: this.options.HTMLAttributes.class,
|
|
35
35
|
},
|
|
36
36
|
target: {
|
|
37
37
|
default: this.options.HTMLAttributes.target,
|
|
38
38
|
// Sanitize target value
|
|
39
|
-
parseHTML: (
|
|
39
|
+
parseHTML: (element) =>
|
|
40
|
+
element.getAttribute('target') !== '_blank' ? null : '_blank',
|
|
40
41
|
},
|
|
41
42
|
title: {
|
|
42
|
-
default: this.options.HTMLAttributes.title
|
|
43
|
+
default: this.options.HTMLAttributes.title,
|
|
43
44
|
},
|
|
44
|
-
|
|
45
|
-
default: this.options.HTMLAttributes[
|
|
45
|
+
'data-id': {
|
|
46
|
+
default: this.options.HTMLAttributes['data-id'],
|
|
47
|
+
},
|
|
48
|
+
'data-app-prefix': {
|
|
49
|
+
default: this.options.HTMLAttributes['data-app-prefix'],
|
|
46
50
|
},
|
|
47
|
-
"data-app-prefix": {
|
|
48
|
-
default: this.options.HTMLAttributes["data-app-prefix"]
|
|
49
|
-
}
|
|
50
51
|
};
|
|
51
52
|
},
|
|
52
53
|
parseHTML() {
|
|
53
54
|
return [
|
|
54
55
|
{
|
|
55
|
-
tag: 'a[href]:not([href *= "javascript:" i])[data-id][data-app-prefix]'
|
|
56
|
-
}
|
|
56
|
+
tag: 'a[href]:not([href *= "javascript:" i])[data-id][data-app-prefix]',
|
|
57
|
+
},
|
|
57
58
|
];
|
|
58
59
|
},
|
|
59
|
-
renderHTML({ HTMLAttributes
|
|
60
|
-
var
|
|
61
|
-
return (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
a(this.options.HTMLAttributes,
|
|
71
|
-
0
|
|
72
|
-
];
|
|
60
|
+
renderHTML({ HTMLAttributes }) {
|
|
61
|
+
var _a;
|
|
62
|
+
return (_a = HTMLAttributes.href) != null && _a.startsWith('javascript:')
|
|
63
|
+
? [
|
|
64
|
+
'a',
|
|
65
|
+
mergeAttributes(this.options.HTMLAttributes, {
|
|
66
|
+
...HTMLAttributes,
|
|
67
|
+
href: '',
|
|
68
|
+
}),
|
|
69
|
+
0,
|
|
70
|
+
]
|
|
71
|
+
: ['a', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
73
72
|
},
|
|
74
73
|
addCommands() {
|
|
75
74
|
return {
|
|
76
|
-
setLinker:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
setLinker:
|
|
76
|
+
(attrs) =>
|
|
77
|
+
({ commands }) => (
|
|
78
|
+
commands.insertContent({
|
|
79
|
+
type: this.name,
|
|
80
|
+
attrs,
|
|
81
|
+
content: [
|
|
82
|
+
{
|
|
83
|
+
type: 'text',
|
|
84
|
+
text: attrs.title,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
}),
|
|
88
|
+
!0
|
|
89
|
+
),
|
|
90
|
+
unsetLinker:
|
|
91
|
+
() =>
|
|
92
|
+
({ state, tr }) => {
|
|
93
|
+
const { node, from, to } = state.selection;
|
|
94
|
+
return (
|
|
95
|
+
(node == null ? void 0 : node.type.name) === 'linker' &&
|
|
96
|
+
tr.delete(from, to).scrollIntoView(),
|
|
97
|
+
!0
|
|
98
|
+
);
|
|
99
|
+
},
|
|
90
100
|
};
|
|
91
|
-
}
|
|
101
|
+
},
|
|
92
102
|
});
|
|
93
|
-
export {
|
|
94
|
-
u as Linker
|
|
95
|
-
};
|
|
103
|
+
export { Linker };
|
|
96
104
|
//# sourceMappingURL=linker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linker.js","sources":["../../src/linker/linker.ts"],"sourcesContent":["import { Node, mergeAttributes } from '@tiptap/core';\nimport { NodeSelection } from '@tiptap/pm/state';\n\n/* Our own model of a link in a rich document. */\nexport type LinkerAttributes = {\n href: string | null;\n target: '_blank' | null;\n title: string | null;\n 'data-id': string | null;\n 'data-app-prefix': string | null;\n};\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n linker: {\n /**\n * Set a linker node\n */\n setLinker: (attributes: LinkerAttributes) => ReturnType;\n /**\n * Unset a linker node\n */\n unsetLinker: () => ReturnType;\n };\n }\n}\n\n/**\n * Internal links extension.\n * Reproduces the legacy angularJs \"linker\" directive.\n *\n * Links to internal resources MAY have a `title` and MUST HAVE `data-id` and `data-app-prefix` attributes :\n * `<a href=\"/blog#/view/35fa4198-blog_id/5e654c71-article_id\" data-app-prefix=\"blog\" data-id=\"35fa4198-blog_id\" target=\"_blank\" title=\"Voir ce billet de blog\" class=\"ng-scope\">/blog#/view/35fa4198-57fe-45eb-94f4-a5e4defff305/5e654c71-1e61-4f84-86dc-6fcfaf33f513</a>`\n */\nexport const Linker = Node.create({\n name: 'linker',\n content: 'text*',\n marks: '',\n group: 'inline',\n\n inline: true,\n selectable: true,\n atom: true,\n draggable: true,\n isolating: true,\n allowGapCursor: false,\n\n priority: 1100,\n keepOnSplit: false,\n\n addOptions() {\n return {\n openOnClick: true,\n HTMLAttributes: {\n target: null,\n title: null,\n class: null,\n 'data-id': null,\n 'data-app-prefix': null,\n },\n validate: undefined,\n };\n },\n\n addAttributes() {\n return {\n href: {\n default: null,\n },\n class: {\n default: this.options.HTMLAttributes.class,\n },\n target: {\n default: this.options.HTMLAttributes.target,\n // Sanitize target value\n parseHTML: (element) =>\n element.getAttribute('target') !== '_blank' ? null : '_blank',\n },\n title: {\n default: this.options.HTMLAttributes.title,\n },\n 'data-id': {\n default: this.options.HTMLAttributes['data-id'],\n },\n 'data-app-prefix': {\n default: this.options.HTMLAttributes['data-app-prefix'],\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'a[href]:not([href *= \"javascript:\" i])[data-id][data-app-prefix]',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n if (HTMLAttributes.href?.startsWith('javascript:')) {\n return [\n 'a',\n mergeAttributes(this.options.HTMLAttributes, {\n ...HTMLAttributes,\n href: '',\n }),\n 0,\n ];\n }\n return [\n 'a',\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setLinker:\n (attrs) =>\n ({ commands }) => {\n // Insert a Linker node with inner text node\n commands.insertContent({\n type: this.name,\n attrs,\n content: [\n {\n type: 'text',\n text: attrs.title,\n },\n ],\n });\n return true;\n },\n\n unsetLinker:\n () =>\n ({ state, tr }) => {\n // Which Linker node is actually selected ?\n const { node, from, to } = state.selection as NodeSelection;\n // Delete any selected Linker node\n if (node?.type.name === 'linker') {\n /* The following does not work as one would expected.\n commands.deleteNode(this.name);\n commands.deleteCurrentNode();\n * Replaced by : */\n tr.delete(from, to).scrollIntoView();\n }\n return true;\n },\n };\n },\n});\n"],"names":[
|
|
1
|
+
{"version":3,"file":"linker.js","sources":["../../src/linker/linker.ts"],"sourcesContent":["import { Node, mergeAttributes } from '@tiptap/core';\nimport { NodeSelection } from '@tiptap/pm/state';\n\n/* Our own model of a link in a rich document. */\nexport type LinkerAttributes = {\n href: string | null;\n target: '_blank' | null;\n title: string | null;\n 'data-id': string | null;\n 'data-app-prefix': string | null;\n};\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n linker: {\n /**\n * Set a linker node\n */\n setLinker: (attributes: LinkerAttributes) => ReturnType;\n /**\n * Unset a linker node\n */\n unsetLinker: () => ReturnType;\n };\n }\n}\n\n/**\n * Internal links extension.\n * Reproduces the legacy angularJs \"linker\" directive.\n *\n * Links to internal resources MAY have a `title` and MUST HAVE `data-id` and `data-app-prefix` attributes :\n * `<a href=\"/blog#/view/35fa4198-blog_id/5e654c71-article_id\" data-app-prefix=\"blog\" data-id=\"35fa4198-blog_id\" target=\"_blank\" title=\"Voir ce billet de blog\" class=\"ng-scope\">/blog#/view/35fa4198-57fe-45eb-94f4-a5e4defff305/5e654c71-1e61-4f84-86dc-6fcfaf33f513</a>`\n */\nexport const Linker = Node.create({\n name: 'linker',\n content: 'text*',\n marks: '',\n group: 'inline',\n\n inline: true,\n selectable: true,\n atom: true,\n draggable: true,\n isolating: true,\n allowGapCursor: false,\n\n priority: 1100,\n keepOnSplit: false,\n\n addOptions() {\n return {\n openOnClick: true,\n HTMLAttributes: {\n target: null,\n title: null,\n class: null,\n 'data-id': null,\n 'data-app-prefix': null,\n },\n validate: undefined,\n };\n },\n\n addAttributes() {\n return {\n href: {\n default: null,\n },\n class: {\n default: this.options.HTMLAttributes.class,\n },\n target: {\n default: this.options.HTMLAttributes.target,\n // Sanitize target value\n parseHTML: (element) =>\n element.getAttribute('target') !== '_blank' ? null : '_blank',\n },\n title: {\n default: this.options.HTMLAttributes.title,\n },\n 'data-id': {\n default: this.options.HTMLAttributes['data-id'],\n },\n 'data-app-prefix': {\n default: this.options.HTMLAttributes['data-app-prefix'],\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'a[href]:not([href *= \"javascript:\" i])[data-id][data-app-prefix]',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n if (HTMLAttributes.href?.startsWith('javascript:')) {\n return [\n 'a',\n mergeAttributes(this.options.HTMLAttributes, {\n ...HTMLAttributes,\n href: '',\n }),\n 0,\n ];\n }\n return [\n 'a',\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setLinker:\n (attrs) =>\n ({ commands }) => {\n // Insert a Linker node with inner text node\n commands.insertContent({\n type: this.name,\n attrs,\n content: [\n {\n type: 'text',\n text: attrs.title,\n },\n ],\n });\n return true;\n },\n\n unsetLinker:\n () =>\n ({ state, tr }) => {\n // Which Linker node is actually selected ?\n const { node, from, to } = state.selection as NodeSelection;\n // Delete any selected Linker node\n if (node?.type.name === 'linker') {\n /* The following does not work as one would expected.\n commands.deleteNode(this.name);\n commands.deleteCurrentNode();\n * Replaced by : */\n tr.delete(from, to).scrollIntoView();\n }\n return true;\n },\n };\n },\n});\n"],"names":[],"mappings":";AAkCa,MAAA,SAAS,KAAK,OAAO;AAAA,EAChC,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,EAEP,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,WAAW;AAAA,EACX,WAAW;AAAA,EACX,gBAAgB;AAAA,EAEhB,UAAU;AAAA,EACV,aAAa;AAAA,EAEb,aAAa;AACJ,WAAA;AAAA,MACL,aAAa;AAAA,MACb,gBAAgB;AAAA,QACd,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,OAAO;AAAA,QACP,WAAW;AAAA,QACX,mBAAmB;AAAA,MACrB;AAAA,MACA,UAAU;AAAA,IAAA;AAAA,EAEd;AAAA,EAEA,gBAAgB;AACP,WAAA;AAAA,MACL,MAAM;AAAA,QACJ,SAAS;AAAA,MACX;AAAA,MACA,OAAO;AAAA,QACL,SAAS,KAAK,QAAQ,eAAe;AAAA,MACvC;AAAA,MACA,QAAQ;AAAA,QACN,SAAS,KAAK,QAAQ,eAAe;AAAA;AAAA,QAErC,WAAW,CAAC,YACV,QAAQ,aAAa,QAAQ,MAAM,WAAW,OAAO;AAAA,MACzD;AAAA,MACA,OAAO;AAAA,QACL,SAAS,KAAK,QAAQ,eAAe;AAAA,MACvC;AAAA,MACA,WAAW;AAAA,QACT,SAAS,KAAK,QAAQ,eAAe,SAAS;AAAA,MAChD;AAAA,MACA,mBAAmB;AAAA,QACjB,SAAS,KAAK,QAAQ,eAAe,iBAAiB;AAAA,MACxD;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,YAAY;AACH,WAAA;AAAA,MACL;AAAA,QACE,KAAK;AAAA,MACP;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,WAAW,EAAE,kBAAkB;;AAC7B,YAAI,oBAAe,SAAf,WAAqB,WAAW,iBAC3B;AAAA,MACL;AAAA,MACA,gBAAgB,KAAK,QAAQ,gBAAgB;AAAA,QAC3C,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACP;AAAA,MACD;AAAA,IAAA,IAGG;AAAA,MACL;AAAA,MACA,gBAAgB,KAAK,QAAQ,gBAAgB,cAAc;AAAA,MAC3D;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,WACE,CAAC,UACD,CAAC,EAAE,gBAED,SAAS,cAAc;AAAA,QACrB,MAAM,KAAK;AAAA,QACX;AAAA,QACA,SAAS;AAAA,UACP;AAAA,YACE,MAAM;AAAA,YACN,MAAM,MAAM;AAAA,UACd;AAAA,QACF;AAAA,MAAA,CACD,GACM;AAAA,MAGX,aACE,MACA,CAAC,EAAE,OAAO,SAAS;AAEjB,cAAM,EAAE,MAAM,MAAM,GAAA,IAAO,MAAM;AAE7B,gBAAA,6BAAM,KAAK,UAAS,YAKtB,GAAG,OAAO,MAAM,EAAE,EAAE,eAAe,GAE9B;AAAA,MACT;AAAA,IAAA;AAAA,EAEN;AACF,CAAC;"}
|