@ctzhian/tiptap 2.0.0 → 2.1.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.
Files changed (45) hide show
  1. package/dist/Editor/demo.js +133 -123
  2. package/dist/EditorToolbar/index.js +11 -9
  3. package/dist/asset/css/index.css +5 -7
  4. package/dist/component/ActionDropdown/index.d.ts +5 -0
  5. package/dist/component/ActionDropdown/index.js +8 -3
  6. package/dist/component/FloatingPopover/index.d.ts +2 -2
  7. package/dist/component/HoverPopover/index.d.ts +2 -0
  8. package/dist/component/HoverPopover/index.js +22 -3
  9. package/dist/component/Icons/{expand-horizontal-line.js → expand-horizontal-line-icon.js} +1 -1
  10. package/dist/component/Icons/index.d.ts +3 -2
  11. package/dist/component/Icons/index.js +4 -3
  12. package/dist/extension/component/Alert/index.js +141 -137
  13. package/dist/extension/component/Flow/Edit.d.ts +1 -1
  14. package/dist/extension/component/Flow/Edit.js +3 -31
  15. package/dist/extension/component/Flow/index.js +20 -19
  16. package/dist/extension/component/Image/index.d.ts +1 -0
  17. package/dist/extension/component/Image/index.js +16 -2
  18. package/dist/extension/component/Link/index.js +1 -1
  19. package/dist/extension/component/TableCellHandleMenu/index.js +60 -3
  20. package/dist/extension/component/TableHandle/TableHandleMenu.js +1 -1
  21. package/dist/extension/component/TableSelectionOverlay/index.js +4 -12
  22. package/dist/extension/component/UploadProgress/index.d.ts +1 -1
  23. package/dist/extension/component/Video/Insert.js +4 -2
  24. package/dist/extension/component/Video/Readonly.js +4 -11
  25. package/dist/extension/component/Video/index.d.ts +2 -1
  26. package/dist/extension/component/Video/index.js +447 -65
  27. package/dist/extension/extension/ImeComposition.d.ts +2 -0
  28. package/dist/extension/extension/ImeComposition.js +145 -0
  29. package/dist/extension/extension/index.d.ts +1 -0
  30. package/dist/extension/extension/index.js +1 -0
  31. package/dist/extension/index.js +2 -2
  32. package/dist/extension/node/Flow/index.d.ts +0 -3
  33. package/dist/extension/node/Flow/index.js +7 -4
  34. package/dist/extension/node/Link/index.js +4 -3
  35. package/dist/extension/node/Table.js +18 -82
  36. package/dist/extension/node/TableOfContents/index.d.ts +5 -3
  37. package/dist/extension/node/TableOfContents/index.js +22 -2
  38. package/dist/extension/node/Video.d.ts +1 -0
  39. package/dist/extension/node/Video.js +38 -6
  40. package/dist/hook/index.js +1 -1
  41. package/dist/index.css +16 -19
  42. package/dist/util/index.d.ts +9 -0
  43. package/dist/util/index.js +26 -0
  44. package/package.json +1 -1
  45. /package/dist/component/Icons/{expand-horizontal-line.d.ts → expand-horizontal-line-icon.d.ts} +0 -0
@@ -1,15 +1,15 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
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
- 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
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import { FloatingPopover } from "../../../component";
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 { ActionDropdown, HoverPopover } from "../../../component";
8
8
  import { CheckboxCircleFillIcon, CloseCircleFillIcon, ErrorWarningFillIcon, Information2FillIcon, ScrollToBottomLineIcon, TextIcon, UserSmileFillIcon } from "../../../component/Icons";
9
9
  import { ToolbarItem } from "../../../component/Toolbar";
10
10
  import { Box, Divider, Stack } from '@mui/material';
11
11
  import { NodeViewContent, NodeViewWrapper } from '@tiptap/react';
