@ctzhian/tiptap 1.7.1 → 1.7.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.
@@ -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
  },
@@ -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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctzhian/tiptap",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "基于 Tiptap 二次开发的编辑器组件",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",