@edifice.io/tiptap-extensions 1.5.16-develop-rc.2

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 (171) hide show
  1. package/.turbo/turbo-build.log +58 -0
  2. package/.turbo/turbo-format.log +142 -0
  3. package/.turbo/turbo-lint.log +5 -0
  4. package/LICENSE +661 -0
  5. package/dist/abbr/abbr.cjs +33 -0
  6. package/dist/abbr/abbr.cjs.map +1 -0
  7. package/dist/abbr/abbr.d.ts +16 -0
  8. package/dist/abbr/abbr.js +37 -0
  9. package/dist/abbr/abbr.js.map +1 -0
  10. package/dist/abbr/index.d.ts +3 -0
  11. package/dist/alert/alert.cjs +33 -0
  12. package/dist/alert/alert.cjs.map +1 -0
  13. package/dist/alert/alert.d.ts +2 -0
  14. package/dist/alert/alert.js +43 -0
  15. package/dist/alert/alert.js.map +1 -0
  16. package/dist/alert/index.d.ts +3 -0
  17. package/dist/attachment/attachment.cjs +74 -0
  18. package/dist/attachment/attachment.cjs.map +1 -0
  19. package/dist/attachment/attachment.d.ts +12 -0
  20. package/dist/attachment/attachment.js +86 -0
  21. package/dist/attachment/attachment.js.map +1 -0
  22. package/dist/attachment/index.d.ts +3 -0
  23. package/dist/audio/audio.cjs +55 -0
  24. package/dist/audio/audio.cjs.map +1 -0
  25. package/dist/audio/audio.d.ts +23 -0
  26. package/dist/audio/audio.js +55 -0
  27. package/dist/audio/audio.js.map +1 -0
  28. package/dist/audio/index.d.ts +3 -0
  29. package/dist/font-size/font-size.cjs +49 -0
  30. package/dist/font-size/font-size.cjs.map +1 -0
  31. package/dist/font-size/font-size.d.ts +19 -0
  32. package/dist/font-size/font-size.js +51 -0
  33. package/dist/font-size/font-size.js.map +1 -0
  34. package/dist/font-size/index.d.ts +3 -0
  35. package/dist/heading/heading.cjs +62 -0
  36. package/dist/heading/heading.cjs.map +1 -0
  37. package/dist/heading/heading.d.ts +17 -0
  38. package/dist/heading/heading.js +60 -0
  39. package/dist/heading/heading.js.map +1 -0
  40. package/dist/heading/index.d.ts +3 -0
  41. package/dist/highlight/highlight.cjs +26 -0
  42. package/dist/highlight/highlight.cjs.map +1 -0
  43. package/dist/highlight/highlight.d.ts +4 -0
  44. package/dist/highlight/highlight.js +26 -0
  45. package/dist/highlight/highlight.js.map +1 -0
  46. package/dist/highlight/index.d.ts +3 -0
  47. package/dist/hyperlink/hyperlink.cjs +48 -0
  48. package/dist/hyperlink/hyperlink.cjs.map +1 -0
  49. package/dist/hyperlink/hyperlink.d.ts +38 -0
  50. package/dist/hyperlink/hyperlink.js +55 -0
  51. package/dist/hyperlink/hyperlink.js.map +1 -0
  52. package/dist/hyperlink/index.d.ts +3 -0
  53. package/dist/iframe/iframe.cjs +70 -0
  54. package/dist/iframe/iframe.cjs.map +1 -0
  55. package/dist/iframe/iframe.d.ts +18 -0
  56. package/dist/iframe/iframe.js +85 -0
  57. package/dist/iframe/iframe.js.map +1 -0
  58. package/dist/iframe/index.d.ts +3 -0
  59. package/dist/image/custom-image.cjs +163 -0
  60. package/dist/image/custom-image.cjs.map +1 -0
  61. package/dist/image/custom-image.d.ts +27 -0
  62. package/dist/image/custom-image.js +181 -0
  63. package/dist/image/custom-image.js.map +1 -0
  64. package/dist/image/index.d.ts +3 -0
  65. package/dist/index.cjs +44 -0
  66. package/dist/index.cjs.map +1 -0
  67. package/dist/index.d.ts +19 -0
  68. package/dist/index.js +44 -0
  69. package/dist/index.js.map +1 -0
  70. package/dist/line-height/index.d.ts +3 -0
  71. package/dist/line-height/line-height.cjs +34 -0
  72. package/dist/line-height/line-height.cjs.map +1 -0
  73. package/dist/line-height/line-height.d.ts +2 -0
  74. package/dist/line-height/line-height.js +36 -0
  75. package/dist/line-height/line-height.js.map +1 -0
  76. package/dist/linker/index.d.ts +3 -0
  77. package/dist/linker/linker.cjs +96 -0
  78. package/dist/linker/linker.cjs.map +1 -0
  79. package/dist/linker/linker.d.ts +30 -0
  80. package/dist/linker/linker.js +104 -0
  81. package/dist/linker/linker.js.map +1 -0
  82. package/dist/mathjax/index.d.ts +3 -0
  83. package/dist/mathjax/mathjax.cjs +48 -0
  84. package/dist/mathjax/mathjax.cjs.map +1 -0
  85. package/dist/mathjax/mathjax.d.ts +2 -0
  86. package/dist/mathjax/mathjax.js +50 -0
  87. package/dist/mathjax/mathjax.js.map +1 -0
  88. package/dist/paragraph/index.d.ts +3 -0
  89. package/dist/paragraph/paragraph.cjs +14 -0
  90. package/dist/paragraph/paragraph.cjs.map +1 -0
  91. package/dist/paragraph/paragraph.d.ts +16 -0
  92. package/dist/paragraph/paragraph.js +14 -0
  93. package/dist/paragraph/paragraph.js.map +1 -0
  94. package/dist/speech-recognition/index.d.ts +3 -0
  95. package/dist/speech-recognition/speech-recognition.cjs +77 -0
  96. package/dist/speech-recognition/speech-recognition.cjs.map +1 -0
  97. package/dist/speech-recognition/speech-recognition.d.ts +21 -0
  98. package/dist/speech-recognition/speech-recognition.js +77 -0
  99. package/dist/speech-recognition/speech-recognition.js.map +1 -0
  100. package/dist/speech-synthesis/index.d.ts +3 -0
  101. package/dist/speech-synthesis/speech-synthesis.cjs +33 -0
  102. package/dist/speech-synthesis/speech-synthesis.cjs.map +1 -0
  103. package/dist/speech-synthesis/speech-synthesis.d.ts +18 -0
  104. package/dist/speech-synthesis/speech-synthesis.js +34 -0
  105. package/dist/speech-synthesis/speech-synthesis.js.map +1 -0
  106. package/dist/table-cell/index.d.ts +3 -0
  107. package/dist/table-cell/table-cell.cjs +28 -0
  108. package/dist/table-cell/table-cell.cjs.map +1 -0
  109. package/dist/table-cell/table-cell.d.ts +8 -0
  110. package/dist/table-cell/table-cell.js +28 -0
  111. package/dist/table-cell/table-cell.js.map +1 -0
  112. package/dist/transform/html-to-json/html-to-json.cjs +5 -0
  113. package/dist/transform/html-to-json/html-to-json.cjs.map +1 -0
  114. package/dist/transform/html-to-json/html-to-json.d.ts +6 -0
  115. package/dist/transform/html-to-json/html-to-json.js +4 -0
  116. package/dist/transform/html-to-json/html-to-json.js.map +1 -0
  117. package/dist/transform/index.d.ts +3 -0
  118. package/dist/transform/json-to-html/json-to-html.cjs +5 -0
  119. package/dist/transform/json-to-html/json-to-html.cjs.map +1 -0
  120. package/dist/transform/json-to-html/json-to-html.d.ts +3 -0
  121. package/dist/transform/json-to-html/json-to-html.js +4 -0
  122. package/dist/transform/json-to-html/json-to-html.js.map +1 -0
  123. package/dist/video/index.d.ts +3 -0
  124. package/dist/video/video.cjs +119 -0
  125. package/dist/video/video.cjs.map +1 -0
  126. package/dist/video/video.d.ts +34 -0
  127. package/dist/video/video.js +123 -0
  128. package/dist/video/video.js.map +1 -0
  129. package/package.json +133 -0
  130. package/src/abbr/abbr.ts +57 -0
  131. package/src/abbr/index.ts +5 -0
  132. package/src/alert/alert.ts +46 -0
  133. package/src/alert/index.ts +5 -0
  134. package/src/attachment/attachment.ts +113 -0
  135. package/src/attachment/index.ts +5 -0
  136. package/src/audio/audio.ts +81 -0
  137. package/src/audio/index.ts +5 -0
  138. package/src/font-size/font-size.ts +74 -0
  139. package/src/font-size/index.ts +5 -0
  140. package/src/heading/heading.ts +90 -0
  141. package/src/heading/index.ts +5 -0
  142. package/src/highlight/highlight.ts +27 -0
  143. package/src/highlight/index.ts +5 -0
  144. package/src/hyperlink/hyperlink.ts +92 -0
  145. package/src/hyperlink/index.ts +5 -0
  146. package/src/iframe/iframe.ts +112 -0
  147. package/src/iframe/index.ts +5 -0
  148. package/src/image/custom-image.ts +226 -0
  149. package/src/image/index.ts +5 -0
  150. package/src/index.ts +19 -0
  151. package/src/line-height/index.ts +5 -0
  152. package/src/line-height/line-height.ts +37 -0
  153. package/src/linker/index.ts +5 -0
  154. package/src/linker/linker.ts +153 -0
  155. package/src/mathjax/index.ts +5 -0
  156. package/src/mathjax/mathjax.ts +55 -0
  157. package/src/paragraph/index.ts +5 -0
  158. package/src/paragraph/paragraph.ts +25 -0
  159. package/src/speech-recognition/index.ts +5 -0
  160. package/src/speech-recognition/speech-recognition.ts +123 -0
  161. package/src/speech-synthesis/index.ts +5 -0
  162. package/src/speech-synthesis/speech-synthesis.ts +52 -0
  163. package/src/table-cell/index.ts +5 -0
  164. package/src/table-cell/table-cell.ts +28 -0
  165. package/src/transform/html-to-json/html-to-json.ts +5 -0
  166. package/src/transform/index.ts +4 -0
  167. package/src/transform/json-to-html/json-to-html.ts +5 -0
  168. package/src/video/index.ts +5 -0
  169. package/src/video/video.ts +173 -0
  170. package/tsconfig.json +20 -0
  171. package/vite.config.ts +46 -0
