@ctzhian/tiptap 2.1.17 → 2.2.0
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/component/ImageViewer/Toolbar.js +11 -41
- package/dist/extension/component/UploadProgress/index.d.ts +1 -1
- package/dist/extension/index.d.ts +1 -1
- package/dist/extension/index.js +4 -2
- package/dist/extension/node/FileHandler.d.ts +1 -1
- package/dist/extension/node/TableOfContents/index.d.ts +4 -2
- package/dist/extension/node/TableOfContents/index.js +18 -5
- package/dist/hook/index.d.ts +1 -1
- package/dist/hook/index.js +4 -2
- package/dist/type/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
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; }
|
|
5
5
|
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; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
import { Box, IconButton, Stack
|
|
7
|
+
import { Box, IconButton, Stack } from '@mui/material';
|
|
8
8
|
import React, { useCallback, useContext, useEffect, useState } from 'react';
|
|
9
9
|
import { createPortal } from 'react-dom';
|
|
10
10
|
import { AnticlockwiseLineIcon, ClockwiseLineIcon, CloseCircleFillIcon, Download2LineIcon, FullscreenExitLineIcon, FullscreenLineIcon, ResetLeftFillIcon, SkipLeftIcon, SkipRightIcon } from "../Icons";
|
|
@@ -142,9 +142,6 @@ export var CustomToolbar = function CustomToolbar() {
|
|
|
142
142
|
padding: '8px 12px',
|
|
143
143
|
backdropFilter: 'blur(10px)'
|
|
144
144
|
}
|
|
145
|
-
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
146
|
-
title: "\u4E0A\u4E00\u5F20",
|
|
147
|
-
placement: "top"
|
|
148
145
|
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
149
146
|
onClick: onPrevImage,
|
|
150
147
|
sx: iconButtonSx,
|
|
@@ -154,10 +151,7 @@ export var CustomToolbar = function CustomToolbar() {
|
|
|
154
151
|
sx: {
|
|
155
152
|
fontSize: '20px'
|
|
156
153
|
}
|
|
157
|
-
}))
|
|
158
|
-
title: "\u4E0B\u4E00\u5F20",
|
|
159
|
-
placement: "top"
|
|
160
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
154
|
+
})), /*#__PURE__*/React.createElement(IconButton, {
|
|
161
155
|
onClick: onNextImage,
|
|
162
156
|
sx: iconButtonSx,
|
|
163
157
|
size: "small",
|
|
@@ -166,28 +160,19 @@ export var CustomToolbar = function CustomToolbar() {
|
|
|
166
160
|
sx: {
|
|
167
161
|
fontSize: '20px'
|
|
168
162
|
}
|
|
169
|
-
}))
|
|
170
|
-
title: "\u653E\u5927",
|
|
171
|
-
placement: "top"
|
|
172
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
163
|
+
})), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(IconButton, {
|
|
173
164
|
onClick: function onClick() {
|
|
174
165
|
return handleZoom(0.5);
|
|
175
166
|
},
|
|
176
167
|
sx: iconButtonSx,
|
|
177
168
|
size: "small"
|
|
178
|
-
}, /*#__PURE__*/React.createElement(ZoomInIcon, null))
|
|
179
|
-
title: "\u7F29\u5C0F",
|
|
180
|
-
placement: "top"
|
|
181
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
169
|
+
}, /*#__PURE__*/React.createElement(ZoomInIcon, null)), /*#__PURE__*/React.createElement(IconButton, {
|
|
182
170
|
onClick: function onClick() {
|
|
183
171
|
return handleZoom(-0.5);
|
|
184
172
|
},
|
|
185
173
|
sx: iconButtonSx,
|
|
186
174
|
size: "small"
|
|
187
|
-
}, /*#__PURE__*/React.createElement(ZoomOutIcon, null))
|
|
188
|
-
title: "\u9006\u65F6\u9488\u65CB\u8F6C",
|
|
189
|
-
placement: "top"
|
|
190
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
175
|
+
}, /*#__PURE__*/React.createElement(ZoomOutIcon, null)), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(IconButton, {
|
|
191
176
|
onClick: function onClick() {
|
|
192
177
|
return handleRotate(-90);
|
|
193
178
|
},
|
|
@@ -197,10 +182,7 @@ export var CustomToolbar = function CustomToolbar() {
|
|
|
197
182
|
sx: {
|
|
198
183
|
fontSize: '20px'
|
|
199
184
|
}
|
|
200
|
-
}))
|
|
201
|
-
title: "\u987A\u65F6\u9488\u65CB\u8F6C",
|
|
202
|
-
placement: "top"
|
|
203
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
185
|
+
})), /*#__PURE__*/React.createElement(IconButton, {
|
|
204
186
|
onClick: function onClick() {
|
|
205
187
|
return handleRotate(90);
|
|
206
188
|
},
|
|
@@ -210,10 +192,7 @@ export var CustomToolbar = function CustomToolbar() {
|
|
|
210
192
|
sx: {
|
|
211
193
|
fontSize: '20px'
|
|
212
194
|
}
|
|
213
|
-
}))
|
|
214
|
-
title: "\u91CD\u7F6E",
|
|
215
|
-
placement: "top"
|
|
216
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
195
|
+
})), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(IconButton, {
|
|
217
196
|
onClick: handleReset,
|
|
218
197
|
sx: iconButtonSx,
|
|
219
198
|
size: "small"
|
|
@@ -221,10 +200,7 @@ export var CustomToolbar = function CustomToolbar() {
|
|
|
221
200
|
sx: {
|
|
222
201
|
fontSize: '20px'
|
|
223
202
|
}
|
|
224
|
-
}))
|
|
225
|
-
title: "\u4E0B\u8F7D",
|
|
226
|
-
placement: "top"
|
|
227
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
203
|
+
})), currentSrc && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(IconButton, {
|
|
228
204
|
onClick: handleDownload,
|
|
229
205
|
sx: iconButtonSx,
|
|
230
206
|
size: "small"
|
|
@@ -232,10 +208,7 @@ export var CustomToolbar = function CustomToolbar() {
|
|
|
232
208
|
sx: {
|
|
233
209
|
fontSize: '20px'
|
|
234
210
|
}
|
|
235
|
-
})))
|
|
236
|
-
title: isFullscreen ? '退出全屏' : '全屏',
|
|
237
|
-
placement: "top"
|
|
238
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
211
|
+
}))), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(IconButton, {
|
|
239
212
|
onClick: handleFullscreen,
|
|
240
213
|
sx: iconButtonSx,
|
|
241
214
|
size: "small"
|
|
@@ -247,10 +220,7 @@ export var CustomToolbar = function CustomToolbar() {
|
|
|
247
220
|
sx: {
|
|
248
221
|
fontSize: '20px'
|
|
249
222
|
}
|
|
250
|
-
}))
|
|
251
|
-
title: "\u5173\u95ED",
|
|
252
|
-
placement: "top"
|
|
253
|
-
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
223
|
+
})), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(IconButton, {
|
|
254
224
|
onClick: handleClose,
|
|
255
225
|
sx: iconButtonSx,
|
|
256
226
|
size: "small"
|
|
@@ -258,7 +228,7 @@ export var CustomToolbar = function CustomToolbar() {
|
|
|
258
228
|
sx: {
|
|
259
229
|
fontSize: '20px'
|
|
260
230
|
}
|
|
261
|
-
}))))
|
|
231
|
+
}))));
|
|
262
232
|
if (typeof document !== 'undefined') {
|
|
263
233
|
return /*#__PURE__*/createPortal(toolbarContent, document.body);
|
|
264
234
|
}
|
|
@@ -7,6 +7,6 @@ export interface UploadProgressAttributes {
|
|
|
7
7
|
tempId: string;
|
|
8
8
|
}
|
|
9
9
|
export declare const getFileIcon: (fileType: string) => React.JSX.Element;
|
|
10
|
-
export declare const getFileTypeText: (fileType: string) => "
|
|
10
|
+
export declare const getFileTypeText: (fileType: string) => "音频" | "图片" | "视频" | "文件";
|
|
11
11
|
declare const UploadProgressView: React.FC<NodeViewProps>;
|
|
12
12
|
export default UploadProgressView;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GetExtensionsProps } from '../type';
|
|
2
|
-
export declare const getExtensions: ({ contentType, limit, exclude, extensions: extensionsProps, youtube, editable, mentionItems, onMentionFilter, onUpload, onError, onTocUpdate, onAiWritingGetSuggestion, onValidateUrl, placeholder, }: GetExtensionsProps) => any;
|
|
2
|
+
export declare const getExtensions: ({ contentType, limit, exclude, extensions: extensionsProps, youtube, editable, mentionItems, onMentionFilter, onUpload, onError, onTocUpdate, onAiWritingGetSuggestion, onValidateUrl, placeholder, tableOfContentsOptions, }: GetExtensionsProps) => any;
|
package/dist/extension/index.js
CHANGED
|
@@ -29,7 +29,8 @@ export var getExtensions = function getExtensions(_ref) {
|
|
|
29
29
|
onTocUpdate = _ref.onTocUpdate,
|
|
30
30
|
onAiWritingGetSuggestion = _ref.onAiWritingGetSuggestion,
|
|
31
31
|
onValidateUrl = _ref.onValidateUrl,
|
|
32
|
-
_placeholder = _ref.placeholder
|
|
32
|
+
_placeholder = _ref.placeholder,
|
|
33
|
+
tableOfContentsOptions = _ref.tableOfContentsOptions;
|
|
33
34
|
var defaultExtensions = [ImeComposition, StarterKit.configure({
|
|
34
35
|
link: false,
|
|
35
36
|
code: false,
|
|
@@ -58,7 +59,8 @@ export var getExtensions = function getExtensions(_ref) {
|
|
|
58
59
|
})].concat(_toConsumableArray(TableExtension({
|
|
59
60
|
editable: editable
|
|
60
61
|
})), [TableOfContentsExtension({
|
|
61
|
-
onTocUpdate: onTocUpdate
|
|
62
|
+
onTocUpdate: onTocUpdate,
|
|
63
|
+
tableOfContentsOptions: tableOfContentsOptions
|
|
62
64
|
}), ImageExtension({
|
|
63
65
|
onUpload: onUpload,
|
|
64
66
|
onError: onError,
|
|
@@ -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>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { TocList } from "../../../type";
|
|
2
|
-
|
|
2
|
+
import { TableOfContentsOptions } from '@tiptap/extension-table-of-contents';
|
|
3
|
+
interface Props {
|
|
3
4
|
onTocUpdate?: (toc: TocList) => void;
|
|
5
|
+
tableOfContentsOptions?: TableOfContentsOptions;
|
|
4
6
|
}
|
|
5
|
-
export declare const TableOfContentsExtension: ({ onTocUpdate }:
|
|
7
|
+
export declare const TableOfContentsExtension: ({ onTocUpdate, tableOfContentsOptions }: Props) => import("@tiptap/core").Extension<TableOfContentsOptions, import("@tiptap/extension-table-of-contents").TableOfContentsStorage>;
|
|
6
8
|
export {};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
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); }
|
|
1
7
|
import { getHierarchicalIndexes, TableOfContents } from '@tiptap/extension-table-of-contents';
|
|
2
8
|
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
3
9
|
export var TableOfContentsExtension = function TableOfContentsExtension(_ref) {
|
|
4
|
-
var onTocUpdate = _ref.onTocUpdate
|
|
10
|
+
var onTocUpdate = _ref.onTocUpdate,
|
|
11
|
+
tableOfContentsOptions = _ref.tableOfContentsOptions;
|
|
5
12
|
return TableOfContents.extend({
|
|
6
13
|
addProseMirrorPlugins: function addProseMirrorPlugins() {
|
|
7
14
|
var imeCompositionPluginKey = new PluginKey('imeComposition');
|
|
@@ -21,9 +28,15 @@ export var TableOfContentsExtension = function TableOfContentsExtension(_ref) {
|
|
|
21
28
|
}
|
|
22
29
|
})];
|
|
23
30
|
}
|
|
24
|
-
}).configure({
|
|
25
|
-
getIndex: getHierarchicalIndexes
|
|
26
|
-
|
|
31
|
+
}).configure(_objectSpread(_objectSpread({
|
|
32
|
+
getIndex: getHierarchicalIndexes
|
|
33
|
+
}, tableOfContentsOptions || {}), {}, {
|
|
34
|
+
onUpdate: function onUpdate(data, isCreate) {
|
|
35
|
+
var _tableOfContentsOptio;
|
|
36
|
+
// 先调用用户传入的 onUpdate 回调(如果存在)
|
|
37
|
+
tableOfContentsOptions === null || tableOfContentsOptions === void 0 || (_tableOfContentsOptio = tableOfContentsOptions.onUpdate) === null || _tableOfContentsOptio === void 0 || _tableOfContentsOptio.call(tableOfContentsOptions, data, isCreate);
|
|
38
|
+
|
|
39
|
+
// 然后调用我们的 onTocUpdate 回调
|
|
27
40
|
setTimeout(function () {
|
|
28
41
|
onTocUpdate === null || onTocUpdate === void 0 || onTocUpdate(data.map(function (content) {
|
|
29
42
|
return {
|
|
@@ -39,5 +52,5 @@ export var TableOfContentsExtension = function TableOfContentsExtension(_ref) {
|
|
|
39
52
|
}));
|
|
40
53
|
}, 60);
|
|
41
54
|
}
|
|
42
|
-
});
|
|
55
|
+
}));
|
|
43
56
|
};
|
package/dist/hook/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { UseTiptapProps, UseTiptapReturn } from "../type";
|
|
2
2
|
import { UseEditorOptions } from '@tiptap/react';
|
|
3
|
-
declare const useTiptap: ({ exclude, extensions: extensionsProps, mentionItems, onMentionFilter, onSave, onError, onUpload, onTocUpdate, onAiWritingGetSuggestion, onValidateUrl, editable, contentType, placeholder, ...options }: UseTiptapProps & UseEditorOptions) => UseTiptapReturn;
|
|
3
|
+
declare const useTiptap: ({ exclude, extensions: extensionsProps, mentionItems, onMentionFilter, onSave, onError, onUpload, onTocUpdate, onAiWritingGetSuggestion, onValidateUrl, editable, contentType, placeholder, tableOfContentsOptions, ...options }: UseTiptapProps & UseEditorOptions) => UseTiptapReturn;
|
|
4
4
|
export default useTiptap;
|
package/dist/hook/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["exclude", "extensions", "mentionItems", "onMentionFilter", "onSave", "onError", "onUpload", "onTocUpdate", "onAiWritingGetSuggestion", "onValidateUrl", "editable", "contentType", "placeholder"];
|
|
2
|
+
var _excluded = ["exclude", "extensions", "mentionItems", "onMentionFilter", "onSave", "onError", "onUpload", "onTocUpdate", "onAiWritingGetSuggestion", "onValidateUrl", "editable", "contentType", "placeholder", "tableOfContentsOptions"];
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -25,6 +25,7 @@ var useTiptap = function useTiptap(_ref) {
|
|
|
25
25
|
editable = _ref$editable === void 0 ? true : _ref$editable,
|
|
26
26
|
contentType = _ref.contentType,
|
|
27
27
|
placeholder = _ref.placeholder,
|
|
28
|
+
tableOfContentsOptions = _ref.tableOfContentsOptions,
|
|
28
29
|
options = _objectWithoutProperties(_ref, _excluded);
|
|
29
30
|
var extensions = getExtensions({
|
|
30
31
|
contentType: contentType,
|
|
@@ -38,7 +39,8 @@ var useTiptap = function useTiptap(_ref) {
|
|
|
38
39
|
onTocUpdate: onTocUpdate,
|
|
39
40
|
onAiWritingGetSuggestion: onAiWritingGetSuggestion,
|
|
40
41
|
onValidateUrl: onValidateUrl,
|
|
41
|
-
placeholder: placeholder
|
|
42
|
+
placeholder: placeholder,
|
|
43
|
+
tableOfContentsOptions: tableOfContentsOptions
|
|
42
44
|
});
|
|
43
45
|
var editor = useEditor(_objectSpread(_objectSpread(_objectSpread({
|
|
44
46
|
editable: editable,
|
package/dist/type/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { PopoverOrigin, SxProps, Theme } from '@mui/material';
|
|
3
3
|
import { Editor, Extension } from '@tiptap/core';
|
|
4
|
+
import { TableOfContentsOptions } from '@tiptap/extension-table-of-contents';
|
|
4
5
|
import { YoutubeOptions } from '@tiptap/extension-youtube';
|
|
5
6
|
import { UseEditorOptions } from '@tiptap/react';
|
|
6
7
|
export type { Editor } from '@tiptap/react';
|
|
@@ -99,6 +100,7 @@ export type ExtensionRelativeProps = MentionExtensionProps & EditorFnProps & {
|
|
|
99
100
|
youtube?: Partial<YoutubeOptions>;
|
|
100
101
|
contentType?: UseEditorOptions['contentType'];
|
|
101
102
|
placeholder?: string;
|
|
103
|
+
tableOfContentsOptions?: TableOfContentsOptions;
|
|
102
104
|
};
|
|
103
105
|
export type UseTiptapProps = {
|
|
104
106
|
onSave?: (editor: Editor) => void;
|