diff options
author | bobzel <zzzman@gmail.com> | 2024-03-27 13:39:36 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-03-27 13:39:36 -0400 |
commit | 3bf4c1e7e9e34b2f4730e3df504ef06c36d05a9e (patch) | |
tree | 2fec903a962e95b7130de9005a6315904bf6a1b0 /src | |
parent | 397e152d6450b4904645ebb271691fb01b267c4e (diff) |
fixed backspacing to delete list items.
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/nodes/formattedText/FormattedTextBox.tsx | 2 | ||||
-rw-r--r-- | src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx index 1a5e1febf..729c4d534 100644 --- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx +++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx @@ -1671,7 +1671,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FormattedTextB this._forceUncollapse = false; clearStyleSheetRules(FormattedTextBox._bulletStyleSheet); const clickPos = this._editorView!.posAtCoords({ left: x, top: y }); - const clickPosVal = clickPos?.pos || 1; // - (this._editorView?.state.doc.nodeAt(clickPos?.pos || 1)?.type === this._editorView?.state.schema.nodes.paragraph ? 1 : 0); + const clickPosVal = clickPos?.pos || 1; let olistPos = clickPosVal; if (clickPos && olistPos && this._props.rootSelected?.()) { const clickNode = this._editorView?.state.doc.resolve(olistPos).node(); diff --git a/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts b/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts index 1058c51da..7b4d8aa03 100644 --- a/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts +++ b/src/client/views/nodes/formattedText/ProsemirrorExampleTransfer.ts @@ -255,7 +255,7 @@ export function buildKeymap<S extends Schema<any>>(schema: S, props: any, mapKey }); // backspace = chainCommands(deleteSelection, joinBackward, selectNodeBackward); - bind('Backspace', (state: EditorState, dispatch: (tx: Transaction) => void) => { + const backspace = (state: EditorState, dispatch: (tx: Transaction) => void, view: EditorView) => { if (props.onKey?.(event, props)) return true; if (!canEdit(state)) return true; @@ -267,6 +267,7 @@ export function buildKeymap<S extends Schema<any>>(schema: S, props: any, mapKey if ( !joinBackward(state, (tx: Transaction) => { dispatch(updateBullets(tx, schema)); + if (!view.state.selection.$from.node().content.size) backspace(view.state, view.dispatch, view); }) ) { if ( @@ -279,7 +280,8 @@ export function buildKeymap<S extends Schema<any>>(schema: S, props: any, mapKey } } return true; - }); + }; + bind('Backspace', backspace); //newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock //command to break line |