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

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 (47) hide show
  1. package/README.md +63 -0
  2. package/package.json +5 -2
  3. package/.turbo/turbo-build.log +0 -58
  4. package/.turbo/turbo-format.log +0 -142
  5. package/.turbo/turbo-lint.log +0 -5
  6. package/src/abbr/abbr.ts +0 -57
  7. package/src/abbr/index.ts +0 -5
  8. package/src/alert/alert.ts +0 -46
  9. package/src/alert/index.ts +0 -5
  10. package/src/attachment/attachment.ts +0 -113
  11. package/src/attachment/index.ts +0 -5
  12. package/src/audio/audio.ts +0 -81
  13. package/src/audio/index.ts +0 -5
  14. package/src/font-size/font-size.ts +0 -74
  15. package/src/font-size/index.ts +0 -5
  16. package/src/heading/heading.ts +0 -90
  17. package/src/heading/index.ts +0 -5
  18. package/src/highlight/highlight.ts +0 -27
  19. package/src/highlight/index.ts +0 -5
  20. package/src/hyperlink/hyperlink.ts +0 -92
  21. package/src/hyperlink/index.ts +0 -5
  22. package/src/iframe/iframe.ts +0 -112
  23. package/src/iframe/index.ts +0 -5
  24. package/src/image/custom-image.ts +0 -226
  25. package/src/image/index.ts +0 -5
  26. package/src/index.ts +0 -19
  27. package/src/line-height/index.ts +0 -5
  28. package/src/line-height/line-height.ts +0 -37
  29. package/src/linker/index.ts +0 -5
  30. package/src/linker/linker.ts +0 -153
  31. package/src/mathjax/index.ts +0 -5
  32. package/src/mathjax/mathjax.ts +0 -55
  33. package/src/paragraph/index.ts +0 -5
  34. package/src/paragraph/paragraph.ts +0 -25
  35. package/src/speech-recognition/index.ts +0 -5
  36. package/src/speech-recognition/speech-recognition.ts +0 -123
  37. package/src/speech-synthesis/index.ts +0 -5
  38. package/src/speech-synthesis/speech-synthesis.ts +0 -52
  39. package/src/table-cell/index.ts +0 -5
  40. package/src/table-cell/table-cell.ts +0 -28
  41. package/src/transform/html-to-json/html-to-json.ts +0 -5
  42. package/src/transform/index.ts +0 -4
  43. package/src/transform/json-to-html/json-to-html.ts +0 -5
  44. package/src/video/index.ts +0 -5
  45. package/src/video/video.ts +0 -173
  46. package/tsconfig.json +0 -20
  47. package/vite.config.ts +0 -46
