quill-table-up 3.3.2 → 3.5.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.
package/README.md CHANGED
@@ -65,16 +65,18 @@ const quill = new Quill('#editor', {
65
65
 
66
66
  **Full options usage see [demo](https://github.com/quill-modules/quill-table-up/blob/master/docs/index.js#L38)**
67
67
 
68
- | Attribute | Description | Type | Default |
69
- | ------------- | --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------ |
70
- | full | if set `true`. width max will be 100% | `boolean` | `false` |
71
- | fullSwitch | enable to choose insert a full width table | `boolean` | `true` |
72
- | texts | the text used to create the table | `TableTextOptions` | `defaultTexts` |
73
- | customSelect | display a custom select to custom row and column number add a table. module provides default selector `defaultCustomSelect` | `(tableModule: TableUp, picker: Picker) => Promise<HTMLElement> \| HTMLElement` | - |
74
- | customBtn | display a custom button to custom row and column number add a table. it only when use `defaultCustomSelect` will effect | `boolean` | `false` |
75
- | icon | picker svg icon string. it will set with `innerHTML` | `string` | `origin table icon` |
76
- | autoMergeCell | empty row or column will auto merge to one | `boolean` | `true` |
77
- | modules | the module plugin to help user control about table operate. see [`Export Internal Module`](#export-internal-module) | `[]` | `{ module: Contstructor, options: any }[]` |
68
+ | Attribute | Description | Type | Default |
69
+ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------ |
70
+ | full | if set `true`. width max will be 100% | `boolean` | `false` |
71
+ | fullSwitch | enable to choose insert a full width table | `boolean` | `true` |
72
+ | texts | the text used to create the table | `TableTextOptions \| ((key: string) => string)` | `defaultTexts` |
73
+ | customSelect | display a custom select to custom row and column number add a table. module provides default selector `defaultCustomSelect` | `(tableModule: TableUp, picker: Picker) => Promise<HTMLElement> \| HTMLElement` | - |
74
+ | customBtn | display a custom button to custom row and column number add a table. it only when use `defaultCustomSelect` will effect | `boolean` | `false` |
75
+ | icon | picker svg icon string. it will set with `innerHTML` | `string` | `origin table icon` |
76
+ | autoMergeCell | empty row or column will auto merge to one | `boolean` | `true` |
77
+ | pasteStyleSheet | resolve `<style>` stylesheet rules to inline styles on table cells when pasting. note: when enabled, it processes **all** pasted HTML (not just tables), which may affect non-table paste content and add extra overhead for large pastes | `boolean` | `false` |
78
+ | pasteDefaultTagStyle | when `pasteStyleSheet` is enabled, also apply rules with tag-only selectors (e.g. `td`, `table td`). otherwise only class/id/attribute selectors are applied | `boolean` | `false` |
79
+ | modules | the module plugin to help user control about table operate. see [`Export Internal Module`](#export-internal-module) | `[]` | `{ module: Contstructor, options: any }[]` |
78
80
 
79
81
  > I'm not suggest to use `TableVirtualScrollbar` and `TableResizeLine` at same time, because it have a little conflict when user hover on it. Just like the first editor in [demo](https://quill-modules.github.io/quill-table-up/)
80
82
 
@@ -116,6 +118,48 @@ const defaultTexts = {
116
118
 
117
119
  </details>
118
120
 
121
+ ### `texts` Dynamic Usage
122
+
123
+ You can pass `texts` as a function.\
124
+ When internal UI reads a text, it will call `texts(key)` and use the returned string.
125
+
126
+ ```ts
127
+ let locale: 'en' | 'zh' = 'en';
128
+
129
+ const textMap = {
130
+ en: {
131
+ customBtnText: 'Custom',
132
+ confirmText: 'Confirm',
133
+ cancelText: 'Cancel',
134
+ },
135
+ zh: {
136
+ customBtnText: '自定义',
137
+ confirmText: '确认',
138
+ cancelText: '取消',
139
+ },
140
+ } as const;
141
+
142
+ const quill = new Quill('#editor', {
143
+ modules: {
144
+ [TableUp.moduleName]: {
145
+ customSelect: defaultCustomSelect,
146
+ customBtn: true,
147
+ texts: key => textMap[locale][key as keyof typeof textMap.en] || '',
148
+ modules: [
149
+ { module: TableSelection },
150
+ { module: TableMenuContextmenu },
151
+ ],
152
+ },
153
+ },
154
+ });
155
+
156
+ // switch language
157
+ locale = 'zh';
158
+ await quill.getModule(TableUp.moduleName).refreshUI();
159
+ ```
160
+
161
+ `refreshUI()` will rebuild table-up UI and read latest text values.
162
+
119
163
  ## Export Internal Module
120
164
 
121
165
  ### TableSelection
package/dist/index.d.ts CHANGED
@@ -442,6 +442,7 @@ declare class TableClipboard extends Clipboard {
442
442
  cellCount: number;
443
443
  colCount: number;
444
444
  constructor(quill: Quill, options: Partial<ClipboardOptions>);
445
+ normalizeHTML(doc: Document): void;
445
446
  getStyleBackgroundColor(node: Node, delta: Delta$1): void;
446
447
  matchTable(node: Node, delta: Delta$1): Delta$1;
447
448
  matchTbody(node: Node, delta: Delta$1): Delta$1;
@@ -919,8 +920,8 @@ declare class TableSelection extends TableDomSelector {
919
920
  updateWithSelectedTds(): void;
920
921
  update(): void;
921
922
  getTableViewScroll(): {
922
- x: number;
923
923
  y: number;
924
+ x: number;
924
925
  };
925
926
  setSelectionTable(table: HTMLTableElement | undefined): void;
926
927
  showDisplay(): void;
@@ -983,6 +984,7 @@ interface TableTextOptions extends TableCreatorTextOptions, TableMenuTexts {
983
984
  transparent: string;
984
985
  perWidthInsufficient: string;
985
986
  }
987
+ type TableTextOptionsInput = Partial<TableTextOptions> | ((this: TableUp, key: string) => string);
986
988
  interface TableUpExtraModule extends Constructor<any, [TableUp, Quill, any]> {
987
989
  moduleName: string;
988
990
  }
@@ -998,8 +1000,13 @@ interface TableUpOptions {
998
1000
  texts: TableTextOptions;
999
1001
  icon: string;
1000
1002
  autoMergeCell: boolean;
1003
+ pasteStyleSheet: boolean;
1004
+ pasteDefaultTagStyle: boolean;
1001
1005
  modules: TableUpModule[];
1002
1006
  }
1007
+ interface TableUpOptionsInput extends Partial<Omit<TableUpOptions, 'texts'>> {
1008
+ texts?: TableTextOptionsInput;
1009
+ }
1003
1010
  interface TableColValue {
1004
1011
  tableId: string;
1005
1012
  colId: string;
@@ -1225,6 +1232,7 @@ declare class TableUp {
1225
1232
  static register(): void;
1226
1233
  quill: Quill;
1227
1234
  options: TableUpOptions;
1235
+ textOptionsInput: TableTextOptionsInput | undefined;
1228
1236
  toolBox: HTMLDivElement;
1229
1237
  fixTableByLisenter: (this: any) => void;
1230
1238
  selector?: HTMLElement;
@@ -1232,36 +1240,13 @@ declare class TableUp {
1232
1240
  editableObserver: MutationObserver;
1233
1241
  modules: Record<string, Constructor>;
1234
1242
  get statics(): any;
1235
- constructor(quill: Quill, options: Partial<TableUpOptions>);
1243
+ constructor(quill: Quill, options: TableUpOptionsInput);
1236
1244
  initialContainer(): HTMLDivElement;
1237
1245
  addContainer(classes: string | HTMLElement): HTMLElement;
1238
- resolveOptions(options: Partial<TableUpOptions>): TableUpOptions;
1239
- resolveTexts(options: Partial<TableTextOptions>): {
1240
- fullCheckboxText: string;
1241
- customBtnText: string;
1242
- confirmText: string;
1243
- cancelText: string;
1244
- rowText: string;
1245
- colText: string;
1246
- notPositiveNumberError: string;
1247
- custom: string;
1248
- clear: string;
1249
- transparent: string;
1250
- perWidthInsufficient: string;
1251
- CopyCell: string;
1252
- CutCell: string;
1253
- InsertTop: string;
1254
- InsertRight: string;
1255
- InsertBottom: string;
1256
- InsertLeft: string;
1257
- MergeCell: string;
1258
- SplitCell: string;
1259
- DeleteRow: string;
1260
- DeleteColumn: string;
1261
- DeleteTable: string;
1262
- BackgroundColor: string;
1263
- BorderColor: string;
1264
- } & Partial<TableTextOptions>;
1246
+ getToolbarPicker(): QuillThemePicker | undefined;
1247
+ resolveOptions(options: TableUpOptionsInput): TableUpOptions;
1248
+ resolveTexts(options?: TableTextOptionsInput): TableTextOptions;
1249
+ refreshUI(): Promise<void>;
1265
1250
  initModules(): void;
1266
1251
  listenEditableChange(): void;
1267
1252
  destroyModules(): void;
@@ -1290,5 +1275,5 @@ declare class TableUp {
1290
1275
  convertTableBodyByCells(tableBlot: TableMainFormat, selecteds: TableCellInnerFormat[], tag: TableBodyTag): void;
1291
1276
  }
1292
1277
  //#endregion
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 };
1278
+ 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, TableTextOptionsInput, TableUp, TableUp as default, TableUpExtraModule, TableUpModule, TableUpOptions, TableUpOptionsInput, 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 };
1294
1279
  //# sourceMappingURL=index.d.ts.map