@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,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
function
|
|
3
|
-
function
|
|
4
|
-
function
|
|
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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
5
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
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
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); }
|
|
@@ -9,10 +9,11 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
9
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
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
11
|
import { getShortcutKeyText } from "../../util";
|
|
12
|
-
import { Box,
|
|
12
|
+
import { Box, Typography } from "@mui/material";
|
|
13
13
|
import React, { useEffect, useState } from "react";
|
|
14
|
-
import { ArrowDownSLineIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, H6Icon,
|
|
15
|
-
import
|
|
14
|
+
import { ArrowDownSLineIcon, H1Icon, H2Icon, H3Icon, H4Icon, H5Icon, H6Icon, TextIcon } from "../Icons";
|
|
15
|
+
import Menu from "../Menu";
|
|
16
|
+
import { default as ToolbarItem } from "./Item";
|
|
16
17
|
var EditorHeading = function EditorHeading(_ref) {
|
|
17
18
|
var editor = _ref.editor;
|
|
18
19
|
var _useState = useState("paragraph"),
|
|
@@ -21,12 +22,12 @@ var EditorHeading = function EditorHeading(_ref) {
|
|
|
21
22
|
setSelectedValue = _useState2[1];
|
|
22
23
|
var HeadingOptions = [{
|
|
23
24
|
id: 'paragraph',
|
|
24
|
-
icon: /*#__PURE__*/React.createElement(
|
|
25
|
+
icon: /*#__PURE__*/React.createElement(TextIcon, {
|
|
25
26
|
sx: {
|
|
26
27
|
fontSize: '1rem'
|
|
27
28
|
}
|
|
28
29
|
}),
|
|
29
|
-
label: '
|
|
30
|
+
label: '正文',
|
|
30
31
|
shortcutKey: ['ctrl', 'alt', '0']
|
|
31
32
|
}, {
|
|
32
33
|
id: '1',
|
|
@@ -35,7 +36,7 @@ var EditorHeading = function EditorHeading(_ref) {
|
|
|
35
36
|
fontSize: '1rem'
|
|
36
37
|
}
|
|
37
38
|
}),
|
|
38
|
-
label: '
|
|
39
|
+
label: '标题1',
|
|
39
40
|
shortcutKey: ['ctrl', 'alt', '1']
|
|
40
41
|
}, {
|
|
41
42
|
id: '2',
|
|
@@ -44,7 +45,7 @@ var EditorHeading = function EditorHeading(_ref) {
|
|
|
44
45
|
fontSize: '1rem'
|
|
45
46
|
}
|
|
46
47
|
}),
|
|
47
|
-
label: '
|
|
48
|
+
label: '标题2',
|
|
48
49
|
shortcutKey: ['ctrl', 'alt', '2']
|
|
49
50
|
}, {
|
|
50
51
|
id: '3',
|
|
@@ -53,7 +54,7 @@ var EditorHeading = function EditorHeading(_ref) {
|
|
|
53
54
|
fontSize: '1rem'
|
|
54
55
|
}
|
|
55
56
|
}),
|
|
56
|
-
label: '
|
|
57
|
+
label: '标题3',
|
|
57
58
|
shortcutKey: ['ctrl', 'alt', '3']
|
|
58
59
|
}, {
|
|
59
60
|
id: '4',
|
|
@@ -62,7 +63,7 @@ var EditorHeading = function EditorHeading(_ref) {
|
|
|
62
63
|
fontSize: '1rem'
|
|
63
64
|
}
|
|
64
65
|
}),
|
|
65
|
-
label: '
|
|
66
|
+
label: '标题4',
|
|
66
67
|
shortcutKey: ['ctrl', 'alt', '4']
|
|
67
68
|
}, {
|
|
68
69
|
id: '5',
|
|
@@ -71,7 +72,7 @@ var EditorHeading = function EditorHeading(_ref) {
|
|
|
71
72
|
fontSize: '1rem'
|
|
72
73
|
}
|
|
73
74
|
}),
|
|
74
|
-
label: '
|
|
75
|
+
label: '标题5',
|
|
75
76
|
shortcutKey: ['ctrl', 'alt', '5']
|
|
76
77
|
}, {
|
|
77
78
|
id: '6',
|
|
@@ -80,15 +81,14 @@ var EditorHeading = function EditorHeading(_ref) {
|
|
|
80
81
|
fontSize: '1rem'
|
|
81
82
|
}
|
|
82
83
|
}),
|
|
83
|
-
label: '
|
|
84
|
+
label: '标题6',
|
|
84
85
|
shortcutKey: ['ctrl', 'alt', '6']
|
|
85
86
|
}];
|
|
86
87
|
var updateSelection = function updateSelection() {
|
|
87
88
|
var level = editor.getAttributes("heading").level || "paragraph";
|
|
88
89
|
setSelectedValue(level);
|
|
89
90
|
};
|
|
90
|
-
var handleChange = function handleChange(
|
|
91
|
-
var value = e.target.value;
|
|
91
|
+
var handleChange = function handleChange(value) {
|
|
92
92
|
setSelectedValue(value);
|
|
93
93
|
if (value !== 'paragraph') {
|
|
94
94
|
var level = parseInt(value);
|
|
@@ -107,79 +107,67 @@ var EditorHeading = function EditorHeading(_ref) {
|
|
|
107
107
|
editor.off('transaction', updateSelection);
|
|
108
108
|
};
|
|
109
109
|
}, [editor]);
|
|
110
|
-
return /*#__PURE__*/React.createElement(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
var _HeadingOptions$find;
|
|
127
|
-
return /*#__PURE__*/React.createElement(ToolItem, {
|
|
128
|
-
tip: '标题',
|
|
129
|
-
icon: /*#__PURE__*/React.createElement(Stack, {
|
|
130
|
-
direction: 'row',
|
|
131
|
-
alignItems: 'center',
|
|
132
|
-
sx: {
|
|
133
|
-
mr: 0.5,
|
|
134
|
-
width: '1.5rem'
|
|
135
|
-
}
|
|
136
|
-
}, ((_HeadingOptions$find = HeadingOptions.find(function (it) {
|
|
137
|
-
return it.id === String(value);
|
|
138
|
-
})) === null || _HeadingOptions$find === void 0 ? void 0 : _HeadingOptions$find.icon) || /*#__PURE__*/React.createElement(HeadingIcon, {
|
|
139
|
-
sx: {
|
|
140
|
-
fontSize: '1rem'
|
|
141
|
-
}
|
|
142
|
-
}))
|
|
143
|
-
});
|
|
144
|
-
},
|
|
145
|
-
IconComponent: function IconComponent(_ref2) {
|
|
146
|
-
var className = _ref2.className,
|
|
147
|
-
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
148
|
-
return /*#__PURE__*/React.createElement(ArrowDownSLineIcon, _extends({
|
|
110
|
+
return /*#__PURE__*/React.createElement(Menu, {
|
|
111
|
+
context: /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
112
|
+
tip: '标题',
|
|
113
|
+
text: /*#__PURE__*/React.createElement(Box, {
|
|
114
|
+
sx: {
|
|
115
|
+
position: 'relative',
|
|
116
|
+
pr: 1
|
|
117
|
+
}
|
|
118
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
119
|
+
sx: {
|
|
120
|
+
width: '38px',
|
|
121
|
+
textAlign: 'left'
|
|
122
|
+
}
|
|
123
|
+
}, HeadingOptions.filter(function (it) {
|
|
124
|
+
return it.id === String(selectedValue);
|
|
125
|
+
})[0].label), /*#__PURE__*/React.createElement(ArrowDownSLineIcon, {
|
|
149
126
|
sx: {
|
|
150
127
|
position: 'absolute',
|
|
151
|
-
right:
|
|
128
|
+
right: -6,
|
|
129
|
+
top: '50%',
|
|
130
|
+
transform: 'translateY(-50%)',
|
|
152
131
|
flexSelf: 'center',
|
|
153
132
|
fontSize: '1rem',
|
|
154
133
|
flexShrink: 0,
|
|
155
134
|
mr: 0,
|
|
156
135
|
color: 'text.disabled',
|
|
157
|
-
transform: className !== null && className !== void 0 && className.includes('MuiSelect-iconOpen') ? 'rotate(-180deg)' : 'none',
|
|
158
|
-
transition: 'transform 0.3s',
|
|
159
136
|
cursor: 'pointer',
|
|
160
137
|
pointerEvents: 'none'
|
|
161
138
|
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
direction: 'row',
|
|
174
|
-
alignItems: 'center',
|
|
175
|
-
justifyContent: "center",
|
|
176
|
-
gap: 1
|
|
177
|
-
}, it.icon, /*#__PURE__*/React.createElement(Box, {
|
|
139
|
+
}))
|
|
140
|
+
}),
|
|
141
|
+
anchorOrigin: {
|
|
142
|
+
vertical: 'bottom',
|
|
143
|
+
horizontal: 'left'
|
|
144
|
+
},
|
|
145
|
+
transformOrigin: {
|
|
146
|
+
vertical: 'top',
|
|
147
|
+
horizontal: 'left'
|
|
148
|
+
},
|
|
149
|
+
arrowIcon: /*#__PURE__*/React.createElement(ArrowDownSLineIcon, {
|
|
178
150
|
sx: {
|
|
179
|
-
|
|
180
|
-
|
|
151
|
+
fontSize: '1rem',
|
|
152
|
+
transform: 'rotate(-90deg)'
|
|
181
153
|
}
|
|
182
|
-
},
|
|
183
|
-
|
|
154
|
+
}),
|
|
155
|
+
list: _toConsumableArray(HeadingOptions.map(function (it) {
|
|
156
|
+
return {
|
|
157
|
+
label: it.label,
|
|
158
|
+
key: it.id,
|
|
159
|
+
icon: it.icon,
|
|
160
|
+
extra: /*#__PURE__*/React.createElement(Typography, {
|
|
161
|
+
sx: {
|
|
162
|
+
fontSize: '12px',
|
|
163
|
+
color: 'text.disabled'
|
|
164
|
+
}
|
|
165
|
+
}, getShortcutKeyText(it.shortcutKey, ' ')),
|
|
166
|
+
onClick: function onClick() {
|
|
167
|
+
return handleChange(it.id);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}))
|
|
171
|
+
});
|
|
184
172
|
};
|
|
185
173
|
export default EditorHeading;
|