package/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # Edifice Rich Text Editor Extensions
2
+
3
+ ![npm](https://img.shields.io/npm/v/@edifice.io/tiptap-extensions?style=flat-square)
4
+ ![bundlephobia](https://img.shields.io/bundlephobia/min/@edifice.io/tiptap-extensions?style=flat-square)
5
+
6
+ Extensions based on Tiptap Editor
7
+
8
+ ## Getting Started
9
+
10
+ ### Install
11
+
12
+ ```bash
13
+ pnpm add @edifice.io/tiptap-extensions
14
+ ```
15
+
16
+ ### Imports
17
+
18
+ #### Global
19
+
20
+ ```bash
21
+ import { Alert, Video } from "@edifice.io/tiptap-extensions"
22
+ ```
23
+
24
+ #### Sub-imports
25
+
26
+ ```bash
27
+ import { Alert } from "@edifice.io/tiptap-extensions/alert"
28
+ ```
29
+
30
+ ## New extension
31
+
32
+ To create a new extension, please do as follow :
33
+
34
+ - Create a subfolder in `src` with the name of the extension (e.g: `my-extension`)
35
+
36
+ ```
37
+ my-extension
38
+ ```
39
+
40
+ - Create two files inside the new folder:
41
+ - `index.ts`
42
+ - `my-extension.ts`
43
+
44
+ ```
45
+ my-extension
46
+ └── my-extension.ts
47
+ └── index.ts
48
+ ```
49
+
50
+ - Check one existing extension or refer to this documentation to develop the extension -> [Tiptap](https://tiptap.dev/docs/editor/extensions/custom-extensionsv)
51
+
52
+ - Then, add your extension in the `package.json` sub-exports in alphabetical order
53
+
54
+ ```
55
+ "./my-extension": {
56
+ "import": "./dist/my-extension/my-extension.js",
57
+ "require": "./dist/my-extension/my-extension.cjs"
58
+ }
59
+ ```
60
+
61
+ - Run `pnpm run build` to generate a bundle
62
+
63
+ - Test your extension before committing and pushing to remote
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/tiptap-extensions",
3
- "version": "1.5.16-develop-rc.2",
3
+ "version": "2.0.0-develop-rc.0",
4
4
  "description": "Edifice Rich Text Editor Extensions",
5
5
  "homepage": "https://github.com/edificeio/edifice-ui/tree/main/packages/tiptap/extensions#readme",
6
6
  "bugs": {
@@ -99,6 +99,9 @@
99
99
  "main": "dist/index.cjs",
100
100
  "module": "dist/index.js",
101
101
  "typings": "dist/index.d.ts",
102
+ "files": [
103
+ "dist"
104
+ ],
102
105
  "scripts": {
103
106
  "build": "vite build",
104
107
  "fix": "eslint . --ext ts --report-unused-disable-directives --max-warnings 0",
@@ -129,5 +132,5 @@
129
132
  "publishConfig": {
130
133
  "access": "public"
131
134
  },
132
- "gitHead": "31c5ddef7d29e860f5f034b13cdd62ff2899f730"
135
+ "gitHead": "6f136eacef86c18be3da824cbf7b9b6bea784457"
133
136
  }
@@ -1,58 +0,0 @@
1
-  WARN  Issue while reading "/home/runner/work/edifice-ui/edifice-ui/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
2
-
3
- > @edifice.io/tiptap-extensions@0.0.1 build /home/runner/work/edifice-ui/edifice-ui/packages/tiptap/extensions
4
- > vite build
5
-
6
- vite v5.4.2 building for production...
7
- "build.lib.formats" will be ignored because "build.rollupOptions.output" is already an array format.
8
- transforming...
9
- ✓ 40 modules transformed.
10
- rendering chunks...
11
-
12
- [vite:dts] Start generate declaration files...
13
- computing gzip size...
14
- dist/transform/html-to-json/html-to-json.js 0.20 kB │ gzip: 0.16 kB │ map: 0.38 kB
15
- dist/transform/json-to-html/json-to-html.js 0.20 kB │ gzip: 0.16 kB │ map: 0.38 kB
16
- dist/paragraph/paragraph.js 0.35 kB │ gzip: 0.25 kB │ map: 1.14 kB
17
- dist/highlight/highlight.js 0.59 kB │ gzip: 0.32 kB │ map: 0.95 kB
18
- dist/abbr/abbr.js 0.63 kB │ gzip: 0.31 kB │ map: 1.61 kB
19
- dist/table-cell/table-cell.js 0.70 kB │ gzip: 0.37 kB │ map: 1.38 kB
20
- dist/alert/alert.js 0.77 kB │ gzip: 0.36 kB │ map: 1.52 kB
21
- dist/line-height/line-height.js 0.79 kB │ gzip: 0.39 kB │ map: 1.38 kB
22
- dist/speech-synthesis/speech-synthesis.js 0.81 kB │ gzip: 0.36 kB │ map: 1.98 kB
23
- dist/font-size/font-size.js 1.04 kB │ gzip: 0.47 kB │ map: 2.34 kB
24
- dist/mathjax/mathjax.js 1.12 kB │ gzip: 0.52 kB │ map: 2.33 kB
25
- dist/audio/audio.js 1.23 kB │ gzip: 0.52 kB │ map: 2.84 kB
26
- dist/hyperlink/hyperlink.js 1.49 kB │ gzip: 0.64 kB │ map: 3.34 kB
27
- dist/index.js 1.49 kB │ gzip: 0.51 kB │ map: 0.11 kB
28
- dist/heading/heading.js 1.55 kB │ gzip: 0.66 kB │ map: 3.71 kB
29
- dist/iframe/iframe.js 1.70 kB │ gzip: 0.59 kB │ map: 3.81 kB
30
- dist/attachment/attachment.js 2.00 kB │ gzip: 0.76 kB │ map: 4.23 kB
31
- dist/linker/linker.js 2.22 kB │ gzip: 0.83 kB │ map: 5.62 kB
32
- dist/speech-recognition/speech-recognition.js 2.29 kB │ gzip: 0.82 kB │ map: 5.24 kB
33
- dist/video/video.js 3.04 kB │ gzip: 0.95 kB │ map: 6.73 kB
34
- dist/image/custom-image.js 4.13 kB │ gzip: 1.28 kB │ map: 8.50 kB
35
- [vite:dts] Declaration files built in 3362ms.
36
-
37
- dist/transform/html-to-json/html-to-json.cjs 0.18 kB │ gzip: 0.16 kB │ map: 0.40 kB
38
- dist/transform/json-to-html/json-to-html.cjs 0.18 kB │ gzip: 0.16 kB │ map: 0.40 kB
39
- dist/paragraph/paragraph.cjs 0.37 kB │ gzip: 0.27 kB │ map: 1.10 kB
40
- dist/highlight/highlight.cjs 0.52 kB │ gzip: 0.33 kB │ map: 0.86 kB
41
- dist/abbr/abbr.cjs 0.53 kB │ gzip: 0.32 kB │ map: 1.53 kB
42
- dist/alert/alert.cjs 0.59 kB │ gzip: 0.37 kB │ map: 1.34 kB
43
- dist/line-height/line-height.cjs 0.62 kB │ gzip: 0.39 kB │ map: 1.27 kB
44
- dist/table-cell/table-cell.cjs 0.62 kB │ gzip: 0.37 kB │ map: 1.30 kB
45
- dist/speech-synthesis/speech-synthesis.cjs 0.79 kB │ gzip: 0.38 kB │ map: 1.93 kB
46
- dist/font-size/font-size.cjs 0.80 kB │ gzip: 0.46 kB │ map: 2.22 kB
47
- dist/hyperlink/hyperlink.cjs 0.92 kB │ gzip: 0.48 kB │ map: 3.13 kB
48
- dist/mathjax/mathjax.cjs 0.95 kB │ gzip: 0.51 kB │ map: 2.18 kB
49
- dist/audio/audio.cjs 0.96 kB │ gzip: 0.51 kB │ map: 2.65 kB
50
- dist/iframe/iframe.cjs 1.25 kB │ gzip: 0.57 kB │ map: 3.52 kB
51
- dist/heading/heading.cjs 1.28 kB │ gzip: 0.64 kB │ map: 3.58 kB
52
- dist/attachment/attachment.cjs 1.45 kB │ gzip: 0.69 kB │ map: 3.92 kB
53
- dist/linker/linker.cjs 1.57 kB │ gzip: 0.75 kB │ map: 5.23 kB
54
- dist/index.cjs 1.87 kB │ gzip: 0.60 kB │ map: 0.09 kB
55
- dist/speech-recognition/speech-recognition.cjs 1.90 kB │ gzip: 0.79 kB │ map: 5.09 kB
56
- dist/video/video.cjs 2.31 kB │ gzip: 0.90 kB │ map: 6.32 kB
57
- dist/image/custom-image.cjs 2.90 kB │ gzip: 1.17 kB │ map: 7.95 kB
58
- ✓ built in 4.09s
@@ -1,142 +0,0 @@
1
-  WARN  Issue while reading "/home/runner/work/edifice-ui/edifice-ui/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
2
-
3
- > @edifice.io/tiptap-extensions@1.5.16-develop-rc.2 format /home/runner/work/edifice-ui/edifice-ui/packages/tiptap/extensions
4
- > pnpm run format:write && pnpm run format:check
5
-
6
-  WARN  Issue while reading "/home/runner/work/edifice-ui/edifice-ui/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
7
-
8
- > @edifice.io/tiptap-extensions@1.5.16-develop-rc.2 format:write /home/runner/work/edifice-ui/edifice-ui/packages/tiptap/extensions
9
- > npx prettier --write .
10
-
11
- dist/abbr/abbr.cjs 178ms
12
- dist/abbr/abbr.d.ts 596ms
13
- dist/abbr/abbr.js 29ms
14
- dist/abbr/index.d.ts 9ms (unchanged)
15
- dist/alert/alert.cjs 23ms
16
- dist/alert/alert.d.ts 29ms (unchanged)
17
- dist/alert/alert.js 35ms
18
- dist/alert/index.d.ts 3ms (unchanged)
19
- dist/attachment/attachment.cjs 79ms
20
- dist/attachment/attachment.d.ts 47ms
21
- dist/attachment/attachment.js 70ms
22
- dist/attachment/index.d.ts 2ms (unchanged)
23
- dist/audio/audio.cjs 45ms
24
- dist/audio/audio.d.ts 74ms
25
- dist/audio/audio.js 35ms
26
- dist/audio/index.d.ts 17ms (unchanged)
27
- dist/font-size/font-size.cjs 56ms
28
- dist/font-size/font-size.d.ts 21ms
29
- dist/font-size/font-size.js 22ms
30
- dist/font-size/index.d.ts 3ms (unchanged)
31
- dist/heading/heading.cjs 21ms
32
- dist/heading/heading.d.ts 41ms
33
- dist/heading/heading.js 18ms
34
- dist/heading/index.d.ts 2ms (unchanged)
35
- dist/highlight/highlight.cjs 5ms
36
- dist/highlight/highlight.d.ts 4ms
37
- dist/highlight/highlight.js 5ms
38
- dist/highlight/index.d.ts 2ms (unchanged)
39
- dist/hyperlink/hyperlink.cjs 11ms
40
- dist/hyperlink/hyperlink.d.ts 9ms
41
- dist/hyperlink/hyperlink.js 12ms
42
- dist/hyperlink/index.d.ts 2ms (unchanged)
43
- dist/iframe/iframe.cjs 52ms
44
- dist/iframe/iframe.d.ts 5ms
45
- dist/iframe/iframe.js 21ms
46
- dist/iframe/index.d.ts 2ms (unchanged)
47
- dist/image/custom-image.cjs 39ms
48
- dist/image/custom-image.d.ts 6ms
49
- dist/image/custom-image.js 35ms
50
- dist/image/index.d.ts 2ms (unchanged)
51
- dist/index.cjs 9ms
52
- dist/index.d.ts 3ms (unchanged)
53
- dist/index.js 4ms
54
- dist/line-height/index.d.ts 2ms (unchanged)
55
- dist/line-height/line-height.cjs 4ms
56
- dist/line-height/line-height.d.ts 3ms (unchanged)
57
- dist/line-height/line-height.js 9ms
58
- dist/linker/index.d.ts 5ms (unchanged)
59
- dist/linker/linker.cjs 20ms
60
- dist/linker/linker.d.ts 10ms
61
- dist/linker/linker.js 9ms
62
- dist/mathjax/index.d.ts 2ms (unchanged)
63
- dist/mathjax/mathjax.cjs 8ms
64
- dist/mathjax/mathjax.d.ts 4ms (unchanged)
65
- dist/mathjax/mathjax.js 6ms
66
- dist/paragraph/index.d.ts 2ms (unchanged)
67
- dist/paragraph/paragraph.cjs 3ms
68
- dist/paragraph/paragraph.d.ts 3ms
69
- dist/paragraph/paragraph.js 3ms
70
- dist/speech-recognition/index.d.ts 1ms (unchanged)
71
- dist/speech-recognition/speech-recognition.cjs 24ms
72
- dist/speech-recognition/speech-recognition.d.ts 18ms
73
- dist/speech-recognition/speech-recognition.js 24ms
74
- dist/speech-synthesis/index.d.ts 1ms (unchanged)
75
- dist/speech-synthesis/speech-synthesis.cjs 6ms
76
- dist/speech-synthesis/speech-synthesis.d.ts 5ms
77
- dist/speech-synthesis/speech-synthesis.js 5ms
78
- dist/table-cell/index.d.ts 2ms (unchanged)
79
- dist/table-cell/table-cell.cjs 5ms
80
- dist/table-cell/table-cell.d.ts 7ms
81
- dist/table-cell/table-cell.js 4ms
82
- dist/transform/html-to-json/html-to-json.cjs 2ms
83
- dist/transform/html-to-json/html-to-json.d.ts 2ms
84
- dist/transform/html-to-json/html-to-json.js 2ms
85
- dist/transform/index.d.ts 1ms (unchanged)
86
- dist/transform/json-to-html/json-to-html.cjs 2ms
87
- dist/transform/json-to-html/json-to-html.d.ts 7ms (unchanged)
88
- dist/transform/json-to-html/json-to-html.js 2ms
89
- dist/video/index.d.ts 9ms (unchanged)
90
- dist/video/video.cjs 19ms
91
- dist/video/video.d.ts 5ms
92
- dist/video/video.js 21ms
93
- package.json 10ms (unchanged)
94
- src/abbr/abbr.ts 38ms (unchanged)
95
- src/abbr/index.ts 3ms (unchanged)
96
- src/alert/alert.ts 7ms (unchanged)
97
- src/alert/index.ts 1ms (unchanged)
98
- src/attachment/attachment.ts 61ms (unchanged)
99
- src/attachment/index.ts 2ms (unchanged)
100
- src/audio/audio.ts 26ms (unchanged)
101
- src/audio/index.ts 13ms (unchanged)
102
- src/font-size/font-size.ts 22ms (unchanged)
103
- src/font-size/index.ts 11ms (unchanged)
104
- src/heading/heading.ts 43ms (unchanged)
105
- src/heading/index.ts 1ms (unchanged)
106
- src/highlight/highlight.ts 4ms (unchanged)
107
- src/highlight/index.ts 2ms (unchanged)
108
- src/hyperlink/hyperlink.ts 13ms (unchanged)
109
- src/hyperlink/index.ts 2ms (unchanged)
110
- src/iframe/iframe.ts 37ms (unchanged)
111
- src/iframe/index.ts 7ms (unchanged)
112
- src/image/custom-image.ts 99ms (unchanged)
113
- src/image/index.ts 2ms (unchanged)
114
- src/index.ts 6ms (unchanged)
115
- src/line-height/index.ts 2ms (unchanged)
116
- src/line-height/line-height.ts 5ms (unchanged)
117
- src/linker/index.ts 1ms (unchanged)
118
- src/linker/linker.ts 22ms (unchanged)
119
- src/mathjax/index.ts 1ms (unchanged)
120
- src/mathjax/mathjax.ts 25ms (unchanged)
121
- src/paragraph/index.ts 1ms (unchanged)
122
- src/paragraph/paragraph.ts 4ms (unchanged)
123
- src/speech-recognition/index.ts 2ms (unchanged)
124
- src/speech-recognition/speech-recognition.ts 38ms (unchanged)
125
- src/speech-synthesis/index.ts 1ms (unchanged)
126
- src/speech-synthesis/speech-synthesis.ts 16ms (unchanged)
127
- src/table-cell/index.ts 2ms (unchanged)
128
- src/table-cell/table-cell.ts 7ms (unchanged)
129
- src/transform/html-to-json/html-to-json.ts 2ms (unchanged)
130
- src/transform/index.ts 1ms (unchanged)
131
- src/transform/json-to-html/json-to-html.ts 2ms (unchanged)
132
- src/video/index.ts 1ms (unchanged)
133
- src/video/video.ts 41ms (unchanged)
134
- tsconfig.json 4ms (unchanged)
135
- vite.config.ts 46ms (unchanged)
136
-  WARN  Issue while reading "/home/runner/work/edifice-ui/edifice-ui/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
137
-
138
- > @edifice.io/tiptap-extensions@1.5.16-develop-rc.2 format:check /home/runner/work/edifice-ui/edifice-ui/packages/tiptap/extensions
139
- > npx prettier --check .
140
-
141
- Checking formatting...
142
- All matched files use Prettier code style!
@@ -1,5 +0,0 @@
1
-  WARN  Issue while reading "/home/runner/work/edifice-ui/edifice-ui/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
2
-
3
- > @edifice.io/tiptap-extensions@1.5.16-develop-rc.2 lint /home/runner/work/edifice-ui/edifice-ui/packages/tiptap/extensions
4
- > eslint "**/*.ts"
5
-
package/src/abbr/abbr.ts DELETED
@@ -1,57 +0,0 @@
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
- });
package/src/abbr/index.ts DELETED
@@ -1,5 +0,0 @@
1
- import { Abbr } from './abbr';
2
-
3
- export * from './abbr';
4
-
5
- export default Abbr;
@@ -1,46 +0,0 @@
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
- });
@@ -1,5 +0,0 @@
1
- import { Alert } from './alert';
2
-
3
- export * from './alert';
4
-
5
- export default Alert;
@@ -1,113 +0,0 @@
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
- });
@@ -1,5 +0,0 @@
1
- import { Attachment } from './attachment';
2
-
3
- export * from './attachment';
4
-
5
- export default Attachment;
@@ -1,81 +0,0 @@
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
- });
@@ -1,5 +0,0 @@
1
- import { Audio } from './audio';
2
-
3
- export * from './audio';
4
-
5
- export default Audio;