@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
package/package.json ADDED
@@ -0,0 +1,133 @@
1
+ {
2
+ "name": "@edifice.io/tiptap-extensions",
3
+ "version": "1.5.16-develop-rc.2",
4
+ "description": "Edifice Rich Text Editor Extensions",
5
+ "homepage": "https://github.com/edificeio/edifice-ui/tree/main/packages/tiptap/extensions#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/edificeio/edifice-ui/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/edificeio/edifice-ui.git"
12
+ },
13
+ "license": "AGPL-3.0",
14
+ "author": "Edifice",
15
+ "sideEffects": false,
16
+ "type": "module",
17
+ "exports": {
18
+ ".": {
19
+ "import": "./dist/index.js",
20
+ "require": "./dist/index.cjs"
21
+ },
22
+ "./abbr": {
23
+ "import": "./dist/abbr/abbr.js",
24
+ "require": "./dist/abbr/abbr.cjs"
25
+ },
26
+ "./alert": {
27
+ "import": "./dist/alert/alert.js",
28
+ "require": "./dist/alert/alert.cjs"
29
+ },
30
+ "./attachment": {
31
+ "import": "./dist/attachment/attachment.js",
32
+ "require": "./dist/attachment/attachment.cjs"
33
+ },
34
+ "./audio": {
35
+ "import": "./dist/audio/audio.js",
36
+ "require": "./dist/audio/audio.cjs"
37
+ },
38
+ "./font-size": {
39
+ "import": "./dist/font-size/font-size.js",
40
+ "require": "./dist/font-size/font-size.cjs"
41
+ },
42
+ "./heading": {
43
+ "import": "./dist/heading/heading.js",
44
+ "require": "./dist/heading/heading.cjs"
45
+ },
46
+ "./highlight": {
47
+ "import": "./dist/highlight/highlight.js",
48
+ "require": "./dist/highlight/highlight.cjs"
49
+ },
50
+ "./hyperlink": {
51
+ "import": "./dist/hyperlink/hyperlink.js",
52
+ "require": "./dist/hyperlink/hyperlink.cjs"
53
+ },
54
+ "./iframe": {
55
+ "import": "./dist/iframe/iframe.js",
56
+ "require": "./dist/iframe/iframe.cjs"
57
+ },
58
+ "./image": {
59
+ "import": "./dist/image/image.js",
60
+ "require": "./dist/image/image.cjs"
61
+ },
62
+ "./line-height": {
63
+ "import": "./dist/line-height/line-height.js",
64
+ "require": "./dist/line-height/line-height.cjs"
65
+ },
66
+ "./linker": {
67
+ "import": "./dist/linker/linker.js",
68
+ "require": "./dist/linker/linker.cjs"
69
+ },
70
+ "./mathjax": {
71
+ "import": "./dist/mathjax/mathjax.js",
72
+ "require": "./dist/mathjax/mathjax.cjs"
73
+ },
74
+ "./paragraph": {
75
+ "import": "./dist/paragraph/paragraph.js",
76
+ "require": "./dist/paragraph/paragraph.cjs"
77
+ },
78
+ "./speech-recognition": {
79
+ "import": "./dist/speech-recognition/speech-recognition.js",
80
+ "require": "./dist/speech-recognition/speech-recognition.cjs"
81
+ },
82
+ "./speech-synthesis": {
83
+ "import": "./dist/speech-synthesis/speech-synthesis.js",
84
+ "require": "./dist/speech-synthesis/speech-synthesis.cjs"
85
+ },
86
+ "./table-cell": {
87
+ "import": "./dist/table-cell/table-cell.js",
88
+ "require": "./dist/table-cell/table-cell.cjs"
89
+ },
90
+ "./transform": {
91
+ "import": "./dist/transform/transform.js",
92
+ "require": "./dist/transform/transform.cjs"
93
+ },
94
+ "./video": {
95
+ "import": "./dist/video/video.js",
96
+ "require": "./dist/video/video.cjs"
97
+ }
98
+ },
99
+ "main": "dist/index.cjs",
100
+ "module": "dist/index.js",
101
+ "typings": "dist/index.d.ts",
102
+ "scripts": {
103
+ "build": "vite build",
104
+ "fix": "eslint . --ext ts --report-unused-disable-directives --max-warnings 0",
105
+ "format": "pnpm run format:write && pnpm run format:check",
106
+ "format:check": "npx prettier --check .",
107
+ "format:write": "npx prettier --write .",
108
+ "lint": "eslint \"**/*.ts\""
109
+ },
110
+ "dependencies": {
111
+ "@tiptap/core": "2.3.0",
112
+ "@tiptap/extension-bold": "2.3.0",
113
+ "@tiptap/extension-document": "2.3.0",
114
+ "@tiptap/extension-heading": "2.3.0",
115
+ "@tiptap/extension-highlight": "2.3.0",
116
+ "@tiptap/extension-image": "2.3.0",
117
+ "@tiptap/extension-link": "2.3.0",
118
+ "@tiptap/extension-paragraph": "2.3.0",
119
+ "@tiptap/extension-table-cell": "2.3.0",
120
+ "@tiptap/extension-text": "2.3.0",
121
+ "@tiptap/extension-text-style": "2.3.0",
122
+ "@tiptap/html": "2.3.0",
123
+ "@tiptap/pm": "2.3.0",
124
+ "@tiptap/starter-kit": "2.3.0"
125
+ },
126
+ "devDependencies": {
127
+ "@types/dom-speech-recognition": "^0.0.1"
128
+ },
129
+ "publishConfig": {
130
+ "access": "public"
131
+ },
132
+ "gitHead": "31c5ddef7d29e860f5f034b13cdd62ff2899f730"
133
+ }
@@ -0,0 +1,57 @@
1
+ import { Mark, mergeAttributes } from '@tiptap/core';
2
+
3
+ declare module '@tiptap/core' {
4
+ interface Commands<ReturnType> {
5
+ abbr: {
6
+ /**
7
+ * Set an abbr mark
8
+ */
9
+ setAbbr: (src: string) => ReturnType;
10
+ /**
11
+ * Toggle an abbr mark
12
+ */
13
+ toggleAbbr: (src: string) => ReturnType;
14
+ };
15
+ }
16
+ }
17
+
18
+ export const Abbr = Mark.create({
19
+ name: 'abbr',
20
+
21
+ addOptions() {
22
+ return {
23
+ HTMLAttributes: {},
24
+ };
25
+ },
26
+
27
+ parseHTML() {
28
+ return [
29
+ {
30
+ tag: 'abbr',
31
+ },
32
+ ];
33
+ },
34
+
35
+ renderHTML({ HTMLAttributes }) {
36
+ return [
37
+ 'abbr',
38
+ mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
39
+ 0,
40
+ ];
41
+ },
42
+
43
+ addCommands() {
44
+ return {
45
+ setAbbr:
46
+ () =>
47
+ ({ commands }) => {
48
+ return commands.setMark(this.name);
49
+ },
50
+ toggleAbbr:
51
+ () =>
52
+ ({ commands }) => {
53
+ return commands.toggleMark(this.name);
54
+ },
55
+ };
56
+ },
57
+ });
@@ -0,0 +1,5 @@
1
+ import { Abbr } from './abbr';
2
+
3
+ export * from './abbr';
4
+
5
+ export default Abbr;
@@ -0,0 +1,46 @@
1
+ import { Node } from '@tiptap/core';
2
+
3
+ export const Alert = Node.create({
4
+ name: 'alert',
5
+ content: 'inline+',
6
+ marks: '',
7
+ group: 'block',
8
+
9
+ inline: false,
10
+ selectable: true,
11
+ draggable: true,
12
+
13
+ parseHTML() {
14
+ return [
15
+ {
16
+ tag: 'p.info',
17
+ priority: 60,
18
+ },
19
+ {
20
+ tag: 'p.warning',
21
+ priority: 60,
22
+ },
23
+ {
24
+ tag: 'div.info',
25
+ priority: 60,
26
+ },
27
+ {
28
+ tag: 'div.warning',
29
+ priority: 60,
30
+ },
31
+ ];
32
+ },
33
+ addAttributes() {
34
+ return {
35
+ class: {
36
+ default: 'info',
37
+ parseHTML: (element) => {
38
+ return element.getAttribute('class');
39
+ },
40
+ },
41
+ };
42
+ },
43
+ renderHTML({ HTMLAttributes }) {
44
+ return ['div', HTMLAttributes, 0];
45
+ },
46
+ });
@@ -0,0 +1,5 @@
1
+ import { Alert } from './alert';
2
+
3
+ export * from './alert';
4
+
5
+ export default Alert;
@@ -0,0 +1,113 @@
1
+ import { Node } from '@tiptap/core';
2
+
3
+ export interface AttachmentOptions {
4
+ HTMLAttributes: Record<string, string>;
5
+ }
6
+
7
+ declare module '@tiptap/core' {
8
+ interface Commands<ReturnType> {
9
+ attachment: {
10
+ setAttachment: (attachment) => ReturnType;
11
+ };
12
+ }
13
+ }
14
+
15
+ export const Attachment = Node.create<AttachmentOptions>({
16
+ name: 'attachments',
17
+ content: '',
18
+ marks: '',
19
+ group: 'block',
20
+ selectable: true,
21
+ atom: true,
22
+ draggable: true,
23
+
24
+ addOptions() {
25
+ return {
26
+ HTMLAttributes: {
27
+ class: 'attachments',
28
+ },
29
+ };
30
+ },
31
+
32
+ parseHTML() {
33
+ return [{ tag: 'div[class=attachments]' }];
34
+ },
35
+
36
+ renderHTML({ HTMLAttributes }) {
37
+ const links = HTMLAttributes.links;
38
+
39
+ const renderedLinks = links.map((el) => {
40
+ return [
41
+ 'a',
42
+ {
43
+ name: el.name,
44
+ href: el.href,
45
+ documentId: el.documentId,
46
+ dataContentType: el.dataContentType,
47
+ },
48
+ el.name,
49
+ ];
50
+ });
51
+
52
+ return ['div', this.options.HTMLAttributes, ...renderedLinks];
53
+ },
54
+
55
+ addAttributes() {
56
+ return {
57
+ links: {
58
+ default: [],
59
+ parseHTML: (element) => {
60
+ const links = element.getElementsByTagName('a');
61
+ const parsedLinks = [];
62
+
63
+ for (let i = 0; i < links.length; i++) {
64
+ const link = links[i];
65
+ const href = link.getAttribute('href');
66
+ const name = link.textContent;
67
+ const regexResult = href.match(/([^/]+$)/);
68
+ const documentId =
69
+ link.getAttribute('data-document-id') ||
70
+ (regexResult && regexResult[0]);
71
+ const dataContentType = link.getAttribute('data-content-type');
72
+
73
+ parsedLinks.push({
74
+ href,
75
+ name,
76
+ documentId,
77
+ dataContentType,
78
+ });
79
+ }
80
+
81
+ return parsedLinks;
82
+ },
83
+ renderHTML: (attributes) => {
84
+ return {
85
+ links: attributes.links.map((link) => ({
86
+ href: link.href,
87
+ name: link.name,
88
+ documentId: link.documentId,
89
+ dataContentType: link.dataContentType,
90
+ })),
91
+ };
92
+ },
93
+ },
94
+ };
95
+ },
96
+
97
+ addCommands() {
98
+ return {
99
+ setAttachment:
100
+ (
101
+ attrs = {
102
+ dataContentType: '',
103
+ name: '',
104
+ documentId: '',
105
+ href: '',
106
+ },
107
+ ) =>
108
+ ({ chain }) => {
109
+ return chain().insertContent({ type: this.name, attrs }).run();
110
+ },
111
+ };
112
+ },
113
+ });
@@ -0,0 +1,5 @@
1
+ import { Attachment } from './attachment';
2
+
3
+ export * from './attachment';
4
+
5
+ export default Attachment;
@@ -0,0 +1,81 @@
1
+ import { mergeAttributes, Node } from '@tiptap/core';
2
+
3
+ export interface AudioOptions {
4
+ url: string;
5
+ HTMLAttributes: Record<string, any>;
6
+ }
7
+
8
+ declare module '@tiptap/core' {
9
+ interface Commands<ReturnType> {
10
+ audio: {
11
+ /**
12
+ * Set a audio node
13
+ * @param options.updateSelection set to true will select the newly inserted content
14
+ */
15
+ setAudio: (
16
+ id: string,
17
+ src: string,
18
+ options?: { updateSelection: boolean },
19
+ ) => ReturnType;
20
+ };
21
+ }
22
+ }
23
+
24
+ export const Audio = Node.create({
25
+ name: 'audio',
26
+
27
+ group: 'block',
28
+
29
+ addAttributes() {
30
+ return {
31
+ src: {
32
+ default: null,
33
+ parseHTML: (el: any) => (el as HTMLSpanElement).getAttribute('src'),
34
+ renderHTML: (attrs: any) => ({ src: attrs.src }),
35
+ },
36
+ documentId: {
37
+ default: '',
38
+ renderHTML: (attributes: any) => {
39
+ return { 'data-document-id': attributes.documentId };
40
+ },
41
+ parseHTML: (element: any) => element.getAttribute('data-document-id'),
42
+ },
43
+ };
44
+ },
45
+
46
+ parseHTML() {
47
+ return [
48
+ {
49
+ tag: 'div.audio-wrapper>audio,audio',
50
+ getAttrs: (el: any) => ({
51
+ src: (el as HTMLAudioElement).getAttribute('src'),
52
+ }),
53
+ },
54
+ ];
55
+ },
56
+
57
+ renderHTML({ HTMLAttributes }) {
58
+ return [
59
+ 'div',
60
+ { class: 'audio-wrapper' },
61
+ ['audio', mergeAttributes(HTMLAttributes)],
62
+ ];
63
+ },
64
+
65
+ addCommands() {
66
+ return {
67
+ setAudio:
68
+ (id, src, options) =>
69
+ ({ commands, state }) => {
70
+ return commands.insertContentAt(
71
+ state.selection,
72
+ `<audio
73
+ src="${src}"
74
+ controls preload="none"
75
+ data-document-id="${id}"></audio>`,
76
+ options,
77
+ );
78
+ },
79
+ };
80
+ },
81
+ });
@@ -0,0 +1,5 @@
1
+ import { Audio } from './audio';
2
+
3
+ export * from './audio';
4
+
5
+ export default Audio;
@@ -0,0 +1,74 @@
1
+ import '@tiptap/extension-text-style';
2
+
3
+ import { Extension } from '@tiptap/core';
4
+
5
+ export type FontSizeOptions = {
6
+ types: string[];
7
+ };
8
+
9
+ declare module '@tiptap/core' {
10
+ interface Commands<ReturnType> {
11
+ fontSize: {
12
+ /**
13
+ * Set the font size
14
+ */
15
+ setFontSize: (fontSize: string) => ReturnType;
16
+ /**
17
+ * Unset the font size
18
+ */
19
+ unsetFontSize: () => ReturnType;
20
+ };
21
+ }
22
+ }
23
+
24
+ export const FontSize = Extension.create<FontSizeOptions>({
25
+ name: 'fontSize',
26
+
27
+ addOptions() {
28
+ return {
29
+ types: ['textStyle'],
30
+ };
31
+ },
32
+
33
+ addGlobalAttributes() {
34
+ return [
35
+ {
36
+ types: this.options.types,
37
+ attributes: {
38
+ fontSize: {
39
+ default: null,
40
+ parseHTML: (element) =>
41
+ element.style.fontSize?.replace(/['"]+/g, ''),
42
+ renderHTML: (attributes) => {
43
+ if (!attributes.fontSize) {
44
+ return {};
45
+ }
46
+
47
+ return {
48
+ style: `font-size: ${attributes.fontSize}`,
49
+ };
50
+ },
51
+ },
52
+ },
53
+ },
54
+ ];
55
+ },
56
+
57
+ addCommands() {
58
+ return {
59
+ setFontSize:
60
+ (fontSize) =>
61
+ ({ chain }) => {
62
+ return chain().setMark('textStyle', { fontSize }).run();
63
+ },
64
+ unsetFontSize:
65
+ () =>
66
+ ({ chain }) => {
67
+ return chain()
68
+ .setMark('textStyle', { fontSize: null })
69
+ .removeEmptyTextStyle()
70
+ .run();
71
+ },
72
+ };
73
+ },
74
+ });
@@ -0,0 +1,5 @@
1
+ import { FontSize } from './font-size';
2
+
3
+ export * from './font-size';
4
+
5
+ export default FontSize;
@@ -0,0 +1,90 @@
1
+ import { mergeAttributes } from '@tiptap/core';
2
+ import { Heading } from '@tiptap/extension-heading';
3
+ import '@tiptap/extension-text-style';
4
+
5
+ export declare type Level = 1 | 2;
6
+
7
+ interface Options {
8
+ levels: Level[];
9
+ HTMLAttributes: Record<string, any>;
10
+ }
11
+
12
+ declare module '@tiptap/core' {
13
+ interface Commands<ReturnType> {
14
+ customHeading: {
15
+ /**
16
+ * Apply Heading Level
17
+ */
18
+ setCustomHeading: (attributes: { level: Level }) => ReturnType;
19
+ };
20
+ }
21
+ }
22
+
23
+ export const CustomHeading = Heading.extend<Options>({
24
+ name: 'customHeading',
25
+
26
+ addOptions() {
27
+ return {
28
+ ...this.parent?.(),
29
+ HTMLAttributes: {},
30
+ };
31
+ },
32
+
33
+ parseHTML() {
34
+ return this.options.levels.map((level: Level) => ({
35
+ tag: `h${level}`,
36
+ attrs: { level },
37
+ }));
38
+ },
39
+
40
+ renderHTML({ node, HTMLAttributes }) {
41
+ const hasLevel = this.options.levels.includes(node.attrs.level);
42
+ const level = hasLevel ? node.attrs.level : this.options.levels[0];
43
+
44
+ return [
45
+ `h${level}`,
46
+ mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
47
+ 0,
48
+ ];
49
+ },
50
+
51
+ addCommands() {
52
+ return {
53
+ setCustomHeading:
54
+ (attributes) =>
55
+ ({ tr, dispatch, commands }) => {
56
+ if (!this.options.levels.includes(attributes.level)) {
57
+ return false;
58
+ }
59
+
60
+ const { selection } = tr;
61
+ const { from, to } = selection;
62
+
63
+ tr.doc.nodesBetween(from, to, (node, pos) => {
64
+ if (node.isBlock && from >= pos && to <= pos + node.nodeSize) {
65
+ /* get node content and iterate through */
66
+ node.content.forEach((content) => {
67
+ /* get content marks and iterate through */
68
+ content.marks.forEach((mark) => {
69
+ /* find textStyle mark and if has fontSize attrs */
70
+ if (
71
+ mark.type.name === 'textStyle' &&
72
+ mark.attrs['fontSize'] &&
73
+ mark.attrs['fontSize'] !== null
74
+ ) {
75
+ /* remove any fontSize attr to reset heading style */
76
+ tr = tr.removeMark(pos, pos + node.nodeSize, mark.type);
77
+ }
78
+ });
79
+ });
80
+ }
81
+ });
82
+
83
+ if (dispatch) {
84
+ dispatch(tr);
85
+ }
86
+ return commands.setHeading({ level: attributes.level });
87
+ },
88
+ };
89
+ },
90
+ });
@@ -0,0 +1,5 @@
1
+ import { CustomHeading } from './heading';
2
+
3
+ export * from './heading';
4
+
5
+ export default CustomHeading;
@@ -0,0 +1,27 @@
1
+ import Highlight from '@tiptap/extension-highlight';
2
+
3
+ export const CustomHighlight = Highlight.extend({
4
+ name: 'customHighlight',
5
+
6
+ addOptions() {
7
+ return {
8
+ ...this.parent?.(),
9
+ multicolor: true,
10
+ HTMLAttributes: {},
11
+ };
12
+ },
13
+
14
+ parseHTML() {
15
+ return [
16
+ {
17
+ ...this.parent?.(),
18
+ style: 'background-color',
19
+ getAttrs: (style) => {
20
+ return {
21
+ color: style,
22
+ };
23
+ },
24
+ },
25
+ ];
26
+ },
27
+ });
@@ -0,0 +1,5 @@
1
+ import { CustomHighlight } from './highlight';
2
+
3
+ export * from './highlight';
4
+
5
+ export default CustomHighlight;