@ctzhian/tiptap 1.12.24 → 1.13.1

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.
Files changed (42) hide show
  1. package/dist/Editor/demo.js +5 -2
  2. package/dist/EditorMarkdown/demo.js +4 -1
  3. package/dist/EditorMarkdown/index.d.ts +2 -0
  4. package/dist/EditorMarkdown/index.js +42 -12
  5. package/dist/component/CustomBubbleMenu/index.js +1 -1
  6. package/dist/component/Toolbar/EditorInsert/index.js +12 -1
  7. package/dist/contants/slash-commands.js +34 -31
  8. package/dist/extension/component/Flow/Edit.d.ts +10 -0
  9. package/dist/extension/component/Flow/Edit.js +97 -0
  10. package/dist/extension/component/Flow/Insert.d.ts +7 -0
  11. package/dist/extension/component/Flow/Insert.js +108 -0
  12. package/dist/extension/component/Flow/Readonly.d.ts +8 -0
  13. package/dist/extension/component/Flow/Readonly.js +65 -0
  14. package/dist/extension/component/Flow/index.d.ts +9 -0
  15. package/dist/extension/component/Flow/index.js +354 -0
  16. package/dist/extension/component/Flow/useMermaidRender.d.ts +16 -0
  17. package/dist/extension/component/Flow/useMermaidRender.js +138 -0
  18. package/dist/extension/component/Flow/utils.d.ts +9 -0
  19. package/dist/extension/component/Flow/utils.js +32 -0
  20. package/dist/extension/component/SlashCommandsList/index.js +1 -1
  21. package/dist/extension/component/UploadProgress/index.d.ts +1 -1
  22. package/dist/extension/index.js +8 -3
  23. package/dist/extension/node/CodeBlockLowlight.js +15 -0
  24. package/dist/extension/node/FileHandler.d.ts +1 -1
  25. package/dist/extension/node/Flow/index.d.ts +18 -0
  26. package/dist/extension/node/Flow/index.js +103 -0
  27. package/dist/extension/node/TableOfContents/index.d.ts +2 -7
  28. package/dist/extension/node/TableOfContents/index.js +5 -373
  29. package/dist/extension/node/index.d.ts +1 -0
  30. package/dist/extension/node/index.js +1 -0
  31. package/dist/hook/index.js +1 -1
  32. package/dist/util/index.d.ts +0 -1
  33. package/dist/util/index.js +0 -1
  34. package/package.json +34 -33
  35. package/dist/extension/node/TableOfContents/plugin.d.ts +0 -6
  36. package/dist/extension/node/TableOfContents/plugin.js +0 -58
  37. package/dist/extension/node/TableOfContents/type.d.ts +0 -45
  38. package/dist/extension/node/TableOfContents/type.js +0 -1
  39. package/dist/extension/node/TableOfContents/utils.d.ts +0 -6
  40. package/dist/extension/node/TableOfContents/utils.js +0 -70
  41. package/dist/util/migrateMathStrings.d.ts +0 -73
  42. package/dist/util/migrateMathStrings.js +0 -192
