Skip to content

Commit

Permalink
Merge pull request #279 from prezly/fix/table-pasting-runtime-error
Browse files Browse the repository at this point in the history
[MT-5032] Fix - Editor crashing on pasting Table from a web-page
  • Loading branch information
e1himself authored Jul 28, 2022
2 parents 8f897e0 + 8156387 commit 5d8ec9b
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 13 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module.exports = {
],
}
],
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import * as React from 'react';
import { useEffect, useState } from 'react';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @jsx jsx */
/* eslint-disable @typescript-eslint/ban-ts-comment */

import { Editor, Node } from 'slate';

Expand Down
1 change: 0 additions & 1 deletion packages/slate-editor/src/modules/events/EventsEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export abstract class EventsEditor {
}

static isEventsEditor = (value: unknown): value is EventsEditor => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return Editor.isEditor(value) && value[EVENTS_PROPERTY] instanceof Events;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export abstract class UploadcareEditor {
}

static isUploadcareEditor = (value: unknown): value is UploadcareEditor => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return Editor.isEditor(value) && typeof value[UPLOADCARE_PROPERTY] !== 'undefined';
};
Expand Down
14 changes: 5 additions & 9 deletions packages/slate-tables/src/normalization/insertMissingCells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ export function insertMissingCells(editor: TablesEditor, path: Path) {
return false;
}

const maxWidth = table.children.reduce((max, row) => {
const rowSize = calculateRowWidth(row);

if (rowSize > max) {
return rowSize;
}

return max;
}, 0);
const maxWidth = Math.max(
...table.children.map((node) =>
editor.isTableRowNode(node) ? calculateRowWidth(node) : 0,
),
);

for (const [row, rowPath] of Node.children(editor, path)) {
if (editor.isTableRowNode(row)) {
Expand Down

0 comments on commit 5d8ec9b

Please sign in to comment.