@ctzhian/tiptap 1.6.2 → 1.6.3
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/Editor/demo.js +6 -47
- package/dist/EditorToolbar/index.js +99 -101
- package/dist/component/CustomDragHandle/index.js +7 -3
- package/dist/component/Icons/add-circle-fill-icon.d.ts +6 -0
- package/dist/component/Icons/add-circle-fill-icon.js +13 -0
- package/dist/component/Icons/eraser-line-icon.d.ts +6 -0
- package/dist/component/Icons/eraser-line-icon.js +13 -0
- package/dist/component/Icons/folder-2-line-icon.d.ts +6 -0
- package/dist/component/Icons/folder-2-line-icon.js +13 -0
- package/dist/component/Icons/index.d.ts +3 -0
- package/dist/component/Icons/index.js +3 -0
- package/dist/component/Menu/NestedList.d.ts +1 -0
- package/dist/component/Menu/NestedList.js +7 -2
- package/dist/component/Menu/index.js +3 -0
- package/dist/component/Toolbar/EditorHeading.js +67 -79
- package/dist/component/Toolbar/EditorInsert/index.d.ts +2 -2
- package/dist/component/Toolbar/EditorInsert/index.js +414 -178
- package/dist/component/Toolbar/Item.d.ts +1 -1
- package/dist/extension/index.js +1 -1
- package/dist/extension/node/FileHandler.d.ts +1 -1
- package/dist/type/index.d.ts +2 -0
- package/dist/util/shortcutKey.d.ts +1 -1
- package/dist/util/shortcutKey.js +2 -1
- package/package.json +1 -1
- /package/dist/types/{images.d.ts → declare.d.ts} +0 -0
|
@@ -1,197 +1,433 @@
|
|
|
1
|
-
var _excluded = ["className"];
|
|
2
|
-
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); }
|
|
3
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
5
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
-
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); }
|
|
8
|
-
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; }
|
|
9
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
1
|
import { getShortcutKeyText } from "../../../util";
|
|
12
|
-
import {
|
|
13
|
-
import React
|
|
14
|
-
import { ArrowDownSLineIcon, AttachmentLineIcon, ImageLineIcon, MovieLineIcon, Music2LineIcon,
|
|
2
|
+
import { Typography } from '@mui/material';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { AddCircleFillIcon, ArrowDownSLineIcon, AttachmentLineIcon, CheckboxCircleFillIcon, CloseCircleFillIcon, CodeBoxLineIcon, CodeLineIcon, CodeSSlashLineIcon, DoubleQuotesLIcon, ErrorWarningFillIcon, Folder2LineIcon, FormulaIcon, FunctionsIcon, ImageLineIcon, Information2FillIcon, Information2LineIcon, MenuFold2FillIcon, MovieLineIcon, Music2LineIcon, SeparatorIcon, SquareRootIcon, Table2Icon, WindowFillIcon } from "../../Icons";
|
|
5
|
+
import Menu from "../../Menu";
|
|
15
6
|
import ToolbarItem from "../Item";
|
|
7
|
+
import TableSizePicker from "../TableSizePicker";
|
|
16
8
|
var EditorInsert = function EditorInsert(_ref) {
|
|
17
9
|
var editor = _ref.editor;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
10
|
+
return /*#__PURE__*/React.createElement(Menu, {
|
|
11
|
+
width: 224,
|
|
12
|
+
context: /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
13
|
+
tip: '插入',
|
|
14
|
+
text: '插入',
|
|
15
|
+
icon: /*#__PURE__*/React.createElement(AddCircleFillIcon, {
|
|
16
|
+
sx: {
|
|
17
|
+
fontSize: '1rem'
|
|
18
|
+
}
|
|
19
|
+
})
|
|
28
20
|
}),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
anchorOrigin: {
|
|
22
|
+
vertical: 'bottom',
|
|
23
|
+
horizontal: 'left'
|
|
24
|
+
},
|
|
25
|
+
transformOrigin: {
|
|
26
|
+
vertical: 'top',
|
|
27
|
+
horizontal: 'left'
|
|
28
|
+
},
|
|
29
|
+
arrowIcon: /*#__PURE__*/React.createElement(ArrowDownSLineIcon, {
|
|
34
30
|
sx: {
|
|
35
|
-
fontSize: '1rem'
|
|
31
|
+
fontSize: '1rem',
|
|
32
|
+
transform: 'rotate(-90deg)'
|
|
36
33
|
}
|
|
37
34
|
}),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
list: [{
|
|
36
|
+
customLabel: /*#__PURE__*/React.createElement(Typography, {
|
|
37
|
+
sx: {
|
|
38
|
+
px: 1,
|
|
39
|
+
pt: 2,
|
|
40
|
+
fontSize: '12px',
|
|
41
|
+
color: 'text.disabled'
|
|
42
|
+
}
|
|
43
|
+
}, "\u901A\u7528"),
|
|
44
|
+
key: 'current-node'
|
|
45
|
+
}, {
|
|
46
|
+
label: '图片',
|
|
47
|
+
key: 'image',
|
|
48
|
+
icon: /*#__PURE__*/React.createElement(ImageLineIcon, {
|
|
49
|
+
sx: {
|
|
50
|
+
fontSize: '1rem'
|
|
51
|
+
}
|
|
52
|
+
}),
|
|
53
|
+
extra: /*#__PURE__*/React.createElement(Typography, {
|
|
54
|
+
sx: {
|
|
55
|
+
fontSize: '12px',
|
|
56
|
+
color: 'text.disabled'
|
|
57
|
+
}
|
|
58
|
+
}, getShortcutKeyText(['ctrl', '2'], '+')),
|
|
59
|
+
onClick: function onClick() {
|
|
60
|
+
return editor.commands.setImage({
|
|
61
|
+
src: '',
|
|
62
|
+
width: 760
|
|
63
|
+
});
|
|
45
64
|
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
65
|
+
}, {
|
|
66
|
+
label: '表格',
|
|
67
|
+
key: 'table',
|
|
68
|
+
icon: /*#__PURE__*/React.createElement(Table2Icon, {
|
|
69
|
+
sx: {
|
|
70
|
+
fontSize: '1rem'
|
|
71
|
+
}
|
|
72
|
+
}),
|
|
73
|
+
extra: /*#__PURE__*/React.createElement(Typography, {
|
|
74
|
+
sx: {
|
|
75
|
+
fontSize: '12px',
|
|
76
|
+
color: 'text.disabled'
|
|
77
|
+
}
|
|
78
|
+
}, getShortcutKeyText(['ctrl', '9'], '+')),
|
|
79
|
+
children: [{
|
|
80
|
+
key: 'table-size-picker',
|
|
81
|
+
customLabel: /*#__PURE__*/React.createElement(TableSizePicker, {
|
|
82
|
+
onConfirm: function onConfirm(cols, rows) {
|
|
83
|
+
editor.commands.insertTable({
|
|
84
|
+
rows: rows,
|
|
85
|
+
cols: cols,
|
|
86
|
+
withHeaderRow: true
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
}]
|
|
91
|
+
}, {
|
|
92
|
+
label: '文件',
|
|
93
|
+
key: 'file',
|
|
94
|
+
icon: /*#__PURE__*/React.createElement(Folder2LineIcon, {
|
|
95
|
+
sx: {
|
|
96
|
+
fontSize: '1rem'
|
|
97
|
+
}
|
|
98
|
+
}),
|
|
99
|
+
children: [{
|
|
100
|
+
label: '附件',
|
|
101
|
+
key: 'attachment',
|
|
102
|
+
extra: /*#__PURE__*/React.createElement(Typography, {
|
|
103
|
+
sx: {
|
|
104
|
+
fontSize: '12px',
|
|
105
|
+
color: 'text.disabled'
|
|
106
|
+
}
|
|
107
|
+
}, getShortcutKeyText(['ctrl', '5'], '+')),
|
|
108
|
+
icon: /*#__PURE__*/React.createElement(AttachmentLineIcon, {
|
|
109
|
+
sx: {
|
|
110
|
+
fontSize: '1rem'
|
|
111
|
+
}
|
|
112
|
+
}),
|
|
113
|
+
onClick: function onClick() {
|
|
114
|
+
return editor.commands.setInlineAttachment({
|
|
115
|
+
url: '',
|
|
116
|
+
title: '',
|
|
117
|
+
size: '0'
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
label: '音频',
|
|
122
|
+
key: 'audio',
|
|
123
|
+
extra: /*#__PURE__*/React.createElement(Typography, {
|
|
124
|
+
sx: {
|
|
125
|
+
fontSize: '12px',
|
|
126
|
+
color: 'text.disabled'
|
|
127
|
+
}
|
|
128
|
+
}, getShortcutKeyText(['ctrl', '4'], '+')),
|
|
129
|
+
icon: /*#__PURE__*/React.createElement(Music2LineIcon, {
|
|
130
|
+
sx: {
|
|
131
|
+
fontSize: '1rem'
|
|
132
|
+
}
|
|
133
|
+
}),
|
|
134
|
+
onClick: function onClick() {
|
|
135
|
+
return editor.commands.setAudio({
|
|
136
|
+
src: '',
|
|
137
|
+
controls: true,
|
|
138
|
+
autoplay: false
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
label: '视频',
|
|
143
|
+
key: 'video',
|
|
144
|
+
extra: /*#__PURE__*/React.createElement(Typography, {
|
|
145
|
+
sx: {
|
|
146
|
+
fontSize: '12px',
|
|
147
|
+
color: 'text.disabled'
|
|
148
|
+
}
|
|
149
|
+
}, getShortcutKeyText(['ctrl', '3'], '+')),
|
|
150
|
+
icon: /*#__PURE__*/React.createElement(MovieLineIcon, {
|
|
151
|
+
sx: {
|
|
152
|
+
fontSize: '1rem'
|
|
153
|
+
}
|
|
154
|
+
}),
|
|
155
|
+
onClick: function onClick() {
|
|
156
|
+
return editor.commands.setVideo({
|
|
157
|
+
src: '',
|
|
158
|
+
width: 760,
|
|
159
|
+
controls: true,
|
|
160
|
+
autoplay: false
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}]
|
|
164
|
+
}, {
|
|
165
|
+
customLabel: /*#__PURE__*/React.createElement(Typography, {
|
|
166
|
+
sx: {
|
|
167
|
+
px: 1,
|
|
168
|
+
pt: 2,
|
|
169
|
+
fontSize: '12px',
|
|
170
|
+
color: 'text.disabled'
|
|
171
|
+
}
|
|
172
|
+
}, "\u6837\u5F0F\u5E03\u5C40"),
|
|
173
|
+
key: 'style'
|
|
174
|
+
}, {
|
|
175
|
+
label: '分割线',
|
|
176
|
+
key: 'separator',
|
|
177
|
+
icon: /*#__PURE__*/React.createElement(SeparatorIcon, {
|
|
178
|
+
sx: {
|
|
179
|
+
fontSize: '1rem'
|
|
180
|
+
}
|
|
181
|
+
}),
|
|
182
|
+
onClick: function onClick() {
|
|
183
|
+
return editor.commands.insertContentAt(editor.state.selection.from, {
|
|
184
|
+
type: 'horizontalRule'
|
|
185
|
+
});
|
|
54
186
|
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
};
|
|
72
|
-
var handleChange = function handleChange(e) {
|
|
73
|
-
var value = e.target.value;
|
|
74
|
-
if (value === 'image') {
|
|
75
|
-
editor.commands.setImage({
|
|
76
|
-
src: '',
|
|
77
|
-
width: 760
|
|
78
|
-
});
|
|
79
|
-
} else if (value === 'video') {
|
|
80
|
-
editor.commands.setVideo({
|
|
81
|
-
src: '',
|
|
82
|
-
width: 760,
|
|
83
|
-
controls: true,
|
|
84
|
-
autoplay: false
|
|
85
|
-
});
|
|
86
|
-
} else if (value === 'audio') {
|
|
87
|
-
editor.commands.setAudio({
|
|
88
|
-
src: '',
|
|
89
|
-
controls: true,
|
|
90
|
-
autoplay: false
|
|
91
|
-
});
|
|
92
|
-
} else if (value === 'attachment') {
|
|
93
|
-
editor.commands.setInlineAttachment({
|
|
94
|
-
url: '',
|
|
95
|
-
title: '',
|
|
96
|
-
size: '0'
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
setSelectedValue(value);
|
|
100
|
-
};
|
|
101
|
-
useEffect(function () {
|
|
102
|
-
editor.on('selectionUpdate', updateSelection);
|
|
103
|
-
editor.on('transaction', updateSelection);
|
|
104
|
-
return function () {
|
|
105
|
-
editor.off('selectionUpdate', updateSelection);
|
|
106
|
-
editor.off('transaction', updateSelection);
|
|
107
|
-
};
|
|
108
|
-
}, [editor]);
|
|
109
|
-
return /*#__PURE__*/React.createElement(Select, {
|
|
110
|
-
value: selectedValue,
|
|
111
|
-
className: ['image', 'video', 'audio', 'attachment'].includes(selectedValue) ? "tool-active" : "",
|
|
112
|
-
onChange: handleChange,
|
|
113
|
-
sx: {
|
|
114
|
-
bgcolor: 'transparent',
|
|
115
|
-
'&:hover .MuiOutlinedInput-notchedOutline': {
|
|
116
|
-
borderWidth: '0px !important',
|
|
117
|
-
borderColor: 'transparent !important'
|
|
118
|
-
},
|
|
119
|
-
'&.Mui-focused .MuiOutlinedInput-notchedOutline': {
|
|
120
|
-
borderWidth: '0px !important',
|
|
121
|
-
borderColor: 'transparent !important'
|
|
187
|
+
}, {
|
|
188
|
+
label: '引用块',
|
|
189
|
+
key: 'blockquote',
|
|
190
|
+
icon: /*#__PURE__*/React.createElement(DoubleQuotesLIcon, {
|
|
191
|
+
sx: {
|
|
192
|
+
fontSize: '1rem'
|
|
193
|
+
}
|
|
194
|
+
}),
|
|
195
|
+
extra: /*#__PURE__*/React.createElement(Typography, {
|
|
196
|
+
sx: {
|
|
197
|
+
fontSize: '12px',
|
|
198
|
+
color: 'text.disabled'
|
|
199
|
+
}
|
|
200
|
+
}, getShortcutKeyText(['ctrl', 'shift', 'B'], '+')),
|
|
201
|
+
onClick: function onClick() {
|
|
202
|
+
return editor.chain().focus().toggleBlockquote().run();
|
|
122
203
|
}
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
204
|
+
}, {
|
|
205
|
+
label: '折叠块',
|
|
206
|
+
key: 'details',
|
|
207
|
+
icon: /*#__PURE__*/React.createElement(MenuFold2FillIcon, {
|
|
208
|
+
sx: {
|
|
209
|
+
fontSize: '1rem'
|
|
210
|
+
}
|
|
211
|
+
}),
|
|
212
|
+
extra: /*#__PURE__*/React.createElement(Typography, {
|
|
213
|
+
sx: {
|
|
214
|
+
fontSize: '12px',
|
|
215
|
+
color: 'text.disabled'
|
|
216
|
+
}
|
|
217
|
+
}, getShortcutKeyText(['ctrl', '8'], '+')),
|
|
218
|
+
onClick: function onClick() {
|
|
219
|
+
return editor.chain().focus().setDetails().run();
|
|
220
|
+
}
|
|
221
|
+
}, {
|
|
222
|
+
label: '警告提示',
|
|
223
|
+
key: 'highlight',
|
|
224
|
+
icon: /*#__PURE__*/React.createElement(Information2LineIcon, {
|
|
225
|
+
sx: {
|
|
226
|
+
fontSize: '1rem'
|
|
227
|
+
}
|
|
228
|
+
}),
|
|
229
|
+
children: [{
|
|
230
|
+
label: '信息 Info',
|
|
231
|
+
key: 'info',
|
|
232
|
+
icon: /*#__PURE__*/React.createElement(Information2FillIcon, {
|
|
233
|
+
sx: {
|
|
234
|
+
fontSize: '1rem',
|
|
235
|
+
color: 'primary.main'
|
|
236
|
+
}
|
|
237
|
+
}),
|
|
238
|
+
onClick: function onClick() {
|
|
239
|
+
editor.commands.setAlert({
|
|
240
|
+
type: 'icon',
|
|
241
|
+
variant: 'info'
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}, {
|
|
245
|
+
label: '警告 Warning',
|
|
246
|
+
key: 'warning',
|
|
247
|
+
icon: /*#__PURE__*/React.createElement(ErrorWarningFillIcon, {
|
|
248
|
+
sx: {
|
|
249
|
+
fontSize: '1rem',
|
|
250
|
+
color: 'warning.main'
|
|
251
|
+
}
|
|
252
|
+
}),
|
|
253
|
+
onClick: function onClick() {
|
|
254
|
+
editor.commands.setAlert({
|
|
255
|
+
type: 'icon',
|
|
256
|
+
variant: 'warning'
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}, {
|
|
260
|
+
label: '错误 Error',
|
|
261
|
+
key: 'error',
|
|
262
|
+
icon: /*#__PURE__*/React.createElement(CloseCircleFillIcon, {
|
|
263
|
+
sx: {
|
|
264
|
+
fontSize: '1rem',
|
|
265
|
+
color: 'error.main'
|
|
266
|
+
}
|
|
267
|
+
}),
|
|
268
|
+
onClick: function onClick() {
|
|
269
|
+
editor.commands.setAlert({
|
|
270
|
+
type: 'icon',
|
|
271
|
+
variant: 'error'
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}, {
|
|
275
|
+
label: '成功 Success',
|
|
276
|
+
key: 'success',
|
|
277
|
+
icon: /*#__PURE__*/React.createElement(CheckboxCircleFillIcon, {
|
|
131
278
|
sx: {
|
|
132
|
-
|
|
133
|
-
|
|
279
|
+
fontSize: '1rem',
|
|
280
|
+
color: 'success.main'
|
|
134
281
|
}
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
|
|
282
|
+
}),
|
|
283
|
+
onClick: function onClick() {
|
|
284
|
+
editor.commands.setAlert({
|
|
285
|
+
type: 'icon',
|
|
286
|
+
variant: 'success'
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}]
|
|
290
|
+
}, {
|
|
291
|
+
label: 'Iframe 链接',
|
|
292
|
+
key: 'iframe',
|
|
293
|
+
icon: /*#__PURE__*/React.createElement(WindowFillIcon, {
|
|
294
|
+
sx: {
|
|
295
|
+
fontSize: '1rem'
|
|
296
|
+
}
|
|
297
|
+
}),
|
|
298
|
+
onClick: function onClick() {
|
|
299
|
+
return editor.commands.setIframe({
|
|
300
|
+
src: '',
|
|
301
|
+
width: 760,
|
|
302
|
+
height: 400
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}, {
|
|
306
|
+
customLabel: /*#__PURE__*/React.createElement(Typography, {
|
|
307
|
+
sx: {
|
|
308
|
+
px: 1,
|
|
309
|
+
pt: 2,
|
|
310
|
+
fontSize: '12px',
|
|
311
|
+
color: 'text.disabled'
|
|
312
|
+
}
|
|
313
|
+
}, "\u7A0B\u5E8F\u5458\u4E13\u7528"),
|
|
314
|
+
key: 'programmer'
|
|
315
|
+
}, {
|
|
316
|
+
label: '代码',
|
|
317
|
+
key: 'code',
|
|
318
|
+
icon: /*#__PURE__*/React.createElement(CodeSSlashLineIcon, {
|
|
319
|
+
sx: {
|
|
320
|
+
fontSize: '1rem'
|
|
321
|
+
}
|
|
322
|
+
}),
|
|
323
|
+
children: [{
|
|
324
|
+
label: '行内代码',
|
|
325
|
+
key: 'inlineCode',
|
|
326
|
+
icon: /*#__PURE__*/React.createElement(CodeLineIcon, {
|
|
138
327
|
sx: {
|
|
139
328
|
fontSize: '1rem'
|
|
140
329
|
}
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
330
|
+
}),
|
|
331
|
+
extra: /*#__PURE__*/React.createElement(Typography, {
|
|
332
|
+
sx: {
|
|
333
|
+
fontSize: '12px',
|
|
334
|
+
color: 'text.disabled'
|
|
335
|
+
}
|
|
336
|
+
}, getShortcutKeyText(['ctrl', 'E'], '+')),
|
|
337
|
+
onClick: function onClick() {
|
|
338
|
+
return editor.commands.toggleCode();
|
|
339
|
+
}
|
|
340
|
+
}, {
|
|
341
|
+
label: '代码块',
|
|
342
|
+
key: 'codeBlock',
|
|
343
|
+
icon: /*#__PURE__*/React.createElement(CodeBoxLineIcon, {
|
|
344
|
+
sx: {
|
|
345
|
+
fontSize: '1rem'
|
|
346
|
+
}
|
|
347
|
+
}),
|
|
348
|
+
extra: /*#__PURE__*/React.createElement(Typography, {
|
|
349
|
+
sx: {
|
|
350
|
+
fontSize: '12px',
|
|
351
|
+
color: 'text.disabled'
|
|
352
|
+
}
|
|
353
|
+
}, getShortcutKeyText(['ctrl', 'alt', 'C'], '+')),
|
|
354
|
+
onClick: function onClick() {
|
|
355
|
+
return editor.commands.toggleCodeBlock();
|
|
356
|
+
}
|
|
357
|
+
}]
|
|
358
|
+
}, {
|
|
359
|
+
label: '数学公式',
|
|
360
|
+
key: 'math',
|
|
361
|
+
icon: /*#__PURE__*/React.createElement(FormulaIcon, {
|
|
362
|
+
sx: {
|
|
363
|
+
fontSize: '1rem'
|
|
364
|
+
}
|
|
365
|
+
}),
|
|
366
|
+
children: [{
|
|
367
|
+
label: '行内数学公式',
|
|
368
|
+
key: 'inline-math',
|
|
369
|
+
icon: /*#__PURE__*/React.createElement(SquareRootIcon, {
|
|
370
|
+
sx: {
|
|
371
|
+
fontSize: '1rem'
|
|
372
|
+
}
|
|
373
|
+
}),
|
|
374
|
+
extra: /*#__PURE__*/React.createElement(Typography, {
|
|
375
|
+
sx: {
|
|
376
|
+
fontSize: '12px',
|
|
377
|
+
color: 'text.disabled'
|
|
378
|
+
}
|
|
379
|
+
}, getShortcutKeyText(['ctrl', '6'], '+')),
|
|
380
|
+
onClick: function onClick() {
|
|
381
|
+
editor.commands.setInlineMath({
|
|
382
|
+
latex: ''
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
}, {
|
|
386
|
+
label: '块级数学公式',
|
|
387
|
+
key: 'block-math',
|
|
388
|
+
icon: /*#__PURE__*/React.createElement(FunctionsIcon, {
|
|
389
|
+
sx: {
|
|
390
|
+
fontSize: '1rem'
|
|
391
|
+
}
|
|
392
|
+
}),
|
|
393
|
+
extra: /*#__PURE__*/React.createElement(Typography, {
|
|
394
|
+
sx: {
|
|
395
|
+
fontSize: '12px',
|
|
396
|
+
color: 'text.disabled'
|
|
397
|
+
}
|
|
398
|
+
}, getShortcutKeyText(['ctrl', '7'], '+')),
|
|
399
|
+
onClick: function onClick() {
|
|
400
|
+
editor.commands.setBlockMath({
|
|
401
|
+
latex: ''
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}]
|
|
405
|
+
}, {
|
|
406
|
+
customLabel: /*#__PURE__*/React.createElement(Typography, {
|
|
407
|
+
sx: {
|
|
408
|
+
px: 1,
|
|
409
|
+
pt: 2,
|
|
410
|
+
fontSize: '12px',
|
|
411
|
+
color: 'text.disabled'
|
|
412
|
+
}
|
|
413
|
+
}, "\u5176\u4ED6"),
|
|
414
|
+
key: 'other'
|
|
415
|
+
}, {
|
|
416
|
+
label: 'Iframe 链接',
|
|
417
|
+
key: 'iframe',
|
|
418
|
+
icon: /*#__PURE__*/React.createElement(WindowFillIcon, {
|
|
419
|
+
sx: {
|
|
420
|
+
fontSize: '1rem'
|
|
421
|
+
}
|
|
422
|
+
}),
|
|
423
|
+
onClick: function onClick() {
|
|
424
|
+
return editor.commands.setIframe({
|
|
425
|
+
src: '',
|
|
426
|
+
width: 760,
|
|
427
|
+
height: 400
|
|
428
|
+
});
|
|
193
429
|
}
|
|
194
|
-
}
|
|
195
|
-
})
|
|
430
|
+
}]
|
|
431
|
+
});
|
|
196
432
|
};
|
|
197
433
|
export default EditorInsert;
|
package/dist/extension/index.js
CHANGED
|
@@ -138,7 +138,7 @@ export var getExtensions = function getExtensions(_ref) {
|
|
|
138
138
|
if (!(exclude !== null && exclude !== void 0 && exclude.includes('slashCommands'))) {
|
|
139
139
|
defaultExtensions.push(SlashCommands);
|
|
140
140
|
}
|
|
141
|
-
if (!(exclude !== null && exclude !== void 0 && exclude.includes('aiWriting'))) {
|
|
141
|
+
if (!(exclude !== null && exclude !== void 0 && exclude.includes('aiWriting')) && onAiWritingGetSuggestion) {
|
|
142
142
|
defaultExtensions.push(AiWritingExtension({
|
|
143
143
|
onAiWritingGetSuggestion: onAiWritingGetSuggestion
|
|
144
144
|
}));
|
|
@@ -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, "editor" | "key">, any>;
|
package/dist/type/index.d.ts
CHANGED
|
@@ -13,12 +13,14 @@ export interface MenuItem {
|
|
|
13
13
|
children?: MenuItem[];
|
|
14
14
|
textSx?: SxProps<Theme>;
|
|
15
15
|
key: number | string;
|
|
16
|
+
width?: number;
|
|
16
17
|
minWidth?: number;
|
|
17
18
|
maxHeight?: number;
|
|
18
19
|
onClick?: () => void;
|
|
19
20
|
}
|
|
20
21
|
export interface MenuProps {
|
|
21
22
|
id?: string;
|
|
23
|
+
width?: number;
|
|
22
24
|
arrowIcon?: React.ReactNode;
|
|
23
25
|
list: MenuItem[];
|
|
24
26
|
header?: React.ReactNode;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const isMac: () => boolean;
|
|
2
|
-
export declare const getShortcutKeyText: (shortcutKey: string[]) => string;
|
|
2
|
+
export declare const getShortcutKeyText: (shortcutKey: string[], separator?: string) => string;
|
package/dist/util/shortcutKey.js
CHANGED
|
@@ -3,7 +3,8 @@ export var isMac = function isMac() {
|
|
|
3
3
|
return typeof navigator !== "undefined" && navigator.platform.toLowerCase().includes("mac");
|
|
4
4
|
};
|
|
5
5
|
export var getShortcutKeyText = function getShortcutKeyText(shortcutKey) {
|
|
6
|
+
var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ' + ';
|
|
6
7
|
return shortcutKey === null || shortcutKey === void 0 ? void 0 : shortcutKey.map(function (it) {
|
|
7
8
|
return isMac() ? MAC_SYMBOLS[it] || it : it;
|
|
8
|
-
}).join(
|
|
9
|
+
}).join(separator);
|
|
9
10
|
};
|