2 * @param {Editor} editor
3 * @param {String} scrollId
5 function scrollToText(editor, scrollId) {
6 const element = editor.dom.get(encodeURIComponent(scrollId).replace(/!/g, '%21'));
11 // scroll the element into the view and put the cursor at the end.
12 element.scrollIntoView();
13 editor.selection.select(element, true);
14 editor.selection.collapse(false);
19 * Scroll to a section dictated by the current URL query string, if present.
20 * Used when directly editing a specific section of the page.
21 * @param {Editor} editor
23 export function scrollToQueryString(editor) {
24 const queryParams = (new URL(window.location)).searchParams;
25 const scrollId = queryParams.get('content-id');
27 scrollToText(editor, scrollId);