@@ -0,0 +1,18 @@
1
+ import { EditorFnProps } from "../../../type";
2
+ import { Node } from '@tiptap/core';
3
+ declare module '@tiptap/core' {
4
+ interface Commands<ReturnType> {
5
+ flow: {
6
+ /**
7
+ * Insert a flow diagram
8
+ */
9
+ setFlow: (options: {
10
+ code?: string;
11
+ width?: string | number;
12
+ }) => ReturnType;
13
+ };
14
+ }
15
+ }
16
+ export type FlowExtensionProps = EditorFnProps;
17
+ export declare const FlowExtension: (props: FlowExtensionProps) => Node<any, any>;
18
+ export default FlowExtension;
@@ -0,0 +1,103 @@
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); }
7
+ import { mergeAttributes, Node } from '@tiptap/core';
8
+ import { ReactNodeViewRenderer } from '@tiptap/react';
9
+ import FlowViewWrapper from "../../component/Flow";
10
+ export var FlowExtension = function FlowExtension(props) {
11
+ return Node.create({
12
+ name: 'flow',
13
+ group: 'block',
14
+ atom: true,
15
+ selectable: true,
16
+ draggable: true,
17
+ addAttributes: function addAttributes() {
18
+ return {
19
+ code: {
20
+ default: '',
21
+ parseHTML: function parseHTML(element) {
22
+ return element.getAttribute('data-code') || '';
23
+ },
24
+ renderHTML: function renderHTML(attributes) {
25
+ if (!attributes.code) return {};
26
+ return {
27
+ 'data-code': attributes.code
28
+ };
29
+ }
30
+ },
31
+ width: {
32
+ default: '100%',
33
+ parseHTML: function parseHTML(element) {
34
+ return element.getAttribute('data-width') || '100%';
35
+ },
36
+ renderHTML: function renderHTML(attributes) {
37
+ if (!attributes.width) return {};
38
+ return {
39
+ 'data-width': String(attributes.width)
40
+ };
41
+ }
42
+ }
43
+ };
44
+ },
45
+ parseHTML: function parseHTML() {
46
+ return [{
47
+ tag: 'div[data-type="flow"]',
48
+ getAttrs: function getAttrs(dom) {
49
+ if (!(dom instanceof HTMLElement)) return false;
50
+ var code = dom.getAttribute('data-code') || '';
51
+ var width = dom.getAttribute('data-width') || '100%';
52
+ return {
53
+ code: code,
54
+ width: width
55
+ };
56
+ }
57
+ }];
58
+ },
59
+ renderHTML: function renderHTML(_ref) {
60
+ var HTMLAttributes = _ref.HTMLAttributes,
61
+ node = _ref.node;
62
+ var attrs = node.attrs;
63
+ return ['div', mergeAttributes({
64
+ 'data-type': 'flow'
65
+ }, attrs.code ? {
66
+ 'data-code': attrs.code
67
+ } : {}, attrs.width ? {
68
+ 'data-width': String(attrs.width)
69
+ } : {}, this.options.HTMLAttributes, HTMLAttributes)];
70
+ },
71
+ renderMarkdown: function renderMarkdown(node) {
72
+ var _ref2 = node.attrs,
73
+ code = _ref2.code;
74
+ if (!code) return '';
75
+ return "```mermaid\n".concat(code, "\n```");
76
+ },
77
+ addCommands: function addCommands() {
78
+ var _this = this;
79
+ return {
80
+ setFlow: function setFlow(options) {
81
+ return function (_ref3) {
82
+ var commands = _ref3.commands;
83
+ return commands.insertContent({
84
+ type: _this.name,
85
+ attrs: {
86
+ code: options.code || '',
87
+ width: options.width || '100%'
88
+ }
89
+ });
90
+ };
91
+ }
92
+ };
93
+ },
94
+ addNodeView: function addNodeView() {
95
+ return ReactNodeViewRenderer(function (renderProps) {
96
+ return FlowViewWrapper(_objectSpread(_objectSpread({}, renderProps), {}, {
97
+ onError: props.onError
98
+ }));
99
+ });
100
+ }
101
+ });
102
+ };
103
+ export default FlowExtension;
@@ -1,9 +1,4 @@
1
- import { Extension } from '@tiptap/core';
2
1
  import { TocList } from "../../../type";