12
- import React, { useMemo, useRef, useState } from 'react';
12
+ import React, { useMemo, useRef } from 'react';
13
13
  var VARIANT_DATA = {
14
14
  info: {
15
15
  icon: /*#__PURE__*/React.createElement(Information2FillIcon, {
@@ -53,17 +53,13 @@ var VARIANT_DATA = {
53
53
  }
54
54
  };
55
55
  var AlertView = function AlertView(_ref) {
56
- var _node$attrs;
56
+ var _node$attrs, _node$attrs2;
57
57
  var editor = _ref.editor,
58
58
  node = _ref.node,
59
59
  updateAttributes = _ref.updateAttributes,
60
60
  selected = _ref.selected;
61
61
  var attrs = node.attrs;
62
62
  var containerRef = useRef(null);
63
- var _useState = useState(null),
64
- _useState2 = _slicedToArray(_useState, 2),
65
- anchorEl = _useState2[0],
66
- setAnchorEl = _useState2[1];
67
63
  var showIcon = attrs.type !== 'text';
68
64
  var variantData = useMemo(function () {
69
65
  if (attrs.variant && VARIANT_DATA[attrs.variant]) {
@@ -71,31 +67,127 @@ var AlertView = function AlertView(_ref) {
71
67
  }
72
68
  return VARIANT_DATA['default'];
73
69
  }, [attrs.variant]);
74
- var handleShowOperationPopover = function handleShowOperationPopover(event) {
75
- return setAnchorEl(event.currentTarget);
76
- };
77
- var handleCloseOperationPopover = function handleCloseOperationPopover() {
78
- return setAnchorEl(null);
70
+ var variantOptions = [{
71
+ key: 'info',
72
+ label: '信息',
73
+ icon: Information2FillIcon,
74
+ color: 'primary.main'
75
+ }, {
76
+ key: 'warning',
77
+ label: '警告',
78
+ icon: ErrorWarningFillIcon,
79
+ color: 'warning.main'
80
+ }, {
81
+ key: 'error',
82
+ label: '错误',
83
+ icon: CloseCircleFillIcon,
84
+ color: 'error.main'
85
+ }, {
86
+ key: 'success',
87
+ label: '成功',
88
+ icon: CheckboxCircleFillIcon,
89
+ color: 'success.main'
90
+ }, {
91
+ key: 'default',
92
+ label: '默认',
93
+ icon: UserSmileFillIcon,
94
+ color: 'text.disabled'
95
+ }];
96
+ var typeOptions = [{
97
+ key: 'text',
98
+ label: '纯文字',
99
+ icon: TextIcon,
100
+ onClick: function onClick() {
101
+ return updateAttributes({
102
+ type: 'text'
103
+ });
104
+ }
105
+ }, {
106
+ key: 'icon',
107
+ label: '图标文字',
108
+ icon: ScrollToBottomLineIcon,
109
+ iconTransform: 'rotate(90deg)',
110
+ onClick: function onClick() {
111
+ return updateAttributes({
112
+ type: 'icon'
113
+ });
114
+ }
115
+ }];
116
+ var renderOperationActions = function renderOperationActions() {
117
+ return /*#__PURE__*/React.createElement(Stack, {
118
+ direction: 'row',
119
+ alignItems: 'center',
120
+ sx: {
121
+ p: 0.5
122
+ }
123
+ }, variantOptions.map(function (option) {
124
+ var IconComponent = option.icon;
125
+ return /*#__PURE__*/React.createElement(ToolbarItem, {
126
+ key: option.key,
127
+ icon: /*#__PURE__*/React.createElement(IconComponent, {
128
+ sx: {
129
+ fontSize: '1rem',
130
+ color: option.color
131
+ }
132
+ }),
133
+ tip: option.label,
134
+ onClick: function onClick() {
135
+ return updateAttributes({
136
+ variant: option.key
137
+ });
138
+ },
139
+ className: attrs.variant === option.key ? 'tool-active' : ''
140
+ });
141
+ }), /*#__PURE__*/React.createElement(Divider, {
142
+ orientation: "vertical",
143
+ flexItem: true,
144
+ sx: {
145
+ height: '1rem',
146
+ mx: 0.5,
147
+ alignSelf: 'center',
148
+ borderColor: 'divider'
149
+ }
150
+ }), /*#__PURE__*/React.createElement(ActionDropdown, {
151
+ id: "alert-type-dropdown",
152
+ selected: attrs.type || 'icon',
153
+ list: typeOptions.map(function (option) {
154
+ var IconComponent = option.icon;
155
+ return {
156
+ key: option.key,
157
+ label: option.label,
158
+ icon: /*#__PURE__*/React.createElement(IconComponent, {
159
+ sx: _objectSpread({
160
+ fontSize: '1rem'
161
+ }, option.iconTransform ? {
162
+ transform: option.iconTransform
163
+ } : {})
164
+ }),
165
+ onClick: option.onClick
166
+ };
167
+ })
168
+ }));
79
169
  };
80
170
  return /*#__PURE__*/React.createElement(NodeViewWrapper, {
81
171
  ref: containerRef,
82
172
  className: "alert-wrapper ".concat(selected ? 'ProseMirror-selectednode' : ''),
83
173
  "data-drag-handle": true,
84
- as: 'div',
85
- style: {
174
+ as: 'div'
175
+ }, editor.isEditable ? /*#__PURE__*/React.createElement(HoverPopover, {
176
+ actions: renderOperationActions(),
177
+ placement: "top",
178
+ offset: 4
179
+ }, /*#__PURE__*/React.createElement(Box, {
180
+ sx: {
86
181
  marginLeft: (_node$attrs = node.attrs) !== null && _node$attrs !== void 0 && _node$attrs.indent ? node.attrs.indent * 32 : undefined,
87
182
  border: '1px solid',
88
183
  borderColor: variantData.color,
89
- // color: attrs.variant === 'default' ? 'var(--mui-palette-text-primary)' : variantData.color,
90
- borderRadius: '10px',
184
+ borderRadius: 'var(--mui-shape-borderRadius)',
91
185
  padding: '12px 16px',
92
- lineHeight: 1.625,
93
186
  display: 'flex',
94
187
  alignItems: 'flex-start',
95
188
  gap: '16px',
96
189
  background: attrs.variant === 'default' ? 'var(--mui-palette-background-paper3)' : "color-mix(in srgb, ".concat(variantData.color, " 10%, transparent)")
97
- },
98
- onClick: handleShowOperationPopover
190
+ }
99
191
  }, showIcon && /*#__PURE__*/React.createElement(Box, {
100
192
  sx: {
101
193
  pt: '2px',
@@ -113,123 +205,35 @@ var AlertView = function AlertView(_ref) {
113
205
  }
114
206
  }, /*#__PURE__*/React.createElement(NodeViewContent, {
115
207
  as: 'div'
116
- })), editor.isEditable && /*#__PURE__*/React.createElement(FloatingPopover, {
117
- open: Boolean(anchorEl),
118
- anchorEl: anchorEl,
119
- onClose: handleCloseOperationPopover,
120
- placement: "top"
121
- }, /*#__PURE__*/React.createElement(Stack, {
122
- direction: 'row',
123
- alignItems: 'center',
208
+ })))) : /*#__PURE__*/React.createElement(Box, {
124
209
  sx: {
125
- p: 0.5
210
+ marginLeft: (_node$attrs2 = node.attrs) !== null && _node$attrs2 !== void 0 && _node$attrs2.indent ? node.attrs.indent * 32 : undefined,
211
+ border: '1px solid',
212
+ borderColor: variantData.color,
213
+ borderRadius: 'var(--mui-shape-borderRadius)',
214
+ padding: '12px 16px',
215
+ display: 'flex',
216
+ alignItems: 'flex-start',
217
+ gap: '16px',
218
+ background: attrs.variant === 'default' ? 'var(--mui-palette-background-paper3)' : "color-mix(in srgb, ".concat(variantData.color, " 10%, transparent)")
126
219
  }
127
- }, /*#__PURE__*/React.createElement(ToolbarItem, {
128
- icon: /*#__PURE__*/React.createElement(Information2FillIcon, {
129
- sx: {
130
- fontSize: '1rem',
131
- color: 'primary.main'
132
- }
133
- }),
134
- tip: "\u4FE1\u606F",
135
- onClick: function onClick() {
136
- return updateAttributes({
137
- variant: 'info'
138
- });
139
- },
140
- className: attrs.variant === 'info' ? 'tool-active' : ''
141
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
142
- icon: /*#__PURE__*/React.createElement(ErrorWarningFillIcon, {
143
- sx: {
144
- fontSize: '1rem',
145
- color: 'warning.main'
146
- }
147
- }),
148
- tip: "\u8B66\u544A",
149
- onClick: function onClick() {
150
- return updateAttributes({
151
- variant: 'warning'
152
- });
153
- },
154
- className: attrs.variant === 'warning' ? 'tool-active' : ''
155
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
156
- icon: /*#__PURE__*/React.createElement(CloseCircleFillIcon, {
157
- sx: {
158
- fontSize: '1rem',
159
- color: 'error.main'
160
- }
161
- }),
162
- tip: "\u9519\u8BEF",
163
- onClick: function onClick() {
164
- return updateAttributes({
165
- variant: 'error'
166
- });
167
- },
168
- className: attrs.variant === 'error' ? 'tool-active' : ''
169
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
170
- icon: /*#__PURE__*/React.createElement(CheckboxCircleFillIcon, {
171
- sx: {
172
- fontSize: '1rem',
173
- color: 'success.main'
174
- }
175
- }),
176
- tip: "\u6210\u529F",
177
- onClick: function onClick() {
178
- return updateAttributes({
179
- variant: 'success'
180
- });
181
- },
182
- className: attrs.variant === 'success' ? 'tool-active' : ''
183
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
184
- icon: /*#__PURE__*/React.createElement(UserSmileFillIcon, {
185
- sx: {
186
- fontSize: '1rem',
187
- color: 'text.disabled'
188
- }
189
- }),
190
- tip: "\u9ED8\u8BA4",
191
- onClick: function onClick() {
192
- return updateAttributes({
193
- variant: 'default'
194
- });
195
- },
196
- className: attrs.variant === 'default' ? 'tool-active' : ''
197
- }), /*#__PURE__*/React.createElement(Divider, {
198
- orientation: "vertical",
199
- flexItem: true,
220
+ }, showIcon && /*#__PURE__*/React.createElement(Box, {
200
221
  sx: {
201
- height: '1rem',
202
- mx: 0.5,
203
- alignSelf: 'center',
204
- borderColor: 'divider'
222
+ pt: '2px',
223
+ lineHeight: 1,
224
+ color: attrs.variant === 'default' ? 'text.disabled' : variantData.color
205
225
  }
206
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
207
- icon: /*#__PURE__*/React.createElement(TextIcon, {
208
- sx: {
209
- fontSize: '1rem'
210
- }
211
- }),
212
- tip: "\u7EAF\u6587\u5B57",
213
- onClick: function onClick() {
214
- return updateAttributes({
215
- type: 'text'
216
- });
217
- },
218
- className: attrs.type === 'text' ? 'tool-active' : ''
219
- }), /*#__PURE__*/React.createElement(ToolbarItem, {
220
- icon: /*#__PURE__*/React.createElement(ScrollToBottomLineIcon, {
221
- sx: {
222
- transform: 'rotate(90deg)',
223
- fontSize: '1rem'
226
+ }, variantData.icon), /*#__PURE__*/React.createElement(Box, {
227
+ sx: {
228
+ flex: 1,
229
+ width: 0,
230
+ 'code': {
231
+ borderColor: attrs.variant === 'default' ? '' : "color-mix(in srgb, ".concat(variantData.color, " 30%, transparent) !important"),
232
+ bgcolor: attrs.variant === 'default' ? '' : "color-mix(in srgb, ".concat(variantData.color, " 10%, transparent) !important")
224
233
  }
225
- }),
226
- tip: "\u56FE\u6807\u6587\u5B57",
227
- onClick: function onClick() {
228
- return updateAttributes({
229
- type: 'icon'
230
- });
231
- },
232
- className: attrs.type === 'icon' ? 'tool-active' : ''
234
+ }
235
+ }, /*#__PURE__*/React.createElement(NodeViewContent, {
236
+ as: 'div'
233
237
  }))));
234
238
  };
235
239
  export default AlertView;
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { FlowAttributes } from ".";
3
3
  type EditFlowProps = {
4
- anchorEl: HTMLDivElement | null;
4
+ anchorEl: HTMLElement | null;
5
5
  attrs: FlowAttributes;
6
6
  updateAttributes: (attrs: FlowAttributes) => void;
7
7
  onCancel: () => void;
@@ -6,7 +6,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import { FloatingPopover } from "../../../component/FloatingPopover";
8
8
  import { Button, Stack, TextField } from "@mui/material";
9
- import React, { useEffect, useMemo, useState } from "react";
9
+ import React, { useEffect, useState } from "react";
10
10
  var EditFlow = function EditFlow(_ref) {
11
11
  var anchorEl = _ref.anchorEl,
12
12
  attrs = _ref.attrs,
@@ -16,34 +16,9 @@ var EditFlow = function EditFlow(_ref) {
16
16
  _useState2 = _slicedToArray(_useState, 2),
17
17
  editCode = _useState2[0],
18
18
  setEditCode = _useState2[1];
19
-
20
- // 当 attrs.code 更新时,同步更新 editCode
21
19
  useEffect(function () {
22
20
  setEditCode(attrs.code || '');
23
21
  }, [attrs.code]);
24
-
25
- // 创建虚拟元素,表示 flow-wrapper 的中心点
26
- var centerVirtualElement = useMemo(function () {
27
- if (!anchorEl) return null;
28
- return {
29
- getBoundingClientRect: function getBoundingClientRect() {
30
- // 每次调用时重新计算,确保位置实时更新
31
- var rect = anchorEl.getBoundingClientRect();
32
- var centerX = rect.left + rect.width / 2;
33
- var centerY = rect.top + rect.height / 2;
34
- return {
35
- width: 0,
36
- height: 0,
37
- x: centerX,
38
- y: centerY,
39
- top: centerY,
40
- left: centerX,
41
- right: centerX,
42
- bottom: centerY
43
- };
44
- }
45
- };
46
- }, [anchorEl]);
47
22
  var handleSaveFlow = function handleSaveFlow() {
48
23
  var trimmedCode = editCode.trim();
49
24
  if (!trimmedCode) return;
@@ -54,12 +29,9 @@ var EditFlow = function EditFlow(_ref) {
54
29
  };
55
30
  return /*#__PURE__*/React.createElement(FloatingPopover, {
56
31
  open: true,
57
- anchorEl: centerVirtualElement,
32
+ anchorEl: anchorEl,
58
33
  onClose: onCancel,
59
- placement: "top",
60
- style: {
61
- transform: 'translate(-50%, 0)'
62
- }
34
+ placement: "bottom"
63
35
  }, /*#__PURE__*/React.createElement(Stack, {
64
36
  gap: 2,
65
37
  sx: {
@@ -35,26 +35,26 @@ var FlowViewWrapper = function FlowViewWrapper(_ref) {
35
35
  _useState6 = _slicedToArray(_useState5, 2),
36
36
  isDragging = _useState6[0],
37
37
  setIsDragging = _useState6[1];
38
- var _useState7 = useState(null),
38
+ var _useState7 = useState(false),
39
39
  _useState8 = _slicedToArray(_useState7, 2),
40
- dragCorner = _useState8[0],
41
- setDragCorner = _useState8[1];
40
+ keepHoverPopoverOpen = _useState8[0],
41
+ setKeepHoverPopoverOpen = _useState8[1];
42
+ var _useState9 = useState(null),
43
+ _useState10 = _slicedToArray(_useState9, 2),
44
+ dragCorner = _useState10[0],
45
+ setDragCorner = _useState10[1];
42
46
  var dragStartXRef = useRef(0);
43
47
  var dragStartWidthRef = useRef(0);
44
48
  var flowWrapperRef = useRef(null);
45
49
  var flowContentRef = useRef(null);
46
-
47
- // 获取当前实际显示的流程图宽度
50
+ var editButtonRef = useRef(null);
48
51
  var getCurrentDisplayWidth = function getCurrentDisplayWidth() {
49
52
  if (flowWrapperRef.current) {
50
53
  return flowWrapperRef.current.offsetWidth;
51
54
  }
52
- // 如果 ref 不存在,使用容器宽度计算
53
55
  var containerWidth = 800;
54
56
  return getPixelValue(attrs.width, containerWidth);
55
57
  };
56
-
57
- // 将 width 转换为像素值
58
58
  var getPixelValue = function getPixelValue(value, containerSize) {
59
59
  var defaultPercent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100;
60
60
  if (!value) return containerSize * (defaultPercent / 100);
@@ -81,7 +81,7 @@ var FlowViewWrapper = function FlowViewWrapper(_ref) {
81
81
  var percent = Math.round(pixels / containerWidth * 100);
82
82
  return "".concat(percent, "%");
83
83
  }
84
- return Math.round(pixels);
84
+ return "".concat(Math.round(pixels), "px");
85
85
  };
86
86
  var handleMouseDown = function handleMouseDown(e, corner) {
87
87
  e.preventDefault();
@@ -95,13 +95,9 @@ var FlowViewWrapper = function FlowViewWrapper(_ref) {
95
95
  if (!isDragging || !dragCorner) return;
96
96
  var deltaX = e.clientX - dragStartXRef.current;
97
97
  var newWidth;
98
-
99
- // 根据不同的角计算宽度变化
100
98
  if (dragCorner === 'top-right' || dragCorner === 'bottom-right') {
101
- // 右侧角:向右拉伸,宽度增加
102
99
  newWidth = dragStartWidthRef.current + deltaX;
103
100
  } else {
104
- // 左侧角:向左拉伸,宽度增加(deltaX 为负时宽度增加)
105
101
  newWidth = dragStartWidthRef.current - deltaX;
106
102
  }
107
103
  newWidth = Math.max(200, Math.min(1920, newWidth));
@@ -125,7 +121,12 @@ var FlowViewWrapper = function FlowViewWrapper(_ref) {
125
121
  }
126
122
  }, [isDragging, handleMouseMove, handleMouseUp]);
127
123
  var handleShowPopover = function handleShowPopover() {
128
- return setIsEditing(true);
124
+ setKeepHoverPopoverOpen(true);
125
+ setIsEditing(true);
126
+ };
127
+ var handleEditCancel = function handleEditCancel() {
128
+ setIsEditing(false);
129
+ setKeepHoverPopoverOpen(false);
129
130
  };
130
131
  if (!editor.isEditable) {
131
132
  return /*#__PURE__*/React.createElement(ReadonlyFlow, {
@@ -167,6 +168,7 @@ var FlowViewWrapper = function FlowViewWrapper(_ref) {
167
168
  style: {
168
169
  width: '100%'
169
170
  },
171
+ keepOpen: keepHoverPopoverOpen,
170
172
  actions: /*#__PURE__*/React.createElement(Stack, {
171
173
  direction: 'row',
172
174
  alignItems: 'center',
@@ -174,6 +176,7 @@ var FlowViewWrapper = function FlowViewWrapper(_ref) {
174
176
  p: 0.5
175
177
  }
176
178
  }, /*#__PURE__*/React.createElement(ToolbarItem, {
179
+ ref: editButtonRef,
177
180
  icon: /*#__PURE__*/React.createElement(EditLineIcon, {
178
181
  sx: {
179
182
  fontSize: '1rem'
@@ -292,15 +295,13 @@ var FlowViewWrapper = function FlowViewWrapper(_ref) {
292
295
  zIndex: 10
293
296
  }
294
297
  }))))), isEditing && /*#__PURE__*/React.createElement(EditFlow, {
295
- anchorEl: flowContentRef.current,
298
+ anchorEl: editButtonRef.current,
296
299
  attrs: attrs,
297
300
  updateAttributes: function updateAttributes(newAttrs) {
298
301
  _updateAttributes(newAttrs);
299
- setIsEditing(false);
302
+ handleEditCancel();
300
303
  },
301
- onCancel: function onCancel() {
302
- return setIsEditing(false);
303
- }
304
+ onCancel: handleEditCancel
304
305
  }));
305
306
  };
306
307
  var FlowDiagram = function FlowDiagram(_ref2) {
@@ -1,6 +1,7 @@
1
1
  import { EditorFnProps } from "../../../type";
2
2
  import { NodeViewProps } from "@tiptap/react";
3
3
  import React from "react";
4
+ import 'react-photo-view/dist/react-photo-view.css';
4
5
  export interface ImageAttributes {
5
6
  src: string;
6
7
  title?: string;
@@ -14,6 +14,8 @@ import { ToolbarItem } from "../../../component/Toolbar";
14
14
  import { alpha, Box, Button, Divider, Stack, TextField, useTheme } from "@mui/material";
15
15
  import { NodeViewWrapper } from "@tiptap/react";
16
16
  import React, { useCallback, useEffect, useRef, useState } from "react";
17
+ import { PhotoView } from "react-photo-view";
18
+ import 'react-photo-view/dist/react-photo-view.css';
17
19
  import { HoverPopover } from "../../../component/HoverPopover";
18
20
  import CropImage from "./Crop";
19
21
  import InsertImage from "./Insert";
@@ -157,6 +159,15 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
157
159
  dragStartXRef.current = e.clientX;
158
160
  dragStartWidthRef.current = getCurrentDisplayWidth();
159
161
  };
162
+ var handleImageClick = function handleImageClick(e) {
163
+ // 如果正在拖拽调整大小,阻止预览
164
+ if (isDragging || dragCorner) {
165
+ e.preventDefault();
166
+ e.stopPropagation();
167
+ return;
168
+ }
169
+ // 允许 PhotoView 处理点击事件进行预览
170
+ };
160
171
  var handleMouseMove = useCallback(function (e) {
161
172
  if (!isDragging || !dragCorner) return;
162
173
  var deltaX = e.clientX - dragStartXRef.current;
@@ -383,6 +394,8 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
383
394
  onMouseLeave: function onMouseLeave() {
384
395
  return setIsHovering(false);
385
396
  }
397
+ }, /*#__PURE__*/React.createElement(PhotoView, {
398
+ src: attrs.src
386
399
  }, /*#__PURE__*/React.createElement("img", {
387
400
  ref: imageRef,
388
401
  src: attrs.src,
@@ -390,14 +403,15 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
390
403
  style: {
391
404
  maxWidth: '100%',
392
405
  height: 'auto',
393
- cursor: 'default',
406
+ cursor: isDragging ? 'default' : 'pointer',
394
407
  border: '2px solid',
395
408
  borderColor: isHovering || isDragging ? alpha(theme.palette.primary.main, 0.3) : 'transparent'
396
409
  },
410
+ onClick: handleImageClick,
397
411
  onError: function onError(e) {
398
412
  _onError === null || _onError === void 0 || _onError(e);
399
413
  }
400
- }), (isHovering || isDragging) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, {
414
+ })), (isHovering || isDragging) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, {
401
415
  onMouseDown: function onMouseDown(e) {
402
416
  return handleMouseDown(e, 'top-left');
403
417
  },
@@ -114,7 +114,7 @@ var LinkViewWrapper = function LinkViewWrapper(_ref) {
114
114
  fontSize: '1rem'
115
115
  }
116
116
  }),
117
- tip: "\u590D\u5236",
117
+ tip: "\u590D\u5236\u94FE\u63A5",
118
118
  onClick: handleCopyLink
119
119
  }), /*#__PURE__*/React.createElement(ToolbarItem, {
120
120
  icon: /*#__PURE__*/React.createElement(LinkUnlinkIcon, {
@@ -18,6 +18,7 @@ import { DeleteBack2LineIcon } from "../../../component/Icons/delete-back-2-line
18
18
  import { getThemeTextBgColor, getThemeTextColor } from "../../../contants/enums";
19
19
  import { Box, Divider, Typography } from '@mui/material';
20
20
  import { useTheme } from '@mui/material/styles';
21
+ import { TextSelection } from '@tiptap/pm/state';
21
22
  import { CellSelection, cellAround, deleteCellSelection, mergeCells, splitCell } from '@tiptap/pm/tables';
22
23
  import { useEditorState } from '@tiptap/react';
23
24
  import React, { forwardRef, useCallback, useEffect, useState } from 'react';
@@ -147,10 +148,66 @@ export var TableCellHandleMenu = /*#__PURE__*/forwardRef(function (_ref, ref) {
147
148
  }
148
149
  }),
149
150
  onClick: function onClick() {
151
+ if (!editor) return;
152
+ if (editor.state.storedMarks) {
153
+ var textStyleMarkType = editor.schema.marks.textStyle;
154
+ if (textStyleMarkType) {
155
+ editor.view.dispatch(editor.state.tr.removeStoredMark(textStyleMarkType));
156
+ }
157
+ }
150
158
  setTimeout(function () {
151
- editor.chain().focus().toggleMark('textStyle', {
152
- color: it.value
153
- }).run();
159
+ var _editor$state = editor.state,
160
+ selection = _editor$state.selection,
161
+ doc = _editor$state.doc;
162
+ var textStyleMark = editor.schema.marks.textStyle;
163
+ if (!textStyleMark) return;
164
+ if (selection instanceof CellSelection) {
165
+ var tr = editor.state.tr;
166
+ var hasContent = false;
167
+ selection.forEachCell(function (cellNode, cellPos) {
168
+ if (cellNode.content.size > 0) {
169
+ hasContent = true;
170
+ var from = cellPos + 1;
171
+ var to = cellPos + cellNode.nodeSize - 1;
172
+ if (from < to) {
173
+ var $from = doc.resolve(from);
174
+ var $to = doc.resolve(to);
175
+ var cellTextSelection = TextSelection.between($from, $to, 1);
176
+ if (cellTextSelection) {
177
+ var mark = textStyleMark.create({
178
+ color: it.value
179
+ });
180
+ tr.addMark(from, to, mark);
181
+ }
182
+ }
183
+ }
184
+ });
185
+ if (hasContent) {
186
+ editor.view.dispatch(tr);
187
+ editor.commands.focus();
188
+ }
189
+ } else {
190
+ var $anchor = selection.$anchor;
191
+ var cell = cellAround($anchor);
192
+ if (cell) {
193
+ var cellNode = doc.nodeAt(cell.pos);
194
+ if (cellNode && cellNode.content.size > 0) {
195
+ var from = cell.pos + 1;
196
+ var to = cell.pos + cellNode.nodeSize - 1;
197
+ if (from < to) {
198
+ var $from = doc.resolve(from);
199
+ var $to = doc.resolve(to);
200
+ var newSelection = TextSelection.between($from, $to, 1);
201
+ if (newSelection) {
202
+ editor.view.dispatch(editor.state.tr.setSelection(newSelection));
203
+ }
204
+ }
205
+ }
206
+ }
207
+ editor.chain().focus().toggleMark('textStyle', {
208
+ color: it.value
209
+ }).run();
210
+ }
154
211
  }, 0);
155
212
  }
156
213
  };
@@ -534,7 +534,7 @@ export var TableHandleMenu = function TableHandleMenu(_ref) {
534
534
  my: 0.5
535
535
  }
536
536
  }),
537
- key: 'divider2'
537
+ key: 'divider3'
538
538
  }, {
539
539
  key: 'duplicate',
540
540
  label: orientation === 'row' ? '复制当前行' : '复制当前列',