@edifice.io/tiptap-extensions 2.0.0-develop-rc.12 → 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.
Files changed (100) hide show
  1. package/README.md +1 -1
  2. package/dist/abbr/abbr.cjs +32 -1
  3. package/dist/abbr/abbr.cjs.map +1 -1
  4. package/dist/abbr/abbr.d.ts +12 -12
  5. package/dist/abbr/abbr.js +20 -16
  6. package/dist/abbr/abbr.js.map +1 -1
  7. package/dist/alert/alert.cjs +32 -1
  8. package/dist/alert/alert.cjs.map +1 -1
  9. package/dist/alert/alert.js +22 -24
  10. package/dist/alert/alert.js.map +1 -1
  11. package/dist/attachment/attachment.cjs +73 -1
  12. package/dist/attachment/attachment.cjs.map +1 -1
  13. package/dist/attachment/attachment.d.ts +6 -6
  14. package/dist/attachment/attachment.js +58 -47
  15. package/dist/attachment/attachment.js.map +1 -1
  16. package/dist/audio/audio.cjs +53 -3
  17. package/dist/audio/audio.cjs.map +1 -1
  18. package/dist/audio/audio.d.ts +17 -13
  19. package/dist/audio/audio.js +33 -30
  20. package/dist/audio/audio.js.map +1 -1
  21. package/dist/font-size/font-size.cjs +48 -1
  22. package/dist/font-size/font-size.cjs.map +1 -1
  23. package/dist/font-size/font-size.d.ts +13 -13
  24. package/dist/font-size/font-size.js +32 -20
  25. package/dist/font-size/font-size.js.map +1 -1
  26. package/dist/heading/heading.cjs +61 -1
  27. package/dist/heading/heading.cjs.map +1 -1
  28. package/dist/heading/heading.d.ts +10 -12
  29. package/dist/heading/heading.js +45 -31
  30. package/dist/heading/heading.js.map +1 -1
  31. package/dist/highlight/highlight.cjs +25 -1
  32. package/dist/highlight/highlight.cjs.map +1 -1
  33. package/dist/highlight/highlight.d.ts +4 -1
  34. package/dist/highlight/highlight.js +15 -17
  35. package/dist/highlight/highlight.js.map +1 -1
  36. package/dist/hyperlink/hyperlink.cjs +47 -1
  37. package/dist/hyperlink/hyperlink.cjs.map +1 -1
  38. package/dist/hyperlink/hyperlink.d.ts +27 -24
  39. package/dist/hyperlink/hyperlink.js +26 -24
  40. package/dist/hyperlink/hyperlink.js.map +1 -1
  41. package/dist/iframe/iframe.cjs +69 -1
  42. package/dist/iframe/iframe.cjs.map +1 -1
  43. package/dist/iframe/iframe.d.ts +12 -14
  44. package/dist/iframe/iframe.js +50 -34
  45. package/dist/iframe/iframe.js.map +1 -1
  46. package/dist/image/custom-image.cjs +162 -1
  47. package/dist/image/custom-image.cjs.map +1 -1
  48. package/dist/image/custom-image.d.ts +19 -16
  49. package/dist/image/custom-image.js +179 -130
  50. package/dist/image/custom-image.js.map +1 -1
  51. package/dist/index.cjs +43 -1
  52. package/dist/index.js +41 -41
  53. package/dist/line-height/line-height.cjs +33 -1
  54. package/dist/line-height/line-height.cjs.map +1 -1
  55. package/dist/line-height/line-height.js +21 -18
  56. package/dist/line-height/line-height.js.map +1 -1
  57. package/dist/linker/linker.cjs +95 -1
  58. package/dist/linker/linker.cjs.map +1 -1
  59. package/dist/linker/linker.d.ts +17 -17
  60. package/dist/linker/linker.js +60 -52
  61. package/dist/linker/linker.js.map +1 -1
  62. package/dist/mathjax/mathjax.cjs +47 -1
  63. package/dist/mathjax/mathjax.cjs.map +1 -1
  64. package/dist/mathjax/mathjax.js +33 -23
  65. package/dist/mathjax/mathjax.js.map +1 -1
  66. package/dist/paragraph/paragraph.cjs +13 -1
  67. package/dist/paragraph/paragraph.cjs.map +1 -1
  68. package/dist/paragraph/paragraph.d.ts +4 -1
  69. package/dist/paragraph/paragraph.js +8 -10
  70. package/dist/paragraph/paragraph.js.map +1 -1
  71. package/dist/speech-recognition/speech-recognition.cjs +76 -1
  72. package/dist/speech-recognition/speech-recognition.cjs.map +1 -1
  73. package/dist/speech-recognition/speech-recognition.d.ts +12 -12
  74. package/dist/speech-recognition/speech-recognition.js +61 -45
  75. package/dist/speech-recognition/speech-recognition.js.map +1 -1
  76. package/dist/speech-synthesis/speech-synthesis.cjs +32 -1
  77. package/dist/speech-synthesis/speech-synthesis.cjs.map +1 -1
  78. package/dist/speech-synthesis/speech-synthesis.d.ts +9 -9
  79. package/dist/speech-synthesis/speech-synthesis.js +23 -14
  80. package/dist/speech-synthesis/speech-synthesis.js.map +1 -1
  81. package/dist/table-cell/table-cell.cjs +27 -1
  82. package/dist/table-cell/table-cell.cjs.map +1 -1
  83. package/dist/table-cell/table-cell.d.ts +4 -1
  84. package/dist/table-cell/table-cell.js +21 -16
  85. package/dist/table-cell/table-cell.js.map +1 -1
  86. package/dist/transform/html-to-json/html-to-json.cjs +4 -1
  87. package/dist/transform/html-to-json/html-to-json.cjs.map +1 -1
  88. package/dist/transform/html-to-json/html-to-json.d.ts +4 -1
  89. package/dist/transform/html-to-json/html-to-json.js +3 -5
  90. package/dist/transform/html-to-json/html-to-json.js.map +1 -1
  91. package/dist/transform/json-to-html/json-to-html.cjs +4 -1
  92. package/dist/transform/json-to-html/json-to-html.cjs.map +1 -1
  93. package/dist/transform/json-to-html/json-to-html.js +3 -5
  94. package/dist/transform/json-to-html/json-to-html.js.map +1 -1
  95. package/dist/video/video.cjs +118 -9
  96. package/dist/video/video.cjs.map +1 -1
  97. package/dist/video/video.d.ts +28 -19
  98. package/dist/video/video.js +121 -97
  99. package/dist/video/video.js.map +1 -1
  100. package/package.json +36 -47
