diff --git a/src/components/Editor/PlainTableContentEditor.vue b/src/components/Editor/PlainTableContentEditor.vue new file mode 100644 index 00000000000..9b2bf8b0870 --- /dev/null +++ b/src/components/Editor/PlainTableContentEditor.vue @@ -0,0 +1,134 @@ + + + + diff --git a/src/editor.js b/src/editor.js index 19f33b2f1f6..26b15268d14 100644 --- a/src/editor.js +++ b/src/editor.js @@ -283,3 +283,47 @@ window.OCA.Text.createEditor = async function ({ .onSearch(onSearch) .render(el) } + +window.OCA.Text.createTable = async function ({ + // Element to render the editor to + el, + + content = '', + + readOnly = false, + autofocus = true, + + onCreate = ({ markdown }) => {}, + onLoaded = () => {}, + onUpdate = ({ markdown }) => {}, +}) { + const { default: PlainTableContentEditor } = await import( + './components/Editor/PlainTableContentEditor.vue' + ) + + const data = Vue.observable({ + readOnly, + content, + }) + + const vm = new Vue({ + data() { + return data + }, + render: (h) => { + return h(PlainTableContentEditor, { + props: { + content: data.content, + readOnly: data.readOnly, + showOutlineOutside: false, + }, + }) + }, + }) + + return new TextEditorEmbed(vm, data) + .onCreate(onCreate) + .onLoaded(onLoaded) + .onUpdate(onUpdate) + .render(el) +} diff --git a/src/extensions/PlainTable.js b/src/extensions/PlainTable.js new file mode 100644 index 00000000000..4240dae36bf --- /dev/null +++ b/src/extensions/PlainTable.js @@ -0,0 +1,21 @@ +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { Extension } from '@tiptap/core' + +import EditableTable from './../nodes/EditableTable.js' +import PlainTableDocument from './../nodes/PlainTableDocument.js' +import Keymap from './Keymap.js' +import Markdown from './Markdown.js' +/* eslint-disable import/no-named-as-default */ +import Text from '@tiptap/extension-text' + +export default Extension.create({ + name: 'PlainTable', + + addExtensions() { + return [Markdown, PlainTableDocument, EditableTable, Keymap, Text] + }, +}) diff --git a/src/extensions/index.js b/src/extensions/index.js index a0de7105c3d..82df9c830f3 100644 --- a/src/extensions/index.js +++ b/src/extensions/index.js @@ -9,6 +9,7 @@ import FocusTrap from './FocusTrap.js' import KeepSyntax from './KeepSyntax.js' import Markdown from './Markdown.js' import Mention from './Mention.js' +import PlainTable from './PlainTable.js' import PlainText from './PlainText.js' import RichText from './RichText.js' import UserColor from './UserColor.js' @@ -20,6 +21,7 @@ export { KeepSyntax, Markdown, Mention, + PlainTable, PlainText, RichText, UserColor, diff --git a/src/nodes/PlainTableDocument.js b/src/nodes/PlainTableDocument.js new file mode 100644 index 00000000000..6564d3639f9 --- /dev/null +++ b/src/nodes/PlainTableDocument.js @@ -0,0 +1,11 @@ +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { Node } from '@tiptap/core' + +export default Node.create({ + name: 'doc', + content: 'table', +})