Skip to content

Commit 3a4ce62

Browse files
fix(table-better): small fixes on table-better
1 parent 5560a78 commit 3a4ce62

File tree

5 files changed

+9
-105
lines changed

5 files changed

+9
-105
lines changed

packages/pluggableWidgets/rich-text-web/src/utils/formats/quill-table-better/modules/clipboard.ts

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
1-
// @ts-nocheck
21
import Quill from "quill";
2+
import QuillClipboard from "quill/modules/clipboard";
33
import Delta from "quill-delta";
44
import logger from "quill/core/logger.js";
5-
import Module from "quill/core/module";
6-
import QuillClipboard from "quill/modules/clipboard";
5+
import type { Range } from "quill";
6+
import type { Props } from "../types";
77
import { TableCellBlock, TableTemporary } from "../formats/table";
8-
import type { Props, Range } from "../types";
98

10-
const Clipboard = QuillClipboard as typeof Module;
9+
const Clipboard = QuillClipboard;
1110
const debug = logger("quill:clipboard");
1211

1312
class TableClipboard extends Clipboard {
14-
convert: (
15-
{
16-
html,
17-
text
18-
}: {
19-
html?: string;
20-
text?: string;
21-
},
22-
formats?: Record<string, unknown>
23-
) => Delta;
24-
2513
onPaste(range: Range, { text, html }: { text?: string; html?: string }) {
2614
const formats = this.quill.getFormat(range.index) as Props;
2715
const pastedDelta = this.getTableDelta({ text, html }, formats);

packages/pluggableWidgets/rich-text-web/src/utils/formats/quill-table-better/modules/toolbar.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ const Toolbar = QuillToolbar as typeof Module;
1818
type Handler = (this: TableToolbar, value: any) => void;
1919

2020
class TableToolbar extends Toolbar {
21-
handlers: Record<string, Handler>;
22-
controls: [string, HTMLElement][];
23-
update: (range: Range | null) => void;
24-
container?: HTMLElement | null;
21+
handlers: Record<string, Handler> = {};
2522

2623
attach(input: HTMLElement) {
2724
let format = Array.from(input.classList).find(className => {

packages/pluggableWidgets/rich-text-web/src/utils/formats/quill-table-better/quill-table-better.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ class Table extends Module {
206206
if (!toolbarTable) return;
207207
Quill.register({ "formats/table-better": ToolbarTable }, true);
208208
const toolbar = this.quill.getModule("toolbar") as TableToolbar;
209-
const button = toolbar.container.querySelector("button.ql-table-better");
209+
const container = document.querySelector(toolbar.options.container);
210+
const button = container.querySelector("button.ql-table-better");
210211
if (!button || !this.tableSelect.root) return;
211212
button.appendChild(this.tableSelect.root);
212213
button.addEventListener("click", (e: MouseEvent) => {

packages/pluggableWidgets/rich-text-web/src/utils/formats/quill-table-better/ui/cell-selection.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,8 @@ class CellSelection {
349349

350350
initWhiteList() {
351351
const toolbar = this.quill.getModule("toolbar");
352-
// @ts-expect-error
353-
Array.from(toolbar.container.querySelectorAll("button, select")).forEach(input => {
354-
// @ts-ignore
352+
const container = document.querySelector(toolbar.options.container);
353+
container.querySelectorAll("button, select").forEach(input => {
355354
this.attach(input);
356355
});
357356
}

packages/pluggableWidgets/rich-text-web/src/utils/formats/table.ts

-81
This file was deleted.

0 commit comments

Comments
 (0)