3
- import type { TableOfContentsOptions, TableOfContentsStorage } from './type';
4
- export * from './type';
5
- export declare const TableOfContentsExtension: Extension<TableOfContentsOptions, TableOfContentsStorage>;
6
- export declare const TableOfContents: ({ onTocUpdate }: {
2
+ export declare const TableOfContentsExtension: ({ onTocUpdate }: {
7
3
  onTocUpdate?: ((toc: TocList) => void) | undefined;
8
- }) => Extension<TableOfContentsOptions, TableOfContentsStorage>;
9
- export default TableOfContents;
4
+ }) => import("@tiptap/core").Extension<import("@tiptap/extension-table-of-contents").TableOfContentsOptions, import("@tiptap/extension-table-of-contents").TableOfContentsStorage>;
@@ -1,374 +1,7 @@
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); }
7
- import { Extension } from '@tiptap/core';
8
- import { v4 as uuidv4 } from 'uuid';
9
- import { TableOfContentsPlugin } from "./plugin";
10
- import { getHeadlineLevel, getHierarchicalIndexes, getLinearIndexes } from "./utils";
11
- export * from "./type";
12
-
13
- // 全局组合状态管理,避免在 IME 组合期间触发 TOC 更新
14
- var globalCompositionState = false;
15
- var globalCompositionEndTimer = null;
16
- var globalInputTimer = null;
17
- var lastInputTime = 0;
18
-
19
- // 全局监听组合状态和输入事件
20
- if (typeof document !== 'undefined') {
21
- document.addEventListener('compositionstart', function () {
22
- globalCompositionState = true;
23
- }, {
24
- passive: true
25
- });
26
- document.addEventListener('compositionend', function () {
27
- globalCompositionState = false;
28
- // 组合结束后,延迟刷新所有 TOC 实例
29
- if (globalCompositionEndTimer) {
30
- clearTimeout(globalCompositionEndTimer);
31
- }
32
- globalCompositionEndTimer = setTimeout(function () {
33
- // 这里会通过 editor 实例来触发刷新
34
- // 具体实现在 onTransaction 中处理
35
- }, 200);
36
- }, {
37
- passive: true
38
- });
39
-
40
- // 监听所有输入事件,记录最后输入时间
41
- document.addEventListener('input', function () {
42
- lastInputTime = Date.now();
43
- }, {
44
- passive: true
45
- });
46
- document.addEventListener('keydown', function () {
47
- lastInputTime = Date.now();
48
- }, {
49
- passive: true
50
- });
51
- }
52
- var addTocActiveStatesAndGetItems = function addTocActiveStatesAndGetItems(content, options) {
53
- var editor = options.editor;
54
- var headlines = [];
55
- var scrolledOverIds = [];
56
- var activeId = null;
57
- if (editor.isDestroyed) {
58
- return content;
59
- }
60
- editor.state.doc.descendants(function (node, pos) {
61
- var _options$anchorTypes;
62
- var isValidType = (_options$anchorTypes = options.anchorTypes) === null || _options$anchorTypes === void 0 ? void 0 : _options$anchorTypes.includes(node.type.name);
63
- if (!isValidType) {
64
- return;
65
- }
66
- headlines.push({
67
- node: node,
68
- pos: pos
69
- });
70
- });
71
- headlines.forEach(function (headline) {
72
- var domElement = editor.view.domAtPos(headline.pos + 1).node;
73
- var scrolledOver = options.storage.scrollPosition >= domElement.offsetTop;
74
- if (scrolledOver) {
75
- activeId = headline.node.attrs.id;
76
- scrolledOverIds.push(headline.node.attrs.id);
77
- }
78
- });
79
- return content.map(function (heading) {
80
- return _objectSpread(_objectSpread({}, heading), {}, {
81
- isActive: heading.id === activeId,
82
- isScrolledOver: scrolledOverIds.includes(heading.id)
83
- });
84
- });
85
- };
86
- var setTocData = function setTocData(options) {
87
- var editor = options.editor,
88
- onUpdate = options.onUpdate;
89
- if (editor.isDestroyed) {
90
- return;
91
- }
92
- var headlines = [];
93
- var anchors = [];
94
- var anchorEls = [];
95
- editor.state.doc.descendants(function (node, pos) {
96
- var _options$anchorTypes2;
97
- var isValidType = (_options$anchorTypes2 = options.anchorTypes) === null || _options$anchorTypes2 === void 0 ? void 0 : _options$anchorTypes2.includes(node.type.name);
98
- if (!isValidType) {
99
- return;
100
- }
101
- headlines.push({
102
- node: node,
103
- pos: pos
104
- });
105
- });
106
- headlines.forEach(function (headline, i) {
107
- if (headline.node.textContent.length === 0) {
108
- return;
109
- }
110
- var domElement = editor.view.domAtPos(headline.pos + 1).node;
111
- var scrolledOver = options.storage.scrollPosition >= domElement.offsetTop;
112
- anchorEls.push(domElement);
113
- var originalLevel = headline.node.attrs.level;
114
- var level = options.getLevelFn(headline, anchors);
115
- var itemIndex = options.getIndexFn(headline, anchors, level);
116
- anchors.push({
117
- itemIndex: itemIndex,
118
- id: headline.node.attrs.id || options.getId(headline.node.textContent),
119
- originalLevel: originalLevel,
120
- level: level,
121
- textContent: headline.node.textContent,
122
- pos: headline.pos,
123
- editor: editor,
124
- isActive: false,
125
- isScrolledOver: scrolledOver,
126
- node: headline.node,
127
- dom: domElement
128
- });
129
- });
130
-
131
- // 计算 active 和 scrolledOver 状态
132
- anchors = addTocActiveStatesAndGetItems(anchors, {
133
- editor: options.editor,
134
- anchorTypes: options.anchorTypes,
135
- storage: options.storage
136
- });
137
-
138
- // 更新存储
139
- options.storage.anchors = anchorEls;
140
- options.storage.content = anchors;
141
-
142
- // 调用回调
143
- if (onUpdate) {
144
- var isInitialCreation = options.storage.content.length === 0;
145
- onUpdate(anchors, isInitialCreation);
146
- }
147
- };
148
- export var TableOfContentsExtension = Extension.create({
149
- name: 'tableOfContents',
150
- addStorage: function addStorage() {
151
- return {
152
- content: [],
153
- anchors: [],
154
- scrollHandler: function scrollHandler() {
155
- return null;
156
- },
157
- scrollPosition: 0
158
- };
159
- },
160
- addGlobalAttributes: function addGlobalAttributes() {
161
- return [{
162
- types: this.options.anchorTypes || ['heading'],
163
- attributes: {
164
- id: {
165
- default: null,
166
- renderHTML: function renderHTML(attributes) {
167
- return {
168
- id: attributes.id
169
- };
170
- },
171
- parseHTML: function parseHTML(element) {
172
- return element.id || null;
173
- }
174
- }
175
- }
176
- }];
177
- },
178
- addOptions: function addOptions() {
179
- var defaultScrollParent = typeof window !== 'undefined' ? function () {
180
- return window;
181
- } : undefined;
182
- return {
183
- // eslint-disable-next-line
184
- onUpdate: function onUpdate() {},
185
- // eslint-disable-next-line
186
- getId: function getId(_textContent) {
187
- return uuidv4();
188
- },
189
- scrollParent: defaultScrollParent,
190
- anchorTypes: ['heading']
191
- };
192
- },
193
- addCommands: function addCommands() {
194
- var _this = this;
195
- return {
196
- updateTableOfContents: function updateTableOfContents() {
197
- return function (_ref) {
198
- var dispatch = _ref.dispatch;
199
- if (dispatch) {
200
- var _this$options$onUpdat;
201
- setTocData({
202
- editor: _this.editor,
203
- storage: _this.storage,
204
- onUpdate: (_this$options$onUpdat = _this.options.onUpdate) === null || _this$options$onUpdat === void 0 ? void 0 : _this$options$onUpdat.bind(_this),
205
- getIndexFn: _this.options.getIndex || getLinearIndexes,
206
- getLevelFn: _this.options.getLevel || getHeadlineLevel,
207
- anchorTypes: _this.options.anchorTypes,
208
- getId: _this.options.getId || function (textContent) {
209
- return uuidv4();
210
- }
211
- });
212
- }
213
- return true;
214
- };
215
- }
216
- };
217
- },
218
- onTransaction: function onTransaction(_ref2) {
219
- var _this2 = this;
220
- var transaction = _ref2.transaction;
221
- if (!transaction.docChanged) return;
222
- var now = Date.now();
223
- var timeSinceLastInput = now - lastInputTime;
224
-
225
- // 组合期间完全不处理 TOC 更新,避免打断输入
226
- if (globalCompositionState || this.editor.view.composing) {
227
- return;
228
- }
229
-
230
- // 如果最近有输入(1秒内),延迟处理
231
- if (timeSinceLastInput < 1000) {
232
- if (globalInputTimer) {
233
- clearTimeout(globalInputTimer);
234
- }
235
- globalInputTimer = setTimeout(function () {
236
- // 再次检查组合状态
237
- if (!globalCompositionState && !_this2.editor.view.composing) {
238
- var _this2$options$onUpda;
239
- setTocData({
240
- editor: _this2.editor,
241
- storage: _this2.storage,
242
- onUpdate: (_this2$options$onUpda = _this2.options.onUpdate) === null || _this2$options$onUpda === void 0 ? void 0 : _this2$options$onUpda.bind(_this2),
243
- getIndexFn: _this2.options.getIndex || getLinearIndexes,
244
- getLevelFn: _this2.options.getLevel || getHeadlineLevel,
245
- anchorTypes: _this2.options.anchorTypes,
246
- getId: _this2.options.getId || function (textContent) {
247
- return uuidv4();
248
- }
249
- });
250
- }
251
- }, 1000 - timeSinceLastInput + 200);
252
- return;
253
- }
254
-
255
- // 非组合期间且无最近输入,使用 setTimeout 确保有足够延迟
256
- setTimeout(function () {
257
- // 再次检查,确保组合状态没有变化
258
- if (!globalCompositionState && !_this2.editor.view.composing) {
259
- var _this2$options$onUpda2;
260
- setTocData({
261
- editor: _this2.editor,
262
- storage: _this2.storage,
263
- onUpdate: (_this2$options$onUpda2 = _this2.options.onUpdate) === null || _this2$options$onUpda2 === void 0 ? void 0 : _this2$options$onUpda2.bind(_this2),
264
- getIndexFn: _this2.options.getIndex || getLinearIndexes,
265
- getLevelFn: _this2.options.getLevel || getHeadlineLevel,
266
- anchorTypes: _this2.options.anchorTypes,
267
- getId: _this2.options.getId || function (textContent) {
268
- return uuidv4();
269
- }
270
- });
271
- }
272
- }, 100);
273
- },
274
- onCreate: function onCreate() {
275
- var _this3 = this;
276
- var tr = this.editor.state.tr;
277
- var existingIds = [];
278
- if (this.options.scrollParent && typeof this.options.scrollParent !== 'function') {
279
- console.warn("[Tiptap Table of Contents Deprecation Notice]: The 'scrollParent' option must now be provided as a callback function that returns the 'scrollParent' element. The ability to pass this option directly will be deprecated in future releases.");
280
- }
281
-
282
- // 异步处理初始 ID 分配,避免与初始输入竞争
283
- requestAnimationFrame(function () {
284
- _this3.editor.state.doc.descendants(function (node, pos) {
285
- var _this3$options$anchor;
286
- var nodeId = node.attrs.id;
287
- var isValidType = (_this3$options$anchor = _this3.options.anchorTypes) === null || _this3$options$anchor === void 0 ? void 0 : _this3$options$anchor.includes(node.type.name);
288
- if (!isValidType || node.textContent.length === 0) {
289
- return;
290
- }
291
- if (nodeId === null || nodeId === undefined || existingIds.includes(nodeId)) {
292
- var id = '';
293
- if (_this3.options.getId) {
294
- id = _this3.options.getId(node.textContent);
295
- } else {
296
- id = uuidv4();
297
- }
298
- tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
299
- id: id
300
- }));
301
- }
302
- existingIds.push(nodeId);
303
- });
304
- _this3.editor.view.dispatch(tr);
305
-
306
- // 延迟初始化 TOC 数据
307
- setTimeout(function () {
308
- var _this3$options$onUpda;
309
- setTocData({
310
- editor: _this3.editor,
311
- storage: _this3.storage,
312
- onUpdate: (_this3$options$onUpda = _this3.options.onUpdate) === null || _this3$options$onUpda === void 0 ? void 0 : _this3$options$onUpda.bind(_this3),
313
- getIndexFn: _this3.options.getIndex || getLinearIndexes,
314
- getLevelFn: _this3.options.getLevel || getHeadlineLevel,
315
- anchorTypes: _this3.options.anchorTypes,
316
- getId: _this3.options.getId || function (textContent) {
317
- return uuidv4();
318
- }
319
- });
320
- }, 100);
321
- });
322
-
323
- // 防抖的 scroll handler,避免滚动期间频繁触发回调
324
- var scrollTimer = null;
325
- this.storage.scrollHandler = function () {
326
- if (!_this3.options.scrollParent) {
327
- return;
328
- }
329
- var scrollParent = typeof _this3.options.scrollParent === 'function' ? _this3.options.scrollParent() : _this3.options.scrollParent;
330
- var scrollPosition = scrollParent instanceof HTMLElement ? scrollParent.scrollTop : scrollParent.scrollY;
331
- _this3.storage.scrollPosition = scrollPosition || 0;
332
- if (scrollTimer) clearTimeout(scrollTimer);
333
- scrollTimer = setTimeout(function () {
334
- var _this3$options$onUpda2, _this3$options;
335
- var updatedItems = addTocActiveStatesAndGetItems(_this3.storage.content, {
336
- editor: _this3.editor,
337
- anchorTypes: _this3.options.anchorTypes,
338
- storage: _this3.storage
339
- });
340
- _this3.storage.content = updatedItems;
341
- // 调用 onUpdate 回调
342
- (_this3$options$onUpda2 = (_this3$options = _this3.options).onUpdate) === null || _this3$options$onUpda2 === void 0 || _this3$options$onUpda2.call(_this3$options, updatedItems, false);
343
- }, 100);
344
- };
345
-
346
- // 添加滚动监听
347
- if (this.options.scrollParent) {
348
- var scrollParent = typeof this.options.scrollParent === 'function' ? this.options.scrollParent() : this.options.scrollParent;
349
- if (scrollParent) {
350
- scrollParent.addEventListener('scroll', this.storage.scrollHandler);
351
- }
352
- }
353
- },
354
- onDestroy: function onDestroy() {
355
- if (this.options.scrollParent) {
356
- var scrollParent = typeof this.options.scrollParent === 'function' ? this.options.scrollParent() : this.options.scrollParent;
357
- if (scrollParent) {
358
- scrollParent.removeEventListener('scroll', this.storage.scrollHandler);
359
- }
360
- }
361
- },
362
- addProseMirrorPlugins: function addProseMirrorPlugins() {
363
- return [TableOfContentsPlugin({
364
- getId: this.options.getId,
365
- anchorTypes: this.options.anchorTypes
366
- })];
367
- }
368
- });
369
- export var TableOfContents = function TableOfContents(_ref3) {
370
- var onTocUpdate = _ref3.onTocUpdate;
371
- return TableOfContentsExtension.configure({
1
+ import { getHierarchicalIndexes, TableOfContents } from '@tiptap/extension-table-of-contents';
2
+ export var TableOfContentsExtension = function TableOfContentsExtension(_ref) {
3
+ var onTocUpdate = _ref.onTocUpdate;
4
+ return TableOfContents.configure({
372
5
  getIndex: getHierarchicalIndexes,
373
6
  onUpdate: function onUpdate(data) {
374
7
  setTimeout(function () {
@@ -387,5 +20,4 @@ export var TableOfContents = function TableOfContents(_ref3) {
387
20
  }, 0);
388
21
  }
389
22
  });
390
- };
391
- export default TableOfContents;
23
+ };
@@ -5,6 +5,7 @@ export * from './CodeBlockLowlight';
5
5
  export * from './Details';
6
6
  export * from './Emoji';
7
7
  export * from './FileHandler';
8
+ export * from './Flow';
8
9
  export * from './HorizontalRule';
9
10
  export * from './Iframe';
10
11
  export * from './Image';
@@ -5,6 +5,7 @@ export * from "./CodeBlockLowlight";
5
5
  export * from "./Details";
6
6
  export * from "./Emoji";
7
7
  export * from "./FileHandler";
8
+ export * from "./Flow";
8
9
  export * from "./HorizontalRule";
9
10
  export * from "./Iframe";
10
11
  export * from "./Image";
@@ -8,7 +8,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
8
8
  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; }
9
9
  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; }
10
10
  import { getExtensions } from "../extension";
11
- import { migrateMathStrings } from "../util";
11
+ import { migrateMathStrings } from '@tiptap/extension-mathematics';
12
12
  import { useEditor } from '@tiptap/react';
13
13
  import { renderToMarkdown } from '@tiptap/static-renderer/pm/markdown';
14
14
  var useTiptap = function useTiptap(_ref) {
@@ -2,7 +2,6 @@ export * from './fileDownload';
2
2
  export * from './fileHandler';
3
3
  export * from './floating';
4
4
  export * from './linewiseConvert';
5
- export * from './migrateMathStrings';
6
5
  export * from './resourceExtractor';
7
6
  export * from './shortcutKey';
8
7
  import { Node } from '@tiptap/pm/model';
@@ -2,7 +2,6 @@ export * from "./fileDownload";
2
2
  export * from "./fileHandler";
3
3
  export * from "./floating";
4
4
  export * from "./linewiseConvert";
5
- export * from "./migrateMathStrings";
6
5
  export * from "./resourceExtractor";
7
6
  export * from "./shortcutKey";
8
7
  export var formatFileSize = function formatFileSize(bytes) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctzhian/tiptap",
3
- "version": "1.12.24",
3
+ "version": "1.13.1",
4
4
  "description": "基于 Tiptap 二次开发的编辑器组件",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -81,38 +81,38 @@
81
81
  },
82
82
  "dependencies": {
83
83
  "@floating-ui/dom": "^1.7.2",
84
- "@tiptap/core": "^3.10.5",
85
- "@tiptap/extension-bubble-menu": "^3.10.5",
86
- "@tiptap/extension-code": "^3.10.5",
87
- "@tiptap/extension-code-block-lowlight": "^3.10.5",
88
- "@tiptap/extension-details": "^3.10.5",
89
- "@tiptap/extension-drag-handle-react": "^3.10.5",
90
- "@tiptap/extension-emoji": "^3.10.5",
91
- "@tiptap/extension-file-handler": "^3.10.5",
92
- "@tiptap/extension-highlight": "^3.10.5",
93
- "@tiptap/extension-horizontal-rule": "^3.10.5",
94
- "@tiptap/extension-image": "^3.10.5",
95
- "@tiptap/extension-invisible-characters": "^3.10.5",
96
- "@tiptap/extension-link": "^3.10.5",
97
- "@tiptap/extension-list": "^3.10.5",
98
- "@tiptap/extension-mathematics": "^3.10.5",
99
- "@tiptap/extension-mention": "^3.10.5",
100
- "@tiptap/extension-subscript": "^3.10.5",
101
- "@tiptap/extension-superscript": "^3.10.5",
102
- "@tiptap/extension-table": "^3.10.5",
103
- "@tiptap/extension-table-of-contents": "^3.10.5",
104
- "@tiptap/extension-text-align": "^3.10.5",
105
- "@tiptap/extension-text-style": "^3.10.5",
106
- "@tiptap/extension-unique-id": "^3.10.5",
107
- "@tiptap/extension-youtube": "^3.10.5",
108
- "@tiptap/extensions": "^3.10.5",
109
- "@tiptap/html": "^3.10.5",
110
- "@tiptap/markdown": "^3.10.5",
111
- "@tiptap/pm": "^3.10.5",
112
- "@tiptap/react": "^3.10.5",
113
- "@tiptap/starter-kit": "^3.10.5",
114
- "@tiptap/static-renderer": "^3.10.5",
115
- "@tiptap/suggestion": "^3.10.5",
84
+ "@tiptap/core": "^3.10.7",
85
+ "@tiptap/extension-bubble-menu": "^3.10.7",
86
+ "@tiptap/extension-code": "^3.10.7",
87
+ "@tiptap/extension-code-block-lowlight": "^3.10.7",
88
+ "@tiptap/extension-details": "^3.10.7",
89
+ "@tiptap/extension-drag-handle-react": "^3.10.7",
90
+ "@tiptap/extension-emoji": "^3.10.7",
91
+ "@tiptap/extension-file-handler": "^3.10.7",
92
+ "@tiptap/extension-highlight": "^3.10.7",
93
+ "@tiptap/extension-horizontal-rule": "^3.10.7",
94
+ "@tiptap/extension-image": "^3.10.7",
95
+ "@tiptap/extension-invisible-characters": "^3.10.7",
96
+ "@tiptap/extension-link": "^3.10.7",
97
+ "@tiptap/extension-list": "^3.10.7",
98
+ "@tiptap/extension-mathematics": "^3.10.7",
99
+ "@tiptap/extension-mention": "^3.10.7",
100
+ "@tiptap/extension-subscript": "^3.10.7",
101
+ "@tiptap/extension-superscript": "^3.10.7",
102
+ "@tiptap/extension-table": "^3.10.7",
103
+ "@tiptap/extension-table-of-contents": "^3.10.7",
104
+ "@tiptap/extension-text-align": "^3.10.7",
105
+ "@tiptap/extension-text-style": "^3.10.7",
106
+ "@tiptap/extension-unique-id": "^3.10.7",
107
+ "@tiptap/extension-youtube": "^3.10.7",
108
+ "@tiptap/extensions": "^3.10.7",
109
+ "@tiptap/html": "^3.10.7",
110
+ "@tiptap/markdown": "^3.10.7",
111
+ "@tiptap/pm": "^3.10.7",
112
+ "@tiptap/react": "^3.10.7",
113
+ "@tiptap/starter-kit": "^3.10.7",
114
+ "@tiptap/static-renderer": "^3.10.7",
115
+ "@tiptap/suggestion": "^3.10.7",
116
116
  "ace-builds": "^1.43.4",
117
117
  "core-js": "^3.46.0",
118
118
  "diff-match-patch": "^1.0.5",
@@ -121,6 +121,7 @@
121
121
  "katex": "^0.16.22",
122
122
  "linkifyjs": "^4.3.2",
123
123
  "lowlight": "^3.3.0",
124
+ "mermaid": "^10.9.5",
124
125
  "react-ace": "^14.0.1",
125
126
  "react-colorful": "^5.6.1",
126
127
  "react-image-crop": "^11.0.10",
@@ -1,6 +0,0 @@
1
- import type { NodeType } from '@tiptap/pm/model';
2
- import { Plugin } from '@tiptap/pm/state';
3
- export declare const TableOfContentsPlugin: ({ getId, anchorTypes, }: {
4
- getId?: ((textContent: string) => string) | undefined;
5
- anchorTypes?: (string | NodeType)[] | undefined;
6
- }) => Plugin<any>;