Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: fix column resize handle hiding after column resize

Abdullah Atta8b03f96a3fc7
diff --git a/packages/editor/src/extensions/table/prosemirror-tables/columnresizing.ts b/packages/editor/src/extensions/table/prosemirror-tables/columnresizing.ts
index 71033d0ae..4b37dfca2 100644
--- a/packages/editor/src/extensions/table/prosemirror-tables/columnresizing.ts
+++ b/packages/editor/src/extensions/table/prosemirror-tables/columnresizing.ts
@@ -121,23 +121,24 @@ export class ResizeState {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const state = this;
const action = tr.getMeta(columnResizingPluginKey);
+ const decorations = tr.docChanged
+ ? state.decorations.map(tr.mapping, tr.doc)
+ : state.decorations;
if (action && action.setHandle != null)
- return new ResizeState(
- action.setHandle,
- false,
- state.decorations.map(tr.mapping, tr.doc)
- );
+ return new ResizeState(action.setHandle, false, decorations);
if (action && action.setDragging !== undefined)
return new ResizeState(
state.activeHandle,
action.setDragging,
- state.decorations.map(tr.mapping, tr.doc)
+ decorations
);
if (action && action.setDecorations !== undefined) {
return new ResizeState(
state.activeHandle,
state.dragging,
- action.setDecorations.map(tr.mapping, tr.doc)
+ tr.docChanged
+ ? action.setDecorations.map(tr.mapping, tr.doc)
+ : action.setDecorations
);
}
if (state.activeHandle > -1 && tr.docChanged) {
@@ -145,11 +146,7 @@ export class ResizeState {
if (!pointsAtCell(tr.doc.resolve(handle))) {
handle = -1;
}
- return new ResizeState(
- handle,
- state.dragging,
- state.decorations.map(tr.mapping, tr.doc)
- );
+ return new ResizeState(handle, state.dragging, decorations);
}
return state;
}
@@ -330,7 +327,7 @@ function updateColumnWidth(
? attrs.colwidth.slice()
: zeroes(attrs.colspan);
colwidth[index] = width;
- tr.setNodeMarkup(start + pos, null, { ...attrs, colwidth: colwidth });
+ tr.setNodeAttribute(start + pos, "colwidth", colwidth);
}
if (tr.docChanged) view.dispatch(tr);
}