X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/15647a040999e8f41265937dc16c1a810b7de631..refs/pull/3247/head:/resources/js/wysiwyg/config.js diff --git a/resources/js/wysiwyg/config.js b/resources/js/wysiwyg/config.js index f1eca3348..1a38c1f59 100644 --- a/resources/js/wysiwyg/config.js +++ b/resources/js/wysiwyg/config.js @@ -1,6 +1,6 @@ import {register as registerShortcuts} from "./shortcuts"; import {listen as listenForCommonEvents} from "./common-events"; -import {scrollToQueryString, fixScrollForMobile} from "./scrolling"; +import {scrollToQueryString} from "./scrolling"; import {listenForDragAndPaste} from "./drop-paste-handling"; import {getPlugin as getCodeeditorPlugin} from "./plugin-codeeditor"; @@ -138,16 +138,16 @@ function gatherPlugins(options) { } /** - * Load custom HTML head content from the settings into the editor. - * TODO: We should be able to get this from current parent page? - * @param {Editor} editor + * Fetch custom HTML head content from the parent page head into the editor. */ -function loadCustomHeadContent(editor) { - window.$http.get(window.baseUrl('/custom-head-content')).then(resp => { - if (!resp.data) return; - let head = editor.getDoc().querySelector('head'); - head.innerHTML += resp.data; - }); +function fetchCustomHeadContent() { + const headContentLines = document.head.innerHTML.split("\n"); + const startLineIndex = headContentLines.findIndex(line => line.trim() === ''); + const endLineIndex = headContentLines.findIndex(line => line.trim() === ''); + if (startLineIndex === -1 || endLineIndex === -1) { + return '' + } + return headContentLines.slice(startLineIndex + 1, endLineIndex).join('\n'); } /** @@ -164,7 +164,6 @@ function getSetupCallback(options) { editor.on('init', () => { editorChange(); scrollToQueryString(editor); - fixScrollForMobile(editor); window.editor = editor; }); @@ -176,15 +175,6 @@ function getSetupCallback(options) { window.$events.emit('editor-html-change', content); } - // TODO - Update to standardise across both editors - // Use events within listenForBookStackEditorEvents instead (Different event signature) - window.$events.listen('editor-html-update', html => { - editor.setContent(html); - editor.selection.select(editor.getBody(), true); - editor.selection.collapse(false); - editorChange(html); - }); - // Custom handler hook window.$events.emitPublic(options.containerElement, 'editor-tinymce::setup', {editor}); @@ -247,13 +237,14 @@ export function build(options) { file_picker_types: 'file image', file_picker_callback, paste_preprocess(plugin, args) { - let content = args.content; + const content = args.content; if (content.indexOf('