diff --git a/cypress/e2e/MenuBar.spec.js b/cypress/e2e/MenuBar.spec.js index 76c885a9be4..14876db599c 100644 --- a/cypress/e2e/MenuBar.spec.js +++ b/cypress/e2e/MenuBar.spec.js @@ -63,14 +63,14 @@ describe('Test the rich text editor menu bar', function () { it('applys default', function () { cy.openTestFile() - cy.get('@maxWidth').should('equal', '80ch') + cy.get('@maxWidth').should('equal', 'min(80ch, (100% - 2 * 40px))') }) it('toggles value', function () { cy.openTestFile() cy.getActionEntry('remain').click() cy.contains('Full width editor').click() - cy.get('@maxWidth').should('equal', '100%') + cy.get('@maxWidth').should('equal', 'calc(100% - 2 * 40px)') }) it('preserves on reopen', function () { @@ -79,7 +79,7 @@ describe('Test the rich text editor menu bar', function () { cy.contains('Full width editor').click() cy.closeFile() cy.openTestFile() - cy.get('@maxWidth').should('equal', '100%') + cy.get('@maxWidth').should('equal', 'calc(100% - 2 * 40px)') }) it('preserves on reload', function () { @@ -88,7 +88,7 @@ describe('Test the rich text editor menu bar', function () { cy.contains('Full width editor').click() cy.visit('/apps/files') cy.openTestFile() - cy.get('@maxWidth').should('equal', '100%') + cy.get('@maxWidth').should('equal', 'calc(100% - 2 * 40px)') }) it('does not interfere if width is already set', function () { diff --git a/cypress/e2e/sections.spec.js b/cypress/e2e/sections.spec.js index e1269c2c395..46c6fdfceb4 100644 --- a/cypress/e2e/sections.spec.js +++ b/cypress/e2e/sections.spec.js @@ -8,7 +8,7 @@ import { randUser } from '../utils/index.js' const user = randUser() const fileName = 'empty.md' -const clickOutline = () => { +const clickMenubarTableOfContents = () => { cy.getActionEntry('headings').click() cy.get('.v-popper__wrapper .open').getActionEntry('outline').click() @@ -107,7 +107,7 @@ describe('Content Sections', () => { }) describe('Table of Contents', () => { - it('sidebar toc', () => { + it('toc via sidebar', () => { cy.visitTestFolder() cy.openFile(fileName, { force: true }) cy.getContent().type( @@ -115,9 +115,9 @@ describe('Content Sections', () => { ) cy.closeFile() .then(() => cy.openFile(fileName, { force: true })) - .then(clickOutline) + .then(clickMenubarTableOfContents) - cy.getOutline().find('header').should('exist') + cy.getTOC().find('.editor__toc-header').should('exist') cy.getTOC().find('ul li').should('have.length', 6) cy.getTOC() @@ -134,11 +134,30 @@ describe('Content Sections', () => { }) }) + it('outline', () => { + cy.visitTestFolder() + cy.openFile(fileName, { force: true }) + cy.getContent().type('# T1 \n') + + // No outline with one heading + cy.getOutline().should('not.exist') + + cy.getContent().type('## T2 \n### T3 \n#### T4 \n##### T5 \n###### T6\n') + + // Open table of contents via outline + cy.getOutline().should('exist').click() + + cy.getTOC().find('.editor__toc-header').should('exist') + cy.getTOC().find('ul li').should('have.length', 6) + }) + it('empty toc', () => { cy.visitTestFolder() - cy.openFile(fileName, { force: true }).then(clickOutline) + cy.openFile(fileName, { force: true }) + // No outline without headings + cy.getOutline().should('not.exist').then(clickMenubarTableOfContents) - cy.getOutline().find('ul').should('be.empty') + cy.getTOC().find('ul').should('be.empty') }) }) }) diff --git a/cypress/e2e/share.spec.js b/cypress/e2e/share.spec.js index e5a1526ed33..ca901fe63aa 100644 --- a/cypress/e2e/share.spec.js +++ b/cypress/e2e/share.spec.js @@ -45,7 +45,7 @@ describe('Open test.md in viewer', function () { .getActionEntry('outline') .click() - cy.getOutline().find('header').should('exist') + cy.getTOC().find('.editor__toc-header').should('exist') }) }) diff --git a/cypress/e2e/shareWithAttachments.spec.js b/cypress/e2e/shareWithAttachments.spec.js index 5d5b13127cf..1bae56c9fae 100644 --- a/cypress/e2e/shareWithAttachments.spec.js +++ b/cypress/e2e/shareWithAttachments.spec.js @@ -92,8 +92,8 @@ describe('Public Share with attachments', () => { it('open attached files in folder description', function () { cy.visit(`/s/${this.token}`) - cy.get('.content-wrapper').should('exist') - cy.get('.content-wrapper .name', { timeout: 10_000 }).click() + cy.get('.editor__content-wrapper').should('exist') + cy.get('.editor__content-wrapper .name', { timeout: 10_000 }).click() cy.get('.viewer').should('exist') cy.get('.language-plaintext').should('contain', 'multiple lines') }) diff --git a/src/components/BaseReader.vue b/src/components/BaseReader.vue index e081af8d933..2c6ee92618e 100644 --- a/src/components/BaseReader.vue +++ b/src/components/BaseReader.vue @@ -4,20 +4,12 @@ --> @@ -26,22 +18,17 @@ import { Editor } from '@tiptap/core' import { EditorContent } from '@tiptap/vue-2' import { inject, watch } from 'vue' import { provideEditor } from '../composables/useEditor.ts' +import { useEditorFlags } from '../composables/useEditorFlags.ts' import { useEditorMethods } from '../composables/useEditorMethods.ts' -import EditorOutline from './Editor/EditorOutline.vue' -import { - useOutlineActions, - useOutlineStateMixin, -} from './Editor/Wrapper.provider.js' +import TocContainer from './Editor/TableOfContents/TocContainer.vue' export default { name: 'BaseReader', components: { EditorContent, - EditorOutline, + TocContainer, }, - mixins: [useOutlineStateMixin, useOutlineActions], - props: { content: { type: String, @@ -55,6 +42,7 @@ export default { const editor = new Editor({ extensions: extensions() }) provideEditor(editor) + const { useTableOfContents } = useEditorFlags() const { setContent, setEditable } = useEditorMethods(editor) watch( () => props.content, @@ -68,13 +56,7 @@ export default { // Render the initial content last as it may render Vue components // that break the vue context of this setup function. setContent(props.content, { addToHistory: false }) - return { editor } - }, - - computed: { - showOutline() { - return this.$outlineState.visible - }, + return { editor, useTableOfContents } }, beforeDestroy() { @@ -86,22 +68,7 @@ export default { diff --git a/src/components/Editor.vue b/src/components/Editor.vue index afa472f7db6..acda7c30893 100644 --- a/src/components/Editor.vue +++ b/src/components/Editor.vue @@ -18,9 +18,7 @@ :is-resolving-conflict="isResolvingConflict" :has-connection-issue="requireReconnect" :content-loaded="contentLoaded" - :show-outline-outside="showOutlineOutside" - @read-only-toggled="readOnlyToggled" - @outline-toggled="outlineToggled"> + @read-only-toggled="readOnlyToggled">