@ctzhian/tiptap 1.13.0 → 1.13.2

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.
@@ -7,6 +7,9 @@ import { Box } from '@mui/material';
7
7
  import React from 'react';
8
8
  import "../index.css";
9
9
  var Reader = function Reader() {
10
+ var handleTocUpdate = function handleTocUpdate(toc) {
11
+ console.log('toc', toc);
12
+ };
10
13
  var _useTiptap = useTiptap({
11
14
  editable: true,
12
15
  exclude: ['invisibleCharacters'],
@@ -90,7 +93,7 @@ var Reader = function Reader() {
90
93
  }
91
94
  return onAiWritingGetSuggestion;
92
95
  }(),
93
- // onTocUpdate: handleTocUpdate,
96
+ onTocUpdate: handleTocUpdate,
94
97
  // onMentionFilter: async ({ query }: { query: string }) => {
95
98
  // return new Promise((resolve) => {
96
99
  // resolve([
@@ -152,7 +155,7 @@ var Reader = function Reader() {
152
155
  }
153
156
  return onUpload;
154
157
  }(),
155
- content: "<p>fadsjlfkas</p><div data-type=\"flow\" data-code=\"C4Context\n title System Context diagram for Internet Banking System\n Enterprise_Boundary(b0, &quot;BankBoundary0&quot;) {\n Person(customerA, &quot;Banking Customer A&quot;, &quot;A customer of the bank, with personal bank accounts.&quot;)\n Person(customerB, &quot;Banking Customer B&quot;)\n Person_Ext(customerC, &quot;Banking Customer C&quot;, &quot;desc&quot;)\n\n Person(customerD, &quot;Banking Customer D&quot;, &quot;A customer of the bank, &lt;br/&gt; with personal bank accounts.&quot;)\n\n System(SystemAA, &quot;Internet Banking System&quot;, &quot;Allows customers to view information about their bank accounts, and make payments.&quot;)\n\n Enterprise_Boundary(b1, &quot;BankBoundary&quot;) {\n SystemDb_Ext(SystemE, &quot;Mainframe Banking System&quot;, &quot;Stores all of the core banking information about customers, accounts, transactions, etc.&quot;)\n\n System_Boundary(b2, &quot;BankBoundary2&quot;) {\n System(SystemA, &quot;Banking System A&quot;)\n System(SystemB, &quot;Banking System B&quot;, &quot;A system of the bank, with personal bank accounts. next line.&quot;)\n }\n\n System_Ext(SystemC, &quot;E-mail system&quot;, &quot;The internal Microsoft Exchange e-mail system.&quot;)\n SystemDb(SystemD, &quot;Banking System D Database&quot;, &quot;A system of the bank, with personal bank accounts.&quot;)\n\n Boundary(b3, &quot;BankBoundary3&quot;, &quot;boundary&quot;) {\n SystemQueue(SystemF, &quot;Banking System F Queue&quot;, &quot;A system of the bank.&quot;)\n SystemQueue_Ext(SystemG, &quot;Banking System G Queue&quot;, &quot;A system of the bank, with personal bank accounts.&quot;)\n }\n }\n }\n\n BiRel(customerA, SystemAA, &quot;Uses&quot;)\n BiRel(SystemAA, SystemE, &quot;Uses&quot;)\n Rel(SystemAA, SystemC, &quot;Sends e-mails&quot;, &quot;SMTP&quot;)\n Rel(SystemC, customerA, &quot;Sends e-mails to&quot;)\" data-width=\"100%\" data-height=\"auto\"></div><p>fsajdlkfjadsl</p>"
158
+ content: "<pre><code>$$ sflsa $$\n\n$fsjadl$</code></pre><p></p><p><span data-latex=\"x+y=1\" data-type=\"inline-math\"></span></p><div data-latex=\"ssss\" data-type=\"block-math\"></div><p></p><p>fadsjlfkas</p><div data-type=\"flow\" data-code=\"C4Context\n title System Context diagram for Internet Banking System\n Enterprise_Boundary(b0, &quot;BankBoundary0&quot;) {\n Person(customerA, &quot;Banking Customer A&quot;, &quot;A customer of the bank, with personal bank accounts.&quot;)\n Person(customerB, &quot;Banking Customer B&quot;)\n Person_Ext(customerC, &quot;Banking Customer C&quot;, &quot;desc&quot;)\n\n Person(customerD, &quot;Banking Customer D&quot;, &quot;A customer of the bank, &lt;br/&gt; with personal bank accounts.&quot;)\n\n System(SystemAA, &quot;Internet Banking System&quot;, &quot;Allows customers to view information about their bank accounts, and make payments.&quot;)\n\n Enterprise_Boundary(b1, &quot;BankBoundary&quot;) {\n SystemDb_Ext(SystemE, &quot;Mainframe Banking System&quot;, &quot;Stores all of the core banking information about customers, accounts, transactions, etc.&quot;)\n\n System_Boundary(b2, &quot;BankBoundary2&quot;) {\n System(SystemA, &quot;Banking System A&quot;)\n System(SystemB, &quot;Banking System B&quot;, &quot;A system of the bank, with personal bank accounts. next line.&quot;)\n }\n\n System_Ext(SystemC, &quot;E-mail system&quot;, &quot;The internal Microsoft Exchange e-mail system.&quot;)\n SystemDb(SystemD, &quot;Banking System D Database&quot;, &quot;A system of the bank, with personal bank accounts.&quot;)\n\n Boundary(b3, &quot;BankBoundary3&quot;, &quot;boundary&quot;) {\n SystemQueue(SystemF, &quot;Banking System F Queue&quot;, &quot;A system of the bank.&quot;)\n SystemQueue_Ext(SystemG, &quot;Banking System G Queue&quot;, &quot;A system of the bank, with personal bank accounts.&quot;)\n }\n }\n }\n\n BiRel(customerA, SystemAA, &quot;Uses&quot;)\n BiRel(SystemAA, SystemE, &quot;Uses&quot;)\n Rel(SystemAA, SystemC, &quot;Sends e-mails&quot;, &quot;SMTP&quot;)\n Rel(SystemC, customerA, &quot;Sends e-mails to&quot;)\" data-width=\"100%\" data-height=\"auto\"></div><p>fsajdlkfjadsl</p>"
156
159
  }),
