{"version":3,"file":"PlainTableContentEditor-CKYRddW1.chunk.mjs","sources":["../src/components/Editor/PlainTableContentEditor.vue"],"sourcesContent":["<!--\n  - SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors\n  - SPDX-License-Identifier: AGPL-3.0-or-later\n-->\n\n<template>\n\t<EditorWrapper contentLoaded>\n\t\t<MainContainer>\n\t\t\t<ContentContainer :readOnly=\"readOnly\" />\n\t\t</MainContainer>\n\t</EditorWrapper>\n</template>\n\n<script>\nimport { Editor } from '@tiptap/core'\nimport { UndoRedo } from '@tiptap/extensions'\nimport { markRaw, provide, watch } from 'vue'\nimport ContentContainer from './ContentContainer.vue'\nimport EditorWrapper from './EditorWrapper.vue'\nimport MainContainer from './MainContainer.vue'\nimport { provideEditor } from '../../composables/useEditor.ts'\nimport { editorFlagsKey } from '../../composables/useEditorFlags.ts'\nimport { useEditorMethods } from '../../composables/useEditorMethods.ts'\nimport { editorWidthKey } from '../../composables/useEditorWidth.ts'\nimport { FocusTrap, PlainTable } from '../../extensions/index.js'\nimport { createMarkdownSerializer } from '../../extensions/Markdown.js'\nimport { logger } from '../../helpers/logger.ts'\n\nexport default {\n\tname: 'PlainTableContentEditor',\n\tcomponents: { ContentContainer, MainContainer, EditorWrapper },\n\n\tprops: {\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\n\t\treadOnly: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\t},\n\n\temits: ['create:content', 'ready', 'update:content'],\n\n\tsetup(props) {\n\t\tconst extensions = [PlainTable, UndoRedo, FocusTrap]\n\t\tconst editor = markRaw(new Editor({ extensions }))\n\n\t\tconst { setEditable, setContent } = useEditorMethods(editor)\n\t\twatch(\n\t\t\t() => props.content,\n\t\t\t(content) => {\n\t\t\t\tsetContent(content)\n\t\t\t},\n\t\t)\n\n\t\tsetEditable(!props.readOnly)\n\t\twatch(\n\t\t\t() => props.readOnly,\n\t\t\t(readOnly) => {\n\t\t\t\tsetEditable(!readOnly)\n\t\t\t},\n\t\t)\n\n\t\tprovideEditor(editor)\n\t\tprovide(editorFlagsKey, {\n\t\t\tisPublic: false,\n\t\t\tisRichEditor: true,\n\t\t\tisRichWorkspace: false,\n\t\t\thasTableOfContents: false,\n\t\t})\n\t\tprovide(editorWidthKey, null)\n\t\treturn { editor, setContent }\n\t},\n\n\tcreated() {\n\t\t// Set content after the setup function\n\t\t// as it may render other vue components such as preview toggle\n\t\t// which breaks the context of the setup function.\n\t\tthis.setContent(this.content, { addToHistory: false })\n\t\tthis.editor.on('create', () => {\n\t\t\tthis.$emit('ready')\n\n\t\t\t// Emit initial content\n\t\t\ttry {\n\t\t\t\tconst markdown = createMarkdownSerializer(this.editor.schema).serialize(this.editor.state.doc)\n\t\t\t\tthis.$emit('create:content', {\n\t\t\t\t\tjson: this.editor.state.doc,\n\t\t\t\t\tmarkdown,\n\t\t\t\t})\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error('Error serializing table:', error)\n\t\t\t}\n\t\t})\n\t\tthis.editor.on('update', ({ editor }) => {\n\t\t\ttry {\n\t\t\t\tconst markdown = createMarkdownSerializer(editor.schema).serialize(editor.state.doc)\n\t\t\t\tthis.$emit('update:content', {\n\t\t\t\t\tjson: editor.state.doc,\n\t\t\t\t\tmarkdown,\n\t\t\t\t})\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error('Error serializing table:', error)\n\t\t\t}\n\t\t})\n\t},\n\n\tbeforeUnmount() {\n\t\tthis.editor.destroy()\n\t},\n}\n</script>\n\n<style lang=\"scss\">\n@use './../../css/prosemirror';\n@use './../../css/print';\n</style>\n"],"names":["_sfc_main","ContentContainer","MainContainer","EditorWrapper","props","extensions","PlainTable","UndoRedo","FocusTrap","editor","markRaw","Editor","setEditable","setContent","useEditorMethods","watch","content","readOnly","provideEditor","provide","editorFlagsKey","editorWidthKey","markdown","createMarkdownSerializer","error","logger","_createBlock","_component_EditorWrapper","_createVNode","_component_MainContainer","_component_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