quill-table-up 3.2.1 → 3.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.
Files changed (37) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +16 -3
  3. package/dist/index.d.ts +45 -37
  4. package/dist/index.js +11 -11
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.umd.js +9 -9
  7. package/dist/index.umd.js.map +1 -1
  8. package/package.json +19 -18
  9. package/src/__tests__/e2e/table-blots.test.ts +5 -2
  10. package/src/__tests__/e2e/table-keyboard-handler.test.ts +32 -24
  11. package/src/__tests__/e2e/table-menu.test.ts +38 -0
  12. package/src/__tests__/e2e/table-resize.test.ts +111 -60
  13. package/src/__tests__/e2e/table-scrollbar.test.ts +2 -2
  14. package/src/__tests__/e2e/table-selection.test.ts +48 -0
  15. package/src/__tests__/unit/table-contenteditable.test.ts +222 -0
  16. package/src/__tests__/unit/utils.ts +1 -2
  17. package/src/formats/container-format.ts +2 -2
  18. package/src/formats/table-body-format.ts +1 -1
  19. package/src/formats/table-caption-format.ts +1 -1
  20. package/src/formats/table-cell-format.ts +2 -2
  21. package/src/formats/table-cell-inner-format.ts +1 -1
  22. package/src/formats/table-row-format.ts +1 -1
  23. package/src/modules/table-align.ts +1 -0
  24. package/src/modules/table-clipboard/paste-cell-into-cell.ts +2 -2
  25. package/src/modules/table-dom-selector.ts +18 -3
  26. package/src/modules/table-menu/table-menu-common.ts +1 -0
  27. package/src/modules/table-menu/table-menu-contextmenu.ts +2 -3
  28. package/src/modules/table-menu/table-menu-select.ts +4 -2
  29. package/src/modules/table-resize/table-resize-box.ts +1 -0
  30. package/src/modules/table-resize/table-resize-line.ts +14 -1
  31. package/src/modules/table-resize/table-resize-scale.ts +34 -53
  32. package/src/modules/table-scrollbar.ts +26 -31
  33. package/src/modules/table-selection.ts +5 -3
  34. package/src/style/table-selection.less +0 -5
  35. package/src/table-up.ts +44 -2
  36. package/src/utils/types.ts +1 -0
  37. package/src/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 zzxming
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 zzxming
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -275,6 +275,18 @@ const tableMenuTools: Record<string, Tool> = {
275
275
  tip: 'Toggle td between th',
276
276
  handle: (tableModule, selectedTds) => {},
277
277
  },
278
+ ConvertTothead: {
279
+ name: 'ConvertTothead',
280
+ icon: ConvertCell,
281
+ tip: 'Convert to thead',
282
+ handle: (tableModule, selectedTds) => {},
283
+ },
284
+ ConvertTotfoot: {
285
+ name: 'ConvertTotfoot',
286
+ icon: ConvertCell,
287
+ tip: 'Convert to tfoot',
288
+ handle: (tableModule, selectedTds) => {},
289
+ },
278
290
  };