package/dist/index.cjs CHANGED
@@ -1,2 +1,44 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./abbr/abbr.cjs"),r=require("./alert/alert.cjs"),i=require("./attachment/attachment.cjs"),o=require("./audio/audio.cjs"),n=require("./font-size/font-size.cjs"),s=require("./heading/heading.cjs"),a=require("./highlight/highlight.cjs"),c=require("./hyperlink/hyperlink.cjs"),u=require("./iframe/iframe.cjs"),e=require("./image/custom-image.cjs"),h=require("./line-height/line-height.cjs"),l=require("./linker/linker.cjs"),g=require("./mathjax/mathjax.cjs"),m=require("./paragraph/paragraph.cjs"),q=require("./speech-recognition/speech-recognition.cjs"),p=require("./speech-synthesis/speech-synthesis.cjs"),S=require("./table-cell/table-cell.cjs"),b=require("./transform/html-to-json/html-to-json.cjs"),d=require("./transform/json-to-html/json-to-html.cjs"),H=require("./video/video.cjs");exports.Abbr=t.Abbr;exports.Alert=r.Alert;exports.Attachment=i.Attachment;exports.Audio=o.Audio;exports.FontSize=n.FontSize;exports.CustomHeading=s.CustomHeading;exports.CustomHighlight=a.CustomHighlight;exports.Hyperlink=c.Hyperlink;exports.Iframe=u.Iframe;exports.CustomImage=e.CustomImage;exports.IMAGE_INPUT_REGEX=e.IMAGE_INPUT_REGEX;exports.LineHeight=h.LineHeight;exports.Linker=l.Linker;exports.MathJax=g.MathJax;exports.Paragraph=m.Paragraph;exports.SpeechRecognition=q.SpeechRecognition;exports.SpeechSynthesis=p.SpeechSynthesis;exports.TableCell=S.TableCell;exports.htmlToJson=b;exports.jsonToHtml=d;exports.Video=H.Video;
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 as e } from "./abbr/abbr.js";
2
- import { Alert as m } from "./alert/alert.js";
3
- import { Attachment as f } from "./attachment/attachment.js";
4
- import { Audio as a } from "./audio/audio.js";
5
- import { FontSize as n } from "./font-size/font-size.js";
6
- import { CustomHeading as l } from "./heading/heading.js";
7
- import { CustomHighlight as g } from "./highlight/highlight.js";
8
- import { Hyperlink as d } from "./hyperlink/hyperlink.js";
9
- import { Iframe as H } from "./iframe/iframe.js";
10
- import { CustomImage as C, IMAGE_INPUT_REGEX as I } from "./image/custom-image.js";
11
- import { LineHeight as T } from "./line-height/line-height.js";
12
- import { Linker as E } from "./linker/linker.js";
13
- import { MathJax as y } from "./mathjax/mathjax.js";
14
- import { Paragraph as J } from "./paragraph/paragraph.js";
15
- import { SpeechRecognition as M } from "./speech-recognition/speech-recognition.js";
16
- import { SpeechSynthesis as R } from "./speech-synthesis/speech-synthesis.js";
17
- import { TableCell as j } from "./table-cell/table-cell.js";
18
- import { default as F } from "./transform/html-to-json/html-to-json.js";
19
- import { default as U } from "./transform/json-to-html/json-to-html.js";
20
- import { Video as X } from "./video/video.js";
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
- e as Abbr,
23
- m as Alert,
24
- f as Attachment,
25
- a as Audio,
26
- l as CustomHeading,
27
- g as CustomHighlight,
28
- C as CustomImage,
29
- n as FontSize,
30
- d as Hyperlink,
31
- I as IMAGE_INPUT_REGEX,
32
- H as Iframe,
33
- T as LineHeight,
34
- E as Linker,
35
- y as MathJax,
36
- J as Paragraph,
37
- M as SpeechRecognition,
38
- R as SpeechSynthesis,
39
- j as TableCell,
40
- X as Video,
41
- F as htmlToJson,
42
- U as jsonToHtml
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
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@tiptap/extension-text-style");const i=require("@tiptap/core"),n=i.Extension.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>{var t;return(t=e.style.lineHeight)==null?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.lineHeight?{style:`line-height: ${e.lineHeight}`}:{}}}}]}});exports.LineHeight=n;
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":["LineHeight","Extension","element","_a","attributes"],"mappings":"wJAIaA,EAAaC,YAAU,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,UAAYC,GACV,OAAA,OAAAC,EAAAD,EAAQ,MAAM,aAAd,YAAAC,EAA0B,QAAQ,SAAU,KAC9C,WAAaC,GACNA,EAAW,WAIT,CACL,MAAO,gBAAgBA,EAAW,UAAU,EAAA,EAJrC,EAOb,CACF,CACF,CAAA,CAEJ,CACF,CAAC"}
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 "@tiptap/extension-text-style";
2
- import { Extension as i } from "@tiptap/core";
3
- const l = i.create({
4
- name: "lineHeight",
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: ["textStyle"]
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: (e) => {
18
- var t;
19
- return (t = e.style.lineHeight) == null ? void 0 : t.replace(/['"]+/g, "");
17
+ parseHTML: (element) => {
18
+ var _a;
19
+ return (_a = element.style.lineHeight) == null
20
+ ? void 0
21
+ : _a.replace(/['"]+/g, '');
20
22
  },
21
- renderHTML: (e) => e.lineHeight ? {
22
- style: `line-height: ${e.lineHeight}`
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":["LineHeight","Extension","element","_a","attributes"],"mappings":";;AAIa,MAAAA,IAAaC,EAAU,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,CAACC,MACV;;AAAA,sBAAAC,IAAAD,EAAQ,MAAM,eAAd,gBAAAC,EAA0B,QAAQ,UAAU;AAAA;AAAA,YAC9C,YAAY,CAACC,MACNA,EAAW,aAIT;AAAA,cACL,OAAO,gBAAgBA,EAAW,UAAU;AAAA,YAAA,IAJrC;UAOb;AAAA,QACF;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;"}
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;"}
@@ -1,2 +1,96 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@tiptap/core"),s=i.Node.create({name:"linker",content:"text*",marks:"",group:"inline",inline:!0,selectable:!0,atom:!0,draggable:!0,isolating:!0,allowGapCursor:!1,priority:1100,keepOnSplit:!1,addOptions(){return{openOnClick:!0,HTMLAttributes:{target:null,title:null,class:null,"data-id":null,"data-app-prefix":null},validate:void 0}},addAttributes(){return{href:{default:null},class:{default:this.options.HTMLAttributes.class},target:{default:this.options.HTMLAttributes.target,parseHTML:t=>t.getAttribute("target")!=="_blank"?null:"_blank"},title:{default:this.options.HTMLAttributes.title},"data-id":{default:this.options.HTMLAttributes["data-id"]},"data-app-prefix":{default:this.options.HTMLAttributes["data-app-prefix"]}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])[data-id][data-app-prefix]'}]},renderHTML({HTMLAttributes:t}){var e;return(e=t.href)!=null&&e.startsWith("javascript:")?["a",i.mergeAttributes(this.options.HTMLAttributes,{...t,href:""}),0]:["a",i.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setLinker:t=>({commands:e})=>(e.insertContent({type:this.name,attrs:t,content:[{type:"text",text:t.title}]}),!0),unsetLinker:()=>({state:t,tr:e})=>{const{node:r,from:a,to:n}=t.selection;return(r==null?void 0:r.type.name)==="linker"&&e.delete(a,n).scrollIntoView(),!0}}}});exports.Linker=s;
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":["Linker","Node","element","HTMLAttributes","_a","mergeAttributes","attrs","commands","state","tr","node","from","to"],"mappings":"gHAkCaA,EAASC,OAAK,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,UAAYC,GACVA,EAAQ,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,eAAAC,GAAkB,OAC7B,OAAIC,EAAAD,EAAe,OAAf,MAAAC,EAAqB,WAAW,eAC3B,CACL,IACAC,kBAAgB,KAAK,QAAQ,eAAgB,CAC3C,GAAGF,EACH,KAAM,EAAA,CACP,EACD,CAAA,EAGG,CACL,IACAE,EAAAA,gBAAgB,KAAK,QAAQ,eAAgBF,CAAc,EAC3D,CAAA,CAEJ,EAEA,aAAc,CACL,MAAA,CACL,UACGG,GACD,CAAC,CAAE,SAAAC,MAEDA,EAAS,cAAc,CACrB,KAAM,KAAK,KACX,MAAAD,EACA,QAAS,CACP,CACE,KAAM,OACN,KAAMA,EAAM,KACd,CACF,CAAA,CACD,EACM,IAGX,YACE,IACA,CAAC,CAAE,MAAAE,EAAO,GAAAC,KAAS,CAEjB,KAAM,CAAE,KAAAC,EAAM,KAAAC,EAAM,GAAAC,CAAA,EAAOJ,EAAM,UAE7B,OAAAE,GAAA,YAAAA,EAAM,KAAK,QAAS,UAKtBD,EAAG,OAAOE,EAAMC,CAAE,EAAE,eAAe,EAE9B,EACT,CAAA,CAEN,CACF,CAAC"}
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"}
@@ -1,24 +1,24 @@
1
1
  import { Node } from '@tiptap/core';
2
2
  export type LinkerAttributes = {
3
- href: string | null;
4
- target: '_blank' | null;
5
- title: string | null;
6
- 'data-id': string | null;
7
- 'data-app-prefix': string | null;
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
- 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
- }
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.
@@ -1,9 +1,9 @@
1
- import { Node as s, mergeAttributes as a } from "@tiptap/core";
2
- const u = s.create({
3
- name: "linker",
4
- content: "text*",
5
- marks: "",
6
- group: "inline",
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
- "data-id": null,
23
- "data-app-prefix": null
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: (t) => t.getAttribute("target") !== "_blank" ? null : "_blank"
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
- "data-id": {
45
- default: this.options.HTMLAttributes["data-id"]
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: t }) {
60
- var e;
61
- return (e = t.href) != null && e.startsWith("javascript:") ? [
62
- "a",
63
- a(this.options.HTMLAttributes, {
64
- ...t,
65
- href: ""
66
- }),
67
- 0
68
- ] : [
69
- "a",
70
- a(this.options.HTMLAttributes, t),
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: (t) => ({ commands: e }) => (e.insertContent({
77
- type: this.name,
78
- attrs: t,
79
- content: [
80
- {
81
- type: "text",
82
- text: t.title
83
- }
84
- ]
85
- }), !0),
86
- unsetLinker: () => ({ state: t, tr: e }) => {
87
- const { node: r, from: i, to: n } = t.selection;
88
- return (r == null ? void 0 : r.type.name) === "linker" && e.delete(i, n).scrollIntoView(), !0;
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":["Linker","Node","element","HTMLAttributes","_a","mergeAttributes","attrs","commands","state","tr","node","from","to"],"mappings":";AAkCa,MAAAA,IAASC,EAAK,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,CAACC,MACVA,EAAQ,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,gBAAAC,KAAkB;;AAC7B,YAAIC,IAAAD,EAAe,SAAf,QAAAC,EAAqB,WAAW,iBAC3B;AAAA,MACL;AAAA,MACAC,EAAgB,KAAK,QAAQ,gBAAgB;AAAA,QAC3C,GAAGF;AAAA,QACH,MAAM;AAAA,MAAA,CACP;AAAA,MACD;AAAA,IAAA,IAGG;AAAA,MACL;AAAA,MACAE,EAAgB,KAAK,QAAQ,gBAAgBF,CAAc;AAAA,MAC3D;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,WACE,CAACG,MACD,CAAC,EAAE,UAAAC,SAEDA,EAAS,cAAc;AAAA,QACrB,MAAM,KAAK;AAAA,QACX,OAAAD;AAAA,QACA,SAAS;AAAA,UACP;AAAA,YACE,MAAM;AAAA,YACN,MAAMA,EAAM;AAAA,UACd;AAAA,QACF;AAAA,MAAA,CACD,GACM;AAAA,MAGX,aACE,MACA,CAAC,EAAE,OAAAE,GAAO,IAAAC,QAAS;AAEjB,cAAM,EAAE,MAAAC,GAAM,MAAAC,GAAM,IAAAC,EAAA,IAAOJ,EAAM;AAE7B,gBAAAE,KAAA,gBAAAA,EAAM,KAAK,UAAS,YAKtBD,EAAG,OAAOE,GAAMC,CAAE,EAAE,eAAe,GAE9B;AAAA,MACT;AAAA,IAAA;AAAA,EAEN;AACF,CAAC;"}
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;"}