157
160
  editor = _useTiptap.editor;
158
161
  return /*#__PURE__*/React.createElement(EditorThemeProvider, {
@@ -13,7 +13,7 @@ import { Box } from '@mui/material';
13
13
  import React, { useCallback, useEffect, useState } from 'react';
14
14
  import "../index.css";
15
15
  var Reader = function Reader() {
16
- var _useState = useState(''),
16
+ var _useState = useState('![ss](/ss)'),
17
17
  _useState2 = _slicedToArray(_useState, 2),
18
18
  mdContent = _useState2[0],
19
19
  setMdContent = _useState2[1];
@@ -123,6 +123,9 @@ var Reader = function Reader() {
123
123
  // contentType: 'markdown'
124
124
  // }).run()
125
125
  },
126
+ // onTocUpdate: (toc) => {
127
+ // console.log('toc', toc)
128
+ // },
126
129
  content: mdContent
127
130
  }),
128
131
  editor = _useTiptap.editor;
@@ -13,6 +13,8 @@ interface EditorMarkdownProps {
13
13
  editor: Editor;
14
14
  value?: string;
15
15
  readOnly?: string;
16
+ showAutocomplete?: boolean;
17
+ highlightActiveLine?: boolean;
16
18
  placeholder?: string;
17
19
  height: number | string;
18
20
  onUpload?: UploadFunction;
@@ -37,6 +37,10 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
37
37
  readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
38
38
  _ref$splitMode = _ref.splitMode,
39
39
  splitMode = _ref$splitMode === void 0 ? false : _ref$splitMode,
40
+ _ref$showAutocomplete = _ref.showAutocomplete,
41
+ showAutocomplete = _ref$showAutocomplete === void 0 ? true : _ref$showAutocomplete,
42
+ _ref$highlightActiveL = _ref.highlightActiveLine,
43
+ highlightActiveLine = _ref$highlightActiveL === void 0 ? true : _ref$highlightActiveL,
40
44
  _ref$defaultDisplayMo = _ref.defaultDisplayMode,
41
45
  defaultDisplayMode = _ref$defaultDisplayMo === void 0 ? 'edit' : _ref$defaultDisplayMo,
42
46
  _ref$showToolbar = _ref.showToolbar,
@@ -57,14 +61,18 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
57
61
  _useState6 = _slicedToArray(_useState5, 2),
58
62
  loading = _useState6[0],
59
63
  setLoading = _useState6[1];
60
- var _useState7 = useState(0),
64
+ var _useState7 = useState(false),
61
65
  _useState8 = _slicedToArray(_useState7, 2),
62
- progress = _useState8[0],
63
- setProgress = _useState8[1];
64
- var _useState9 = useState(''),
66
+ isComposing = _useState8[0],
67
+ setIsComposing = _useState8[1];
68
+ var _useState9 = useState(0),
65
69
  _useState10 = _slicedToArray(_useState9, 2),
66
- fileName = _useState10[0],
67
- setFileName = _useState10[1];
70
+ progress = _useState10[0],
71
+ setProgress = _useState10[1];
72
+ var _useState11 = useState(''),
73
+ _useState12 = _slicedToArray(_useState11, 2),
74
+ fileName = _useState12[0],
75
+ setFileName = _useState12[1];
68
76
  var EditorHeight = useMemo(function () {
69
77
  return isExpend ? 'calc(100vh - 45px)' : height;
70
78
  }, [isExpend, height]);
@@ -357,6 +365,25 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
357
365
  editor.setEditable(false);
358
366
  }
359
367
  }, [editor]);
