diff --git a/css/text-editor.css b/css/text-editor.css new file mode 100644 index 00000000000..d1b6d1a87fc --- /dev/null +++ b/css/text-editor.css @@ -0,0 +1 @@ +/* extracted by css-entry-points-plugin */ diff --git a/js/text-editors.mjs b/js/text-editor.mjs similarity index 100% rename from js/text-editors.mjs rename to js/text-editor.mjs diff --git a/js/text-editors.mjs.license b/js/text-editor.mjs.license similarity index 100% rename from js/text-editors.mjs.license rename to js/text-editor.mjs.license diff --git a/js/text-editors.mjs.map b/js/text-editor.mjs.map similarity index 99% rename from js/text-editors.mjs.map rename to js/text-editor.mjs.map index 72d4fc47b10..596e2913337 100644 --- a/js/text-editors.mjs.map +++ b/js/text-editor.mjs.map @@ -1 +1 @@ -{"version":3,"mappings":";uxBAaA,MAAMA,EAAa,MAEnBC,EAAI,UAAU,EAAI,OAAO,EACzBA,EAAI,UAAU,EAAI,OAAO,EACzBA,EAAI,UAAU,IAAM,OAAO,IAE3B,OAAO,IAAI,KAAO,CACjB,GAAG,OAAO,IAAI,IACf,gBAEA,MAAMC,CAAgB,CAIrB,YAAYC,EAAIC,EAAM,CAJvBC,EAAA,KAAAC,GAECC,UACAC,UAEC,OAAAC,EAAA,KAAKF,EAAMJ,GACXM,EAAA,KAAKD,EAAQJ,GACbM,EAAA,KAAKC,KAAL,WACO,IACP,CAMD,SAASC,EAAmB,IAAM,GAAI,CACrC,OAAAC,EAAA,KAAKN,GAAI,IAAI,iBAAmBO,GAAY,CAC3CF,EAAiBE,CAAO,CAC3B,CAAG,EACM,IACP,CAED,SAASC,EAAmB,IAAM,GAAI,CACrC,cAAKR,GAAI,IAAI,QAAS,IAAM,CAC3BQ,EAAkB,CACrB,CAAG,EACM,IACP,CAED,SAASC,EAAmB,IAAM,GAAI,CACrC,cAAKT,GAAI,IAAI,iBAAmBO,GAAY,CAC3CE,EAAiBF,CAAO,CAC3B,CAAG,EACM,IACP,CAED,gBAAgBG,EAA0B,IAAM,GAAI,CACnD,OAAKV,UAAI,IAAI,kBAAoBW,GA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,CAAe,EAC/B,SAASI,CAAQ,EACjB,OAAOxB,CAAE,CACZ","names":["apiVersion","Vue","TextEditorEmbed","vm","data","__privateAdd","_S_instances","#vm","#data","__privateSet","__privateMethod","#registerDebug","onCreateCallback","__privateGet","content","onLoadedCallback","onUpdateCallback","onOutlineToggleCallback","visible","onSearchCallback","subscribe","el","element","_b","_a","#getEditorComponent","query","matchAll","value","yjsData","fileId","useSession","filePath","shareToken","readOnly","autofocus","readonlyBar","onCreate","markdown","onLoaded","onUpdate","onOutlineToggle","onFileInsert","onMentionSearch","onMentionInsert","onSearch","MarkdownContentEditor","Editor","__vitePreload","sessionEditor","ACTION_ATTACHMENT_PROMPT","EDITOR_UPLOAD","HOOK_MENTION_SEARCH","HOOK_MENTION_INSERT","ATTACHMENT_RESOLVER","src","preferRaw","h","scopedSlots","store"],"ignoreList":[],"sources":["../src/editor.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport Vue from 'vue'\nimport store from './store/index.js'\nimport { subscribe } from '@nextcloud/event-bus'\nimport { EDITOR_UPLOAD, HOOK_MENTION_SEARCH, HOOK_MENTION_INSERT, ATTACHMENT_RESOLVER } from './components/Editor.provider.js'\nimport { ACTION_ATTACHMENT_PROMPT } from './components/Editor/MediaHandler.provider.js'\n// eslint-disable-next-line import/no-unresolved, n/no-missing-import\nimport 'vite/modulepreload-polyfill'\n\nconst apiVersion = '1.2'\n\nVue.prototype.t = window.t\nVue.prototype.n = window.n\nVue.prototype.OCA = window.OCA\n\nwindow.OCA.Text = {\n\t...window.OCA.Text,\n}\n\nclass TextEditorEmbed {\n\n\t#vm\n\t#data\n\tconstructor(vm, data) {\n\t\tthis.#vm = vm\n\t\tthis.#data = data\n\t\tthis.#registerDebug()\n\t\treturn this\n\t}\n\n\t#getEditorComponent() {\n\t\treturn this.#vm.$children[0]\n\t}\n\n\tonCreate(onCreateCallback = () => {}) {\n\t\tthis.#vm.$on('create:content', (content) => {\n\t\t\tonCreateCallback(content)\n\t\t})\n\t\treturn this\n\t}\n\n\tonLoaded(onLoadedCallback = () => {}) {\n\t\tthis.#vm.$on('ready', () => {\n\t\t\tonLoadedCallback()\n\t\t})\n\t\treturn this\n\t}\n\n\tonUpdate(onUpdateCallback = () => {}) {\n\t\tthis.#vm.$on('update:content', (content) => {\n\t\t\tonUpdateCallback(content)\n\t\t})\n\t\treturn this\n\t}\n\n\tonOutlineToggle(onOutlineToggleCallback = () => {}) {\n\t\tthis.#vm.$on('outline-toggled', (visible) => {\n\t\t\tonOutlineToggleCallback(visible)\n\t\t})\n\t\treturn this\n\t}\n\n\tonSearch(onSearchCallback = () => {}) {\n\t subscribe('text:editor:search-results', onSearchCallback)\n\t return this\n\t}\n\n\trender(el) {\n\t\tel.innerHTML = ''\n\t\tconst element = document.createElement('div')\n\t\tel.appendChild(element)\n\t\tthis.#vm.$mount(element)\n\t\treturn this\n\t}\n\n\tdestroy() {\n\t\tthis.#vm.$destroy()\n\t\tthis.#vm.$el.innerHTML = ''\n\t}\n\n\tsetContent(content) {\n\t\t// Update reactive prop for MarkdownContentEditor\n\t\tthis.#vm.$set(this.#data, 'content', content)\n\t\t// Call setContent for file based Editor\n\t\tthis.#getEditorComponent()?.setContent?.(content)\n\t\treturn this\n\t}\n\n\tsetSearchQuery(query, matchAll) {\n\t\tconst editor = this.#getEditorComponent()?.$editor\n\t\teditor.commands.setSearchQuery(query, matchAll)\n\t}\n\n\tsearchNext() {\n\t\tconst editor = this.#getEditorComponent()?.$editor\n\t\teditor.commands.nextMatch()\n\t}\n\n\tsearchPrevious() {\n\t\tconst editor = this.#getEditorComponent()?.$editor\n\t\teditor.commands.previousMatch()\n\t}\n\n\tasync save() {\n\t\treturn this.#getEditorComponent().save?.()\n\t}\n\n\tsetShowOutline(value) {\n\t\tthis.#vm.$set(this.#data, 'showOutlineOutside', value)\n\t\treturn this\n\t}\n\n\tsetReadOnly(value) {\n\t\tthis.#vm.$set(this.#data, 'readOnly', value)\n\t\treturn this\n\t}\n\n\tupdateReadonlyBarProps(value) {\n\t\tthis.#vm.$set(this.#data, 'readonlyBarProps', value)\n\t\treturn this\n\t}\n\n\tinsertAtCursor(content) {\n\t\tthis.#getEditorComponent().$editor.chain().insertContent(content).focus().run()\n\t}\n\n\tfocus() {\n\t\tthis.#getEditorComponent().$editor.commands.focus()\n\t}\n\n\tdebugYjs() {\n\t\tconst yjsData = this.#getEditorComponent().debugYjsData()\n\n\t\tconst intro = 'Editor Yjs debug data. Copy the object below that starts with \"clientId\".'\n\t\tconst introChrome = '- In Chrome, select \"Copy\" at the end of the line.'\n\t\tconst introFirefox = '- In Firefox, right-click on the object and select \"Copy object\".'\n\t\tconst styleBold = 'font-weight: bold;'\n\t\tconst styleItalic = 'font-weight: normal; font-style: italic;'\n\t\tconsole.warn(JSON.stringify(yjsData, null, ' '))\n\t\tconsole.warn('%c%s\\n%c%s\\n%s', styleBold, intro, styleItalic, introChrome, introFirefox)\n\t}\n\n\t#registerDebug() {\n\t\tif (window?._oc_debug) {\n\t\t\tthis.vm = this.#vm\n\t\t\twindow.OCA.Text._debug = [\n\t\t\t\t...(window.OCA.Text._debug ?? []),\n\t\t\t\tthis,\n\t\t\t]\n\t\t}\n\t}\n\n}\n\nwindow.OCA.Text.apiVersion = apiVersion\nwindow.OCA.Text.createEditor = async function({\n\t// Element to render the editor to\n\tel,\n\n\t// Session editor with file mode is enabled by setting the fileId and useSession.\n\t// Otherwise, content needs to be provided.\n\tfileId = undefined,\n\tuseSession = true,\n\tfilePath = undefined,\n\tshareToken = null,\n\n\tcontent = '',\n\n\treadOnly = false,\n\tautofocus = true,\n\treadonlyBar = {\n\t\tcomponent: null,\n\t\tprops: null,\n\t},\n\n\tonCreate = ({ markdown }) => {},\n\tonLoaded = () => {},\n\tonUpdate = ({ markdown }) => {},\n\tonOutlineToggle = (visible) => {},\n\tonFileInsert = undefined,\n\tonMentionSearch = undefined,\n\tonMentionInsert = undefined,\n\tonSearch = undefined,\n}) {\n\tconst { default: MarkdownContentEditor } = await import(/* webpackChunkName: \"editor\" */'./components/Editor/MarkdownContentEditor.vue')\n\tconst { default: Editor } = await import(/* webpackChunkName: \"editor\" */'./components/Editor.vue')\n\n\tconst data = Vue.observable({\n\t\tshowOutlineOutside: false,\n\t\treadonlyBarProps: readonlyBar.props,\n\t\treadOnly,\n\t\tcontent,\n\t})\n\n\tconst sessionEditor = fileId && useSession\n\n\tconst vm = new Vue({\n\t\tprovide() {\n\t\t\treturn {\n\t\t\t\t[ACTION_ATTACHMENT_PROMPT]: onFileInsert,\n\t\t\t\t[EDITOR_UPLOAD]: !!sessionEditor,\n\t\t\t\t[HOOK_MENTION_SEARCH]: sessionEditor ? true : onMentionSearch,\n\t\t\t\t[HOOK_MENTION_INSERT]: sessionEditor ? true : onMentionInsert,\n\t\t\t\t[ATTACHMENT_RESOLVER]: {\n\t\t\t\t\tresolve(src, preferRaw) {\n\t\t\t\t\t\treturn [{\n\t\t\t\t\t\t\ttype: 'image',\n\t\t\t\t\t\t\turl: src,\n\t\t\t\t\t\t}]\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t\tdata() {\n\t\t\treturn data\n\t\t},\n\t\trender: h => {\n\t\t\tconst scopedSlots = readonlyBar?.component\n\t\t\t\t? {\n\t\t\t\t\treadonlyBar: () => {\n\t\t\t\t\t\treturn h(readonlyBar.component, {\n\t\t\t\t\t\t\tprops: data.readonlyBarProps,\n\t\t\t\t\t\t})\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t\t: {}\n\n\t\t\treturn sessionEditor\n\t\t\t\t? h(Editor, {\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tfileId,\n\t\t\t\t\t\trelativePath: filePath,\n\t\t\t\t\t\tshareToken,\n\t\t\t\t\t\tmime: 'text/markdown',\n\t\t\t\t\t\tactive: true,\n\t\t\t\t\t\tautofocus,\n\t\t\t\t\t\tshowOutlineOutside: data.showOutlineOutside,\n\t\t\t\t\t},\n\t\t\t\t\tscopedSlots,\n\t\t\t\t})\n\t\t\t\t: h(MarkdownContentEditor, {\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tfileId,\n\t\t\t\t\t\tcontent: data.content,\n\t\t\t\t\t\trelativePath: filePath,\n\t\t\t\t\t\tshareToken,\n\t\t\t\t\t\treadOnly: data.readOnly,\n\t\t\t\t\t\tshowOutlineOutside: data.showOutlineOutside,\n\t\t\t\t\t},\n\t\t\t\t\tscopedSlots,\n\t\t\t\t})\n\t\t},\n\t\tstore,\n\t})\n\treturn new TextEditorEmbed(vm, data)\n\t\t.onCreate(onCreate)\n\t\t.onLoaded(onLoaded)\n\t\t.onUpdate(onUpdate)\n\t\t.onOutlineToggle(onOutlineToggle)\n\t\t.onSearch(onSearch)\n\t\t.render(el)\n}\n"],"file":"js/text-editors.mjs"} \ No newline at end of file +{"version":3,"mappings":";uxBAaA,MAAMA,EAAa,MAEnBC,EAAI,UAAU,EAAI,OAAO,EACzBA,EAAI,UAAU,EAAI,OAAO,EACzBA,EAAI,UAAU,IAAM,OAAO,IAE3B,OAAO,IAAI,KAAO,CACjB,GAAG,OAAO,IAAI,IACf,gBAEA,MAAMC,CAAgB,CAIrB,YAAYC,EAAIC,EAAM,CAJvBC,EAAA,KAAAC,GAECC,UACAC,UAEC,OAAAC,EAAA,KAAKF,EAAMJ,GACXM,EAAA,KAAKD,EAAQJ,GACbM,EAAA,KAAKC,KAAL,WACO,IACP,CAMD,SAASC,EAAmB,IAAM,GAAI,CACrC,OAAAC,EAAA,KAAKN,GAAI,IAAI,iBAAmBO,GAAY,CAC3CF,EAAiBE,CAAO,CAC3B,CAAG,EACM,IACP,CAED,SAASC,EAAmB,IAAM,GAAI,CACrC,cAAKR,GAAI,IAAI,QAAS,IAAM,CAC3BQ,EAAkB,CACrB,CAAG,EACM,IACP,CAED,SAASC,EAAmB,IAAM,GAAI,CACrC,cAAKT,GAAI,IAAI,iBAAmBO,GAAY,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E,EACD,OAAO,IAAIzD,EAAgBC,EAAIC,CAAI,EACjC,SAASiC,CAAQ,EACjB,SAASE,CAAQ,EACjB,SAASC,CAAQ,EACjB,gBAAgBC,CAAe,EAC/B,SAASI,CAAQ,EACjB,OAAOxB,CAAE,CACZ","names":["apiVersion","Vue","TextEditorEmbed","vm","data","__privateAdd","_S_instances","#vm","#data","__privateSet","__privateMethod","#registerDebug","onCreateCallback","__privateGet","content","onLoadedCallback","onUpdateCallback","onOutlineToggleCallback","visible","onSearchCallback","subscribe","el","element","_b","_a","#getEditorComponent","query","matchAll","value","yjsData","fileId","useSession","filePath","shareToken","readOnly","autofocus","readonlyBar","onCreate","markdown","onLoaded","onUpdate","onOutlineToggle","onFileInsert","onMentionSearch","onMentionInsert","onSearch","MarkdownContentEditor","Editor","__vitePreload","sessionEditor","ACTION_ATTACHMENT_PROMPT","EDITOR_UPLOAD","HOOK_MENTION_SEARCH","HOOK_MENTION_INSERT","ATTACHMENT_RESOLVER","src","preferRaw","h","scopedSlots","store"],"ignoreList":[],"sources":["../src/editor.js"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport Vue from 'vue'\nimport store from './store/index.js'\nimport { subscribe } from '@nextcloud/event-bus'\nimport { EDITOR_UPLOAD, HOOK_MENTION_SEARCH, HOOK_MENTION_INSERT, ATTACHMENT_RESOLVER } from './components/Editor.provider.js'\nimport { ACTION_ATTACHMENT_PROMPT } from './components/Editor/MediaHandler.provider.js'\n// eslint-disable-next-line import/no-unresolved, n/no-missing-import\nimport 'vite/modulepreload-polyfill'\n\nconst apiVersion = '1.2'\n\nVue.prototype.t = window.t\nVue.prototype.n = window.n\nVue.prototype.OCA = window.OCA\n\nwindow.OCA.Text = {\n\t...window.OCA.Text,\n}\n\nclass TextEditorEmbed {\n\n\t#vm\n\t#data\n\tconstructor(vm, data) {\n\t\tthis.#vm = vm\n\t\tthis.#data = data\n\t\tthis.#registerDebug()\n\t\treturn this\n\t}\n\n\t#getEditorComponent() {\n\t\treturn this.#vm.$children[0]\n\t}\n\n\tonCreate(onCreateCallback = () => {}) {\n\t\tthis.#vm.$on('create:content', (content) => {\n\t\t\tonCreateCallback(content)\n\t\t})\n\t\treturn this\n\t}\n\n\tonLoaded(onLoadedCallback = () => {}) {\n\t\tthis.#vm.$on('ready', () => {\n\t\t\tonLoadedCallback()\n\t\t})\n\t\treturn this\n\t}\n\n\tonUpdate(onUpdateCallback = () => {}) {\n\t\tthis.#vm.$on('update:content', (content) => {\n\t\t\tonUpdateCallback(content)\n\t\t})\n\t\treturn this\n\t}\n\n\tonOutlineToggle(onOutlineToggleCallback = () => {}) {\n\t\tthis.#vm.$on('outline-toggled', (visible) => {\n\t\t\tonOutlineToggleCallback(visible)\n\t\t})\n\t\treturn this\n\t}\n\n\tonSearch(onSearchCallback = () => {}) {\n\t subscribe('text:editor:search-results', onSearchCallback)\n\t return this\n\t}\n\n\trender(el) {\n\t\tel.innerHTML = ''\n\t\tconst element = document.createElement('div')\n\t\tel.appendChild(element)\n\t\tthis.#vm.$mount(element)\n\t\treturn this\n\t}\n\n\tdestroy() {\n\t\tthis.#vm.$destroy()\n\t\tthis.#vm.$el.innerHTML = ''\n\t}\n\n\tsetContent(content) {\n\t\t// Update reactive prop for MarkdownContentEditor\n\t\tthis.#vm.$set(this.#data, 'content', content)\n\t\t// Call setContent for file based Editor\n\t\tthis.#getEditorComponent()?.setContent?.(content)\n\t\treturn this\n\t}\n\n\tsetSearchQuery(query, matchAll) {\n\t\tconst editor = this.#getEditorComponent()?.$editor\n\t\teditor.commands.setSearchQuery(query, matchAll)\n\t}\n\n\tsearchNext() {\n\t\tconst editor = this.#getEditorComponent()?.$editor\n\t\teditor.commands.nextMatch()\n\t}\n\n\tsearchPrevious() {\n\t\tconst editor = this.#getEditorComponent()?.$editor\n\t\teditor.commands.previousMatch()\n\t}\n\n\tasync save() {\n\t\treturn this.#getEditorComponent().save?.()\n\t}\n\n\tsetShowOutline(value) {\n\t\tthis.#vm.$set(this.#data, 'showOutlineOutside', value)\n\t\treturn this\n\t}\n\n\tsetReadOnly(value) {\n\t\tthis.#vm.$set(this.#data, 'readOnly', value)\n\t\treturn this\n\t}\n\n\tupdateReadonlyBarProps(value) {\n\t\tthis.#vm.$set(this.#data, 'readonlyBarProps', value)\n\t\treturn this\n\t}\n\n\tinsertAtCursor(content) {\n\t\tthis.#getEditorComponent().$editor.chain().insertContent(content).focus().run()\n\t}\n\n\tfocus() {\n\t\tthis.#getEditorComponent().$editor.commands.focus()\n\t}\n\n\tdebugYjs() {\n\t\tconst yjsData = this.#getEditorComponent().debugYjsData()\n\n\t\tconst intro = 'Editor Yjs debug data. Copy the object below that starts with \"clientId\".'\n\t\tconst introChrome = '- In Chrome, select \"Copy\" at the end of the line.'\n\t\tconst introFirefox = '- In Firefox, right-click on the object and select \"Copy object\".'\n\t\tconst styleBold = 'font-weight: bold;'\n\t\tconst styleItalic = 'font-weight: normal; font-style: italic;'\n\t\tconsole.warn(JSON.stringify(yjsData, null, ' '))\n\t\tconsole.warn('%c%s\\n%c%s\\n%s', styleBold, intro, styleItalic, introChrome, introFirefox)\n\t}\n\n\t#registerDebug() {\n\t\tif (window?._oc_debug) {\n\t\t\tthis.vm = this.#vm\n\t\t\twindow.OCA.Text._debug = [\n\t\t\t\t...(window.OCA.Text._debug ?? []),\n\t\t\t\tthis,\n\t\t\t]\n\t\t}\n\t}\n\n}\n\nwindow.OCA.Text.apiVersion = apiVersion\nwindow.OCA.Text.createEditor = async function({\n\t// Element to render the editor to\n\tel,\n\n\t// Session editor with file mode is enabled by setting the fileId and useSession.\n\t// Otherwise, content needs to be provided.\n\tfileId = undefined,\n\tuseSession = true,\n\tfilePath = undefined,\n\tshareToken = null,\n\n\tcontent = '',\n\n\treadOnly = false,\n\tautofocus = true,\n\treadonlyBar = {\n\t\tcomponent: null,\n\t\tprops: null,\n\t},\n\n\tonCreate = ({ markdown }) => {},\n\tonLoaded = () => {},\n\tonUpdate = ({ markdown }) => {},\n\tonOutlineToggle = (visible) => {},\n\tonFileInsert = undefined,\n\tonMentionSearch = undefined,\n\tonMentionInsert = undefined,\n\tonSearch = undefined,\n}) {\n\tconst { default: MarkdownContentEditor } = await import(/* webpackChunkName: \"editor\" */'./components/Editor/MarkdownContentEditor.vue')\n\tconst { default: Editor } = await import(/* webpackChunkName: \"editor\" */'./components/Editor.vue')\n\n\tconst data = Vue.observable({\n\t\tshowOutlineOutside: false,\n\t\treadonlyBarProps: readonlyBar.props,\n\t\treadOnly,\n\t\tcontent,\n\t})\n\n\tconst sessionEditor = fileId && useSession\n\n\tconst vm = new Vue({\n\t\tprovide() {\n\t\t\treturn {\n\t\t\t\t[ACTION_ATTACHMENT_PROMPT]: onFileInsert,\n\t\t\t\t[EDITOR_UPLOAD]: !!sessionEditor,\n\t\t\t\t[HOOK_MENTION_SEARCH]: sessionEditor ? true : onMentionSearch,\n\t\t\t\t[HOOK_MENTION_INSERT]: sessionEditor ? true : onMentionInsert,\n\t\t\t\t[ATTACHMENT_RESOLVER]: {\n\t\t\t\t\tresolve(src, preferRaw) {\n\t\t\t\t\t\treturn [{\n\t\t\t\t\t\t\ttype: 'image',\n\t\t\t\t\t\t\turl: src,\n\t\t\t\t\t\t}]\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t\tdata() {\n\t\t\treturn data\n\t\t},\n\t\trender: h => {\n\t\t\tconst scopedSlots = readonlyBar?.component\n\t\t\t\t? {\n\t\t\t\t\treadonlyBar: () => {\n\t\t\t\t\t\treturn h(readonlyBar.component, {\n\t\t\t\t\t\t\tprops: data.readonlyBarProps,\n\t\t\t\t\t\t})\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t\t: {}\n\n\t\t\treturn sessionEditor\n\t\t\t\t? h(Editor, {\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tfileId,\n\t\t\t\t\t\trelativePath: filePath,\n\t\t\t\t\t\tshareToken,\n\t\t\t\t\t\tmime: 'text/markdown',\n\t\t\t\t\t\tactive: true,\n\t\t\t\t\t\tautofocus,\n\t\t\t\t\t\tshowOutlineOutside: data.showOutlineOutside,\n\t\t\t\t\t},\n\t\t\t\t\tscopedSlots,\n\t\t\t\t})\n\t\t\t\t: h(MarkdownContentEditor, {\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tfileId,\n\t\t\t\t\t\tcontent: data.content,\n\t\t\t\t\t\trelativePath: filePath,\n\t\t\t\t\t\tshareToken,\n\t\t\t\t\t\treadOnly: data.readOnly,\n\t\t\t\t\t\tshowOutlineOutside: data.showOutlineOutside,\n\t\t\t\t\t},\n\t\t\t\t\tscopedSlots,\n\t\t\t\t})\n\t\t},\n\t\tstore,\n\t})\n\treturn new TextEditorEmbed(vm, data)\n\t\t.onCreate(onCreate)\n\t\t.onLoaded(onLoaded)\n\t\t.onUpdate(onUpdate)\n\t\t.onOutlineToggle(onOutlineToggle)\n\t\t.onSearch(onSearch)\n\t\t.render(el)\n}\n"],"file":"js/text-editor.mjs"} \ No newline at end of file