X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/5ffec2c52d6b6c1cf61e53813fe4bfbece3da1aa..HEAD:/resources/js/markdown/actions.ts diff --git a/resources/js/markdown/actions.ts b/resources/js/markdown/actions.ts index ed4ee5904..36d21ab1d 100644 --- a/resources/js/markdown/actions.ts +++ b/resources/js/markdown/actions.ts @@ -236,7 +236,7 @@ export class Actions { if (lineStart === newStart) { const newLineContent = lineContent.replace(`${newStart} `, ''); const selectFrom = selectionRange.from + (newLineContent.length - lineContent.length); - this.editor.input.spliceText(selectionRange.from, selectionRange.to, newLineContent, {from: selectFrom}); + this.editor.input.spliceText(lineRange.from, lineRange.to, newLineContent, {from: selectFrom}); return; } @@ -353,8 +353,8 @@ export class Actions { * Fetch and insert the template of the given ID. * The page-relative position provided can be used to determine insert location if possible. */ - async insertTemplate(templateId: string, posX: number, posY: number): Promise { - const cursorPos = this.editor.input.coordsToSelection(posX, posY).from; + async insertTemplate(templateId: string, event: MouseEvent): Promise { + const cursorPos = this.editor.input.eventToPosition(event).from; const responseData = (await window.$http.get(`/templates/${templateId}`)).data as {markdown: string, html: string}; const content = responseData.markdown || responseData.html; this.editor.input.spliceText(cursorPos, cursorPos, content, {from: cursorPos}); @@ -364,8 +364,8 @@ export class Actions { * Insert multiple images from the clipboard from an event at the provided * screen coordinates (Typically form a paste event). */ - insertClipboardImages(images: File[], posX: number, posY: number): void { - const cursorPos = this.editor.input.coordsToSelection(posX, posY).from; + insertClipboardImages(images: File[], event: MouseEvent): void { + const cursorPos = this.editor.input.eventToPosition(event).from; for (const image of images) { this.uploadImage(image, cursorPos); }