279
291
  const defaultTools = [
280
292
  tableMenuTools.InsertTop,
@@ -302,9 +314,10 @@ Equal scale table cell handler
302
314
 
303
315
  #### Options
304
316
 
305
- | Attribute | Description | Type | Default |
306
- | --------- | ------------------------ | -------- | ------- |
307
- | blockSize | resize handle block size | `number` | `12` |
317
+ | Attribute | Description | Type | Default |
318
+ | --------- | ----------------------------- | -------- | ------- |
319
+ | blockSize | resize handle block size | `number` | `12` |
320
+ | offset | resize handle offset to table | `number` | `6` |
308
321
 
309
322
  ### TableAlign
310
323
 
package/dist/index.d.ts CHANGED
@@ -81,7 +81,7 @@ declare class TableCellFormat extends ContainerFormat {
81
81
  static isAllowStyle(str: string): boolean;
82
82
  static create(value: TableCellValue): HTMLTableCellElement;
83
83
  static formats(domNode: HTMLElement): Record<string, any>;
84
- isChildHeadTableCellInner(): boolean | null;
84
+ isChildHeadTableCellInner(): boolean;
85
85
  setFormatValue(name: string, value?: any): void;
86
86
  setStyleBoder(name: string, value?: any): void;
87
87
  getNearByCell(direction: 'left' | 'top'): TableCellFormat[];
@@ -322,16 +322,24 @@ declare const tableUpInternal: {
322
322
  };
323
323
  //#endregion
324
324
  //#region src/modules/table-dom-selector.d.ts
325
- declare class TableDomSelector {
325
+ interface TableModuleLifecycle {
326
+ hide: () => void;
327
+ show: () => void;
328
+ update: () => void;
329
+ destroy: () => void;
330
+ }
331
+ declare class TableDomSelector implements TableModuleLifecycle {
326
332
  tableModule: TableUp;
327
333
  quill: Quill;
328
334
  table?: HTMLTableElement;
335
+ tableSelectMouseDownHandler: (event: MouseEvent) => void;
329
336
  constructor(tableModule: TableUp, quill: Quill);
330
337
  tableSelectHandler(event: MouseEvent): void;
331
338
  setSelectionTable(table: HTMLTableElement | undefined): void;
332
339
  hide(): void;
333
340
  show(): void;
334
341
  update(): void;
342
+ destroy(): void;
335
343
  }
336
344
  //#endregion
337
345
  //#region src/modules/table-align.d.ts
@@ -375,8 +383,8 @@ interface CellUpdate {
375
383
  length: number;
376
384
  insertDelta: Delta;
377
385
  cell: TableCellInnerFormat;
378
- rowspan?: number;
379
- colspan?: number;
386
+ rowspan: number;
387
+ colspan: number;
380
388
  emptyRow?: string[];
381
389
  }
382
390
  interface TableCellValueLike {
@@ -730,9 +738,6 @@ declare class TableResizeScale extends TableDomSelector {
730
738
  cv: (v?: string) => string;
731
739
  is: (n: string) => string;
732
740
  };
733
- startX: number;
734
- startY: number;
735
- offset: number;
736
741
  options: TableResizeScaleOptions;
737
742
  root?: HTMLElement;
738
743
  block?: HTMLElement;
@@ -741,9 +746,9 @@ declare class TableResizeScale extends TableDomSelector {
741
746
  updateWhenTextChange: (eventName: string) => void;
742
747
  resolveOptions(options: Partial<TableResizeScaleOptions>): {
743
748
  blockSize: number;
749
+ offset: number;
744
750
  } & Partial<TableResizeScaleOptions>;
745
751
  buildResizer(): void;
746
- isTableOutofEditor(): boolean;
747
752
  update(): void;
748
753
  show(): void;
749
754
  hide(): void;
@@ -763,6 +768,24 @@ declare function isCellsSpan(isX: boolean, tableBlot: TableMainFormat, cells: Ta
763
768
  };
764
769
  //#endregion
765
770
  //#region src/modules/table-scrollbar.d.ts
771
+ declare const propertyMapY: {
772
+ readonly size: "height";
773
+ readonly offset: "offsetHeight";
774
+ readonly scrollDirection: "scrollTop";
775
+ readonly scrollSize: "scrollHeight";
776
+ readonly axis: "y";
777
+ readonly direction: "top";
778
+ readonly client: "clientY";
779
+ };
780
+ declare const propertyMapX: {
781
+ readonly size: "width";
782
+ readonly offset: "offsetWidth";
783
+ readonly scrollDirection: "scrollLeft";
784
+ readonly scrollSize: "scrollWidth";
785
+ readonly axis: "x";
786
+ readonly direction: "left";
787
+ readonly client: "clientX";
788
+ };
766
789
  declare class Scrollbar {
767
790
  quill: Quill;
768
791
  table: HTMLElement;
@@ -779,32 +802,6 @@ declare class Scrollbar {
779
802
  sizeWidth: string;
780
803
  sizeHeight: string;
781
804
  size: string;
782
- thumbState: {
783
- X: number;
784
- Y: number;
785
- };
786
- ob: ResizeObserver;
787
- container: HTMLElement;
788
- scrollbar: HTMLElement;
789
- thumb: HTMLElement;
790
- scrollHandler: [HTMLElement, (e: Event) => void][];
791
- propertyMap: {
792
- readonly size: 'height';
793
- readonly offset: 'offsetHeight';
794
- readonly scrollDirection: 'scrollTop';
795
- readonly scrollSize: 'scrollHeight';
796
- readonly axis: 'Y';
797
- readonly direction: 'top';
798
- readonly client: 'clientY';
799
- } | {
800
- readonly size: 'width';
801
- readonly offset: 'offsetWidth';
802
- readonly scrollDirection: 'scrollLeft';
803
- readonly scrollSize: 'scrollWidth';
804
- readonly axis: 'X';
805
- readonly direction: 'left';
806
- readonly client: 'clientX';
807
- };
808
805
  bem: {
809
806
  b: () => string;
810
807
  be: (e?: string) => string;
@@ -816,6 +813,13 @@ declare class Scrollbar {
816
813
  is: (n: string) => string;
817
814
  };
818
815
  tableMainBlot: TableMainFormat;
816
+ ob: ResizeObserver;
817
+ container: HTMLElement;
818
+ scrollbar: HTMLElement;
819
+ thumb: HTMLElement;
820
+ scrollHandler: [HTMLElement, (e: Event) => void][];
821
+ propertyMap: typeof propertyMapY | typeof propertyMapX;
822
+ thumbState: Position;
819
823
  get isVertical(): boolean;
820
824
  constructor(quill: Quill, table: HTMLElement, options: {
821
825
  isVertical: boolean;
@@ -905,7 +909,7 @@ declare class TableSelection extends TableDomSelector {
905
909
  setSelectionData(selection: Selection, selectionData: SelectionData): void;
906
910
  selectionDirectionUp(selection: SelectionData): boolean;
907
911
  resolveOptions(options: Partial<TableSelectionOptions>): TableSelectionOptions;
908
- selectionChangeHandler(): void;
912
+ selectionChangeHandler: () => void;
909
913
  helpLinesInitial(): HTMLDivElement;
910
914
  computeSelectedTds(startPoint: Position, endPoint: Position): TableCellInnerFormat[];
911
915
  getScrollPositionDiff(): Position;
@@ -915,8 +919,8 @@ declare class TableSelection extends TableDomSelector {
915
919
  updateWithSelectedTds(): void;
916
920
  update(): void;
917
921
  getTableViewScroll(): {
918
- x: number;
919
922
  y: number;
923
+ x: number;
920
924
  };
921
925
  setSelectionTable(table: HTMLTableElement | undefined): void;
922
926
  showDisplay(): void;
@@ -956,6 +960,7 @@ interface TableSelectionOptions {
956
960
  }
957
961
  interface TableResizeScaleOptions {
958
962
  blockSize: number;
963
+ offset: number;
959
964
  }
960
965
  interface TableResizeBoxOptions {
961
966
  size: number;
@@ -1224,6 +1229,7 @@ declare class TableUp {
1224
1229
  fixTableByLisenter: (this: any) => void;
1225
1230
  selector?: HTMLElement;
1226
1231
  resizeOb: ResizeObserver;
1232
+ editableObserver: MutationObserver;
1227
1233
  modules: Record<string, Constructor>;
1228
1234
  get statics(): any;
1229
1235
  constructor(quill: Quill, options: Partial<TableUpOptions>);
@@ -1257,6 +1263,8 @@ declare class TableUp {
1257
1263
  BorderColor: string;
1258
1264
  } & Partial<TableTextOptions>;
1259
1265
  initModules(): void;
1266
+ listenEditableChange(): void;
1267
+ destroyModules(): void;
1260
1268
  getModule<T>(name: string): T | undefined;
1261
1269
  quillHack(): void;
1262
1270
  buildCustomSelect(customSelect: ((module: TableUp, picker: QuillThemePicker) => HTMLElement | Promise<HTMLElement>) | undefined, picker: QuillThemePicker): Promise<void>;
@@ -1282,5 +1290,5 @@ declare class TableUp {
1282
1290
  convertTableBodyByCells(tableBlot: TableMainFormat, selecteds: TableCellInnerFormat[], tag: TableBodyTag): void;
1283
1291
  }
1284
1292
  //#endregion
1285
- export { BlockEmbedOverride, BlockOverride, ClipboardOptions, Constructor, ContainerFormat, InternalModule, InternalTableMenuModule, InternalTableSelectionModule, Matcher, MenuTooltipInstance, Position, QuillTheme, QuillThemePicker, RelactiveRect, ScrollOverride, Scrollbar, SelectionData, Selector, SkipRowCount, TableAlign, TableBodyFormat, TableBodyTag, TableCaptionFormat, TableCaptionValue, TableCellFormat, TableCellInnerFormat, TableCellValue, TableClipboard, TableColFormat, TableColValue, TableColgroupFormat, TableConstantsData, TableCreatorTextOptions, TableDomSelector, TableFootFormat, TableHeadFormat, TableMainFormat, TableMenuCommon, TableMenuContextmenu, TableMenuOptions, TableMenuOptionsInput, TableMenuSelect, TableMenuTexts, TableResizeBox, TableResizeBoxOptions, TableResizeCommon, TableResizeCommonHelper, TableResizeLine, TableResizeScale, TableResizeScaleOptions, TableRowFormat, TableRowValue, TableSelection, TableSelectionOptions, TableTextOptions, TableUp, TableUp as default, TableUpExtraModule, TableUpModule, TableUpOptions, TableValue, TableVirtualScrollbar, TableWrapperFormat, Tool, ToolOption, ToolOptionBreak, Writable, applyCellUpdates, blotName, createColorPicker, createSelectBox, createTooltip, defaultCustomSelect, findParentBlot, findParentBlots, getCellPositions, getColRect, getCountByPosition, getTableCellStructure, getTableMainRect, groupCellByRow, isCellsSpan, isTableAlignRight, parsePasteDelta, pasteCells, pasteWithLoop, pasteWithStructure, prepareCellUpdate, randomId, removeOverlappingCells, tableMenuTools, tableUpEvent, tableUpInternal, tableUpSize, updateTableConstants };
1293
+ export { BlockEmbedOverride, BlockOverride, ClipboardOptions, Constructor, ContainerFormat, InternalModule, InternalTableMenuModule, InternalTableSelectionModule, Matcher, MenuTooltipInstance, Position, QuillTheme, QuillThemePicker, RelactiveRect, ScrollOverride, Scrollbar, SelectionData, Selector, SkipRowCount, TableAlign, TableBodyFormat, TableBodyTag, TableCaptionFormat, TableCaptionValue, TableCellFormat, TableCellInnerFormat, TableCellValue, TableClipboard, TableColFormat, TableColValue, TableColgroupFormat, TableConstantsData, TableCreatorTextOptions, TableDomSelector, TableFootFormat, TableHeadFormat, TableMainFormat, TableMenuCommon, TableMenuContextmenu, TableMenuOptions, TableMenuOptionsInput, TableMenuSelect, TableMenuTexts, TableModuleLifecycle, TableResizeBox, TableResizeBoxOptions, TableResizeCommon, TableResizeCommonHelper, TableResizeLine, TableResizeScale, TableResizeScaleOptions, TableRowFormat, TableRowValue, TableSelection, TableSelectionOptions, TableTextOptions, TableUp, TableUp as default, TableUpExtraModule, TableUpModule, TableUpOptions, TableValue, TableVirtualScrollbar, TableWrapperFormat, Tool, ToolOption, ToolOptionBreak, Writable, applyCellUpdates, blotName, createColorPicker, createSelectBox, createTooltip, defaultCustomSelect, findParentBlot, findParentBlots, getCellPositions, getColRect, getCountByPosition, getTableCellStructure, getTableMainRect, groupCellByRow, isCellsSpan, isTableAlignRight, parsePasteDelta, pasteCells, pasteWithLoop, pasteWithStructure, prepareCellUpdate, randomId, removeOverlappingCells, tableMenuTools, tableUpEvent, tableUpInternal, tableUpSize, updateTableConstants };
1286
1294
  //# sourceMappingURL=index.d.ts.map