@teamias/rex-design 0.0.7 → 0.0.9
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/components/action-buttons/demo/index.js +17 -3
- package/dist/components/base-form/base-form.js +1 -1
- package/dist/components/base-form/demo/index.js +12 -10
- package/dist/components/base-list-table/demo/BasicBaseListTable.js +1467 -1450
- package/dist/components/base-list-table/demo/TableMaxRowCount.js +7 -5
- package/dist/components/base-table/demo/BaseTableIndex.js +7 -5
- package/dist/components/icons/demo/index.js +11 -3
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +2 -1
- package/dist/components/tiptap-editor/demo/index.d.ts +2 -0
- package/dist/components/tiptap-editor/demo/index.js +22 -0
- package/dist/components/tiptap-editor/index.d.ts +2 -0
- package/dist/components/tiptap-editor/index.js +2 -0
- package/dist/components/tiptap-editor/modules/plugin-image-node/index.d.ts +1 -0
- package/dist/components/tiptap-editor/modules/plugin-image-node/index.js +25 -0
- package/dist/components/tiptap-editor/modules/plugin-link-node/index.d.ts +1 -0
- package/dist/components/tiptap-editor/modules/plugin-link-node/index.js +85 -0
- package/dist/components/tiptap-editor/modules/plugin-variable-node/component.d.ts +3 -0
- package/dist/components/tiptap-editor/modules/plugin-variable-node/component.js +133 -0
- package/dist/components/tiptap-editor/modules/plugin-variable-node/index.d.ts +14 -0
- package/dist/components/tiptap-editor/modules/plugin-variable-node/index.js +84 -0
- package/dist/components/tiptap-editor/styles.d.ts +4 -0
- package/dist/components/tiptap-editor/styles.js +11 -0
- package/dist/components/tiptap-editor/tiptap-editor.d.ts +40 -0
- package/dist/components/tiptap-editor/tiptap-editor.js +529 -0
- package/dist/index.d.ts +42 -0
- package/dist/locales/en-US.json +21 -0
- package/dist/locales/zh-CN.json +21 -0
- package/package.json +17 -1
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
// src/Tiptap.tsx
|
|
8
|
+
import { Icons } from "../..";
|
|
9
|
+
import BulletList from '@tiptap/extension-bullet-list';
|
|
10
|
+
import { Color } from '@tiptap/extension-color';
|
|
11
|
+
import FileHandler from '@tiptap/extension-file-handler';
|
|
12
|
+
import Highlight from '@tiptap/extension-highlight';
|
|
13
|
+
import OrderedList from '@tiptap/extension-ordered-list';
|
|
14
|
+
import SubSub from '@tiptap/extension-subscript';
|
|
15
|
+
import SubSup from '@tiptap/extension-superscript';
|
|
16
|
+
import TextAlign from '@tiptap/extension-text-align';
|
|
17
|
+
import TextStyleKit from '@tiptap/extension-text-style';
|
|
18
|
+
import { EditorContent, useEditor } from '@tiptap/react';
|
|
19
|
+
import StarterKit from '@tiptap/starter-kit';
|
|
20
|
+
import { ColorPicker, Divider, Flex, Tooltip } from 'antd';
|
|
21
|
+
import { keys } from 'radash';
|
|
22
|
+
import { useEffect } from 'react';
|
|
23
|
+
import { useIntl } from 'react-intl';
|
|
24
|
+
import { Image } from "./modules/plugin-image-node";
|
|
25
|
+
import { Link } from "./modules/plugin-link-node";
|
|
26
|
+
import { PluginVariableBNode } from "./modules/plugin-variable-node";
|
|
27
|
+
import { Box } from "./styles";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* https://v2.tiptap.dev/docs/editor/extensions/nodes/task-item
|
|
31
|
+
*/
|
|
32
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
33
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
34
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
35
|
+
export var TiptapEditor = function TiptapEditor(_ref) {
|
|
36
|
+
var _ref$type = _ref.type,
|
|
37
|
+
type = _ref$type === void 0 ? 'html' : _ref$type,
|
|
38
|
+
_ref$maxHeight = _ref.maxHeight,
|
|
39
|
+
maxHeight = _ref$maxHeight === void 0 ? 100 : _ref$maxHeight,
|
|
40
|
+
_ref$variableObject = _ref.variableObject,
|
|
41
|
+
variableObject = _ref$variableObject === void 0 ? {} : _ref$variableObject,
|
|
42
|
+
value = _ref.value,
|
|
43
|
+
defaultValue = _ref.defaultValue,
|
|
44
|
+
onChange = _ref.onChange,
|
|
45
|
+
hiddenToolBar = _ref.hiddenToolBar,
|
|
46
|
+
preventLineBreaks = _ref.preventLineBreaks,
|
|
47
|
+
renderToolBar = _ref.renderToolBar,
|
|
48
|
+
extensions = _ref.extensions;
|
|
49
|
+
var intl = useIntl();
|
|
50
|
+
var editor = useEditor({
|
|
51
|
+
extensions: [].concat(_toConsumableArray(extensions || []), [BulletList, OrderedList, StarterKit.configure({
|
|
52
|
+
paragraph: {
|
|
53
|
+
HTMLAttributes: {
|
|
54
|
+
style: 'margin: 0'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}), TextStyleKit, Color, TextAlign.configure({
|
|
58
|
+
types: ['heading', 'paragraph']
|
|
59
|
+
}), SubSup, SubSub, Highlight.configure({
|
|
60
|
+
multicolor: true
|
|
61
|
+
}),
|
|
62
|
+
// Variable,
|
|
63
|
+
PluginVariableBNode.configure({
|
|
64
|
+
options: keys(variableObject).map(function (ii) {
|
|
65
|
+
return {
|
|
66
|
+
label: ii,
|
|
67
|
+
key: ii
|
|
68
|
+
};
|
|
69
|
+
})
|
|
70
|
+
}), Image.configure({
|
|
71
|
+
allowBase64: true,
|
|
72
|
+
inline: true
|
|
73
|
+
}), FileHandler.configure({
|
|
74
|
+
allowedMimeTypes: ['image/png', 'image/jpeg', 'image/gif', 'image/webp'],
|
|
75
|
+
onDrop: function onDrop(currentEditor, files, pos) {
|
|
76
|
+
files.forEach(function (file) {
|
|
77
|
+
var fileReader = new FileReader();
|
|
78
|
+
fileReader.readAsDataURL(file);
|
|
79
|
+
fileReader.onload = function () {
|
|
80
|
+
currentEditor.chain().insertContentAt(pos, {
|
|
81
|
+
type: 'image',
|
|
82
|
+
attrs: {
|
|
83
|
+
src: fileReader.result
|
|
84
|
+
}
|
|
85
|
+
}).focus().run();
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
onPaste: function onPaste(currentEditor, files, htmlContent) {
|
|
90
|
+
files.forEach(function (file) {
|
|
91
|
+
if (htmlContent) {
|
|
92
|
+
// if there is htmlContent, stop manual insertion & let other extensions handle insertion via inputRule
|
|
93
|
+
// you could extract the pasted file from this url string and upload it to a server for example
|
|
94
|
+
console.log(htmlContent);
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
var fileReader = new FileReader();
|
|
98
|
+
fileReader.readAsDataURL(file);
|
|
99
|
+
fileReader.onload = function () {
|
|
100
|
+
currentEditor.chain().insertContentAt(currentEditor.state.selection.anchor, {
|
|
101
|
+
type: 'image',
|
|
102
|
+
attrs: {
|
|
103
|
+
src: fileReader.result
|
|
104
|
+
}
|
|
105
|
+
}).focus().run();
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}), Link.configure({
|
|
110
|
+
defaultProtocol: 'https',
|
|
111
|
+
openOnClick: false,
|
|
112
|
+
protocols: ['http', 'https']
|
|
113
|
+
})
|
|
114
|
+
// ImageUploadNode.configure({
|
|
115
|
+
// accept: 'image/*',
|
|
116
|
+
// maxSize: MAX_FILE_SIZE,
|
|
117
|
+
// limit: 3,
|
|
118
|
+
// upload: handleImageUpload,
|
|
119
|
+
// onError: (error) => console.error('Upload failed:', error),
|
|
120
|
+
// }),
|
|
121
|
+
]),
|
|
122
|
+
content: defaultValue || '',
|
|
123
|
+
onUpdate: function onUpdate(_ref2) {
|
|
124
|
+
var editor = _ref2.editor;
|
|
125
|
+
if (type === 'text') {
|
|
126
|
+
// `<p style="margin: 0">/qwe/<react-variable-node selected="qwe"></react-variable-node></p>`.replace(/<p.*?>(.*?)<\/p>/, '$1');
|
|
127
|
+
var text = editor.getHTML();
|
|
128
|
+
onChange === null || onChange === void 0 || onChange(text.replace(/<p.*?>(.*?)<\/p>/, '$1'));
|
|
129
|
+
} else {
|
|
130
|
+
var html = editor.getHTML();
|
|
131
|
+
onChange === null || onChange === void 0 || onChange(html);
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
editorProps: {
|
|
135
|
+
handleKeyDown: function handleKeyDown(view, event) {
|
|
136
|
+
if (preventLineBreaks && event.key === 'Enter') {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
return true; // 阻止换行
|
|
139
|
+
}
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
var config = [{
|
|
145
|
+
title: intl.formatMessage({
|
|
146
|
+
id: 'rex.components.tiptap-editor.undo',
|
|
147
|
+
defaultMessage: '撤回'
|
|
148
|
+
}),
|
|
149
|
+
key: 'undo',
|
|
150
|
+
onClick: function onClick() {
|
|
151
|
+
return editor === null || editor === void 0 ? void 0 : editor.commands.undo();
|
|
152
|
+
},
|
|
153
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
154
|
+
type: "iconify",
|
|
155
|
+
name: "ic:round-undo",
|
|
156
|
+
color: "#666"
|
|
157
|
+
})
|
|
158
|
+
}, {
|
|
159
|
+
title: intl.formatMessage({
|
|
160
|
+
id: 'rex.components.tiptap-editor.redo',
|
|
161
|
+
defaultMessage: '恢复'
|
|
162
|
+
}),
|
|
163
|
+
key: 'redo',
|
|
164
|
+
onClick: function onClick() {
|
|
165
|
+
return editor === null || editor === void 0 ? void 0 : editor.commands.redo();
|
|
166
|
+
},
|
|
167
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
168
|
+
type: "iconify",
|
|
169
|
+
name: "ic:round-redo",
|
|
170
|
+
color: "#666"
|
|
171
|
+
})
|
|
172
|
+
}, {
|
|
173
|
+
title: intl.formatMessage({
|
|
174
|
+
id: 'rex.components.tiptap-editor.divider',
|
|
175
|
+
defaultMessage: '分割'
|
|
176
|
+
}),
|
|
177
|
+
key: 'divider'
|
|
178
|
+
}, {
|
|
179
|
+
title: intl.formatMessage({
|
|
180
|
+
id: 'rex.components.tiptap-editor.font-color',
|
|
181
|
+
defaultMessage: '字体颜色'
|
|
182
|
+
}),
|
|
183
|
+
key: 'color',
|
|
184
|
+
icon: /*#__PURE__*/_jsx(ColorPicker, {
|
|
185
|
+
defaultValue: "#333",
|
|
186
|
+
format: "hex",
|
|
187
|
+
allowClear: true,
|
|
188
|
+
onChangeComplete: function onChangeComplete(color) {
|
|
189
|
+
editor === null || editor === void 0 || editor.commands.setColor(color.toHexString());
|
|
190
|
+
},
|
|
191
|
+
children: /*#__PURE__*/_jsx(Icons, {
|
|
192
|
+
type: "iconify",
|
|
193
|
+
name: "ic:round-color-lens",
|
|
194
|
+
color: "#666"
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
}, {
|
|
198
|
+
title: intl.formatMessage({
|
|
199
|
+
id: 'rex.components.tiptap-editor.background-color',
|
|
200
|
+
defaultMessage: '背景颜色'
|
|
201
|
+
}),
|
|
202
|
+
key: 'backgroundColor',
|
|
203
|
+
icon: /*#__PURE__*/_jsx(ColorPicker, {
|
|
204
|
+
defaultValue: "#333",
|
|
205
|
+
format: "hex",
|
|
206
|
+
allowClear: true,
|
|
207
|
+
onChangeComplete: function onChangeComplete(color) {
|
|
208
|
+
editor === null || editor === void 0 || editor.commands.setHighlight({
|
|
209
|
+
color: color.toHexString()
|
|
210
|
+
});
|
|
211
|
+
},
|
|
212
|
+
children: /*#__PURE__*/_jsx(Icons, {
|
|
213
|
+
type: "iconify",
|
|
214
|
+
name: "ic:twotone-color-lens",
|
|
215
|
+
color: "#666"
|
|
216
|
+
})
|
|
217
|
+
})
|
|
218
|
+
}, {
|
|
219
|
+
title: intl.formatMessage({
|
|
220
|
+
id: 'rex.components.tiptap-editor.divider',
|
|
221
|
+
defaultMessage: '分割'
|
|
222
|
+
}),
|
|
223
|
+
key: 'divider'
|
|
224
|
+
}, {
|
|
225
|
+
title: intl.formatMessage({
|
|
226
|
+
id: 'rex.components.tiptap-editor.bullet-list',
|
|
227
|
+
defaultMessage: '有序列表'
|
|
228
|
+
}),
|
|
229
|
+
key: 'bulletList',
|
|
230
|
+
onClick: function onClick() {
|
|
231
|
+
return editor === null || editor === void 0 ? void 0 : editor.commands.toggleOrderedList();
|
|
232
|
+
},
|
|
233
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
234
|
+
type: "iconify",
|
|
235
|
+
name: "ic:round-format-list-numbered",
|
|
236
|
+
color: "#666"
|
|
237
|
+
})
|
|
238
|
+
}, {
|
|
239
|
+
title: intl.formatMessage({
|
|
240
|
+
id: 'rex.components.tiptap-editor.ordered-list',
|
|
241
|
+
defaultMessage: '无序列表'
|
|
242
|
+
}),
|
|
243
|
+
key: 'orderedList',
|
|
244
|
+
onClick: function onClick() {
|
|
245
|
+
return editor === null || editor === void 0 ? void 0 : editor.commands.toggleBulletList();
|
|
246
|
+
},
|
|
247
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
248
|
+
type: "iconify",
|
|
249
|
+
name: "ic:round-reorder",
|
|
250
|
+
color: "#666"
|
|
251
|
+
})
|
|
252
|
+
}, {
|
|
253
|
+
title: intl.formatMessage({
|
|
254
|
+
id: 'rex.components.tiptap-editor.divider',
|
|
255
|
+
defaultMessage: '分割'
|
|
256
|
+
}),
|
|
257
|
+
key: 'divider'
|
|
258
|
+
}, {
|
|
259
|
+
title: intl.formatMessage({
|
|
260
|
+
id: 'rex.components.tiptap-editor.bold',
|
|
261
|
+
defaultMessage: '加粗'
|
|
262
|
+
}),
|
|
263
|
+
key: 'toggleBold',
|
|
264
|
+
onClick: function onClick() {
|
|
265
|
+
return editor === null || editor === void 0 ? void 0 : editor.commands.toggleBold();
|
|
266
|
+
},
|
|
267
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
268
|
+
type: "iconify",
|
|
269
|
+
name: "ic:round-format-bold",
|
|
270
|
+
color: "#666"
|
|
271
|
+
})
|
|
272
|
+
}, {
|
|
273
|
+
title: intl.formatMessage({
|
|
274
|
+
id: 'rex.components.tiptap-editor.italic',
|
|
275
|
+
defaultMessage: '斜体'
|
|
276
|
+
}),
|
|
277
|
+
key: 'toggleItalic',
|
|
278
|
+
onClick: function onClick() {
|
|
279
|
+
return editor === null || editor === void 0 ? void 0 : editor.commands.toggleItalic();
|
|
280
|
+
},
|
|
281
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
282
|
+
type: "iconify",
|
|
283
|
+
name: "ic:round-format-italic",
|
|
284
|
+
color: "#666"
|
|
285
|
+
})
|
|
286
|
+
}, {
|
|
287
|
+
title: intl.formatMessage({
|
|
288
|
+
id: 'rex.components.tiptap-editor.strike',
|
|
289
|
+
defaultMessage: '划线'
|
|
290
|
+
}),
|
|
291
|
+
key: 'toggleStrike',
|
|
292
|
+
onClick: function onClick() {
|
|
293
|
+
return editor === null || editor === void 0 ? void 0 : editor.commands.toggleStrike();
|
|
294
|
+
},
|
|
295
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
296
|
+
type: "iconify",
|
|
297
|
+
name: "ic:round-strikethrough-s",
|
|
298
|
+
color: "#666"
|
|
299
|
+
})
|
|
300
|
+
}, {
|
|
301
|
+
title: intl.formatMessage({
|
|
302
|
+
id: 'rex.components.tiptap-editor.divider',
|
|
303
|
+
defaultMessage: '分割'
|
|
304
|
+
}),
|
|
305
|
+
key: 'divider'
|
|
306
|
+
}, {
|
|
307
|
+
title: intl.formatMessage({
|
|
308
|
+
id: 'rex.components.tiptap-editor.superscript',
|
|
309
|
+
defaultMessage: '上标'
|
|
310
|
+
}),
|
|
311
|
+
key: 'toggleSuperscript',
|
|
312
|
+
onClick: function onClick() {
|
|
313
|
+
return editor === null || editor === void 0 ? void 0 : editor.commands.toggleSuperscript();
|
|
314
|
+
},
|
|
315
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
316
|
+
type: "iconify",
|
|
317
|
+
name: "ic:round-superscript",
|
|
318
|
+
color: "#666"
|
|
319
|
+
})
|
|
320
|
+
}, {
|
|
321
|
+
title: intl.formatMessage({
|
|
322
|
+
id: 'rex.components.tiptap-editor.subscript',
|
|
323
|
+
defaultMessage: '下标'
|
|
324
|
+
}),
|
|
325
|
+
key: 'toggleSubscript',
|
|
326
|
+
onClick: function onClick() {
|
|
327
|
+
return editor === null || editor === void 0 ? void 0 : editor.commands.toggleSubscript();
|
|
328
|
+
},
|
|
329
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
330
|
+
type: "iconify",
|
|
331
|
+
name: "ic:round-subscript",
|
|
332
|
+
color: "#666"
|
|
333
|
+
})
|
|
334
|
+
}, {
|
|
335
|
+
title: intl.formatMessage({
|
|
336
|
+
id: 'rex.components.tiptap-editor.divider',
|
|
337
|
+
defaultMessage: '分割'
|
|
338
|
+
}),
|
|
339
|
+
key: 'divider'
|
|
340
|
+
}, {
|
|
341
|
+
title: intl.formatMessage({
|
|
342
|
+
id: 'rex.components.tiptap-editor.align-left',
|
|
343
|
+
defaultMessage: '左对齐'
|
|
344
|
+
}),
|
|
345
|
+
key: 'left',
|
|
346
|
+
onClick: function onClick() {
|
|
347
|
+
return editor === null || editor === void 0 ? void 0 : editor.commands.setTextAlign('left');
|
|
348
|
+
},
|
|
349
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
350
|
+
type: "iconify",
|
|
351
|
+
name: "ic:round-align-horizontal-left",
|
|
352
|
+
color: "#666"
|
|
353
|
+
})
|
|
354
|
+
}, {
|
|
355
|
+
title: intl.formatMessage({
|
|
356
|
+
id: 'rex.components.tiptap-editor.align-center',
|
|
357
|
+
defaultMessage: '居中'
|
|
358
|
+
}),
|
|
359
|
+
key: 'center',
|
|
360
|
+
onClick: function onClick() {
|
|
361
|
+
return editor === null || editor === void 0 ? void 0 : editor.commands.setTextAlign('center');
|
|
362
|
+
},
|
|
363
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
364
|
+
type: "iconify",
|
|
365
|
+
name: "ic:round-align-horizontal-center",
|
|
366
|
+
color: "#666"
|
|
367
|
+
})
|
|
368
|
+
}, {
|
|
369
|
+
title: intl.formatMessage({
|
|
370
|
+
id: 'rex.components.tiptap-editor.align-right',
|
|
371
|
+
defaultMessage: '右对齐'
|
|
372
|
+
}),
|
|
373
|
+
key: 'right',
|
|
374
|
+
onClick: function onClick() {
|
|
375
|
+
return editor === null || editor === void 0 ? void 0 : editor.commands.setTextAlign('right');
|
|
376
|
+
},
|
|
377
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
378
|
+
type: "iconify",
|
|
379
|
+
name: "ic:round-align-horizontal-right",
|
|
380
|
+
color: "#666"
|
|
381
|
+
})
|
|
382
|
+
}, {
|
|
383
|
+
title: intl.formatMessage({
|
|
384
|
+
id: 'rex.components.tiptap-editor.divider',
|
|
385
|
+
defaultMessage: '分割'
|
|
386
|
+
}),
|
|
387
|
+
key: 'divider'
|
|
388
|
+
}, {
|
|
389
|
+
title: intl.formatMessage({
|
|
390
|
+
id: 'rex.components.tiptap-editor.set-link',
|
|
391
|
+
defaultMessage: '设置链接'
|
|
392
|
+
}),
|
|
393
|
+
key: 'link',
|
|
394
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
395
|
+
type: "iconify",
|
|
396
|
+
name: "ic:baseline-link",
|
|
397
|
+
color: editor !== null && editor !== void 0 && editor.isActive('link') ? '#006cff' : '#666'
|
|
398
|
+
}),
|
|
399
|
+
onClick: function onClick() {
|
|
400
|
+
var previousUrl = editor === null || editor === void 0 ? void 0 : editor.getAttributes('link').href;
|
|
401
|
+
var url = prompt(intl.formatMessage({
|
|
402
|
+
id: 'rex.components.tiptap-editor.enter-link-url',
|
|
403
|
+
defaultMessage: '请输入链接地址:'
|
|
404
|
+
}), previousUrl);
|
|
405
|
+
if (url) {
|
|
406
|
+
editor === null || editor === void 0 || editor.chain().focus().setLink({
|
|
407
|
+
href: url
|
|
408
|
+
}).run();
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}, {
|
|
412
|
+
title: intl.formatMessage({
|
|
413
|
+
id: 'rex.components.tiptap-editor.unset-link',
|
|
414
|
+
defaultMessage: '取消链接'
|
|
415
|
+
}),
|
|
416
|
+
key: 'unsetLink',
|
|
417
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
418
|
+
type: "iconify",
|
|
419
|
+
name: "ic:baseline-link-off",
|
|
420
|
+
color: editor !== null && editor !== void 0 && editor.isActive('link') ? '#006cff' : '#666'
|
|
421
|
+
}),
|
|
422
|
+
onClick: function onClick() {
|
|
423
|
+
return editor !== null && editor !== void 0 && editor.isActive('link') ? editor === null || editor === void 0 ? void 0 : editor.chain().focus().unsetLink().run() : '';
|
|
424
|
+
}
|
|
425
|
+
}, {
|
|
426
|
+
title: intl.formatMessage({
|
|
427
|
+
id: 'rex.components.tiptap-editor.divider',
|
|
428
|
+
defaultMessage: '分割'
|
|
429
|
+
}),
|
|
430
|
+
key: 'divider'
|
|
431
|
+
}, {
|
|
432
|
+
title: intl.formatMessage({
|
|
433
|
+
id: 'rex.components.tiptap-editor.upload-image',
|
|
434
|
+
defaultMessage: '上传图片'
|
|
435
|
+
}),
|
|
436
|
+
key: 'image',
|
|
437
|
+
onClick: function onClick() {
|
|
438
|
+
// 创建隐藏的文件输入框
|
|
439
|
+
var input = document.createElement('input');
|
|
440
|
+
input.type = 'file';
|
|
441
|
+
input.accept = 'image/*';
|
|
442
|
+
input.onchange = function (event) {
|
|
443
|
+
var _files;
|
|
444
|
+
var file = (_files = event.target.files) === null || _files === void 0 ? void 0 : _files[0];
|
|
445
|
+
if (!file) return;
|
|
446
|
+
var fileReader = new FileReader();
|
|
447
|
+
fileReader.readAsDataURL(file);
|
|
448
|
+
fileReader.onload = function () {
|
|
449
|
+
editor === null || editor === void 0 || editor.chain().insertContentAt(editor.state.selection.anchor, {
|
|
450
|
+
type: 'image',
|
|
451
|
+
attrs: {
|
|
452
|
+
src: fileReader.result
|
|
453
|
+
}
|
|
454
|
+
}).focus().run();
|
|
455
|
+
};
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
// 触发文件选择
|
|
459
|
+
input.click();
|
|
460
|
+
},
|
|
461
|
+
icon: /*#__PURE__*/_jsx(Icons, {
|
|
462
|
+
type: "iconify",
|
|
463
|
+
name: "ic:outline-broken-image",
|
|
464
|
+
color: "#666"
|
|
465
|
+
})
|
|
466
|
+
}];
|
|
467
|
+
useEffect(function () {
|
|
468
|
+
return function () {
|
|
469
|
+
editor === null || editor === void 0 || editor.destroy();
|
|
470
|
+
};
|
|
471
|
+
}, []);
|
|
472
|
+
useEffect(function () {
|
|
473
|
+
if (type === 'text') {
|
|
474
|
+
if (value && value === (editor === null || editor === void 0 ? void 0 : editor.getText())) return;
|
|
475
|
+
editor === null || editor === void 0 || editor.commands.setContent(value || '');
|
|
476
|
+
} else {
|
|
477
|
+
if (value && value === (editor === null || editor === void 0 ? void 0 : editor.getHTML())) return;
|
|
478
|
+
editor === null || editor === void 0 || editor.commands.setContent(value || '');
|
|
479
|
+
}
|
|
480
|
+
}, [value]);
|
|
481
|
+
return /*#__PURE__*/_jsxs(Box, {
|
|
482
|
+
"data-max-height": maxHeight,
|
|
483
|
+
onClick: function onClick() {
|
|
484
|
+
setTimeout(function () {
|
|
485
|
+
editor === null || editor === void 0 || editor.chain().focus();
|
|
486
|
+
}, 0);
|
|
487
|
+
},
|
|
488
|
+
children: [function () {
|
|
489
|
+
if (hiddenToolBar) return /*#__PURE__*/_jsx(_Fragment, {});
|
|
490
|
+
var oldNode = /*#__PURE__*/_jsx(Flex, {
|
|
491
|
+
wrap: true,
|
|
492
|
+
gap: "small",
|
|
493
|
+
align: "center",
|
|
494
|
+
style: {
|
|
495
|
+
padding: '4px 10px',
|
|
496
|
+
borderBottom: '1px solid #ddd',
|
|
497
|
+
background: '#f8f8f8'
|
|
498
|
+
},
|
|
499
|
+
children: config.map(function (item, index) {
|
|
500
|
+
if (item.key === 'divider') {
|
|
501
|
+
return /*#__PURE__*/_jsx(Divider, {
|
|
502
|
+
type: "vertical"
|
|
503
|
+
}, "".concat(item.key, "-").concat(index));
|
|
504
|
+
}
|
|
505
|
+
return /*#__PURE__*/_jsx(Tooltip, {
|
|
506
|
+
title: item.title,
|
|
507
|
+
arrow: false,
|
|
508
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
509
|
+
onClick: function onClick() {
|
|
510
|
+
var _item$onClick;
|
|
511
|
+
return (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item);
|
|
512
|
+
},
|
|
513
|
+
style: {
|
|
514
|
+
cursor: 'pointer'
|
|
515
|
+
},
|
|
516
|
+
children: item.icon
|
|
517
|
+
})
|
|
518
|
+
}, "".concat(item.key, "-").concat(index));
|
|
519
|
+
})
|
|
520
|
+
});
|
|
521
|
+
if (renderToolBar) {
|
|
522
|
+
return renderToolBar(oldNode, editor, config);
|
|
523
|
+
}
|
|
524
|
+
return oldNode;
|
|
525
|
+
}(), /*#__PURE__*/_jsx(EditorContent, {
|
|
526
|
+
editor: editor
|
|
527
|
+
})]
|
|
528
|
+
});
|
|
529
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,27 @@ export declare const designLocales: {
|
|
|
5
5
|
zhCN: {
|
|
6
6
|
rex: {
|
|
7
7
|
components: {
|
|
8
|
+
"tiptap-editor": {
|
|
9
|
+
undo: string;
|
|
10
|
+
redo: string;
|
|
11
|
+
divider: string;
|
|
12
|
+
"font-color": string;
|
|
13
|
+
"background-color": string;
|
|
14
|
+
bold: string;
|
|
15
|
+
italic: string;
|
|
16
|
+
strike: string;
|
|
17
|
+
superscript: string;
|
|
18
|
+
subscript: string;
|
|
19
|
+
"align-left": string;
|
|
20
|
+
"align-center": string;
|
|
21
|
+
"align-right": string;
|
|
22
|
+
"set-link": string;
|
|
23
|
+
"unset-link": string;
|
|
24
|
+
"upload-image": string;
|
|
25
|
+
"enter-link-url": string;
|
|
26
|
+
"bullet-list": string;
|
|
27
|
+
"ordered-list": string;
|
|
28
|
+
};
|
|
8
29
|
"base-list-table": {
|
|
9
30
|
"expand-more-data-hide": string;
|
|
10
31
|
"expand-more-data": string;
|
|
@@ -44,6 +65,27 @@ export declare const designLocales: {
|
|
|
44
65
|
enUS: {
|
|
45
66
|
rex: {
|
|
46
67
|
components: {
|
|
68
|
+
"tiptap-editor": {
|
|
69
|
+
undo: string;
|
|
70
|
+
redo: string;
|
|
71
|
+
divider: string;
|
|
72
|
+
"font-color": string;
|
|
73
|
+
"background-color": string;
|
|
74
|
+
bold: string;
|
|
75
|
+
italic: string;
|
|
76
|
+
strike: string;
|
|
77
|
+
superscript: string;
|
|
78
|
+
subscript: string;
|
|
79
|
+
"align-left": string;
|
|
80
|
+
"align-center": string;
|
|
81
|
+
"align-right": string;
|
|
82
|
+
"set-link": string;
|
|
83
|
+
"unset-link": string;
|
|
84
|
+
"upload-image": string;
|
|
85
|
+
"enter-link-url": string;
|
|
86
|
+
"bullet-list": string;
|
|
87
|
+
"ordered-list": string;
|
|
88
|
+
};
|
|
47
89
|
"base-list-table": {
|
|
48
90
|
"expand-more-data": string;
|
|
49
91
|
"expand-more-data-hide": string;
|
package/dist/locales/en-US.json
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"rex": {
|
|
3
3
|
"components": {
|
|
4
|
+
"tiptap-editor": {
|
|
5
|
+
"undo": "Undo",
|
|
6
|
+
"redo": "Redo",
|
|
7
|
+
"divider": "Divider",
|
|
8
|
+
"font-color": "Font Color",
|
|
9
|
+
"background-color": "Background Color",
|
|
10
|
+
"bold": "Bold",
|
|
11
|
+
"italic": "Italic",
|
|
12
|
+
"strike": "Strike",
|
|
13
|
+
"superscript": "Superscript",
|
|
14
|
+
"subscript": "Subscript",
|
|
15
|
+
"align-left": "Align Left",
|
|
16
|
+
"align-center": "Align Center",
|
|
17
|
+
"align-right": "Align Right",
|
|
18
|
+
"set-link": "Set Link",
|
|
19
|
+
"unset-link": "Unset Link",
|
|
20
|
+
"upload-image": "Upload Image",
|
|
21
|
+
"enter-link-url": "Please enter link URL:",
|
|
22
|
+
"bullet-list": "Ordered list",
|
|
23
|
+
"ordered-list": "Unordered list"
|
|
24
|
+
},
|
|
4
25
|
"base-list-table": {
|
|
5
26
|
"expand-more-data": "There are still {count} pieces of data not displayed",
|
|
6
27
|
"expand-more-data-hide": "Close"
|
package/dist/locales/zh-CN.json
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"rex": {
|
|
3
3
|
"components": {
|
|
4
|
+
"tiptap-editor": {
|
|
5
|
+
"undo": "撤回",
|
|
6
|
+
"redo": "恢复",
|
|
7
|
+
"divider": "分割",
|
|
8
|
+
"font-color": "字体颜色",
|
|
9
|
+
"background-color": "背景颜色",
|
|
10
|
+
"bold": "加粗",
|
|
11
|
+
"italic": "斜体",
|
|
12
|
+
"strike": "划线",
|
|
13
|
+
"superscript": "上标",
|
|
14
|
+
"subscript": "下标",
|
|
15
|
+
"align-left": "左对齐",
|
|
16
|
+
"align-center": "居中",
|
|
17
|
+
"align-right": "右对齐",
|
|
18
|
+
"set-link": "设置链接",
|
|
19
|
+
"unset-link": "取消链接",
|
|
20
|
+
"upload-image": "上传图片",
|
|
21
|
+
"enter-link-url": "请输入链接地址:",
|
|
22
|
+
"bullet-list": "有序列表",
|
|
23
|
+
"ordered-list": "无序列表"
|
|
24
|
+
},
|
|
4
25
|
"base-list-table": {
|
|
5
26
|
"expand-more-data-hide": "收起",
|
|
6
27
|
"expand-more-data": "还有{count}条数据未展示"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamias/rex-design",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "A react library developed with dumi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -51,11 +51,27 @@
|
|
|
51
51
|
"@ant-design/icons": "^6.0.0",
|
|
52
52
|
"@ant-design/pro-components": "^2.8.10",
|
|
53
53
|
"@iconify/react": "^6.0.0",
|
|
54
|
+
"@tiptap/core": "^2.12.0",
|
|
55
|
+
"@tiptap/extension-bullet-list": "2.12.0",
|
|
56
|
+
"@tiptap/extension-color": "^2.12.0",
|
|
57
|
+
"@tiptap/extension-file-handler": "^3.0.7",
|
|
58
|
+
"@tiptap/extension-highlight": "^2.12.0",
|
|
59
|
+
"@tiptap/extension-image": "2.12.0",
|
|
60
|
+
"@tiptap/extension-link": "2.12.0",
|
|
61
|
+
"@tiptap/extension-ordered-list": "2.12.0",
|
|
62
|
+
"@tiptap/extension-subscript": "^2.12.0",
|
|
63
|
+
"@tiptap/extension-superscript": "^2.12.0",
|
|
64
|
+
"@tiptap/extension-text-align": "^2.12.0",
|
|
65
|
+
"@tiptap/extension-text-style": "^2.12.0",
|
|
66
|
+
"@tiptap/pm": "^2.12.0",
|
|
67
|
+
"@tiptap/react": "^2.12.0",
|
|
68
|
+
"@tiptap/starter-kit": "^2.12.0",
|
|
54
69
|
"ahooks": "^3.9.0",
|
|
55
70
|
"antd": "^5.26.7",
|
|
56
71
|
"classnames": "^2.5.1",
|
|
57
72
|
"dayjs": "^1.11.13",
|
|
58
73
|
"lodash": "^4.17.21",
|
|
74
|
+
"prosemirror-state": "^1.4.3",
|
|
59
75
|
"radash": "^12.1.1",
|
|
60
76
|
"rc-virtual-list": "^3.19.1",
|
|
61
77
|
"react-intl": "^7.1.11",
|