@akinon/ui-editor 1.0.3 → 1.0.5
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
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data Attributes Helper for Tiptap Extensions
|
|
3
|
+
*
|
|
4
|
+
* This helper provides utilities for adding data-* attribute support to Tiptap extensions.
|
|
5
|
+
*/
|
|
6
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
7
|
+
var t = {};
|
|
8
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
9
|
+
t[p] = s[p];
|
|
10
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
11
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
12
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
13
|
+
t[p[i]] = s[p[i]];
|
|
14
|
+
}
|
|
15
|
+
return t;
|
|
16
|
+
};
|
|
17
|
+
export const createDataAttributesConfig = () => ({
|
|
18
|
+
dataAttributes: {
|
|
19
|
+
default: {},
|
|
20
|
+
parseHTML: (element) => {
|
|
21
|
+
const dataAttrs = {};
|
|
22
|
+
Array.from(element.attributes).forEach(attr => {
|
|
23
|
+
if (attr.name.startsWith('data-')) {
|
|
24
|
+
dataAttrs[attr.name] = attr.value;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return Object.keys(dataAttrs).length > 0 ? dataAttrs : {};
|
|
28
|
+
},
|
|
29
|
+
renderHTML: (attributes) => {
|
|
30
|
+
return attributes.dataAttributes || {};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
export const extractDataAttributes = (nodeAttrs) => {
|
|
35
|
+
const { dataAttributes } = nodeAttrs, otherAttrs = __rest(nodeAttrs, ["dataAttributes"]);
|
|
36
|
+
return {
|
|
37
|
+
dataAttributes: dataAttributes || {},
|
|
38
|
+
otherAttrs
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export const addDataAttributesToParent = (parent) => {
|
|
42
|
+
const parentAttributes = (parent === null || parent === void 0 ? void 0 : parent()) || {};
|
|
43
|
+
return Object.assign(Object.assign(Object.assign({}, parentAttributes), { class: {
|
|
44
|
+
default: null,
|
|
45
|
+
parseHTML: (element) => element.getAttribute('class'),
|
|
46
|
+
renderHTML: (attributes) => {
|
|
47
|
+
if (!attributes.class)
|
|
48
|
+
return {};
|
|
49
|
+
return { class: attributes.class };
|
|
50
|
+
}
|
|
51
|
+
}, id: {
|
|
52
|
+
default: null,
|
|
53
|
+
parseHTML: (element) => element.getAttribute('id'),
|
|
54
|
+
renderHTML: (attributes) => {
|
|
55
|
+
if (!attributes.id)
|
|
56
|
+
return {};
|
|
57
|
+
return { id: attributes.id };
|
|
58
|
+
}
|
|
59
|
+
}, style: {
|
|
60
|
+
default: null,
|
|
61
|
+
parseHTML: (element) => element.getAttribute('style'),
|
|
62
|
+
renderHTML: (attributes) => {
|
|
63
|
+
if (!attributes.style)
|
|
64
|
+
return {};
|
|
65
|
+
return { style: attributes.style };
|
|
66
|
+
}
|
|
67
|
+
} }), createDataAttributesConfig());
|
|
68
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './clean-html';
|
|
2
|
+
export * from './data-attributes-helper';
|
|
2
3
|
export * from './highlight-html';
|
|
3
|
-
export * from './
|
|
4
|
+
export * from './prettier-format';
|
|
4
5
|
export * from './tiptap-extensions';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prettier-format.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/utils/prettier-format.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,MAAM,CAiBzE,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as prettierPluginHtml from 'prettier/plugins/html';
|
|
2
|
+
import * as prettier from 'prettier/standalone';
|
|
3
|
+
/**
|
|
4
|
+
* Formats HTML using Prettier
|
|
5
|
+
*
|
|
6
|
+
* @param html - Raw HTML string to format
|
|
7
|
+
* @returns Promise<formatted HTML string>
|
|
8
|
+
*/
|
|
9
|
+
export const formatHtmlWithPrettier = async (html) => {
|
|
10
|
+
try {
|
|
11
|
+
const formatted = await prettier.format(html, {
|
|
12
|
+
parser: 'html',
|
|
13
|
+
plugins: [prettierPluginHtml],
|
|
14
|
+
printWidth: 60,
|
|
15
|
+
tabWidth: 2,
|
|
16
|
+
useTabs: false,
|
|
17
|
+
htmlWhitespaceSensitivity: 'css',
|
|
18
|
+
singleAttributePerLine: false,
|
|
19
|
+
proseWrap: 'always'
|
|
20
|
+
});
|
|
21
|
+
return formatted.trim();
|
|
22
|
+
}
|
|
23
|
+
catch (_a) {
|
|
24
|
+
return html;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiptap-extensions.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/utils/tiptap-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"tiptap-extensions.d.ts","sourceRoot":"","sources":["../../../../src/tiptap/utils/tiptap-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AA6DzD,eAAO,MAAM,aAAa,GAAI,cAAc,MAAM,KAAG,YAAY,EA2NhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,MAAM,IAAI,EAAE,MAAM,MAAM,SAqBvE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,GACvB,KAAK,MAAM,EACX,KAAK;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,CAAC,MAAM,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IAC3C,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CAC5C,YAmCF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,YAW3C,CAAC"}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import Blockquote from '@tiptap/extension-blockquote';
|
|
2
13
|
import Bold from '@tiptap/extension-bold';
|
|
3
14
|
import Code from '@tiptap/extension-code';
|
|
@@ -24,10 +35,11 @@ import Typography from '@tiptap/extension-typography';
|
|
|
24
35
|
import Underline from '@tiptap/extension-underline';
|
|
25
36
|
import Youtube from '@tiptap/extension-youtube';
|
|
26
37
|
import { Dropcursor, Gapcursor } from '@tiptap/extensions';
|
|
27
|
-
import { ALLOWED_IMAGE_MIMES, EXTENSION_PRIORITIES, HEADING_LEVELS, LINK_CONFIG, TEXT_ALIGN_TYPES } from '../constants/editor-config';
|
|
38
|
+
import { ALLOWED_IMAGE_MIMES, EXTENSION_PRIORITIES, HEADING_LEVELS, LINK_CONFIG, TEXT_ALIGN_TYPES, TIPTAP_CONTENT_HOLE } from '../constants/editor-config';
|
|
28
39
|
import { HTML_ELEMENTS } from '../constants/html-elements';
|
|
29
40
|
import { CommentExtension, CustomTableCell, CustomTableHeader, HtmlBlockExtension, HtmlInlineExtension, IframeExtension, ImageUploadExtension, ResetMarksOnEnter } from '../extensions';
|
|
30
41
|
import { SecureScriptExtension } from '../extensions/secure-script-extension';
|
|
42
|
+
import { addDataAttributesToParent, extractDataAttributes } from './data-attributes-helper';
|
|
31
43
|
const DROP_CURSOR_COLOR = '#fff';
|
|
32
44
|
export const getExtensions = (placeholder) => [
|
|
33
45
|
Document.extend({
|
|
@@ -36,11 +48,15 @@ export const getExtensions = (placeholder) => [
|
|
|
36
48
|
Text,
|
|
37
49
|
Paragraph.extend({
|
|
38
50
|
addAttributes() {
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
return addDataAttributesToParent(this.parent);
|
|
52
|
+
},
|
|
53
|
+
renderHTML({ HTMLAttributes, node }) {
|
|
54
|
+
const { dataAttributes, otherAttrs } = extractDataAttributes(node.attrs);
|
|
55
|
+
return [
|
|
56
|
+
HTML_ELEMENTS.P,
|
|
57
|
+
Object.assign(Object.assign(Object.assign({}, HTMLAttributes), otherAttrs), dataAttributes),
|
|
58
|
+
TIPTAP_CONTENT_HOLE
|
|
59
|
+
];
|
|
44
60
|
}
|
|
45
61
|
}),
|
|
46
62
|
HardBreak,
|
|
@@ -60,11 +76,55 @@ export const getExtensions = (placeholder) => [
|
|
|
60
76
|
};
|
|
61
77
|
}
|
|
62
78
|
}),
|
|
63
|
-
Heading.
|
|
79
|
+
Heading.extend({
|
|
80
|
+
addAttributes() {
|
|
81
|
+
return addDataAttributesToParent(this.parent);
|
|
82
|
+
},
|
|
83
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
84
|
+
const { dataAttributes, otherAttrs } = extractDataAttributes(node.attrs);
|
|
85
|
+
const hasLevel = this.options.levels.includes(node.attrs.level);
|
|
86
|
+
const level = hasLevel ? node.attrs.level : this.options.levels[0];
|
|
87
|
+
// Remove 'level' from attributes
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
89
|
+
const { level: _level } = otherAttrs, cleanAttrs = __rest(otherAttrs, ["level"]);
|
|
90
|
+
return [
|
|
91
|
+
`h${level}`,
|
|
92
|
+
Object.assign(Object.assign(Object.assign({}, HTMLAttributes), cleanAttrs), dataAttributes),
|
|
93
|
+
TIPTAP_CONTENT_HOLE
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
}).configure({
|
|
64
97
|
levels: [...HEADING_LEVELS]
|
|
65
98
|
}),
|
|
66
|
-
Blockquote
|
|
67
|
-
|
|
99
|
+
Blockquote.extend({
|
|
100
|
+
addAttributes() {
|
|
101
|
+
return addDataAttributesToParent(this.parent);
|
|
102
|
+
},
|
|
103
|
+
renderHTML({ HTMLAttributes, node }) {
|
|
104
|
+
const { dataAttributes, otherAttrs } = extractDataAttributes(node.attrs);
|
|
105
|
+
return [
|
|
106
|
+
HTML_ELEMENTS.BLOCKQUOTE,
|
|
107
|
+
Object.assign(Object.assign(Object.assign({}, HTMLAttributes), otherAttrs), dataAttributes),
|
|
108
|
+
TIPTAP_CONTENT_HOLE
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
}),
|
|
112
|
+
CodeBlock.extend({
|
|
113
|
+
addAttributes() {
|
|
114
|
+
return addDataAttributesToParent(this.parent);
|
|
115
|
+
},
|
|
116
|
+
renderHTML({ HTMLAttributes, node }) {
|
|
117
|
+
const { dataAttributes, otherAttrs } = extractDataAttributes(node.attrs);
|
|
118
|
+
// Remove 'language' from pre attributes
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
120
|
+
const { language: _language } = otherAttrs, cleanAttrs = __rest(otherAttrs, ["language"]);
|
|
121
|
+
return [
|
|
122
|
+
HTML_ELEMENTS.PRE,
|
|
123
|
+
Object.assign(Object.assign(Object.assign({}, HTMLAttributes), cleanAttrs), dataAttributes),
|
|
124
|
+
[HTML_ELEMENTS.CODE, {}, TIPTAP_CONTENT_HOLE]
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
}),
|
|
68
128
|
HtmlBlockExtension,
|
|
69
129
|
HtmlInlineExtension,
|
|
70
130
|
IframeExtension,
|
|
@@ -81,9 +141,45 @@ export const getExtensions = (placeholder) => [
|
|
|
81
141
|
TextAlign.configure({
|
|
82
142
|
types: [...TEXT_ALIGN_TYPES]
|
|
83
143
|
}),
|
|
84
|
-
BulletList
|
|
85
|
-
|
|
86
|
-
|
|
144
|
+
BulletList.extend({
|
|
145
|
+
addAttributes() {
|
|
146
|
+
return addDataAttributesToParent(this.parent);
|
|
147
|
+
},
|
|
148
|
+
renderHTML({ HTMLAttributes, node }) {
|
|
149
|
+
const { dataAttributes, otherAttrs } = extractDataAttributes(node.attrs);
|
|
150
|
+
return [
|
|
151
|
+
HTML_ELEMENTS.UL,
|
|
152
|
+
Object.assign(Object.assign(Object.assign({}, HTMLAttributes), otherAttrs), dataAttributes),
|
|
153
|
+
0
|
|
154
|
+
];
|
|
155
|
+
}
|
|
156
|
+
}),
|
|
157
|
+
OrderedList.extend({
|
|
158
|
+
addAttributes() {
|
|
159
|
+
return addDataAttributesToParent(this.parent);
|
|
160
|
+
},
|
|
161
|
+
renderHTML({ HTMLAttributes, node }) {
|
|
162
|
+
const { dataAttributes, otherAttrs } = extractDataAttributes(node.attrs);
|
|
163
|
+
return [
|
|
164
|
+
HTML_ELEMENTS.OL,
|
|
165
|
+
Object.assign(Object.assign(Object.assign({}, HTMLAttributes), otherAttrs), dataAttributes),
|
|
166
|
+
TIPTAP_CONTENT_HOLE
|
|
167
|
+
];
|
|
168
|
+
}
|
|
169
|
+
}),
|
|
170
|
+
ListItem.extend({
|
|
171
|
+
addAttributes() {
|
|
172
|
+
return addDataAttributesToParent(this.parent);
|
|
173
|
+
},
|
|
174
|
+
renderHTML({ HTMLAttributes, node }) {
|
|
175
|
+
const { dataAttributes, otherAttrs } = extractDataAttributes(node.attrs);
|
|
176
|
+
return [
|
|
177
|
+
HTML_ELEMENTS.LI,
|
|
178
|
+
Object.assign(Object.assign(Object.assign({}, HTMLAttributes), otherAttrs), dataAttributes),
|
|
179
|
+
TIPTAP_CONTENT_HOLE
|
|
180
|
+
];
|
|
181
|
+
}
|
|
182
|
+
}),
|
|
87
183
|
TaskList,
|
|
88
184
|
TaskItem.configure({
|
|
89
185
|
nested: true
|
|
@@ -101,8 +197,32 @@ export const getExtensions = (placeholder) => [
|
|
|
101
197
|
files.forEach(file => handleImageFile(currentEditor, file));
|
|
102
198
|
}
|
|
103
199
|
}),
|
|
104
|
-
Table.
|
|
105
|
-
|
|
200
|
+
Table.extend({
|
|
201
|
+
addAttributes() {
|
|
202
|
+
return addDataAttributesToParent(this.parent);
|
|
203
|
+
},
|
|
204
|
+
renderHTML({ HTMLAttributes, node }) {
|
|
205
|
+
const { dataAttributes, otherAttrs } = extractDataAttributes(node.attrs);
|
|
206
|
+
return [
|
|
207
|
+
HTML_ELEMENTS.TABLE,
|
|
208
|
+
Object.assign(Object.assign(Object.assign({}, HTMLAttributes), otherAttrs), dataAttributes),
|
|
209
|
+
TIPTAP_CONTENT_HOLE
|
|
210
|
+
];
|
|
211
|
+
}
|
|
212
|
+
}).configure({ resizable: true }),
|
|
213
|
+
TableRow.extend({
|
|
214
|
+
addAttributes() {
|
|
215
|
+
return addDataAttributesToParent(this.parent);
|
|
216
|
+
},
|
|
217
|
+
renderHTML({ HTMLAttributes, node }) {
|
|
218
|
+
const { dataAttributes, otherAttrs } = extractDataAttributes(node.attrs);
|
|
219
|
+
return [
|
|
220
|
+
HTML_ELEMENTS.TR,
|
|
221
|
+
Object.assign(Object.assign(Object.assign({}, HTMLAttributes), otherAttrs), dataAttributes),
|
|
222
|
+
TIPTAP_CONTENT_HOLE
|
|
223
|
+
];
|
|
224
|
+
}
|
|
225
|
+
}),
|
|
106
226
|
CustomTableHeader,
|
|
107
227
|
CustomTableCell,
|
|
108
228
|
Link.configure({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/ui-editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A headless lightweight text editor for Akinon.",
|
|
6
6
|
"type": "module",
|
|
@@ -50,25 +50,26 @@
|
|
|
50
50
|
"@tiptap/y-tiptap": "^3.0.1",
|
|
51
51
|
"antd": "^5.27.0",
|
|
52
52
|
"clsx": "^2.1.1",
|
|
53
|
+
"prettier": "^3.6.2",
|
|
53
54
|
"y-protocols": "^1.0.7",
|
|
54
55
|
"yjs": "^13.6.29",
|
|
55
|
-
"@akinon/ui-button": "1.4.
|
|
56
|
-
"@akinon/
|
|
57
|
-
"@akinon/ui-
|
|
58
|
-
"@akinon/ui-
|
|
59
|
-
"@akinon/ui-select": "1.4.
|
|
60
|
-
"@akinon/ui-theme": "1.2.
|
|
61
|
-
"@akinon/ui-upload": "1.4.
|
|
62
|
-
"@akinon/
|
|
63
|
-
"@akinon/ui-dropdown": "1.1.
|
|
56
|
+
"@akinon/ui-button": "1.4.5",
|
|
57
|
+
"@akinon/akilocale": "1.2.4",
|
|
58
|
+
"@akinon/ui-color-picker": "1.1.4",
|
|
59
|
+
"@akinon/ui-input": "1.2.4",
|
|
60
|
+
"@akinon/ui-select": "1.4.5",
|
|
61
|
+
"@akinon/ui-theme": "1.2.4",
|
|
62
|
+
"@akinon/ui-upload": "1.4.5",
|
|
63
|
+
"@akinon/ui-popover": "1.1.4",
|
|
64
|
+
"@akinon/ui-dropdown": "1.1.4"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
67
|
"clean-package": "^2.2.0",
|
|
67
68
|
"copyfiles": "^2.4.1",
|
|
68
69
|
"rimraf": "^5.0.10",
|
|
69
70
|
"typescript": "*",
|
|
70
|
-
"@akinon/typescript-config": "1.1.
|
|
71
|
-
"@akinon/vitest-config": "1.1.
|
|
71
|
+
"@akinon/typescript-config": "1.1.4",
|
|
72
|
+
"@akinon/vitest-config": "1.1.4"
|
|
72
73
|
},
|
|
73
74
|
"peerDependencies": {
|
|
74
75
|
"react": "^18 || ^19",
|