@ctzhian/tiptap 2.1.18 → 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/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
|
@@ -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;
|