@@ -0,0 +1,51 @@
1
+ import '@tiptap/extension-text-style';
2
+ import { Extension } from '@tiptap/core';
3
+ const FontSize = Extension.create({
4
+ name: 'fontSize',
5
+ addOptions() {
6
+ return {
7
+ types: ['textStyle'],
8
+ };
9
+ },
10
+ addGlobalAttributes() {
11
+ return [
12
+ {
13
+ types: this.options.types,
14
+ attributes: {
15
+ fontSize: {
16
+ default: null,
17
+ parseHTML: (element) => {
18
+ var _a;
19
+ return (_a = element.style.fontSize) == null
20
+ ? void 0
21
+ : _a.replace(/['"]+/g, '');
22
+ },
23
+ renderHTML: (attributes) =>
24
+ attributes.fontSize
25
+ ? {
26
+ style: `font-size: ${attributes.fontSize}`,
27
+ }
28
+ : {},
29
+ },
30
+ },
31
+ },
32
+ ];
33
+ },
34
+ addCommands() {
35
+ return {
36
+ setFontSize:
37
+ (fontSize) =>
38
+ ({ chain }) =>
39
+ chain().setMark('textStyle', { fontSize }).run(),
40
+ unsetFontSize:
41
+ () =>
42
+ ({ chain }) =>
43
+ chain()
44
+ .setMark('textStyle', { fontSize: null })
45
+ .removeEmptyTextStyle()
46
+ .run(),
47
+ };
48
+ },
49
+ });
50
+ export { FontSize };
51
+ //# sourceMappingURL=font-size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"font-size.js","sources":["../../src/font-size/font-size.ts"],"sourcesContent":["import '@tiptap/extension-text-style';\n\nimport { Extension } from '@tiptap/core';\n\nexport type FontSizeOptions = {\n types: string[];\n};\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n fontSize: {\n /**\n * Set the font size\n */\n setFontSize: (fontSize: string) => ReturnType;\n /**\n * Unset the font size\n */\n unsetFontSize: () => ReturnType;\n };\n }\n}\n\nexport const FontSize = Extension.create<FontSizeOptions>({\n name: 'fontSize',\n\n addOptions() {\n return {\n types: ['textStyle'],\n };\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n fontSize: {\n default: null,\n parseHTML: (element) =>\n element.style.fontSize?.replace(/['\"]+/g, ''),\n renderHTML: (attributes) => {\n if (!attributes.fontSize) {\n return {};\n }\n\n return {\n style: `font-size: ${attributes.fontSize}`,\n };\n },\n },\n },\n },\n ];\n },\n\n addCommands() {\n return {\n setFontSize:\n (fontSize) =>\n ({ chain }) => {\n return chain().setMark('textStyle', { fontSize }).run();\n },\n unsetFontSize:\n () =>\n ({ chain }) => {\n return chain()\n .setMark('textStyle', { fontSize: null })\n .removeEmptyTextStyle()\n .run();\n },\n };\n },\n});\n"],"names":[],"mappings":";;AAuBa,MAAA,WAAW,UAAU,OAAwB;AAAA,EACxD,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,UAAU;AAAA,YACR,SAAS;AAAA,YACT,WAAW,CAAC,YACV;;AAAA,mCAAQ,MAAM,aAAd,mBAAwB,QAAQ,UAAU;AAAA;AAAA,YAC5C,YAAY,CAAC,eACN,WAAW,WAIT;AAAA,cACL,OAAO,cAAc,WAAW,QAAQ;AAAA,YAAA,IAJjC;UAOb;AAAA,QACF;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,aACE,CAAC,aACD,CAAC,EAAE,YACM,QAAQ,QAAQ,aAAa,EAAE,SAAU,CAAA,EAAE;MAEtD,eACE,MACA,CAAC,EAAE,YACM,MACJ,EAAA,QAAQ,aAAa,EAAE,UAAU,KAAA,CAAM,EACvC,uBACA;IACL;AAAA,EAEN;AACF,CAAC;"}
@@ -0,0 +1,3 @@
1
+ import { FontSize } from './font-size';
2
+ export * from './font-size';
3
+ export default FontSize;
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
+ const core = require('@tiptap/core'),
4
+ extensionHeading = require('@tiptap/extension-heading');
5
+ require('@tiptap/extension-text-style');
6
+ const CustomHeading = extensionHeading.Heading.extend({
7
+ name: 'customHeading',
8
+ addOptions() {
9
+ var _a;
10
+ return {
11
+ ...((_a = this.parent) == null ? void 0 : _a.call(this)),
12
+ HTMLAttributes: {},
13
+ };
14
+ },
15
+ parseHTML() {
16
+ return this.options.levels.map((level) => ({
17
+ tag: `h${level}`,
18
+ attrs: { level },
19
+ }));
20
+ },
21
+ renderHTML({ node, HTMLAttributes }) {
22
+ return [
23
+ `h${
24
+ this.options.levels.includes(node.attrs.level)
25
+ ? node.attrs.level
26
+ : this.options.levels[0]
27
+ }`,
28
+ core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
29
+ 0,
30
+ ];
31
+ },
32
+ addCommands() {
33
+ return {
34
+ setCustomHeading:
35
+ (attributes) =>
36
+ ({ tr, dispatch, commands }) => {
37
+ if (!this.options.levels.includes(attributes.level)) return !1;
38
+ const { selection } = tr,
39
+ { from, to } = selection;
40
+ return (
41
+ tr.doc.nodesBetween(from, to, (node, pos) => {
42
+ node.isBlock &&
43
+ from >= pos &&
44
+ to <= pos + node.nodeSize &&
45
+ node.content.forEach((content) => {
46
+ content.marks.forEach((mark) => {
47
+ mark.type.name === 'textStyle' &&
48
+ mark.attrs.fontSize &&
49
+ mark.attrs.fontSize !== null &&
50
+ (tr = tr.removeMark(pos, pos + node.nodeSize, mark.type));
51
+ });
52
+ });
53
+ }),
54
+ dispatch && dispatch(tr),
55
+ commands.setHeading({ level: attributes.level })
56
+ );
57
+ },
58
+ };
59
+ },
60
+ });
61
+ exports.CustomHeading = CustomHeading;
62
+ //# sourceMappingURL=heading.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading.cjs","sources":["../../src/heading/heading.ts"],"sourcesContent":["import { mergeAttributes } from '@tiptap/core';\nimport { Heading } from '@tiptap/extension-heading';\nimport '@tiptap/extension-text-style';\n\nexport declare type Level = 1 | 2;\n\ninterface Options {\n levels: Level[];\n HTMLAttributes: Record<string, any>;\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n customHeading: {\n /**\n * Apply Heading Level\n */\n setCustomHeading: (attributes: { level: Level }) => ReturnType;\n };\n }\n}\n\nexport const CustomHeading = Heading.extend<Options>({\n name: 'customHeading',\n\n addOptions() {\n return {\n ...this.parent?.(),\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return this.options.levels.map((level: Level) => ({\n tag: `h${level}`,\n attrs: { level },\n }));\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const hasLevel = this.options.levels.includes(node.attrs.level);\n const level = hasLevel ? node.attrs.level : this.options.levels[0];\n\n return [\n `h${level}`,\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setCustomHeading:\n (attributes) =>\n ({ tr, dispatch, commands }) => {\n if (!this.options.levels.includes(attributes.level)) {\n return false;\n }\n\n const { selection } = tr;\n const { from, to } = selection;\n\n tr.doc.nodesBetween(from, to, (node, pos) => {\n if (node.isBlock && from >= pos && to <= pos + node.nodeSize) {\n /* get node content and iterate through */\n node.content.forEach((content) => {\n /* get content marks and iterate through */\n content.marks.forEach((mark) => {\n /* find textStyle mark and if has fontSize attrs */\n if (\n mark.type.name === 'textStyle' &&\n mark.attrs['fontSize'] &&\n mark.attrs['fontSize'] !== null\n ) {\n /* remove any fontSize attr to reset heading style */\n tr = tr.removeMark(pos, pos + node.nodeSize, mark.type);\n }\n });\n });\n }\n });\n\n if (dispatch) {\n dispatch(tr);\n }\n return commands.setHeading({ level: attributes.level });\n },\n };\n },\n});\n"],"names":["Heading","mergeAttributes"],"mappings":"iNAsBa,MAAA,cAAgBA,yBAAQ,OAAgB,CACnD,KAAM,gBAEN,YAAa,QACJ,MAAA,CACL,IAAG,QAAK,SAAL,0BACH,eAAgB,CAAC,CAAA,CAErB,EAEA,WAAY,CACV,OAAO,KAAK,QAAQ,OAAO,IAAK,QAAkB,CAChD,IAAK,IAAI,KAAK,GACd,MAAO,CAAE,KAAM,CACf,EAAA,CACJ,EAEA,WAAW,CAAE,KAAM,gBAAkB,CAI5B,MAAA,CACL,IAJe,KAAK,QAAQ,OAAO,SAAS,KAAK,MAAM,KAAK,EACrC,KAAK,MAAM,MAAQ,KAAK,QAAQ,OAAO,CAAC,CAGtD,GACTC,KAAAA,gBAAgB,KAAK,QAAQ,eAAgB,cAAc,EAC3D,CAAA,CAEJ,EAEA,aAAc,CACL,MAAA,CACL,iBACG,YACD,CAAC,CAAE,GAAI,SAAU,YAAe,CAC9B,GAAI,CAAC,KAAK,QAAQ,OAAO,SAAS,WAAW,KAAK,EACzC,MAAA,GAGH,KAAA,CAAE,SAAc,EAAA,GAChB,CAAE,KAAM,EAAO,EAAA,UAErB,UAAG,IAAI,aAAa,KAAM,GAAI,CAAC,KAAM,MAAQ,CACvC,KAAK,SAAW,MAAQ,KAAO,IAAM,IAAM,KAAK,UAE7C,KAAA,QAAQ,QAAS,SAAY,CAExB,QAAA,MAAM,QAAS,MAAS,CAG5B,KAAK,KAAK,OAAS,aACnB,KAAK,MAAM,UACX,KAAK,MAAM,WAAgB,OAG3B,GAAK,GAAG,WAAW,IAAK,IAAM,KAAK,SAAU,KAAK,IAAI,EACxD,CACD,CAAA,CACF,CACH,CACD,EAEG,UACF,SAAS,EAAE,EAEN,SAAS,WAAW,CAAE,MAAO,WAAW,MAAO,CACxD,CAAA,CAEN,CACF,CAAC"}
@@ -0,0 +1,17 @@
1
+ export declare type Level = 1 | 2;
2
+ interface Options {
3
+ levels: Level[];
4
+ HTMLAttributes: Record<string, any>;
5
+ }
6
+ declare module '@tiptap/core' {
7
+ interface Commands<ReturnType> {
8
+ customHeading: {
9
+ /**
10
+ * Apply Heading Level
11
+ */
12
+ setCustomHeading: (attributes: { level: Level }) => ReturnType;
13
+ };
14
+ }
15
+ }
16
+ export declare const CustomHeading: import('@tiptap/core').Node<Options, any>;
17
+ export {};
@@ -0,0 +1,60 @@
1
+ import { mergeAttributes } from '@tiptap/core';
2
+ import { Heading } from '@tiptap/extension-heading';
3
+ import '@tiptap/extension-text-style';
4
+ const CustomHeading = Heading.extend({
5
+ name: 'customHeading',
6
+ addOptions() {
7
+ var _a;
8
+ return {
9
+ ...((_a = this.parent) == null ? void 0 : _a.call(this)),
10
+ HTMLAttributes: {},
11
+ };
12
+ },
13
+ parseHTML() {
14
+ return this.options.levels.map((level) => ({
15
+ tag: `h${level}`,
16
+ attrs: { level },
17
+ }));
18
+ },
19
+ renderHTML({ node, HTMLAttributes }) {
20
+ return [
21
+ `h${
22
+ this.options.levels.includes(node.attrs.level)
23
+ ? node.attrs.level
24
+ : this.options.levels[0]
25
+ }`,
26
+ mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
27
+ 0,
28
+ ];
29
+ },
30
+ addCommands() {
31
+ return {
32
+ setCustomHeading:
33
+ (attributes) =>
34
+ ({ tr, dispatch, commands }) => {
35
+ if (!this.options.levels.includes(attributes.level)) return !1;
36
+ const { selection } = tr,
37
+ { from, to } = selection;
38
+ return (
39
+ tr.doc.nodesBetween(from, to, (node, pos) => {
40
+ node.isBlock &&
41
+ from >= pos &&
42
+ to <= pos + node.nodeSize &&
43
+ node.content.forEach((content) => {
44
+ content.marks.forEach((mark) => {
45
+ mark.type.name === 'textStyle' &&
46
+ mark.attrs.fontSize &&
47
+ mark.attrs.fontSize !== null &&
48
+ (tr = tr.removeMark(pos, pos + node.nodeSize, mark.type));
49
+ });
50
+ });
51
+ }),
52
+ dispatch && dispatch(tr),
53
+ commands.setHeading({ level: attributes.level })
54
+ );
55
+ },
56
+ };
57
+ },
58
+ });
59
+ export { CustomHeading };
60
+ //# sourceMappingURL=heading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading.js","sources":["../../src/heading/heading.ts"],"sourcesContent":["import { mergeAttributes } from '@tiptap/core';\nimport { Heading } from '@tiptap/extension-heading';\nimport '@tiptap/extension-text-style';\n\nexport declare type Level = 1 | 2;\n\ninterface Options {\n levels: Level[];\n HTMLAttributes: Record<string, any>;\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n customHeading: {\n /**\n * Apply Heading Level\n */\n setCustomHeading: (attributes: { level: Level }) => ReturnType;\n };\n }\n}\n\nexport const CustomHeading = Heading.extend<Options>({\n name: 'customHeading',\n\n addOptions() {\n return {\n ...this.parent?.(),\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return this.options.levels.map((level: Level) => ({\n tag: `h${level}`,\n attrs: { level },\n }));\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const hasLevel = this.options.levels.includes(node.attrs.level);\n const level = hasLevel ? node.attrs.level : this.options.levels[0];\n\n return [\n `h${level}`,\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setCustomHeading:\n (attributes) =>\n ({ tr, dispatch, commands }) => {\n if (!this.options.levels.includes(attributes.level)) {\n return false;\n }\n\n const { selection } = tr;\n const { from, to } = selection;\n\n tr.doc.nodesBetween(from, to, (node, pos) => {\n if (node.isBlock && from >= pos && to <= pos + node.nodeSize) {\n /* get node content and iterate through */\n node.content.forEach((content) => {\n /* get content marks and iterate through */\n content.marks.forEach((mark) => {\n /* find textStyle mark and if has fontSize attrs */\n if (\n mark.type.name === 'textStyle' &&\n mark.attrs['fontSize'] &&\n mark.attrs['fontSize'] !== null\n ) {\n /* remove any fontSize attr to reset heading style */\n tr = tr.removeMark(pos, pos + node.nodeSize, mark.type);\n }\n });\n });\n }\n });\n\n if (dispatch) {\n dispatch(tr);\n }\n return commands.setHeading({ level: attributes.level });\n },\n };\n },\n});\n"],"names":[],"mappings":";;;AAsBa,MAAA,gBAAgB,QAAQ,OAAgB;AAAA,EACnD,MAAM;AAAA,EAEN,aAAa;;AACJ,WAAA;AAAA,MACL,IAAG,UAAK,WAAL;AAAA,MACH,gBAAgB,CAAC;AAAA,IAAA;AAAA,EAErB;AAAA,EAEA,YAAY;AACV,WAAO,KAAK,QAAQ,OAAO,IAAI,CAAC,WAAkB;AAAA,MAChD,KAAK,IAAI,KAAK;AAAA,MACd,OAAO,EAAE,MAAM;AAAA,IACf,EAAA;AAAA,EACJ;AAAA,EAEA,WAAW,EAAE,MAAM,kBAAkB;AAI5B,WAAA;AAAA,MACL,IAJe,KAAK,QAAQ,OAAO,SAAS,KAAK,MAAM,KAAK,IACrC,KAAK,MAAM,QAAQ,KAAK,QAAQ,OAAO,CAAC,CAGtD;AAAA,MACT,gBAAgB,KAAK,QAAQ,gBAAgB,cAAc;AAAA,MAC3D;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,cAAc;AACL,WAAA;AAAA,MACL,kBACE,CAAC,eACD,CAAC,EAAE,IAAI,UAAU,eAAe;AAC9B,YAAI,CAAC,KAAK,QAAQ,OAAO,SAAS,WAAW,KAAK;AACzC,iBAAA;AAGH,cAAA,EAAE,UAAc,IAAA,IAChB,EAAE,MAAM,GAAO,IAAA;AAErB,kBAAG,IAAI,aAAa,MAAM,IAAI,CAAC,MAAM,QAAQ;AAC3C,UAAI,KAAK,WAAW,QAAQ,OAAO,MAAM,MAAM,KAAK,YAE7C,KAAA,QAAQ,QAAQ,CAAC,YAAY;AAExB,oBAAA,MAAM,QAAQ,CAAC,SAAS;AAE9B,cACE,KAAK,KAAK,SAAS,eACnB,KAAK,MAAM,YACX,KAAK,MAAM,aAAgB,SAG3B,KAAK,GAAG,WAAW,KAAK,MAAM,KAAK,UAAU,KAAK,IAAI;AAAA,YACxD,CACD;AAAA,UAAA,CACF;AAAA,QACH,CACD,GAEG,YACF,SAAS,EAAE,GAEN,SAAS,WAAW,EAAE,OAAO,WAAW,OAAO;AAAA,MACxD;AAAA,IAAA;AAAA,EAEN;AACF,CAAC;"}
@@ -0,0 +1,3 @@
1
+ import { CustomHeading } from './heading';
2
+ export * from './heading';
3
+ export default CustomHeading;
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
+ const Highlight = require('@tiptap/extension-highlight'),
4
+ CustomHighlight = Highlight.extend({
5
+ name: 'customHighlight',
6
+ addOptions() {
7
+ var _a;
8
+ return {
9
+ ...((_a = this.parent) == null ? void 0 : _a.call(this)),
10
+ multicolor: !0,
11
+ HTMLAttributes: {},
12
+ };
13
+ },
14
+ parseHTML() {
15
+ var _a;
16
+ return [
17
+ {
18
+ ...((_a = this.parent) == null ? void 0 : _a.call(this)),
19
+ style: 'background-color',
20
+ getAttrs: (style) => ({ color: style }),
21
+ },
22
+ ];
23
+ },
24
+ });
25
+ exports.CustomHighlight = CustomHighlight;
26
+ //# sourceMappingURL=highlight.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlight.cjs","sources":["../../src/highlight/highlight.ts"],"sourcesContent":["import Highlight from '@tiptap/extension-highlight';\n\nexport const CustomHighlight = Highlight.extend({\n name: 'customHighlight',\n\n addOptions() {\n return {\n ...this.parent?.(),\n multicolor: true,\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return [\n {\n ...this.parent?.(),\n style: 'background-color',\n getAttrs: (style) => {\n return {\n color: style,\n };\n },\n },\n ];\n },\n});\n"],"names":[],"mappings":"uIAEa,gBAAkB,UAAU,OAAO,CAC9C,KAAM,kBAEN,YAAa,QACJ,MAAA,CACL,IAAG,QAAK,SAAL,0BACH,WAAY,GACZ,eAAgB,CAAC,CAAA,CAErB,EAEA,WAAY,QACH,MAAA,CACL,CACE,IAAG,QAAK,SAAL,0BACH,MAAO,mBACP,SAAW,QACF,CACL,MAAO,KAAA,EAGb,CAAA,CAEJ,CACF,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const CustomHighlight: import('@tiptap/core').Mark<
2
+ import('@tiptap/extension-highlight').HighlightOptions,
3
+ any
4
+ >;
@@ -0,0 +1,26 @@
1
+ import Highlight from '@tiptap/extension-highlight';
2
+ const CustomHighlight = Highlight.extend({
3
+ name: 'customHighlight',
4
+ addOptions() {
5
+ var _a;
6
+ return {
7
+ ...((_a = this.parent) == null ? void 0 : _a.call(this)),
8
+ multicolor: !0,
9
+ HTMLAttributes: {},
10
+ };
11
+ },
12
+ parseHTML() {
13
+ var _a;
14
+ return [
15
+ {
16
+ ...((_a = this.parent) == null ? void 0 : _a.call(this)),
17
+ style: 'background-color',
18
+ getAttrs: (style) => ({
19
+ color: style,
20
+ }),
21
+ },
22
+ ];
23
+ },
24
+ });
25
+ export { CustomHighlight };
26
+ //# sourceMappingURL=highlight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlight.js","sources":["../../src/highlight/highlight.ts"],"sourcesContent":["import Highlight from '@tiptap/extension-highlight';\n\nexport const CustomHighlight = Highlight.extend({\n name: 'customHighlight',\n\n addOptions() {\n return {\n ...this.parent?.(),\n multicolor: true,\n HTMLAttributes: {},\n };\n },\n\n parseHTML() {\n return [\n {\n ...this.parent?.(),\n style: 'background-color',\n getAttrs: (style) => {\n return {\n color: style,\n };\n },\n },\n ];\n },\n});\n"],"names":[],"mappings":";AAEa,MAAA,kBAAkB,UAAU,OAAO;AAAA,EAC9C,MAAM;AAAA,EAEN,aAAa;;AACJ,WAAA;AAAA,MACL,IAAG,UAAK,WAAL;AAAA,MACH,YAAY;AAAA,MACZ,gBAAgB,CAAC;AAAA,IAAA;AAAA,EAErB;AAAA,EAEA,YAAY;;AACH,WAAA;AAAA,MACL;AAAA,QACE,IAAG,UAAK,WAAL;AAAA,QACH,OAAO;AAAA,QACP,UAAU,CAAC,WACF;AAAA,UACL,OAAO;AAAA,QAAA;AAAA,MAGb;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;"}
@@ -0,0 +1,3 @@
1
+ import { CustomHighlight } from './highlight';
2
+ export * from './highlight';
3
+ export default CustomHighlight;
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
+ const extensionLink = require('@tiptap/extension-link'),
4
+ Hyperlink = extensionLink.Link.extend({
5
+ name: 'hyperlink',
6
+ parseHTML() {
7
+ return [
8
+ {
9
+ tag: 'a[href]:not([href *= "javascript:" i])',
10
+ getAttrs: (node) => {
11
+ if (
12
+ node.getAttribute('data-id') &&
13
+ node.getAttribute('data-app-prefix')
14
+ )
15
+ return !1;
16
+ },
17
+ },
18
+ ];
19
+ },
20
+ addOptions() {
21
+ var _a, _b;
22
+ return {
23
+ ...((_a = this.parent) == null ? void 0 : _a.call(this)),
24
+ openOnClick: !1,
25
+ HTMLAttributes: {
26
+ ...((_b = this.parent) == null
27
+ ? void 0
28
+ : _b.call(this).HTMLAttributes),
29
+ target: null,
30
+ },
31
+ };
32
+ },
33
+ addAttributes() {
34
+ var _a;
35
+ return {
36
+ ...((_a = this.parent) == null ? void 0 : _a.call(this)),
37
+ target: {
38
+ default: this.options.HTMLAttributes.target,
39
+ parseHTML: (element) =>
40
+ element.getAttribute('target') !== '_blank' ? null : '_blank',
41
+ renderHTML: (attributes) => ({ target: attributes.target }),
42
+ },
43
+ title: { default: this.options.HTMLAttributes.title },
44
+ };
45
+ },
46
+ });
47
+ exports.Hyperlink = Hyperlink;
48
+ //# sourceMappingURL=hyperlink.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyperlink.cjs","sources":["../../src/hyperlink/hyperlink.ts"],"sourcesContent":["import { Link } from '@tiptap/extension-link';\n\n/** Our own model of an hyperlink in a rich document. */\nexport type HyperlinkAttributes = {\n href: string | null;\n target: '_blank' | null;\n title: string | null;\n text: string | null;\n};\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n hyperlink: {\n /**\n * Set an hyperlink mark\n */\n setLink: (attributes: Partial<HyperlinkAttributes>) => ReturnType;\n /**\n * Toggle an hyperlink mark\n */\n toggleLink: (attributes: {\n href: string;\n target?: string | null;\n }) => ReturnType;\n /**\n * Unset an hyperlink mark\n */\n unsetLink: () => ReturnType;\n };\n }\n}\n\n/**\n * Hyperlink (external links), extends `Link` extension from TipTap.\n *\n * Links to external resources MUST NOT have a `data-id` nor a `data-app-prefix` attribute.\n * The `target` attribute has to be sanitized, so it is overriden.\n */\nexport const Hyperlink = Link.extend({\n name: 'hyperlink',\n\n parseHTML() {\n return [\n {\n tag: 'a[href]:not([href *= \"javascript:\" i])',\n // Be sure no data-id and data-app-prefix attribute exists :\n // it would then be an Linker, not an Hyperlink !\n getAttrs: (node: HTMLAnchorElement) => {\n // See https://prosemirror.net/docs/ref/version/0.18.0.html#model.ParseRule.getAttrs\n if (\n node.getAttribute('data-id') &&\n node.getAttribute('data-app-prefix')\n )\n return false;\n },\n },\n ];\n },\n\n addOptions() {\n return {\n ...this.parent?.(),\n openOnClick: false,\n HTMLAttributes: {\n ...this.parent?.().HTMLAttributes,\n target: null,\n },\n };\n },\n\n /* Manage `title` and `target` attributes. */\n addAttributes() {\n return {\n // Preserve attributes of parent extension...\n ...this.parent?.(),\n // ...then add or override the following :\n //------------------\n target: {\n default: this.options.HTMLAttributes.target,\n // Sanitize target value\n parseHTML: (element) =>\n element.getAttribute('target') !== '_blank' ? null : '_blank',\n renderHTML: (attributes) => ({\n target: attributes['target'],\n }),\n },\n title: {\n default: this.options.HTMLAttributes.title,\n },\n };\n },\n});\n"],"names":["Link"],"mappings":"sIAsCa,UAAYA,mBAAK,OAAO,CACnC,KAAM,YAEN,WAAY,CACH,MAAA,CACL,CACE,IAAK,yCAGL,SAAW,MAA4B,CAErC,GACE,KAAK,aAAa,SAAS,GAC3B,KAAK,aAAa,iBAAiB,EAE5B,MAAA,EACX,CACF,CAAA,CAEJ,EAEA,YAAa,WACJ,MAAA,CACL,IAAG,QAAK,SAAL,0BACH,YAAa,GACb,eAAgB,CACd,IAAG,QAAK,SAAL,0BAAgB,eACnB,OAAQ,IACV,CAAA,CAEJ,EAGA,eAAgB,QACP,MAAA,CAEL,IAAG,QAAK,SAAL,0BAGH,OAAQ,CACN,QAAS,KAAK,QAAQ,eAAe,OAErC,UAAY,SACV,QAAQ,aAAa,QAAQ,IAAM,SAAW,KAAO,SACvD,WAAa,aAAgB,CAC3B,OAAQ,WAAW,MAAQ,EAE/B,EACA,MAAO,CACL,QAAS,KAAK,QAAQ,eAAe,KACvC,CAAA,CAEJ,CACF,CAAC"}
@@ -0,0 +1,38 @@
1
+ /** Our own model of an hyperlink in a rich document. */
2
+ export type HyperlinkAttributes = {
3
+ href: string | null;
4
+ target: '_blank' | null;
5
+ title: string | null;
6
+ text: string | null;
7
+ };
8
+ declare module '@tiptap/core' {
9
+ interface Commands<ReturnType> {
10
+ hyperlink: {
11
+ /**
12
+ * Set an hyperlink mark
13
+ */
14
+ setLink: (attributes: Partial<HyperlinkAttributes>) => ReturnType;
15
+ /**
16
+ * Toggle an hyperlink mark
17
+ */
18
+ toggleLink: (attributes: {
19
+ href: string;
20
+ target?: string | null;
21
+ }) => ReturnType;
22
+ /**
23
+ * Unset an hyperlink mark
24
+ */
25
+ unsetLink: () => ReturnType;
26
+ };
27
+ }
28
+ }
29
+ /**
30
+ * Hyperlink (external links), extends `Link` extension from TipTap.
31
+ *
32
+ * Links to external resources MUST NOT have a `data-id` nor a `data-app-prefix` attribute.
33
+ * The `target` attribute has to be sanitized, so it is overriden.
34
+ */
35
+ export declare const Hyperlink: import('@tiptap/core').Mark<
36
+ import('@tiptap/extension-link').LinkOptions,
37
+ any
38
+ >;
@@ -0,0 +1,55 @@
1
+ import { Link } from '@tiptap/extension-link';
2
+ const Hyperlink = Link.extend({
3
+ name: 'hyperlink',
4
+ parseHTML() {
5
+ return [
6
+ {
7
+ tag: 'a[href]:not([href *= "javascript:" i])',
8
+ // Be sure no data-id and data-app-prefix attribute exists :
9
+ // it would then be an Linker, not an Hyperlink !
10
+ getAttrs: (node) => {
11
+ if (
12
+ node.getAttribute('data-id') &&
13
+ node.getAttribute('data-app-prefix')
14
+ )
15
+ return !1;
16
+ },
17
+ },
18
+ ];
19
+ },
20
+ addOptions() {
21
+ var _a, _b;
22
+ return {
23
+ ...((_a = this.parent) == null ? void 0 : _a.call(this)),
24
+ openOnClick: !1,
25
+ HTMLAttributes: {
26
+ ...((_b = this.parent) == null ? void 0 : _b.call(this).HTMLAttributes),
27
+ target: null,
28
+ },
29
+ };
30
+ },
31
+ /* Manage `title` and `target` attributes. */
32
+ addAttributes() {
33
+ var _a;
34
+ return {
35
+ // Preserve attributes of parent extension...
36
+ ...((_a = this.parent) == null ? void 0 : _a.call(this)),
37
+ // ...then add or override the following :
38
+ //------------------
39
+ target: {
40
+ default: this.options.HTMLAttributes.target,
41
+ // Sanitize target value
42
+ parseHTML: (element) =>
43
+ element.getAttribute('target') !== '_blank' ? null : '_blank',
44
+ renderHTML: (attributes) => ({
45
+ target: attributes.target,
46
+ }),
47
+ },
48
+ title: {
49
+ default: this.options.HTMLAttributes.title,
50
+ },
51
+ };
52
+ },
53
+ });
54
+ export { Hyperlink };
55
+ //# sourceMappingURL=hyperlink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hyperlink.js","sources":["../../src/hyperlink/hyperlink.ts"],"sourcesContent":["import { Link } from '@tiptap/extension-link';\n\n/** Our own model of an hyperlink in a rich document. */\nexport type HyperlinkAttributes = {\n href: string | null;\n target: '_blank' | null;\n title: string | null;\n text: string | null;\n};\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n hyperlink: {\n /**\n * Set an hyperlink mark\n */\n setLink: (attributes: Partial<HyperlinkAttributes>) => ReturnType;\n /**\n * Toggle an hyperlink mark\n */\n toggleLink: (attributes: {\n href: string;\n target?: string | null;\n }) => ReturnType;\n /**\n * Unset an hyperlink mark\n */\n unsetLink: () => ReturnType;\n };\n }\n}\n\n/**\n * Hyperlink (external links), extends `Link` extension from TipTap.\n *\n * Links to external resources MUST NOT have a `data-id` nor a `data-app-prefix` attribute.\n * The `target` attribute has to be sanitized, so it is overriden.\n */\nexport const Hyperlink = Link.extend({\n name: 'hyperlink',\n\n parseHTML() {\n return [\n {\n tag: 'a[href]:not([href *= \"javascript:\" i])',\n // Be sure no data-id and data-app-prefix attribute exists :\n // it would then be an Linker, not an Hyperlink !\n getAttrs: (node: HTMLAnchorElement) => {\n // See https://prosemirror.net/docs/ref/version/0.18.0.html#model.ParseRule.getAttrs\n if (\n node.getAttribute('data-id') &&\n node.getAttribute('data-app-prefix')\n )\n return false;\n },\n },\n ];\n },\n\n addOptions() {\n return {\n ...this.parent?.(),\n openOnClick: false,\n HTMLAttributes: {\n ...this.parent?.().HTMLAttributes,\n target: null,\n },\n };\n },\n\n /* Manage `title` and `target` attributes. */\n addAttributes() {\n return {\n // Preserve attributes of parent extension...\n ...this.parent?.(),\n // ...then add or override the following :\n //------------------\n target: {\n default: this.options.HTMLAttributes.target,\n // Sanitize target value\n parseHTML: (element) =>\n element.getAttribute('target') !== '_blank' ? null : '_blank',\n renderHTML: (attributes) => ({\n target: attributes['target'],\n }),\n },\n title: {\n default: this.options.HTMLAttributes.title,\n },\n };\n },\n});\n"],"names":[],"mappings":";AAsCa,MAAA,YAAY,KAAK,OAAO;AAAA,EACnC,MAAM;AAAA,EAEN,YAAY;AACH,WAAA;AAAA,MACL;AAAA,QACE,KAAK;AAAA;AAAA;AAAA,QAGL,UAAU,CAAC,SAA4B;AAErC,cACE,KAAK,aAAa,SAAS,KAC3B,KAAK,aAAa,iBAAiB;AAE5B,mBAAA;AAAA,QACX;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AAAA,EAEA,aAAa;;AACJ,WAAA;AAAA,MACL,IAAG,UAAK,WAAL;AAAA,MACH,aAAa;AAAA,MACb,gBAAgB;AAAA,QACd,IAAG,UAAK,WAAL,8BAAgB;AAAA,QACnB,QAAQ;AAAA,MACV;AAAA,IAAA;AAAA,EAEJ;AAAA;AAAA,EAGA,gBAAgB;;AACP,WAAA;AAAA;AAAA,MAEL,IAAG,UAAK,WAAL;AAAA;AAAA;AAAA,MAGH,QAAQ;AAAA,QACN,SAAS,KAAK,QAAQ,eAAe;AAAA;AAAA,QAErC,WAAW,CAAC,YACV,QAAQ,aAAa,QAAQ,MAAM,WAAW,OAAO;AAAA,QACvD,YAAY,CAAC,gBAAgB;AAAA,UAC3B,QAAQ,WAAW;AAAA,QAAQ;AAAA,MAE/B;AAAA,MACA,OAAO;AAAA,QACL,SAAS,KAAK,QAAQ,eAAe;AAAA,MACvC;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;"}
@@ -0,0 +1,3 @@
1
+ import { Hyperlink } from './hyperlink';
2
+ export * from './hyperlink';
3
+ export default Hyperlink;
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
+ const core = require('@tiptap/core'),
4
+ Iframe = core.Node.create({
5
+ name: 'iframe',
6
+ group: 'block',
7
+ atom: !0,
8
+ draggable: !0,
9
+ addOptions() {
10
+ return {
11
+ allowFullscreen: !0,
12
+ HTMLAttributes: { class: 'iframe-wrapper' },
13
+ };
14
+ },
15
+ addAttributes() {
16
+ return {
17
+ src: { default: null },
18
+ frameborder: { default: 0 },
19
+ allowfullscreen: {
20
+ default: this.options.allowFullscreen,
21
+ parseHTML: () => this.options.allowFullscreen,
22
+ },
23
+ width: {
24
+ renderHTML: (attributes) =>
25
+ attributes.width
26
+ ? {
27
+ width:
28
+ attributes.width === '100%'
29
+ ? '100%'
30
+ : parseInt(attributes.width),
31
+ }
32
+ : {},
33
+ parseHTML: (element) => element.getAttribute('width'),
34
+ },
35
+ height: {
36
+ renderHTML: (attributes) =>
37
+ attributes.height ? { height: parseInt(attributes.height) } : {},
38
+ parseHTML: (element) => element.getAttribute('height'),
39
+ },
40
+ style: {
41
+ renderHTML: (attributes) =>
42
+ attributes.style ? { style: attributes.style } : {},
43
+ parseHTML: (element) => element.getAttribute('style'),
44
+ },
45
+ };
46
+ },
47
+ parseHTML() {
48
+ return [{ tag: 'iframe' }];
49
+ },
50
+ renderHTML({ HTMLAttributes }) {
51
+ return ['div', this.options.HTMLAttributes, ['iframe', HTMLAttributes]];
52
+ },
53
+ addCommands() {
54
+ return {
55
+ setIframe:
56
+ (options) =>
57
+ ({ tr, dispatch }) => {
58
+ const { selection } = tr,
59
+ node = this.type.create(options);
60
+ return (
61
+ dispatch &&
62
+ tr.replaceRangeWith(selection.from, selection.to, node),
63
+ !0
64
+ );
65
+ },
66
+ };
67
+ },
68
+ });
69
+ exports.Iframe = Iframe;
70
+ //# sourceMappingURL=iframe.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iframe.cjs","sources":["../../src/iframe/iframe.ts"],"sourcesContent":["import { Node } from '@tiptap/core';\n\nexport interface IframeOptions {\n allowFullscreen: boolean;\n HTMLAttributes: {\n [key: string]: any;\n };\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n iframe: {\n /**\n * Add an iframe\n */\n setIframe: (options: { src: string }) => ReturnType;\n };\n }\n}\n\nexport const Iframe = Node.create<IframeOptions>({\n name: 'iframe',\n group: 'block',\n atom: true,\n draggable: true,\n\n addOptions() {\n return {\n allowFullscreen: true,\n HTMLAttributes: {\n class: 'iframe-wrapper',\n },\n };\n },\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n frameborder: {\n default: 0,\n },\n allowfullscreen: {\n default: this.options.allowFullscreen,\n parseHTML: () => this.options.allowFullscreen,\n },\n width: {\n renderHTML: (attributes) => {\n return attributes.width\n ? {\n width:\n attributes.width === '100%'\n ? '100%'\n : parseInt(attributes.width),\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('width'),\n },\n height: {\n renderHTML: (attributes) => {\n return attributes.height\n ? {\n height: parseInt(attributes.height),\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('height'),\n },\n style: {\n renderHTML: (attributes) => {\n return attributes.style\n ? {\n style: attributes.style,\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute('style'),\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'iframe',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['div', this.options.HTMLAttributes, ['iframe', HTMLAttributes]];\n },\n\n addCommands() {\n return {\n setIframe:\n (options: { src: string }) =>\n ({ tr, dispatch }) => {\n const { selection } = tr;\n const node = this.type.create(options);\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node);\n }\n\n return true;\n },\n };\n },\n});\n"],"names":["Node"],"mappings":"mHAoBa,OAASA,UAAK,OAAsB,CAC/C,KAAM,SACN,MAAO,QACP,KAAM,GACN,UAAW,GAEX,YAAa,CACJ,MAAA,CACL,gBAAiB,GACjB,eAAgB,CACd,MAAO,gBACT,CAAA,CAEJ,EAEA,eAAgB,CACP,MAAA,CACL,IAAK,CACH,QAAS,IACX,EACA,YAAa,CACX,QAAS,CACX,EACA,gBAAiB,CACf,QAAS,KAAK,QAAQ,gBACtB,UAAW,IAAM,KAAK,QAAQ,eAChC,EACA,MAAO,CACL,WAAa,YACJ,WAAW,MACd,CACE,MACE,WAAW,QAAU,OACjB,OACA,SAAS,WAAW,KAAK,GAEjC,GAEN,UAAY,SAAY,QAAQ,aAAa,OAAO,CACtD,EACA,OAAQ,CACN,WAAa,YACJ,WAAW,OACd,CACE,OAAQ,SAAS,WAAW,MAAM,GAEpC,GAEN,UAAY,SAAY,QAAQ,aAAa,QAAQ,CACvD,EACA,MAAO,CACL,WAAa,YACJ,WAAW,MACd,CACE,MAAO,WAAW,OAEpB,GAEN,UAAY,SAAY,QAAQ,aAAa,OAAO,CACtD,CAAA,CAEJ,EAEA,WAAY,CACH,MAAA,CACL,CACE,IAAK,QACP,CAAA,CAEJ,EAEA,WAAW,CAAE,gBAAkB,CACtB,MAAA,CAAC,MAAO,KAAK,QAAQ,eAAgB,CAAC,SAAU,cAAc,CAAC,CACxE,EAEA,aAAc,CACL,MAAA,CACL,UACG,SACD,CAAC,CAAE,GAAI,YAAe,CACd,KAAA,CAAE,SAAc,EAAA,GAChB,KAAO,KAAK,KAAK,OAAO,OAAO,EAErC,OAAI,UACF,GAAG,iBAAiB,UAAU,KAAM,UAAU,GAAI,IAAI,EAGjD,EACT,CAAA,CAEN,CACF,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { Node } from '@tiptap/core';
2
+ export interface IframeOptions {
3
+ allowFullscreen: boolean;
4
+ HTMLAttributes: {
5
+ [key: string]: any;
6
+ };
7
+ }
8
+ declare module '@tiptap/core' {
9
+ interface Commands<ReturnType> {
10
+ iframe: {
11
+ /**
12
+ * Add an iframe
13
+ */
14
+ setIframe: (options: { src: string }) => ReturnType;
15
+ };
16
+ }
17
+ }
18
+ export declare const Iframe: Node<IframeOptions, any>;
@@ -0,0 +1,85 @@
1
+ import { Node } from '@tiptap/core';
2
+ const Iframe = Node.create({
3
+ name: 'iframe',
4
+ group: 'block',
5
+ atom: !0,
6
+ draggable: !0,
7
+ addOptions() {
8
+ return {
9
+ allowFullscreen: !0,
10
+ HTMLAttributes: {
11
+ class: 'iframe-wrapper',
12
+ },
13
+ };
14
+ },
15
+ addAttributes() {
16
+ return {
17
+ src: {
18
+ default: null,
19
+ },
20
+ frameborder: {
21
+ default: 0,
22
+ },
23
+ allowfullscreen: {
24
+ default: this.options.allowFullscreen,
25
+ parseHTML: () => this.options.allowFullscreen,
26
+ },
27
+ width: {
28
+ renderHTML: (attributes) =>
29
+ attributes.width
30
+ ? {
31
+ width:
32
+ attributes.width === '100%'
33
+ ? '100%'
34
+ : parseInt(attributes.width),
35
+ }
36
+ : {},
37
+ parseHTML: (element) => element.getAttribute('width'),
38
+ },
39
+ height: {
40
+ renderHTML: (attributes) =>
41
+ attributes.height
42
+ ? {
43
+ height: parseInt(attributes.height),
44
+ }
45
+ : {},
46
+ parseHTML: (element) => element.getAttribute('height'),
47
+ },
48
+ style: {
49
+ renderHTML: (attributes) =>
50
+ attributes.style
51
+ ? {
52
+ style: attributes.style,
53
+ }
54
+ : {},
55
+ parseHTML: (element) => element.getAttribute('style'),
56
+ },
57
+ };
58
+ },
59
+ parseHTML() {
60
+ return [
61
+ {
62
+ tag: 'iframe',
63
+ },
64
+ ];
65
+ },
66
+ renderHTML({ HTMLAttributes }) {
67
+ return ['div', this.options.HTMLAttributes, ['iframe', HTMLAttributes]];
68
+ },
69
+ addCommands() {
70
+ return {
71
+ setIframe:
72
+ (options) =>
73
+ ({ tr, dispatch }) => {
74
+ const { selection } = tr,
75
+ node = this.type.create(options);
76
+ return (
77
+ dispatch && tr.replaceRangeWith(selection.from, selection.to, node),
78
+ !0
79
+ );
80
+ },
81
+ };
82
+ },
83
+ });
84
+ export { Iframe };
85
+ //# sourceMappingURL=iframe.js.map