368
+ useEffect(function () {
369
+ var _aceEditor$textInput;
370
+ if (!aceEditorRef.current) return;
371
+ var aceEditor = aceEditorRef.current.editor;
372
+ var textarea = (_aceEditor$textInput = aceEditor.textInput) === null || _aceEditor$textInput === void 0 ? void 0 : _aceEditor$textInput.getElement();
373
+ if (!textarea) return;
374
+ var handleCompositionStart = function handleCompositionStart() {
375
+ setIsComposing(true);
376
+ };
377
+ var handleCompositionEnd = function handleCompositionEnd() {
378
+ setIsComposing(false);
379
+ };
380
+ textarea.addEventListener('compositionstart', handleCompositionStart);
381
+ textarea.addEventListener('compositionend', handleCompositionEnd);
382
+ return function () {
383
+ textarea.removeEventListener('compositionstart', handleCompositionStart);
384
+ textarea.removeEventListener('compositionend', handleCompositionEnd);
385
+ };
386
+ }, [displayMode]);
360
387
  return /*#__PURE__*/React.createElement(Box, {
361
388
  sx: _objectSpread({
362
389
  position: 'relative',
@@ -472,14 +499,15 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
472
499
  onDrop: handleDrop,
473
500
  sx: {
474
501
  flex: 1,
475
- fontFamily: 'monospace',
476
- '.ace_placeholder': {
502
+ '.ace_placeholder': _objectSpread({
477
503
  transform: 'scale(1)',
478
504
  height: '100%',
479
505
  overflow: 'auto',
480
506
  width: '100%',
481
507
  fontStyle: 'normal'
482
- }
508
+ }, isComposing && {
509
+ display: 'none'
510
+ })
483
511
  }
484
512
  }, /*#__PURE__*/React.createElement(AceEditor, {
485
513
  ref: aceEditorRef,
@@ -497,10 +525,12 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
497
525
  $blockScrolling: true
498
526
  },
499
527
  setOptions: {
500
- enableBasicAutocompletion: true,
501
- enableLiveAutocompletion: true,
528
+ tabSize: 2,
529
+ showGutter: showLineNumbers,
502
530
  showLineNumbers: showLineNumbers,
503
- tabSize: 2
531
+ enableBasicAutocompletion: showAutocomplete,
532
+ enableLiveAutocompletion: showAutocomplete,
533
+ highlightActiveLine: highlightActiveLine
504
534
  },
505
535
  style: {
506
536
  width: '100%',
@@ -22,9 +22,6 @@ var ReadonlyImage = function ReadonlyImage(_ref) {
22
22
  maxWidth: '100%',
23
23
  height: 'auto',
24
24
  cursor: 'pointer'
25
- },
26
- onError: function onError(e) {
27
- console.error('Image load error:', e);
28
25
  }
29
26
  })), attrs.title && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(Box, {
30
27
  component: "span",
@@ -134,10 +134,7 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
134
134
  }
135
135
  return attrs.width;
136
136
  };
137
-
138
- // 自动获取图片尺寸并设置
139
137
  useEffect(function () {
140
- // 当有 src 但没有 width 时,自动获取图片尺寸
141
138
  if (attrs.src && (!attrs.width || attrs.width <= 0)) {
142
139
  getImageDimensions(attrs.src).then(function (dimensions) {
143
140
  updateAttributes({
@@ -145,11 +142,9 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
145
142
  width: dimensions.width
146
143
  });
147
144
  }).catch(function (error) {
148
- console.warn('无法获取图片尺寸,使用默认宽度:', error);
149
- // 如果无法获取尺寸,设置默认宽度
150
145
  updateAttributes({
151
146
  src: attrs.src,
152
- width: 400 // 默认宽度
147
+ width: 400
153
148
  });
154
149
  });
155
150
  }
@@ -15,7 +15,7 @@ import { PLACEHOLDER } from "../contants/placeholder";
15
15
  import { AiWritingExtension, SlashCommands, StructuredDiffExtension } from "./extension";
16
16
  import { CodeExtension } from "./mark/Code";
17
17
  import CustomLink from "./mark/Link";
18
- import { AlertExtension, AudioExtension, BlockAttachmentExtension, BlockLinkExtension, CodeBlockLowlightExtension, CustomBlockMathExtension, CustomHorizontalRule, CustomInlineMathExtension, CustomSubscript, CustomSuperscript, DetailsContentExtension, DetailsExtension, DetailsSummaryExtension, EmojiExtension, FileHandlerExtension, FlowExtension, IframeExtension, ImageExtension, Indent, InlineAttachmentExtension, InlineLinkExtension, InlineUploadProgressExtension, ListExtension, MentionExtension, TableExtension, TableOfContents, UploadProgressExtension, VerticalAlign, VideoExtension, YamlFormat, YoutubeExtension } from "./node";
18
+ import { AlertExtension, AudioExtension, BlockAttachmentExtension, BlockLinkExtension, CodeBlockLowlightExtension, CustomBlockMathExtension, CustomHorizontalRule, CustomInlineMathExtension, CustomSubscript, CustomSuperscript, DetailsContentExtension, DetailsExtension, DetailsSummaryExtension, EmojiExtension, FileHandlerExtension, FlowExtension, IframeExtension, ImageExtension, Indent, InlineAttachmentExtension, InlineLinkExtension, InlineUploadProgressExtension, ListExtension, MentionExtension, TableExtension, TableOfContentsExtension, UploadProgressExtension, VerticalAlign, VideoExtension, YamlFormat, YoutubeExtension } from "./node";
19
19
  export var getExtensions = function getExtensions(_ref) {
20
20
  var contentType = _ref.contentType,
21
21
  limit = _ref.limit,
@@ -57,7 +57,7 @@ export var getExtensions = function getExtensions(_ref) {
57
57
  onValidateUrl: onValidateUrl
58
58
  })].concat(_toConsumableArray(TableExtension({
59
59
  editable: editable
60
- })), [TableOfContents({
60
+ })), [TableOfContentsExtension({
61
61
  onTocUpdate: onTocUpdate
62
62
  }), ImageExtension({
63
63
  onUpload: onUpload,
@@ -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, "editor" | "key">, any>;
4
+ }) => import("@tiptap/core").Extension<Omit<import("@tiptap/extension-file-handler").FileHandlePluginOptions, "key" | "editor">, any>;
@@ -73,7 +73,7 @@ export var FileHandlerExtension = function FileHandlerExtension(props) {
73
73
  chain.setTextSelection(progressPos);
74
74
  }
75
75
  _context.t0 = fileType;
76
- _context.next = _context.t0 === 'image' ? 18 : _context.t0 === 'video' ? 32 : 34;
76
+ _context.next = _context.t0 === 'image' ? 18 : _context.t0 === 'video' ? 31 : 33;
77
77
  break;
78
78
  case 18:
79
79
  _context.prev = 18;
@@ -83,14 +83,13 @@ export var FileHandlerExtension = function FileHandlerExtension(props) {
83
83
  dimensions = _context.sent;
84
84
  chain.setImage({
85
85
  src: url,
86
- width: Math.min(dimensions.width, 760) // 使用原始宽度,但不超过760px
86
+ width: Math.min(dimensions.width, 760)
87
87
  }).run();
88
- _context.next = 31;
88
+ _context.next = 30;
89
89
  break;
90
90
  case 25:
91
91
  _context.prev = 25;
92
92
  _context.t1 = _context["catch"](18);
93
- console.warn('无法获取图片尺寸,使用默认宽度:', _context.t1);
94
93
  fallbackChain = editor.chain().focus();
95
94
  if (progressPos !== null) {
96
95
  fallbackChain.setTextSelection(progressPos);
@@ -99,28 +98,28 @@ export var FileHandlerExtension = function FileHandlerExtension(props) {
99
98
  src: url,
100
99
  width: 760
101
100
  }).run();
101
+ case 30:
102
+ return _context.abrupt("break", 35);
102
103
  case 31:
103
- return _context.abrupt("break", 36);
104
- case 32:
105
104
  chain.setVideo({
106
105
  src: url,
107
106
  width: 760,
108
107
  controls: true,
109
108
  autoplay: false
110
109
  }).run();
111
- return _context.abrupt("break", 36);
112
- case 34:
110
+ return _context.abrupt("break", 35);
111
+ case 33:
113
112
  chain.setBlockAttachment({
114
113
  url: url,
115
114
  title: file.name,
116
115
  size: formatFileSize(file.size)
117
116
  }).run();
118
- return _context.abrupt("break", 36);
119
- case 36:
120
- _context.next = 54;
117
+ return _context.abrupt("break", 35);
118
+ case 35:
119
+ _context.next = 53;
121
120
  break;
122
- case 38:
123
- _context.prev = 38;
121
+ case 37:
122
+ _context.prev = 37;
124
123
  _context.t2 = _context["catch"](6);
125
124
  console.error('文件上传失败:', _context.t2);
126
125
  if (isImage) {
@@ -134,34 +133,34 @@ export var FileHandlerExtension = function FileHandlerExtension(props) {
134
133
  _chain.setTextSelection(_progressPos);
135
134
  }
136
135
  _context.t3 = fileType;
137
- _context.next = _context.t3 === 'image' ? 48 : _context.t3 === 'video' ? 50 : 52;
136
+ _context.next = _context.t3 === 'image' ? 47 : _context.t3 === 'video' ? 49 : 51;
138
137
  break;
139
- case 48:
138
+ case 47:
140
139
  _chain.setImage({
141
140
  src: '',
142
141
  width: 760
143
142
  }).run();
144
- return _context.abrupt("break", 54);
145
- case 50:
143
+ return _context.abrupt("break", 53);
144
+ case 49:
146
145
  _chain.setVideo({
147
146
  src: '',
148
147
  width: 760,
149
148
  controls: true,
150
149
  autoplay: false
151
150
  }).run();
152
- return _context.abrupt("break", 54);
153
- case 52:
151
+ return _context.abrupt("break", 53);
152
+ case 51:
154
153
  _chain.setBlockAttachment({
155
154
  url: 'error',
156
155
  title: "\u4E0A\u4F20\u5931\u8D25: ".concat(file.name),
157
156
  size: formatFileSize(file.size)
158
157
  }).run();
159
- return _context.abrupt("break", 54);
160
- case 54:
158
+ return _context.abrupt("break", 53);
159
+ case 53:
161
160
  case "end":
162
161
  return _context.stop();
163
162
  }
164
- }, _loop, null, [[6, 38], [18, 25]]);
163
+ }, _loop, null, [[6, 37], [18, 25]]);
165
164
  });
