@ctzhian/tiptap 2.5.0 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EditorDiff/index.d.ts +2 -1
- package/dist/EditorDiff/index.js +3 -1
- package/dist/EditorMarkdown/index.js +7 -3
- package/dist/component/CustomBubbleMenu/index.js +4 -12
- package/dist/component/Icons/{flip-horizontal-2-line-icon.d.ts → flip-grid-icon.d.ts} +1 -1
- package/dist/component/Icons/{flip-horizontal-2-line-icon.js → flip-grid-icon.js} +3 -3
- package/dist/component/Icons/index.d.ts +1 -1
- package/dist/component/Icons/index.js +1 -1
- package/dist/component/Toolbar/EditorInsert/index.js +63 -56
- package/dist/extension/node/Alert.js +2 -3
- package/dist/extension/node/FileHandler.d.ts +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import 'core-js/actual/array/find-last';
|
|
|
3
3
|
interface EditorDiffProps {
|
|
4
4
|
oldHtml: string;
|
|
5
5
|
newHtml: string;
|
|
6
|
+
baseUrl?: string;
|
|
6
7
|
}
|
|
7
|
-
declare const EditorDiff: ({ oldHtml, newHtml }: EditorDiffProps) => React.JSX.Element;
|
|
8
|
+
declare const EditorDiff: ({ oldHtml, newHtml, baseUrl }: EditorDiffProps) => React.JSX.Element;
|
|
8
9
|
export default EditorDiff;
|
package/dist/EditorDiff/index.js
CHANGED
|
@@ -8,10 +8,12 @@ import useTiptap from "../hook";
|
|
|
8
8
|
|
|
9
9
|
var EditorDiff = function EditorDiff(_ref) {
|
|
10
10
|
var oldHtml = _ref.oldHtml,
|
|
11
|
-
newHtml = _ref.newHtml
|
|
11
|
+
newHtml = _ref.newHtml,
|
|
12
|
+
baseUrl = _ref.baseUrl;
|
|
12
13
|
var editorRef = useTiptap({
|
|
13
14
|
editable: false,
|
|
14
15
|
content: newHtml,
|
|
16
|
+
baseUrl: baseUrl,
|
|
15
17
|
exclude: ['youtube', 'mention']
|
|
16
18
|
});
|
|
17
19
|
useEffect(function () {
|
|
@@ -375,10 +375,14 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
375
375
|
var textarea = (_aceEditor$textInput = aceEditor.textInput) === null || _aceEditor$textInput === void 0 ? void 0 : _aceEditor$textInput.getElement();
|
|
376
376
|
if (!textarea) return;
|
|
377
377
|
var handleCompositionStart = function handleCompositionStart() {
|
|
378
|
-
|
|
378
|
+
setTimeout(function () {
|
|
379
|
+
return setIsComposing(true);
|
|
380
|
+
}, 0);
|
|
379
381
|
};
|
|
380
382
|
var handleCompositionEnd = function handleCompositionEnd() {
|
|
381
|
-
|
|
383
|
+
setTimeout(function () {
|
|
384
|
+
return setIsComposing(false);
|
|
385
|
+
}, 0);
|
|
382
386
|
};
|
|
383
387
|
textarea.addEventListener('compositionstart', handleCompositionStart);
|
|
384
388
|
textarea.addEventListener('compositionend', handleCompositionEnd);
|
|
@@ -386,7 +390,7 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
386
390
|
textarea.removeEventListener('compositionstart', handleCompositionStart);
|
|
387
391
|
textarea.removeEventListener('compositionend', handleCompositionEnd);
|
|
388
392
|
};
|
|
389
|
-
}, [
|
|
393
|
+
}, []);
|
|
390
394
|
return /*#__PURE__*/React.createElement(Box, {
|
|
391
395
|
sx: _objectSpread({
|
|
392
396
|
position: 'relative',
|
|
@@ -73,18 +73,10 @@ var CustomBubbleMenu = function CustomBubbleMenu(_ref) {
|
|
|
73
73
|
offset: 8,
|
|
74
74
|
flip: true
|
|
75
75
|
},
|
|
76
|
-
shouldShow: function shouldShow() {
|
|
77
|
-
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
// if (cellSelection.ranges.length > 1) {
|
|
81
|
-
// return false
|
|
82
|
-
// }
|
|
83
|
-
// if (cellSelection.$anchorCell && cellSelection.$headCell) {
|
|
84
|
-
// return cellSelection.$anchorCell.pos !== cellSelection.$headCell.pos;
|
|
85
|
-
// }
|
|
86
|
-
// }
|
|
87
|
-
if (editor.state.selection.empty || editor.isActive('image') || editor.isActive('video') || editor.isActive('audio') || editor.isActive('emoji') || editor.isActive('codeBlock') || editor.isActive('blockMath') || editor.isActive('inlineMath') || editor.isActive('blockLink') || editor.isActive('inlineLink') || editor.isActive('blockAttachment') || editor.isActive('inlineAttachment') || editor.isActive('horizontalRule') || editor.isActive('iframe') || editor.isActive('yamlFormat') || editor.isActive('flow') || editor.isActive('table')) {
|
|
76
|
+
shouldShow: function shouldShow(_ref2) {
|
|
77
|
+
var editor = _ref2.editor;
|
|
78
|
+
// 在某些特定节点类型时不显示
|
|
79
|
+
if (editor.state.selection.empty || editor.isEmpty || editor.isActive('image') || editor.isActive('video') || editor.isActive('audio') || editor.isActive('emoji') || editor.isActive('codeBlock') || editor.isActive('blockMath') || editor.isActive('inlineMath') || editor.isActive('blockLink') || editor.isActive('inlineLink') || editor.isActive('blockAttachment') || editor.isActive('inlineAttachment') || editor.isActive('horizontalRule') || editor.isActive('iframe') || editor.isActive('yamlFormat') || editor.isActive('flow') || editor.isActive('table')) {
|
|
88
80
|
return false;
|
|
89
81
|
}
|
|
90
82
|
return true;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import { SvgIcon } from "@mui/material";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
export var
|
|
4
|
+
export var FlipGridIcon = function FlipGridIcon(props) {
|
|
5
5
|
return /*#__PURE__*/React.createElement(SvgIcon, _extends({
|
|
6
6
|
viewBox: "0 0 24 24",
|
|
7
7
|
version: "1.1",
|
|
8
8
|
xmlns: "http://www.w3.org/2000/svg"
|
|
9
9
|
}, props), /*#__PURE__*/React.createElement("path", {
|
|
10
|
-
d: "
|
|
10
|
+
d: "M7 6V18H4L4 6H7ZM4 4C2.89543 4 2 4.89543 2 6V18C2 19.1046 2.89543 20 4 20H7C8.10457 20 9 19.1046 9 18V6C9 4.89543 8.10457 4 7 4H4ZM11 2V22H13V2H11ZM20 6V18H17V6H20ZM17 4C15.8954 4 15 4.89543 15 6V18C15 19.1046 15.8954 20 17 20H20C21.1046 20 22 19.1046 22 18V6C22 4.89543 21.1046 4 20 4H17Z"
|
|
11
11
|
}));
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
FlipGridIcon.displayName = 'icon-flip-grid';
|
|
@@ -54,7 +54,7 @@ export { ExportLineIcon } from './export-line-icon';
|
|
|
54
54
|
export { FileCopyLineIcon } from './file-copy-line-icon';
|
|
55
55
|
export { FileIcon } from './file-icon';
|
|
56
56
|
export { FileUploadLineIcon } from './file-upload-line-icon';
|
|
57
|
-
export {
|
|
57
|
+
export { FlipGridIcon } from './flip-grid-icon';
|
|
58
58
|
export { FlowChartIcon } from './flow-chart-icon';
|
|
59
59
|
export { Folder2LineIcon } from './folder-2-line-icon';
|
|
60
60
|
export { FontColorIcon } from './font-color-icon';
|
|
@@ -57,7 +57,7 @@ export { ExportLineIcon } from "./export-line-icon";
|
|
|
57
57
|
export { FileCopyLineIcon } from "./file-copy-line-icon";
|
|
58
58
|
export { FileIcon } from "./file-icon";
|
|
59
59
|
export { FileUploadLineIcon } from "./file-upload-line-icon";
|
|
60
|
-
export {
|
|
60
|
+
export { FlipGridIcon } from "./flip-grid-icon";
|
|
61
61
|
export { FlowChartIcon } from "./flow-chart-icon";
|
|
62
62
|
export { Folder2LineIcon } from "./folder-2-line-icon";
|
|
63
63
|
export { FontColorIcon } from "./font-color-icon";
|
|
@@ -145,43 +145,6 @@ var EditorInsert = function EditorInsert(_ref) {
|
|
|
145
145
|
size: '0'
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
-
}, {
|
|
149
|
-
label: '流程图',
|
|
150
|
-
key: 'flow',
|
|
151
|
-
icon: /*#__PURE__*/React.createElement(FlowChartIcon, {
|
|
152
|
-
sx: {
|
|
153
|
-
fontSize: '1rem'
|
|
154
|
-
}
|
|
155
|
-
}),
|
|
156
|
-
onClick: function onClick() {
|
|
157
|
-
return editor.commands.setFlow({});
|
|
158
|
-
}
|
|
159
|
-
}, {
|
|
160
|
-
label: '表格',
|
|
161
|
-
key: 'table',
|
|
162
|
-
icon: /*#__PURE__*/React.createElement(Table2Icon, {
|
|
163
|
-
sx: {
|
|
164
|
-
fontSize: '1rem'
|
|
165
|
-
}
|
|
166
|
-
}),
|
|
167
|
-
extra: /*#__PURE__*/React.createElement(Typography, {
|
|
168
|
-
sx: {
|
|
169
|
-
fontSize: '12px',
|
|
170
|
-
color: 'text.disabled'
|
|
171
|
-
}
|
|
172
|
-
}, getShortcutKeyText(['ctrl', '9'], '+')),
|
|
173
|
-
children: [{
|
|
174
|
-
key: 'table-size-picker',
|
|
175
|
-
customLabel: /*#__PURE__*/React.createElement(TableSizePicker, {
|
|
176
|
-
onConfirm: function onConfirm(cols, rows) {
|
|
177
|
-
editor.commands.insertTable({
|
|
178
|
-
rows: rows,
|
|
179
|
-
cols: cols,
|
|
180
|
-
withHeaderRow: false
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
})
|
|
184
|
-
}]
|
|
185
148
|
}, {
|
|
186
149
|
customLabel: /*#__PURE__*/React.createElement(Typography, {
|
|
187
150
|
sx: {
|
|
@@ -192,17 +155,6 @@ var EditorInsert = function EditorInsert(_ref) {
|
|
|
192
155
|
}
|
|
193
156
|
}, "\u6A21\u5757"),
|
|
194
157
|
key: 'style'
|
|
195
|
-
}, {
|
|
196
|
-
label: '分割线',
|
|
197
|
-
key: 'separator',
|
|
198
|
-
icon: /*#__PURE__*/React.createElement(SeparatorIcon, {
|
|
199
|
-
sx: {
|
|
200
|
-
fontSize: '1rem'
|
|
201
|
-
}
|
|
202
|
-
}),
|
|
203
|
-
onClick: function onClick() {
|
|
204
|
-
return editor.chain().focus().setHorizontalRule().run();
|
|
205
|
-
}
|
|
206
158
|
}, {
|
|
207
159
|
label: '引用',
|
|
208
160
|
key: 'blockquote',
|
|
@@ -220,10 +172,17 @@ var EditorInsert = function EditorInsert(_ref) {
|
|
|
220
172
|
onClick: function onClick() {
|
|
221
173
|
return editor.chain().focus().toggleBlockquote().run();
|
|
222
174
|
}
|
|
223
|
-
},
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
175
|
+
},
|
|
176
|
+
// {
|
|
177
|
+
// label: '分栏',
|
|
178
|
+
// key: 'flipGrid',
|
|
179
|
+
// icon: <FlipGridIcon sx={{ fontSize: '1rem' }} />,
|
|
180
|
+
// onClick: () => editor.chain().focus().setFlipGrid().run(),
|
|
181
|
+
// },
|
|
182
|
+
{
|
|
183
|
+
label: '表格',
|
|
184
|
+
key: 'table',
|
|
185
|
+
icon: /*#__PURE__*/React.createElement(Table2Icon, {
|
|
227
186
|
sx: {
|
|
228
187
|
fontSize: '1rem'
|
|
229
188
|
}
|
|
@@ -233,10 +192,19 @@ var EditorInsert = function EditorInsert(_ref) {
|
|
|
233
192
|
fontSize: '12px',
|
|
234
193
|
color: 'text.disabled'
|
|
235
194
|
}
|
|
236
|
-
}, getShortcutKeyText(['ctrl', '
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
195
|
+
}, getShortcutKeyText(['ctrl', '9'], '+')),
|
|
196
|
+
children: [{
|
|
197
|
+
key: 'table-size-picker',
|
|
198
|
+
customLabel: /*#__PURE__*/React.createElement(TableSizePicker, {
|
|
199
|
+
onConfirm: function onConfirm(cols, rows) {
|
|
200
|
+
editor.commands.insertTable({
|
|
201
|
+
rows: rows,
|
|
202
|
+
cols: cols,
|
|
203
|
+
withHeaderRow: false
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
}]
|
|
240
208
|
}, {
|
|
241
209
|
label: '警告块',
|
|
242
210
|
key: 'highlight',
|
|
@@ -321,6 +289,34 @@ var EditorInsert = function EditorInsert(_ref) {
|
|
|
321
289
|
}).run();
|
|
322
290
|
}
|
|
323
291
|
}]
|
|
292
|
+
}, {
|
|
293
|
+
label: '折叠面板',
|
|
294
|
+
key: 'details',
|
|
295
|
+
icon: /*#__PURE__*/React.createElement(MenuFold2FillIcon, {
|
|
296
|
+
sx: {
|
|
297
|
+
fontSize: '1rem'
|
|
298
|
+
}
|
|
299
|
+
}),
|
|
300
|
+
extra: /*#__PURE__*/React.createElement(Typography, {
|
|
301
|
+
sx: {
|
|
302
|
+
fontSize: '12px',
|
|
303
|
+
color: 'text.disabled'
|
|
304
|
+
}
|
|
305
|
+
}, getShortcutKeyText(['ctrl', '8'], '+')),
|
|
306
|
+
onClick: function onClick() {
|
|
307
|
+
return editor.chain().focus().setDetails().run();
|
|
308
|
+
}
|
|
309
|
+
}, {
|
|
310
|
+
label: '分割线',
|
|
311
|
+
key: 'separator',
|
|
312
|
+
icon: /*#__PURE__*/React.createElement(SeparatorIcon, {
|
|
313
|
+
sx: {
|
|
314
|
+
fontSize: '1rem'
|
|
315
|
+
}
|
|
316
|
+
}),
|
|
317
|
+
onClick: function onClick() {
|
|
318
|
+
return editor.chain().focus().setHorizontalRule().run();
|
|
319
|
+
}
|
|
324
320
|
}, {
|
|
325
321
|
customLabel: /*#__PURE__*/React.createElement(Typography, {
|
|
326
322
|
sx: {
|
|
@@ -331,6 +327,17 @@ var EditorInsert = function EditorInsert(_ref) {
|
|
|
331
327
|
}
|
|
332
328
|
}, "\u4E13\u4E1A"),
|
|
333
329
|
key: 'programmer'
|
|
330
|
+
}, {
|
|
331
|
+
label: '流程图',
|
|
332
|
+
key: 'flow',
|
|
333
|
+
icon: /*#__PURE__*/React.createElement(FlowChartIcon, {
|
|
334
|
+
sx: {
|
|
335
|
+
fontSize: '1rem'
|
|
336
|
+
}
|
|
337
|
+
}),
|
|
338
|
+
onClick: function onClick() {
|
|
339
|
+
return editor.commands.setFlow({});
|
|
340
|
+
}
|
|
334
341
|
}, {
|
|
335
342
|
label: '代码',
|
|
336
343
|
key: 'code',
|
|
@@ -6,6 +6,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
import { createBlockMarkdownSpec, mergeAttributes, Node } from '@tiptap/core';
|
|
8
8
|
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
9
|
+
import { v4 as uuid } from 'uuid';
|
|
9
10
|
import AlertView from "../component/Alert";
|
|
10
11
|
export var AlertExtension = Node.create(_objectSpread(_objectSpread({
|
|
11
12
|
name: 'alert',
|
|
@@ -76,7 +77,7 @@ export var AlertExtension = Node.create(_objectSpread(_objectSpread({
|
|
|
76
77
|
var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
77
78
|
return function (_ref2) {
|
|
78
79
|
var commands = _ref2.commands;
|
|
79
|
-
var id = "alert_".concat(
|
|
80
|
+
var id = "alert_".concat(uuid());
|
|
80
81
|
var variant = attrs.variant || 'default';
|
|
81
82
|
var type = attrs.type || 'icon';
|
|
82
83
|
return commands.wrapIn(_this.name, {
|
|
@@ -106,11 +107,9 @@ export var AlertExtension = Node.create(_objectSpread(_objectSpread({
|
|
|
106
107
|
var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
107
108
|
return function (_ref5) {
|
|
108
109
|
var commands = _ref5.commands;
|
|
109
|
-
var id = "alert_".concat(Math.random().toString(36).slice(2));
|
|
110
110
|
var variant = attrs.variant || 'default';
|
|
111
111
|
var type = attrs.type || 'icon';
|
|
112
112
|
return commands.toggleWrap(_this.name, {
|
|
113
|
-
id: id,
|
|
114
113
|
variant: variant,
|
|
115
114
|
type: type
|
|
116
115
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { UploadFunction } from "../../type";
|
|
2
2
|
export declare const FileHandlerExtension: (props: {
|
|
3
3
|
onUpload?: UploadFunction;
|
|
4
|
-
}) => import("@tiptap/core").Extension<Omit<import("@tiptap/extension-file-handler").FileHandlePluginOptions, "
|
|
4
|
+
}) => import("@tiptap/core").Extension<Omit<import("@tiptap/extension-file-handler").FileHandlePluginOptions, "key" | "editor">, any>;
|