@ctzhian/tiptap 2.1.18 → 2.3.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.
@@ -491,13 +491,14 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
491
491
  borderColor: 'divider',
492
492
  borderRadius: '0 0 4px 4px'
493
493
  }
494
- }, ['edit', 'split'].includes(displayMode) && /*#__PURE__*/React.createElement(Stack, {
494
+ }, /*#__PURE__*/React.createElement(Stack, {
495
495
  direction: "column",
496
496
  onPaste: handlePaste,
497
497
  onDragOver: handleDragOver,
498
498
  onDragLeave: handleDragLeave,
499
499
  onDrop: handleDrop,
500
500
  sx: {
501
+ display: ['edit', 'split'].includes(displayMode) ? 'flex' : 'none',
501
502
  flex: 1,
502
503
  '.ace_placeholder': _objectSpread({
503
504
  transform: 'scale(1)',
@@ -539,13 +540,14 @@ var EditorMarkdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
539
540
  })), displayMode === 'split' && /*#__PURE__*/React.createElement(Divider, {
540
541
  orientation: "vertical",
541
542
  flexItem: true
542
- }), ['split', 'preview'].includes(displayMode) && /*#__PURE__*/React.createElement(Box, {
543
+ }), /*#__PURE__*/React.createElement(Box, {
543
544
  id: "markdown-preview-container",
544
545
  sx: _objectSpread({
545
546
  overflowY: 'scroll',
546
547
  flex: 1,
547
548
  p: 2,
548
- height: EditorHeight
549
+ height: EditorHeight,
550
+ display: ['split', 'preview'].includes(displayMode) ? 'block' : 'none'
549
551
  }, displayMode === 'preview' && isExpend && {
550
552
  px: '10%'
551
553
  })
@@ -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;
@@ -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, "key" | "editor">, any>;
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
- interface TableOfContentsOptions {
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 }: TableOfContentsOptions) => import("@tiptap/core").Extension<import("@tiptap/extension-table-of-contents").TableOfContentsOptions, import("@tiptap/extension-table-of-contents").TableOfContentsStorage>;
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
- onUpdate: function onUpdate(data) {
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
  };
@@ -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;
@@ -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,
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctzhian/tiptap",
3
- "version": "2.1.18",
3
+ "version": "2.3.0",
4
4
  "description": "基于 Tiptap 二次开发的编辑器组件",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -67,7 +67,7 @@
67
67
  "@types/react": "^18.0.0",
68
68
  "@types/react-dom": "^18.0.0",
69
69
  "@umijs/lint": "^4.0.0",
70
- "dumi": "^2.4.13",
70
+ "dumi": "^2.4.21",
71
71
  "eslint": "^8.23.0",
72
72
  "father": "^4.1.0",
73
73
  "husky": "^8.0.1",
@@ -82,38 +82,38 @@
82
82
  "dependencies": {
83
83
  "@floating-ui/dom": "^1.7.2",
84
84
  "@floating-ui/react": "^0.27.16",
85
- "@tiptap/core": "^3.11.0",
86
- "@tiptap/extension-bubble-menu": "^3.11.0",
87
- "@tiptap/extension-code": "^3.11.0",
88
- "@tiptap/extension-code-block-lowlight": "^3.11.0",
89
- "@tiptap/extension-details": "^3.11.0",
90
- "@tiptap/extension-drag-handle-react": "^3.11.0",
91
- "@tiptap/extension-emoji": "^3.11.0",
92
- "@tiptap/extension-file-handler": "^3.11.0",
93
- "@tiptap/extension-highlight": "^3.11.0",
94
- "@tiptap/extension-horizontal-rule": "^3.11.0",
95
- "@tiptap/extension-image": "^3.11.0",
96
- "@tiptap/extension-invisible-characters": "^3.11.0",
97
- "@tiptap/extension-link": "^3.11.0",
98
- "@tiptap/extension-list": "^3.11.0",
99
- "@tiptap/extension-mathematics": "^3.11.0",
100
- "@tiptap/extension-mention": "^3.11.0",
101
- "@tiptap/extension-subscript": "^3.11.0",
102
- "@tiptap/extension-superscript": "^3.11.0",
103
- "@tiptap/extension-table": "^3.11.0",
104
- "@tiptap/extension-table-of-contents": "^3.11.0",
105
- "@tiptap/extension-text-align": "^3.11.0",
106
- "@tiptap/extension-text-style": "^3.11.0",
107
- "@tiptap/extension-unique-id": "^3.11.0",
108
- "@tiptap/extension-youtube": "^3.11.0",
109
- "@tiptap/extensions": "^3.11.0",
110
- "@tiptap/html": "^3.11.0",
111
- "@tiptap/markdown": "^3.11.0",
112
- "@tiptap/pm": "^3.11.0",
113
- "@tiptap/react": "^3.11.0",
114
- "@tiptap/starter-kit": "^3.11.0",
115
- "@tiptap/static-renderer": "^3.11.0",
116
- "@tiptap/suggestion": "^3.11.0",
85
+ "@tiptap/core": "^3.11.1",
86
+ "@tiptap/extension-bubble-menu": "^3.11.1",
87
+ "@tiptap/extension-code": "^3.11.1",
88
+ "@tiptap/extension-code-block-lowlight": "^3.11.1",
89
+ "@tiptap/extension-details": "^3.11.1",
90
+ "@tiptap/extension-drag-handle-react": "^3.11.1",
91
+ "@tiptap/extension-emoji": "^3.11.1",
92
+ "@tiptap/extension-file-handler": "^3.11.1",
93
+ "@tiptap/extension-highlight": "^3.11.1",
94
+ "@tiptap/extension-horizontal-rule": "^3.11.1",
95
+ "@tiptap/extension-image": "^3.11.1",
96
+ "@tiptap/extension-invisible-characters": "^3.11.1",
97
+ "@tiptap/extension-link": "^3.11.1",
98
+ "@tiptap/extension-list": "^3.11.1",
99
+ "@tiptap/extension-mathematics": "^3.11.1",
100
+ "@tiptap/extension-mention": "^3.11.1",
101
+ "@tiptap/extension-subscript": "^3.11.1",
102
+ "@tiptap/extension-superscript": "^3.11.1",
103
+ "@tiptap/extension-table": "^3.11.1",
104
+ "@tiptap/extension-table-of-contents": "^3.11.1",
105
+ "@tiptap/extension-text-align": "^3.11.1",
106
+ "@tiptap/extension-text-style": "^3.11.1",
107
+ "@tiptap/extension-unique-id": "^3.11.1",
108
+ "@tiptap/extension-youtube": "^3.11.1",
109
+ "@tiptap/extensions": "^3.11.1",
110
+ "@tiptap/html": "^3.11.1",
111
+ "@tiptap/markdown": "^3.11.1",
112
+ "@tiptap/pm": "^3.11.1",
113
+ "@tiptap/react": "^3.11.1",
114
+ "@tiptap/starter-kit": "^3.11.1",
115
+ "@tiptap/static-renderer": "^3.11.1",
116
+ "@tiptap/suggestion": "^3.11.1",
117
117
  "ace-builds": "^1.43.4",
118
118
  "core-js": "^3.46.0",
119
119
  "diff-match-patch": "^1.0.5",