1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-31 15:24:31 +03:00

Editors: Added lexical editor for testing

Started basic playground for testing lexical as a new WYSIWYG editor.
Moved out tinymce to be under wysiwyg-tinymce instead so lexical is the
default, but TinyMce code remains.
This commit is contained in:
Dan Brown
2024-05-27 15:39:41 +01:00
parent 6019d2ee14
commit 5a4f595341
32 changed files with 303 additions and 30 deletions

View File

@ -0,0 +1,29 @@
/**
* @param {Editor} editor
* @param {String} scrollId
*/
function scrollToText(editor, scrollId) {
const element = editor.dom.get(encodeURIComponent(scrollId).replace(/!/g, '%21'));
if (!element) {
return;
}
// scroll the element into the view and put the cursor at the end.
element.scrollIntoView();
editor.selection.select(element, true);
editor.selection.collapse(false);
editor.focus();
}
/**
* Scroll to a section dictated by the current URL query string, if present.
* Used when directly editing a specific section of the page.
* @param {Editor} editor
*/
export function scrollToQueryString(editor) {
const queryParams = (new URL(window.location)).searchParams;
const scrollId = queryParams.get('content-id');
if (scrollId) {
scrollToText(editor, scrollId);
}
}