mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-13 00:41:59 +03:00
Page Drafts: Added new "Delete Draft" action to draft menu
Provides a way for users to actually delte their user drafts where required. For #3927 Added test to cover new endpoint. Makes update to MD editor #setText so that new selection is within new range, otherwise it errors and fails operation.
This commit is contained in:
@ -433,7 +433,9 @@ export class Actions {
|
||||
*/
|
||||
#setText(text, selectionRange = null) {
|
||||
selectionRange = selectionRange || this.#getSelectionRange();
|
||||
this.#dispatchChange(0, this.editor.cm.state.doc.length, text, selectionRange.from);
|
||||
const newDoc = this.editor.cm.state.toText(text);
|
||||
const newSelectFrom = Math.min(selectionRange.from, newDoc.length);
|
||||
this.#dispatchChange(0, this.editor.cm.state.doc.length, text, newSelectFrom);
|
||||
this.focus();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user