@akinon/ui-editor 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/tiptap/components/__tests__/html-code-viewer.test.js +79 -3
- package/dist/cjs/tiptap/components/__tests__/html-code-viewer.test.tsx +106 -3
- package/dist/cjs/tiptap/components/__tests__/tiptap.test.js +42 -4
- package/dist/cjs/tiptap/components/__tests__/tiptap.test.tsx +57 -7
- package/dist/cjs/tiptap/components/format-bubble-menu.d.ts.map +1 -1
- package/dist/cjs/tiptap/components/format-bubble-menu.js +6 -5
- package/dist/cjs/tiptap/components/html-code-viewer.d.ts +2 -1
- package/dist/cjs/tiptap/components/html-code-viewer.d.ts.map +1 -1
- package/dist/cjs/tiptap/components/html-code-viewer.js +62 -22
- package/dist/cjs/tiptap/components/image-upload-placeholder.d.ts.map +1 -1
- package/dist/cjs/tiptap/components/image-upload-placeholder.js +5 -2
- package/dist/cjs/tiptap/components/secure-script-component.d.ts.map +1 -1
- package/dist/cjs/tiptap/components/secure-script-component.js +2 -5
- package/dist/cjs/tiptap/components/tiptap.d.ts +1 -1
- package/dist/cjs/tiptap/components/tiptap.d.ts.map +1 -1
- package/dist/cjs/tiptap/components/tiptap.js +84 -56
- package/dist/cjs/tiptap/constants/editor-config.d.ts +10 -1
- package/dist/cjs/tiptap/constants/editor-config.d.ts.map +1 -1
- package/dist/cjs/tiptap/constants/editor-config.js +11 -2
- package/dist/cjs/tiptap/constants/html-elements.d.ts +1 -0
- package/dist/cjs/tiptap/constants/html-elements.d.ts.map +1 -1
- package/dist/cjs/tiptap/constants/html-elements.js +2 -1
- package/dist/cjs/tiptap/extensions/comment-extension.d.ts.map +1 -1
- package/dist/cjs/tiptap/extensions/comment-extension.js +3 -3
- package/dist/cjs/tiptap/extensions/custom-table-cell-extension.d.ts.map +1 -1
- package/dist/cjs/tiptap/extensions/custom-table-cell-extension.js +11 -2
- package/dist/cjs/tiptap/extensions/custom-table-header-extension.d.ts.map +1 -1
- package/dist/cjs/tiptap/extensions/custom-table-header-extension.js +11 -2
- package/dist/cjs/tiptap/extensions/html-block-extension.d.ts.map +1 -1
- package/dist/cjs/tiptap/extensions/html-block-extension.js +11 -14
- package/dist/cjs/tiptap/extensions/html-inline-extension.d.ts.map +1 -1
- package/dist/cjs/tiptap/extensions/html-inline-extension.js +11 -14
- package/dist/cjs/tiptap/types/index.d.ts +12 -5
- package/dist/cjs/tiptap/types/index.d.ts.map +1 -1
- package/dist/cjs/tiptap/utils/__tests__/clean-html.test.d.ts +2 -0
- package/dist/cjs/tiptap/utils/__tests__/clean-html.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/__tests__/clean-html.test.js +93 -0
- package/dist/cjs/tiptap/utils/__tests__/clean-html.test.ts +129 -0
- package/dist/cjs/tiptap/utils/__tests__/data-attributes-helper.test.d.ts +2 -0
- package/dist/cjs/tiptap/utils/__tests__/data-attributes-helper.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/__tests__/data-attributes-helper.test.js +105 -0
- package/dist/cjs/tiptap/utils/__tests__/data-attributes-helper.test.ts +148 -0
- package/dist/cjs/tiptap/utils/__tests__/index.test.js +0 -2
- package/dist/cjs/tiptap/utils/__tests__/index.test.ts +0 -2
- package/dist/cjs/tiptap/utils/__tests__/prettier-format.test.d.ts +2 -0
- package/dist/cjs/tiptap/utils/__tests__/prettier-format.test.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/__tests__/prettier-format.test.js +33 -0
- package/dist/cjs/tiptap/utils/__tests__/prettier-format.test.ts +49 -0
- package/dist/cjs/tiptap/utils/__tests__/tiptap-extensions.test.js +157 -0
- package/dist/cjs/tiptap/utils/__tests__/tiptap-extensions.test.ts +234 -0
- package/dist/cjs/tiptap/utils/clean-html.d.ts +9 -0
- package/dist/cjs/tiptap/utils/clean-html.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/clean-html.js +75 -0
- package/dist/cjs/tiptap/utils/data-attributes-helper.d.ts +20 -0
- package/dist/cjs/tiptap/utils/data-attributes-helper.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/data-attributes-helper.js +68 -0
- package/dist/cjs/tiptap/utils/index.d.ts +3 -2
- package/dist/cjs/tiptap/utils/index.d.ts.map +1 -1
- package/dist/cjs/tiptap/utils/index.js +3 -2
- package/dist/cjs/tiptap/utils/prettier-format.d.ts +8 -0
- package/dist/cjs/tiptap/utils/prettier-format.d.ts.map +1 -0
- package/dist/cjs/tiptap/utils/prettier-format.js +26 -0
- package/dist/cjs/tiptap/utils/tiptap-extensions.d.ts.map +1 -1
- package/dist/cjs/tiptap/utils/tiptap-extensions.js +134 -14
- package/dist/esm/tiptap/components/__tests__/html-code-viewer.test.js +79 -3
- package/dist/esm/tiptap/components/__tests__/html-code-viewer.test.tsx +106 -3
- package/dist/esm/tiptap/components/__tests__/tiptap.test.js +42 -4
- package/dist/esm/tiptap/components/__tests__/tiptap.test.tsx +57 -7
- package/dist/esm/tiptap/components/format-bubble-menu.d.ts.map +1 -1
- package/dist/esm/tiptap/components/format-bubble-menu.js +6 -5
- package/dist/esm/tiptap/components/html-code-viewer.d.ts +2 -1
- package/dist/esm/tiptap/components/html-code-viewer.d.ts.map +1 -1
- package/dist/esm/tiptap/components/html-code-viewer.js +62 -22
- package/dist/esm/tiptap/components/image-upload-placeholder.d.ts.map +1 -1
- package/dist/esm/tiptap/components/image-upload-placeholder.js +5 -2
- package/dist/esm/tiptap/components/secure-script-component.d.ts.map +1 -1
- package/dist/esm/tiptap/components/secure-script-component.js +2 -5
- package/dist/esm/tiptap/components/tiptap.d.ts +1 -1
- package/dist/esm/tiptap/components/tiptap.d.ts.map +1 -1
- package/dist/esm/tiptap/components/tiptap.js +84 -56
- package/dist/esm/tiptap/constants/editor-config.d.ts +10 -1
- package/dist/esm/tiptap/constants/editor-config.d.ts.map +1 -1
- package/dist/esm/tiptap/constants/editor-config.js +11 -2
- package/dist/esm/tiptap/constants/html-elements.d.ts +1 -0
- package/dist/esm/tiptap/constants/html-elements.d.ts.map +1 -1
- package/dist/esm/tiptap/constants/html-elements.js +2 -1
- package/dist/esm/tiptap/extensions/comment-extension.d.ts.map +1 -1
- package/dist/esm/tiptap/extensions/comment-extension.js +3 -3
- package/dist/esm/tiptap/extensions/custom-table-cell-extension.d.ts.map +1 -1
- package/dist/esm/tiptap/extensions/custom-table-cell-extension.js +11 -2
- package/dist/esm/tiptap/extensions/custom-table-header-extension.d.ts.map +1 -1
- package/dist/esm/tiptap/extensions/custom-table-header-extension.js +11 -2
- package/dist/esm/tiptap/extensions/html-block-extension.d.ts.map +1 -1
- package/dist/esm/tiptap/extensions/html-block-extension.js +11 -14
- package/dist/esm/tiptap/extensions/html-inline-extension.d.ts.map +1 -1
- package/dist/esm/tiptap/extensions/html-inline-extension.js +11 -14
- package/dist/esm/tiptap/types/index.d.ts +12 -5
- package/dist/esm/tiptap/types/index.d.ts.map +1 -1
- package/dist/esm/tiptap/utils/__tests__/clean-html.test.d.ts +2 -0
- package/dist/esm/tiptap/utils/__tests__/clean-html.test.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/__tests__/clean-html.test.js +93 -0
- package/dist/esm/tiptap/utils/__tests__/clean-html.test.ts +129 -0
- package/dist/esm/tiptap/utils/__tests__/data-attributes-helper.test.d.ts +2 -0
- package/dist/esm/tiptap/utils/__tests__/data-attributes-helper.test.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/__tests__/data-attributes-helper.test.js +105 -0
- package/dist/esm/tiptap/utils/__tests__/data-attributes-helper.test.ts +148 -0
- package/dist/esm/tiptap/utils/__tests__/index.test.js +0 -2
- package/dist/esm/tiptap/utils/__tests__/index.test.ts +0 -2
- package/dist/esm/tiptap/utils/__tests__/prettier-format.test.d.ts +2 -0
- package/dist/esm/tiptap/utils/__tests__/prettier-format.test.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/__tests__/prettier-format.test.js +33 -0
- package/dist/esm/tiptap/utils/__tests__/prettier-format.test.ts +49 -0
- package/dist/esm/tiptap/utils/__tests__/tiptap-extensions.test.js +157 -0
- package/dist/esm/tiptap/utils/__tests__/tiptap-extensions.test.ts +234 -0
- package/dist/esm/tiptap/utils/clean-html.d.ts +9 -0
- package/dist/esm/tiptap/utils/clean-html.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/clean-html.js +75 -0
- package/dist/esm/tiptap/utils/data-attributes-helper.d.ts +20 -0
- package/dist/esm/tiptap/utils/data-attributes-helper.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/data-attributes-helper.js +68 -0
- package/dist/esm/tiptap/utils/index.d.ts +3 -2
- package/dist/esm/tiptap/utils/index.d.ts.map +1 -1
- package/dist/esm/tiptap/utils/index.js +3 -2
- package/dist/esm/tiptap/utils/prettier-format.d.ts +8 -0
- package/dist/esm/tiptap/utils/prettier-format.d.ts.map +1 -0
- package/dist/esm/tiptap/utils/prettier-format.js +26 -0
- package/dist/esm/tiptap/utils/tiptap-extensions.d.ts.map +1 -1
- package/dist/esm/tiptap/utils/tiptap-extensions.js +134 -14
- package/package.json +13 -12
|
@@ -5,25 +5,28 @@ import { generateJSON } from '@tiptap/html';
|
|
|
5
5
|
import { EditorContent, useEditor } from '@tiptap/react';
|
|
6
6
|
import { ConfigProvider } from 'antd';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
|
-
import React, { useEffect } from 'react';
|
|
8
|
+
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
9
9
|
import { DragHandleIcon } from '../assets/icons';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { EDITOR_CONTENT_HEIGHT, getTableCellDefaults, getTableHeaderDefaults } from '../constants';
|
|
11
|
+
import { cleanDuplicateSpans, getExtensions } from '../utils';
|
|
12
12
|
import { FormatBubbleMenu } from './format-bubble-menu';
|
|
13
13
|
import { HtmlCodeViewer } from './html-code-viewer';
|
|
14
14
|
import { MenuBar } from './menu-bar';
|
|
15
15
|
import { TableBubbleMenu } from './table-bubble-menu';
|
|
16
|
-
export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classNames, toolbar, defaultSourceMode = true, placeholder }) => {
|
|
16
|
+
export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classNames, toolbar, defaultSourceMode = true, placeholder, contentHeight = EDITOR_CONTENT_HEIGHT }) => {
|
|
17
17
|
var _a;
|
|
18
18
|
const isSourceModeButtonHidden = (_a = toolbar === null || toolbar === void 0 ? void 0 : toolbar.hiddenButtons) === null || _a === void 0 ? void 0 : _a.includes('sourceMode');
|
|
19
19
|
const [isSourceMode, setIsSourceMode] = React.useState(isSourceModeButtonHidden ? false : defaultSourceMode);
|
|
20
|
-
const
|
|
20
|
+
const initialContent = React.useMemo(() => {
|
|
21
|
+
return defaultValue !== undefined ? defaultValue : value || '';
|
|
22
|
+
}, [defaultValue, value]);
|
|
23
|
+
const [rawHTML, setRawHTML] = React.useState(initialContent);
|
|
21
24
|
const { getPrefixCls, theme } = React.useContext(ConfigProvider.ConfigContext);
|
|
22
25
|
const { token, hashId } = useToken();
|
|
23
26
|
const customTokens = getSafeCustomTokens(theme);
|
|
24
27
|
const colors = (theme === null || theme === void 0 ? void 0 : theme.colors) || {};
|
|
25
28
|
const baseCls = getPrefixCls('tiptap-editor');
|
|
26
|
-
const handleEditorClick = (_view, _pos, event) => {
|
|
29
|
+
const handleEditorClick = useCallback((_view, _pos, event) => {
|
|
27
30
|
const target = event.target;
|
|
28
31
|
const anchor = target.closest('a');
|
|
29
32
|
if (anchor) {
|
|
@@ -31,12 +34,13 @@ export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classN
|
|
|
31
34
|
return true;
|
|
32
35
|
}
|
|
33
36
|
return false;
|
|
34
|
-
};
|
|
37
|
+
}, []);
|
|
35
38
|
const extensions = React.useMemo(() => getExtensions(placeholder), [placeholder]);
|
|
36
|
-
const editorProps =
|
|
39
|
+
const editorProps = useMemo(() => ({
|
|
37
40
|
handleClick: handleEditorClick
|
|
38
|
-
}), []);
|
|
39
|
-
const onChangeRef =
|
|
41
|
+
}), [handleEditorClick]);
|
|
42
|
+
const onChangeRef = useRef(onChange);
|
|
43
|
+
const prevValueRef = useRef(undefined);
|
|
40
44
|
useEffect(() => {
|
|
41
45
|
onChangeRef.current = onChange;
|
|
42
46
|
}, [onChange]);
|
|
@@ -59,51 +63,77 @@ export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classN
|
|
|
59
63
|
}
|
|
60
64
|
}, [editor, readOnly]);
|
|
61
65
|
useEffect(() => {
|
|
62
|
-
if (editor &&
|
|
66
|
+
if (editor &&
|
|
67
|
+
value !== undefined &&
|
|
68
|
+
value !== prevValueRef.current &&
|
|
69
|
+
value !== editor.getHTML()) {
|
|
63
70
|
editor.commands.setContent(value);
|
|
71
|
+
if (isSourceMode) {
|
|
72
|
+
setRawHTML(value);
|
|
73
|
+
}
|
|
74
|
+
prevValueRef.current = value;
|
|
64
75
|
}
|
|
65
|
-
}, [editor, value]);
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
if (editor && isSourceMode && !rawHTML) {
|
|
68
|
-
setRawHTML(formatHtml(editor.getHTML()));
|
|
69
|
-
}
|
|
70
|
-
}, [editor, isSourceMode, rawHTML]);
|
|
76
|
+
}, [editor, value, isSourceMode]);
|
|
71
77
|
{
|
|
72
78
|
/* Cleans the HTML by removing the safe 'text/inert' type from script tags,
|
|
73
79
|
making them executable again for the client/production usage. */
|
|
74
80
|
}
|
|
75
|
-
const getCleanHtml = () => {
|
|
81
|
+
const getCleanHtml = useCallback(() => {
|
|
82
|
+
/* v8 ignore next */
|
|
83
|
+
if (!editor)
|
|
84
|
+
return '';
|
|
76
85
|
const safeHtml = editor.getHTML();
|
|
77
86
|
const cleanHtml = safeHtml.replace(/ type="text\/inert"/g, '');
|
|
78
87
|
return cleanHtml;
|
|
79
|
-
};
|
|
80
|
-
const toggleSource = () => {
|
|
88
|
+
}, [editor]);
|
|
89
|
+
const toggleSource = useCallback(() => {
|
|
90
|
+
/* v8 ignore next */
|
|
91
|
+
if (!editor)
|
|
92
|
+
return;
|
|
81
93
|
if (isSourceMode) {
|
|
82
|
-
|
|
94
|
+
// Clean duplicate spans before setting content to prevent accumulation
|
|
95
|
+
const cleanedHTML = cleanDuplicateSpans(rawHTML);
|
|
96
|
+
editor.commands.setContent(cleanedHTML, {
|
|
83
97
|
emitUpdate: false
|
|
84
98
|
});
|
|
85
99
|
editor.commands.blur();
|
|
100
|
+
editor.commands.blur();
|
|
86
101
|
}
|
|
87
102
|
else {
|
|
88
|
-
|
|
103
|
+
const html = editor.getHTML().replace(/ type="text\/inert"/g, '');
|
|
104
|
+
setRawHTML(cleanDuplicateSpans(html));
|
|
89
105
|
}
|
|
90
106
|
setIsSourceMode(!isSourceMode);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
|
|
107
|
+
}, [editor, isSourceMode, rawHTML]);
|
|
108
|
+
// Debounced parent onChange - expensive operations
|
|
109
|
+
const debouncedParentOnChange = useRef(null);
|
|
110
|
+
const handleSourceChange = useCallback((val) => {
|
|
94
111
|
setRawHTML(val);
|
|
95
|
-
(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
112
|
+
if (debouncedParentOnChange.current) {
|
|
113
|
+
clearTimeout(debouncedParentOnChange.current);
|
|
114
|
+
}
|
|
115
|
+
debouncedParentOnChange.current = setTimeout(() => {
|
|
116
|
+
var _a;
|
|
117
|
+
(_a = onChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onChangeRef, {
|
|
118
|
+
html: val,
|
|
119
|
+
json: generateJSON(val, extensions)
|
|
120
|
+
});
|
|
121
|
+
}, 300);
|
|
122
|
+
}, [extensions]);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
return () => {
|
|
125
|
+
if (debouncedParentOnChange.current) {
|
|
126
|
+
clearTimeout(debouncedParentOnChange.current);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}, []);
|
|
100
130
|
const useStyle = useStyleRegister({
|
|
101
131
|
token: token,
|
|
102
|
-
path: ['TiptapEditor'],
|
|
132
|
+
path: ['TiptapEditor', String(contentHeight)],
|
|
103
133
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
134
|
theme: theme
|
|
105
135
|
}, () => {
|
|
106
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
136
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
107
137
|
const prefixCls = `:where(.${hashId}).${baseCls}`;
|
|
108
138
|
const tableCellDefaults = getTableCellDefaults(colors);
|
|
109
139
|
const tableHeaderDefaults = getTableHeaderDefaults(colors);
|
|
@@ -112,13 +142,12 @@ export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classN
|
|
|
112
142
|
width: '100%'
|
|
113
143
|
},
|
|
114
144
|
[`${prefixCls} .${baseCls}__content`]: {
|
|
115
|
-
marginTop: '10px',
|
|
116
145
|
backgroundColor: (_a = colors.ebonyClay) === null || _a === void 0 ? void 0 : _a['475'],
|
|
146
|
+
border: `${customTokens.border.borderWidthThick} ${customTokens.border.borderSolid} ${(_b = colors.ebonyClay) === null || _b === void 0 ? void 0 : _b['550']}`,
|
|
147
|
+
borderTop: 'none',
|
|
117
148
|
outline: 'none',
|
|
118
|
-
minHeight:
|
|
119
|
-
maxHeight:
|
|
120
|
-
width: '100%',
|
|
121
|
-
maxWidth: '100%',
|
|
149
|
+
minHeight: `${contentHeight}px`,
|
|
150
|
+
maxHeight: `${contentHeight}px`,
|
|
122
151
|
borderBottomLeftRadius: '5px',
|
|
123
152
|
borderBottomRightRadius: '5px',
|
|
124
153
|
overflowY: 'auto',
|
|
@@ -142,19 +171,19 @@ export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classN
|
|
|
142
171
|
letterSpacing: '0.5px'
|
|
143
172
|
},
|
|
144
173
|
[`${prefixCls} .${baseCls}__content > .tiptap pre`]: {
|
|
145
|
-
backgroundColor: (
|
|
146
|
-
color: (
|
|
147
|
-
border: `1px solid ${(
|
|
174
|
+
backgroundColor: (_c = colors.indigo) === null || _c === void 0 ? void 0 : _c['50-05'],
|
|
175
|
+
color: (_d = colors.neutral) === null || _d === void 0 ? void 0 : _d['60-88'],
|
|
176
|
+
border: `1px solid ${(_e = colors.indigo) === null || _e === void 0 ? void 0 : _e['100-11']}`,
|
|
148
177
|
padding: '2px 6px',
|
|
149
178
|
borderRadius: '5px',
|
|
150
179
|
margin: '16px 0'
|
|
151
180
|
},
|
|
152
181
|
[`${prefixCls} .${baseCls}__content > .tiptap :not(pre) code`]: {
|
|
153
|
-
backgroundColor: (
|
|
154
|
-
color: (
|
|
182
|
+
backgroundColor: (_f = colors.indigo) === null || _f === void 0 ? void 0 : _f['50-08'],
|
|
183
|
+
color: (_g = colors.orange) === null || _g === void 0 ? void 0 : _g['300'],
|
|
155
184
|
padding: '5px',
|
|
156
185
|
borderRadius: '4px',
|
|
157
|
-
border: `1px solid ${(
|
|
186
|
+
border: `1px solid ${(_h = colors.indigo) === null || _h === void 0 ? void 0 : _h['100-15']}`,
|
|
158
187
|
fontWeight: customTokens.typography.fontWeightMedium
|
|
159
188
|
},
|
|
160
189
|
[`${prefixCls} .${baseCls}__content > .tiptap[contenteditable='true'] pre code`]: {
|
|
@@ -168,7 +197,7 @@ export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classN
|
|
|
168
197
|
fontWeight: 'normal'
|
|
169
198
|
},
|
|
170
199
|
[`${prefixCls} .${baseCls}__content .tiptap a`]: {
|
|
171
|
-
color: (
|
|
200
|
+
color: (_j = colors.azure) === null || _j === void 0 ? void 0 : _j['500'],
|
|
172
201
|
textDecoration: 'underline',
|
|
173
202
|
cursor: 'pointer'
|
|
174
203
|
},
|
|
@@ -181,7 +210,7 @@ export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classN
|
|
|
181
210
|
marginTop: '12px'
|
|
182
211
|
},
|
|
183
212
|
[`${prefixCls} .${baseCls}__content a:hover`]: {
|
|
184
|
-
color: (
|
|
213
|
+
color: (_k = colors.azure) === null || _k === void 0 ? void 0 : _k['400']
|
|
185
214
|
},
|
|
186
215
|
[`${prefixCls} .${baseCls}__content .tiptap ul:not([data-type=taskList])`]: {
|
|
187
216
|
listStyle: 'disc',
|
|
@@ -205,7 +234,7 @@ export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classN
|
|
|
205
234
|
marginBottom: '16px'
|
|
206
235
|
},
|
|
207
236
|
[`${prefixCls} .${baseCls}__content .tiptap blockquote p`]: {
|
|
208
|
-
borderLeft: `4px solid ${(
|
|
237
|
+
borderLeft: `4px solid ${(_l = colors.neutral) === null || _l === void 0 ? void 0 : _l['600']}`,
|
|
209
238
|
paddingLeft: '0.5rem',
|
|
210
239
|
marginLeft: '0.5rem',
|
|
211
240
|
fontStyle: 'italic'
|
|
@@ -216,11 +245,11 @@ export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classN
|
|
|
216
245
|
width: '100%',
|
|
217
246
|
margin: '16px 0',
|
|
218
247
|
overflow: 'hidden',
|
|
219
|
-
border: `1px solid ${(
|
|
248
|
+
border: `1px solid ${(_m = colors.neutral) === null || _m === void 0 ? void 0 : _m['600']}`
|
|
220
249
|
},
|
|
221
250
|
[`${prefixCls} .${baseCls}__content .tiptap table td`]: {
|
|
222
251
|
minWidth: '1em',
|
|
223
|
-
border: `1px solid ${(
|
|
252
|
+
border: `1px solid ${(_o = colors.neutral) === null || _o === void 0 ? void 0 : _o['600']}`,
|
|
224
253
|
padding: '8px 12px',
|
|
225
254
|
verticalAlign: 'top',
|
|
226
255
|
boxSizing: 'border-box',
|
|
@@ -238,11 +267,11 @@ export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classN
|
|
|
238
267
|
fontWeight: 600,
|
|
239
268
|
textAlign: 'center',
|
|
240
269
|
backgroundColor: tableHeaderDefaults.backgroundColor,
|
|
241
|
-
color: (
|
|
270
|
+
color: (_p = colors.neutral) === null || _p === void 0 ? void 0 : _p['100'],
|
|
242
271
|
fontSize: '14px'
|
|
243
272
|
},
|
|
244
273
|
[`${prefixCls} .${baseCls}__content .tiptap thead`]: {
|
|
245
|
-
borderBottom: `2px solid ${(
|
|
274
|
+
borderBottom: `2px solid ${(_q = colors.azure) === null || _q === void 0 ? void 0 : _q['500']}`
|
|
246
275
|
},
|
|
247
276
|
[`${prefixCls} .${baseCls}__content .tiptap table .selectedCell:after`]: {
|
|
248
277
|
zIndex: 2,
|
|
@@ -252,7 +281,7 @@ export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classN
|
|
|
252
281
|
right: 0,
|
|
253
282
|
top: 0,
|
|
254
283
|
bottom: 0,
|
|
255
|
-
background: (
|
|
284
|
+
background: (_r = colors.indigo) === null || _r === void 0 ? void 0 : _r['300-40'],
|
|
256
285
|
pointerEvents: 'none'
|
|
257
286
|
},
|
|
258
287
|
[`${prefixCls} .${baseCls}__content .tiptap table .column-resize-handle`]: {
|
|
@@ -261,7 +290,7 @@ export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classN
|
|
|
261
290
|
top: 0,
|
|
262
291
|
bottom: '-2px',
|
|
263
292
|
width: '4px',
|
|
264
|
-
backgroundColor: (
|
|
293
|
+
backgroundColor: (_s = colors.azure) === null || _s === void 0 ? void 0 : _s['500'],
|
|
265
294
|
pointerEvents: 'none',
|
|
266
295
|
zIndex: 20
|
|
267
296
|
},
|
|
@@ -274,9 +303,8 @@ export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classN
|
|
|
274
303
|
},
|
|
275
304
|
[`${prefixCls} .source-textarea`]: {
|
|
276
305
|
width: '100%',
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
height: EDITOR_HEIGHT,
|
|
306
|
+
minHeight: `${contentHeight}px`,
|
|
307
|
+
height: `${contentHeight}px`,
|
|
280
308
|
backgroundColor: token.colorBgContainer,
|
|
281
309
|
color: token.colorText,
|
|
282
310
|
fontFamily: 'monospace',
|
|
@@ -307,5 +335,5 @@ export const Tiptap = ({ value, defaultValue, onChange, readOnly = false, classN
|
|
|
307
335
|
React.createElement(TableBubbleMenu, { editor: editor }),
|
|
308
336
|
React.createElement(DragHandle, { editor: editor },
|
|
309
337
|
React.createElement(DragHandleIcon, null)))),
|
|
310
|
-
isSourceMode && editor ? (React.createElement(HtmlCodeViewer, { value: rawHTML, onChange: handleSourceChange, readOnly: readOnly })) : (React.createElement(EditorContent, { className: clsx(`${baseCls}__content`, classNames === null || classNames === void 0 ? void 0 : classNames.editorContent), editor: editor }))));
|
|
338
|
+
isSourceMode && editor ? (React.createElement(HtmlCodeViewer, { value: rawHTML, onChange: handleSourceChange, contentHeight: contentHeight, readOnly: readOnly, className: clsx(`${baseCls}__source-mode-wrapper`, classNames === null || classNames === void 0 ? void 0 : classNames.editorSourceModeWrapper) })) : (React.createElement(EditorContent, { className: clsx(`${baseCls}__content`, classNames === null || classNames === void 0 ? void 0 : classNames.editorContent), editor: editor }))));
|
|
311
339
|
};
|
|
@@ -31,7 +31,16 @@ export declare const FONT_SIZES: {
|
|
|
31
31
|
export declare const EXTENSION_PRIORITIES: {
|
|
32
32
|
readonly IMAGE_UPLOAD: 1000;
|
|
33
33
|
readonly HORIZONTAL_RULE: 100;
|
|
34
|
+
readonly COMMENT: 1001;
|
|
35
|
+
readonly TABLE_SECTION: 80;
|
|
34
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Represents a content "hole" in Tiptap's renderHTML return value.
|
|
39
|
+
* This special value (0) tells Tiptap where to insert child nodes in the rendered HTML structure.
|
|
40
|
+
*
|
|
41
|
+
* @see https://tiptap.dev/guide/custom-extensions#render-html
|
|
42
|
+
*/
|
|
43
|
+
export declare const TIPTAP_CONTENT_HOLE = 0;
|
|
35
44
|
export declare const TOOLBAR_BUTTON_IDS: {
|
|
36
45
|
readonly BOLD: "bold";
|
|
37
46
|
readonly ITALIC: "italic";
|
|
@@ -85,5 +94,5 @@ export declare const LINK_CONFIG: {
|
|
|
85
94
|
PHISHING_DOMAINS: string[];
|
|
86
95
|
NO_AUTOLINK_DOMAINS: string[];
|
|
87
96
|
};
|
|
88
|
-
export declare const
|
|
97
|
+
export declare const EDITOR_CONTENT_HEIGHT = 400;
|
|
89
98
|
//# sourceMappingURL=editor-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-config.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/constants/editor-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,eAAO,MAAM,aAAa,UAqBzB,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;EAMlB,CAAC;AAEX,eAAO,MAAM,UAAU;IAErB,SAAA,CAAC,aAAa,CAAC,EAAE,CAAC,KAAI;IACtB,SAAA,CAAC,aAAa,CAAC,EAAE,CAAC,KAAI;IACtB,SAAA,CAAC,aAAa,CAAC,EAAE,CAAC,KAAI;IACtB,SAAA,CAAC,aAAa,CAAC,EAAE,CAAC,KAAI;;CACd,CAAC;AAEX,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"editor-config.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/constants/editor-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,eAAO,MAAM,aAAa,UAqBzB,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;EAMlB,CAAC;AAEX,eAAO,MAAM,UAAU;IAErB,SAAA,CAAC,aAAa,CAAC,EAAE,CAAC,KAAI;IACtB,SAAA,CAAC,aAAa,CAAC,EAAE,CAAC,KAAI;IACtB,SAAA,CAAC,aAAa,CAAC,EAAE,CAAC,KAAI;IACtB,SAAA,CAAC,aAAa,CAAC,EAAE,CAAC,KAAI;;CACd,CAAC;AAEX,eAAO,MAAM,oBAAoB;;;;;CAKvB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BrB,CAAC;AAEX,eAAO,MAAM,iBAAiB;;;;;;;;CAQpB,CAAC;AAEX,eAAO,MAAM,iBAAiB;;;;;CAK7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,UAK/B,CAAC;AAEF,eAAO,MAAM,cAAc,uBAAwB,CAAC;AAEpD,eAAO,MAAM,gBAAgB,6BAG5B,CAAC;AAEF,eAAO,MAAM,WAAW;;;;sBAIE,MAAM,EAAE;yBACL,MAAM,EAAE;CACpC,CAAC;AAEF,eAAO,MAAM,qBAAqB,MAAM,CAAC"}
|
|
@@ -37,8 +37,17 @@ export const FONT_SIZES = {
|
|
|
37
37
|
};
|
|
38
38
|
export const EXTENSION_PRIORITIES = {
|
|
39
39
|
IMAGE_UPLOAD: 1000,
|
|
40
|
-
HORIZONTAL_RULE: 100
|
|
40
|
+
HORIZONTAL_RULE: 100,
|
|
41
|
+
COMMENT: 1001,
|
|
42
|
+
TABLE_SECTION: 80
|
|
41
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Represents a content "hole" in Tiptap's renderHTML return value.
|
|
46
|
+
* This special value (0) tells Tiptap where to insert child nodes in the rendered HTML structure.
|
|
47
|
+
*
|
|
48
|
+
* @see https://tiptap.dev/guide/custom-extensions#render-html
|
|
49
|
+
*/
|
|
50
|
+
export const TIPTAP_CONTENT_HOLE = 0;
|
|
42
51
|
export const TOOLBAR_BUTTON_IDS = {
|
|
43
52
|
BOLD: 'bold',
|
|
44
53
|
ITALIC: 'italic',
|
|
@@ -100,4 +109,4 @@ export const LINK_CONFIG = {
|
|
|
100
109
|
PHISHING_DOMAINS: [],
|
|
101
110
|
NO_AUTOLINK_DOMAINS: []
|
|
102
111
|
};
|
|
103
|
-
export const
|
|
112
|
+
export const EDITOR_CONTENT_HEIGHT = 400;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-elements.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/constants/html-elements.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"html-elements.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/constants/html-elements.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4FzB,CAAC;AAEF,eAAO,MAAM,cAAc,UAiD1B,CAAC;AAEF,eAAO,MAAM,aAAa,UAezB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment-extension.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/extensions/comment-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"comment-extension.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/extensions/comment-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AAQrD,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,OAAO,EAAE;YACP,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,UAAU,CAAC;SAC7C,CAAC;KACH;CACF;AAED,eAAO,MAAM,gBAAgB,2BAgD3B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mark, mergeAttributes } from '@tiptap/core';
|
|
2
|
-
import { HTML_ELEMENTS } from '../constants';
|
|
2
|
+
import { EXTENSION_PRIORITIES, HTML_ELEMENTS, TIPTAP_CONTENT_HOLE } from '../constants';
|
|
3
3
|
export const CommentExtension = Mark.create({
|
|
4
4
|
name: 'comment',
|
|
5
5
|
addOptions() {
|
|
@@ -24,7 +24,7 @@ export const CommentExtension = Mark.create({
|
|
|
24
24
|
return [
|
|
25
25
|
{
|
|
26
26
|
tag: `${HTML_ELEMENTS.SPAN}[data-type="comment"]`,
|
|
27
|
-
priority:
|
|
27
|
+
priority: EXTENSION_PRIORITIES.COMMENT
|
|
28
28
|
}
|
|
29
29
|
];
|
|
30
30
|
},
|
|
@@ -34,7 +34,7 @@ export const CommentExtension = Mark.create({
|
|
|
34
34
|
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
|
|
35
35
|
'data-type': 'comment'
|
|
36
36
|
}),
|
|
37
|
-
|
|
37
|
+
TIPTAP_CONTENT_HOLE
|
|
38
38
|
];
|
|
39
39
|
},
|
|
40
40
|
addCommands() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-table-cell-extension.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/extensions/custom-table-cell-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,cAAc,CAAC;AAKrD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,eAAe,EAAE;YACf,oBAAoB,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,UAAU,CAAC;SAC3E,CAAC;KACH;CACF;AAED,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"custom-table-cell-extension.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/extensions/custom-table-cell-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,cAAc,CAAC;AAKrD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,eAAe,EAAE;YACf,oBAAoB,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,UAAU,CAAC;SAC3E,CAAC;KACH;CACF;AAED,eAAO,MAAM,eAAe,EAAE,IAsF5B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mergeAttributes } from '@tiptap/core';
|
|
2
2
|
import { TableCell } from '@tiptap/extension-table';
|
|
3
|
-
import { HTML_ELEMENTS } from '../constants';
|
|
3
|
+
import { HTML_ELEMENTS, TIPTAP_CONTENT_HOLE } from '../constants';
|
|
4
4
|
export const CustomTableCell = TableCell.extend({
|
|
5
5
|
addAttributes() {
|
|
6
6
|
var _a;
|
|
@@ -53,12 +53,21 @@ export const CustomTableCell = TableCell.extend({
|
|
|
53
53
|
delete rest.borderColor;
|
|
54
54
|
delete rest.borderWidth;
|
|
55
55
|
delete rest.borderStyle;
|
|
56
|
+
// Remove default colspan/rowspan
|
|
57
|
+
if (rest.colspan === 1)
|
|
58
|
+
delete rest.colspan;
|
|
59
|
+
if (rest.rowspan === 1)
|
|
60
|
+
delete rest.rowspan;
|
|
56
61
|
const existingStyle = HTMLAttributes.style;
|
|
57
62
|
{
|
|
58
63
|
/* Merge existing style with our custom styles */
|
|
59
64
|
}
|
|
60
65
|
const allStyles = [...(existingStyle ? [existingStyle] : []), ...styles];
|
|
61
66
|
const style = allStyles.length > 0 ? allStyles.join('; ') : undefined;
|
|
62
|
-
return [
|
|
67
|
+
return [
|
|
68
|
+
HTML_ELEMENTS.TD,
|
|
69
|
+
mergeAttributes(rest, style ? { style } : {}),
|
|
70
|
+
TIPTAP_CONTENT_HOLE
|
|
71
|
+
];
|
|
63
72
|
}
|
|
64
73
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-table-header-extension.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/extensions/custom-table-header-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,cAAc,CAAC;AAKrD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,iBAAiB,EAAE;YACjB,sBAAsB,EAAE,CACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAChC,UAAU,CAAC;SACjB,CAAC;KACH;CACF;AAED,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"custom-table-header-extension.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/extensions/custom-table-header-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,cAAc,CAAC;AAKrD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,iBAAiB,EAAE;YACjB,sBAAsB,EAAE,CACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAChC,UAAU,CAAC;SACjB,CAAC;KACH;CACF;AAED,eAAO,MAAM,iBAAiB,EAAE,IAoF9B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mergeAttributes } from '@tiptap/core';
|
|
2
2
|
import { TableHeader } from '@tiptap/extension-table';
|
|
3
|
-
import { HTML_ELEMENTS } from '../constants';
|
|
3
|
+
import { HTML_ELEMENTS, TIPTAP_CONTENT_HOLE } from '../constants';
|
|
4
4
|
export const CustomTableHeader = TableHeader.extend({
|
|
5
5
|
addAttributes() {
|
|
6
6
|
var _a;
|
|
@@ -52,12 +52,21 @@ export const CustomTableHeader = TableHeader.extend({
|
|
|
52
52
|
delete rest.borderColor;
|
|
53
53
|
delete rest.borderWidth;
|
|
54
54
|
delete rest.borderStyle;
|
|
55
|
+
// Remove default colspan/rowspan
|
|
56
|
+
if (rest.colspan === 1)
|
|
57
|
+
delete rest.colspan;
|
|
58
|
+
if (rest.rowspan === 1)
|
|
59
|
+
delete rest.rowspan;
|
|
55
60
|
const existingStyle = HTMLAttributes.style;
|
|
56
61
|
{
|
|
57
62
|
/* Merge existing style with our custom styles */
|
|
58
63
|
}
|
|
59
64
|
const allStyles = [...(existingStyle ? [existingStyle] : []), ...styles];
|
|
60
65
|
const style = allStyles.length > 0 ? allStyles.join('; ') : undefined;
|
|
61
|
-
return [
|
|
66
|
+
return [
|
|
67
|
+
HTML_ELEMENTS.TH,
|
|
68
|
+
mergeAttributes(rest, style ? { style } : {}),
|
|
69
|
+
TIPTAP_CONTENT_HOLE
|
|
70
|
+
];
|
|
62
71
|
}
|
|
63
72
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-block-extension.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/extensions/html-block-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"html-block-extension.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/extensions/html-block-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,cAAc,CAAC;AAQrD,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CAC9E;AAED,eAAO,MAAM,kBAAkB,6BAoF7B,CAAC"}
|
|
@@ -10,7 +10,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { mergeAttributes, Node } from '@tiptap/core';
|
|
13
|
-
import { HTML_ELEMENTS } from '../constants';
|
|
13
|
+
import { HTML_ELEMENTS, TIPTAP_CONTENT_HOLE } from '../constants';
|
|
14
|
+
import { createDataAttributesConfig, extractDataAttributes } from '../utils/data-attributes-helper';
|
|
14
15
|
export const HtmlBlockExtension = Node.create({
|
|
15
16
|
name: 'htmlBlock',
|
|
16
17
|
group: 'block',
|
|
@@ -21,24 +22,19 @@ export const HtmlBlockExtension = Node.create({
|
|
|
21
22
|
};
|
|
22
23
|
},
|
|
23
24
|
addAttributes() {
|
|
24
|
-
return {
|
|
25
|
-
tagName: {
|
|
25
|
+
return Object.assign({ tagName: {
|
|
26
26
|
default: HTML_ELEMENTS.DIV,
|
|
27
27
|
parseHTML: element => element.tagName.toLowerCase(),
|
|
28
28
|
renderHTML: () => {
|
|
29
29
|
return {};
|
|
30
30
|
}
|
|
31
|
-
},
|
|
32
|
-
style: {
|
|
31
|
+
}, style: {
|
|
33
32
|
default: null
|
|
34
|
-
},
|
|
35
|
-
class: {
|
|
33
|
+
}, class: {
|
|
36
34
|
default: null
|
|
37
|
-
},
|
|
38
|
-
id: {
|
|
35
|
+
}, id: {
|
|
39
36
|
default: null
|
|
40
|
-
}
|
|
41
|
-
};
|
|
37
|
+
} }, createDataAttributesConfig());
|
|
42
38
|
},
|
|
43
39
|
parseHTML() {
|
|
44
40
|
return [
|
|
@@ -79,12 +75,13 @@ export const HtmlBlockExtension = Node.create({
|
|
|
79
75
|
];
|
|
80
76
|
},
|
|
81
77
|
renderHTML({ node, HTMLAttributes }) {
|
|
82
|
-
const _a = node.attrs, { tagName } = _a,
|
|
78
|
+
const _a = node.attrs, { tagName } = _a, attrs = __rest(_a, ["tagName"]);
|
|
79
|
+
const { dataAttributes, otherAttrs } = extractDataAttributes(attrs);
|
|
83
80
|
const tag = tagName || HTML_ELEMENTS.DIV;
|
|
84
81
|
return [
|
|
85
82
|
tag,
|
|
86
|
-
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes,
|
|
87
|
-
|
|
83
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, otherAttrs, dataAttributes),
|
|
84
|
+
TIPTAP_CONTENT_HOLE
|
|
88
85
|
];
|
|
89
86
|
}
|
|
90
87
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-inline-extension.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/extensions/html-inline-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"html-inline-extension.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/extensions/html-inline-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,cAAc,CAAC;AAQrD,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CAC9E;AAED,eAAO,MAAM,mBAAmB,8BAkF9B,CAAC"}
|
|
@@ -10,7 +10,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { mergeAttributes, Node } from '@tiptap/core';
|
|
13
|
-
import { HTML_ELEMENTS } from '../constants';
|
|
13
|
+
import { HTML_ELEMENTS, TIPTAP_CONTENT_HOLE } from '../constants';
|
|
14
|
+
import { createDataAttributesConfig, extractDataAttributes } from '../utils/data-attributes-helper';
|
|
14
15
|
export const HtmlInlineExtension = Node.create({
|
|
15
16
|
name: 'htmlInline',
|
|
16
17
|
group: 'inline',
|
|
@@ -22,24 +23,19 @@ export const HtmlInlineExtension = Node.create({
|
|
|
22
23
|
};
|
|
23
24
|
},
|
|
24
25
|
addAttributes() {
|
|
25
|
-
return {
|
|
26
|
-
tagName: {
|
|
26
|
+
return Object.assign({ tagName: {
|
|
27
27
|
default: HTML_ELEMENTS.SPAN,
|
|
28
28
|
parseHTML: element => element.tagName.toLowerCase(),
|
|
29
29
|
renderHTML: () => {
|
|
30
30
|
return {};
|
|
31
31
|
}
|
|
32
|
-
},
|
|
33
|
-
style: {
|
|
32
|
+
}, style: {
|
|
34
33
|
default: null
|
|
35
|
-
},
|
|
36
|
-
class: {
|
|
34
|
+
}, class: {
|
|
37
35
|
default: null
|
|
38
|
-
},
|
|
39
|
-
id: {
|
|
36
|
+
}, id: {
|
|
40
37
|
default: null
|
|
41
|
-
}
|
|
42
|
-
};
|
|
38
|
+
} }, createDataAttributesConfig());
|
|
43
39
|
},
|
|
44
40
|
parseHTML() {
|
|
45
41
|
return [
|
|
@@ -76,12 +72,13 @@ export const HtmlInlineExtension = Node.create({
|
|
|
76
72
|
];
|
|
77
73
|
},
|
|
78
74
|
renderHTML({ node, HTMLAttributes }) {
|
|
79
|
-
const _a = node.attrs, { tagName } = _a,
|
|
75
|
+
const _a = node.attrs, { tagName } = _a, attrs = __rest(_a, ["tagName"]);
|
|
76
|
+
const { dataAttributes, otherAttrs } = extractDataAttributes(attrs);
|
|
80
77
|
const tag = tagName || HTML_ELEMENTS.SPAN;
|
|
81
78
|
return [
|
|
82
79
|
tag,
|
|
83
|
-
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes,
|
|
84
|
-
|
|
80
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, otherAttrs, dataAttributes),
|
|
81
|
+
TIPTAP_CONTENT_HOLE
|
|
85
82
|
];
|
|
86
83
|
}
|
|
87
84
|
});
|