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