166
165
  i = 0;
167
166
  case 5:
@@ -185,141 +184,5 @@ export var FileHandlerExtension = function FileHandlerExtension(props) {
185
184
  }
186
185
  return onDrop;
187
186
  }()
188
- // onPaste: async (editor, files, pasteContent) => {
189
- // if (!props.onUpload || files.length === 0 || !!pasteContent) return false;
190
- // const { from } = editor.state.selection;
191
- // if (files.length > 0) {
192
- // const findNodePosition = (typeName: string, tempId: string) => {
193
- // let targetPos: number | null = null;
194
- // editor.state.doc.descendants((node, position) => {
195
- // if (node.type.name === typeName && node.attrs.tempId === tempId) {
196
- // targetPos = position;
197
- // return false;
198
- // }
199
- // return undefined;
200
- // });
201
- // return targetPos;
202
- // };
203
- // for (let i = 0; i < files.length; i++) {
204
- // const file = files[i];
205
- // const fileType = getFileType(file);
206
- // const tempId = `upload-${Date.now()}-${i}`;
207
- // const insertPosition = from + i;
208
- // const isImage = fileType === 'image';
209
- // const progressNodeType = isImage ? 'inlineUploadProgress' : 'uploadProgress';
210
- // try {
211
- // editor.chain().insertContentAt(insertPosition, {
212
- // type: progressNodeType,
213
- // attrs: {
214
- // fileName: file.name,
215
- // fileType,
216
- // progress: 0,
217
- // tempId,
218
- // },
219
- // }).focus().run();
220
-
221
- // const progressPos = findNodePosition(progressNodeType, tempId);
222
-
223
- // const url = await props.onUpload(file, (progressEvent) => {
224
- // const progressValue = progressEvent.progress;
225
- // if (isImage) {
226
- // editor.chain().updateInlineUploadProgress(tempId, progressValue).focus().run();
227
- // } else {
228
- // editor.chain().updateUploadProgress(tempId, progressValue).focus().run();
229
- // }
230
- // });
231
-
232
- // if (isImage) {
233
- // editor.chain().removeInlineUploadProgress(tempId).focus().run();
234
- // } else {
235
- // editor.chain().removeUploadProgress(tempId).focus().run();
236
- // }
237
-
238
- // const chain = editor.chain().focus();
239
- // if (progressPos !== null) {
240
- // chain.setTextSelection(progressPos);
241
- // }
242
-
243
- // switch (fileType) {
244
- // case 'image':
245
- // try {
246
- // const dimensions = await getImageDimensionsFromFile(file);
247
- // chain.setImage({
248
- // src: url,
249
- // width: Math.min(dimensions.width, 760) // 使用原始宽度,但不超过760px
250
- // }).run();
251
- // } catch (error) {
252
- // console.warn('无法获取图片尺寸,使用默认宽度:', error);
253
- // const fallbackChain = editor.chain().focus();
254
- // if (progressPos !== null) {
255
- // fallbackChain.setTextSelection(progressPos);
256
- // }
257
- // fallbackChain.setImage({
258
- // src: url,
259
- // width: 760
260
- // }).run();
261
- // }
262
- // break;
263
- // case 'video':
264
- // chain.setVideo({
265
- // src: url,
266
- // width: 760,
267
- // controls: true,
268
- // autoplay: false
269
- // }).run();
270
- // break;
271
- // default:
272
- // chain.setBlockAttachment({
273
- // url: url,
274
- // title: file.name,
275
- // size: formatFileSize(file.size)
276
- // }).run();
277
- // break;
278
- // }
279
- // } catch (error) {
280
- // console.error('文件上传失败:', error);
281
- // const tempId = `upload-${Date.now()}-${i}`;
282
- // const isImage = fileType === 'image';
283
- // const progressNodeType = isImage ? 'inlineUploadProgress' : 'uploadProgress';
284
- // const progressPos = findNodePosition(progressNodeType, tempId);
285
-
286
- // if (isImage) {
287
- // editor.chain().removeInlineUploadProgress(tempId).focus().run();
288
- // } else {
289
- // editor.chain().removeUploadProgress(tempId).focus().run();
290
- // }
291
-
292
- // const chain = editor.chain().focus();
293
- // if (progressPos !== null) {
294
- // chain.setTextSelection(progressPos);
295
- // }
296
- // switch (fileType) {
297
- // case 'image':
298
- // chain.setImage({
299
- // src: '',
300
- // width: 760
301
- // }).run();
302
- // break;
303
- // case 'video':
304
- // chain.setVideo({
305
- // src: '',
306
- // width: 760,
307
- // controls: true,
308
- // autoplay: false
309
- // }).run();
310
- // break;
311
- // default:
312
- // chain.setBlockAttachment({
313
- // url: 'error',
314
- // title: `上传失败: ${file.name}`,
315
- // size: formatFileSize(file.size)
316
- // }).run();
317
- // break;
318
- // }
319
- // }
320
- // }
321
- // }
322
- // return true;
323
- // },
324
187
  });
