@ctzhian/tiptap 1.7.1 → 1.7.3

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.
@@ -95,7 +95,7 @@ var LinkViewWrapper = function LinkViewWrapper(_ref) {
95
95
  };
96
96
  var handleDeleteLink = function handleDeleteLink() {
97
97
  editor.commands.deleteNode(node.type);
98
- editor.commands.insertContent(attrs.title || attrs.href);
98
+ editor.chain().insertContent(attrs.title || attrs.href).focus().run();
99
99
  };
100
100
  var handleCopyLink = useCallback( /*#__PURE__*/function () {
101
101
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
@@ -5,6 +5,7 @@ interface TableContextMenuProps {
5
5
  onClose: () => void;
6
6
  onCommandExecute?: () => void;
7
7
  hasMultipleSelection: boolean;
8
+ hasMultipleCellElements: boolean;
8
9
  }
9
10
  declare const TableContextMenu: React.FC<TableContextMenuProps>;
10
11
  export default TableContextMenu;
@@ -5,6 +5,7 @@ var TableContextMenu = function TableContextMenu(_ref) {
5
5
  var editor = _ref.editor,
6
6
  onClose = _ref.onClose,
7
7
  hasMultipleSelection = _ref.hasMultipleSelection,
8
+ hasMultipleCellElements = _ref.hasMultipleCellElements,
8
9
  onCommandExecute = _ref.onCommandExecute;
9
10
  var handleCommand = function handleCommand(command) {
10
11
  command();
@@ -88,7 +89,7 @@ var TableContextMenu = function TableContextMenu(_ref) {
88
89
  return editor.chain().focus().splitCell().run();
89
90
  });
90
91
  },
91
- show: true
92
+ show: !hasMultipleSelection && hasMultipleCellElements
92
93
  }, {
93
94
  label: '切换表头行',
94
95
  icon: /*#__PURE__*/React.createElement(LayoutTop2LineIcon, {
@@ -180,7 +180,7 @@ export var createTableContextMenuPlugin = function createTableContextMenuPlugin(
180
180
  commandExecuted = false;
181
181
  preventSelectionLoss = false;
182
182
  };
183
- var showContextMenu = function showContextMenu(anchorEl, hasMultipleSelection) {
183
+ var showContextMenu = function showContextMenu(anchorEl, hasMultipleSelection, hasMultipleCellElements) {
184
184
  // console.log('🍊 showContextMenu', anchorEl, 'hasMultipleSelection', hasMultipleSelection)
185
185
  var _createMenuContainer = createMenuContainer(),
186
186
  root = _createMenuContainer.root;
@@ -200,6 +200,7 @@ export var createTableContextMenuPlugin = function createTableContextMenuPlugin(
200
200
  }, /*#__PURE__*/React.createElement(TableContextMenu, {
201
201
  editor: editor,
202
202
  hasMultipleSelection: hasMultipleSelection,
203
+ hasMultipleCellElements: hasMultipleCellElements,
203
204
  onClose: handleClose,
204
205
  onCommandExecute: handleCommandExecute
205
206
  })));
@@ -234,6 +235,7 @@ export var createTableContextMenuPlugin = function createTableContextMenuPlugin(
234
235
  event.preventDefault();
235
236
  event.stopPropagation();
236
237
  var cellElement = getTableCell(target);
238
+ console.log('🍊 cellElement', cellElement === null || cellElement === void 0 ? void 0 : cellElement.getAttribute('colspan'), cellElement === null || cellElement === void 0 ? void 0 : cellElement.getAttribute('rowspan'));
237
239
  if (!cellElement) {
238
240
  preventSelectionLoss = false;
239
241
  return false;
@@ -247,8 +249,9 @@ export var createTableContextMenuPlugin = function createTableContextMenuPlugin(
247
249
  }, 50);
248
250
  }
249
251
  var hasMultipleSelection = savedSelection ? true : hasMultipleCellSelection(editor);
252
+ var hasMultipleCellElements = (cellElement === null || cellElement === void 0 ? void 0 : cellElement.getAttribute('colspan')) && parseInt(cellElement.getAttribute('colspan') || '1') > 1 || (cellElement === null || cellElement === void 0 ? void 0 : cellElement.getAttribute('rowspan')) && parseInt(cellElement.getAttribute('rowspan') || '1') > 1 || false;
250
253
  // console.log('🍊 contextmenu hasMultipleSelection', hasMultipleSelection)
251
- showContextMenu(cellElement, hasMultipleSelection);
254
+ showContextMenu(cellElement, hasMultipleSelection, hasMultipleCellElements);
252
255
  preventSelectionLoss = false;
253
256
  return true;
254
257
  },
@@ -57,7 +57,7 @@ export var InlineLinkExtension = Node.create({
57
57
  },
58
58
  addOptions: function addOptions() {
59
59
  return {
60
- autolink: true,
60
+ autolink: false,
61
61
  linkOnPaste: false,
62
62
  protocols: [],
63
63
  defaultProtocol: 'http',
@@ -1,5 +1,5 @@
1
1
  import { Extension } from '@tiptap/core';
2
2
  export declare const TableExtension: ({ editable }: {
3
3
  editable: boolean;
4
- }) => (import("@tiptap/core").Node<import("@tiptap/extension-table").TableOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableHeaderOptions, any> | Extension<any, any>)[];
4
+ }) => (Extension<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableHeaderOptions, any>)[];
5
5
  export default TableExtension;
package/dist/index.css CHANGED
@@ -369,6 +369,11 @@
369
369
  line-height: 24px;
370
370
  }
371
371
 
372
+ .tiptap.ProseMirror table th *,
373
+ .tiptap.ProseMirror table td * {
374
+ word-break: break-all;
375
+ }
376
+
372
377
  /* 表格单元格基础样式 */
373
378
  .tiptap.ProseMirror table td,
374
379
  .tiptap.ProseMirror table th {
@@ -450,17 +455,20 @@
450
455
 
451
456
  /* 表格滚动条样式 */
452
457
  .tiptap.ProseMirror .tableWrapper::-webkit-scrollbar {
453
- height: 2px;
458
+ height: 5px;
459
+ cursor: pointer;
454
460
  }
455
461
 
456
462
  .tiptap.ProseMirror .tableWrapper::-webkit-scrollbar-track {
457
463
  background: var(--mui-palette-divider);
458
464
  border-radius: 4px;
465
+ cursor: pointer;
459
466
  }
460
467
 
461
468
  .tiptap.ProseMirror .tableWrapper::-webkit-scrollbar-thumb {
462
469
  background: var(--mui-palette-text-disabled);
463
470
  border-radius: 4px;
471
+ cursor: pointer;
464
472
  }
465
473
 
466
474
  /* youtube */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctzhian/tiptap",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "description": "基于 Tiptap 二次开发的编辑器组件",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",