325
188
  };
@@ -111,14 +111,13 @@ var customImage = function customImage(props) {
111
111
  dimensions = _context.sent;
112
112
  chain.setImage({
113
113
  src: url,
114
- width: Math.min(dimensions.width, 760) // 使用原始宽度,但不超过760px
114
+ width: Math.min(dimensions.width, 760)
115
115
  }).run();
116
- _context.next = 25;
116
+ _context.next = 24;
117
117
  break;
118
118
  case 19:
119
119
  _context.prev = 19;
120
120
  _context.t0 = _context["catch"](12);
121
- console.warn('无法获取图片尺寸,使用默认宽度:', _context.t0);
122
121
  fallbackChain = editor.chain().focus();
123
122
  if (progressPos !== null) {
124
123
  fallbackChain.setTextSelection(progressPos);
@@ -127,13 +126,12 @@ var customImage = function customImage(props) {
127
126
  src: url,
128
127
  width: 760
129
128
  }).run();
130
- case 25:
131
- _context.next = 35;
129
+ case 24:
130
+ _context.next = 33;
132
131
  break;
133
- case 27:
134
- _context.prev = 27;
132
+ case 26:
133
+ _context.prev = 26;
135
134
  _context.t1 = _context["catch"](3);
136
- console.error('图片上传失败:', _context.t1);
137
135
  editor.chain().removeInlineUploadProgress(tempId).focus().run();
138
136
  _progressPos = findNodePosition('inlineUploadProgress', tempId);
139
137
  _chain = editor.chain().focus();
@@ -144,11 +142,11 @@ var customImage = function customImage(props) {
144
142
  src: '',
145
143
  width: 760
146
144
  }).run();
147
- case 35:
145
+ case 33:
148
146
  case "end":
149
147
  return _context.stop();
150
148
  }
151
- }, _loop, null, [[3, 27], [12, 19]]);
149
+ }, _loop, null, [[3, 26], [12, 19]]);
152
150
  });
153
151
  i = 0;
154
152
  case 4:
@@ -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>;