Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 0 additions & 51 deletions cypress/e2e/nodes/Details.spec.js

This file was deleted.

18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"lowlight": "^3.3.0",
"markdown-it": "^14.3.0",
"markdown-it-container": "^4.0.0",
"markdown-it-footnote": "^4.0.0",
"markdown-it-front-matter": "^0.2.4",
"markdown-it-image-figures": "^2.1.1",
"markdown-it-mark": "^4.0.0",
Expand Down Expand Up @@ -113,6 +114,7 @@
"@nextcloud/vite-config": "^2.5.4",
"@playwright/test": "^1.61.1",
"@types/markdown-it": "^14.1.2",
"@types/markdown-it-footnote": "^3.0.4",
"@vitejs/plugin-vue": "^6.0.7",
"@vitest/coverage-v8": "^4.1.10",
"@vue/test-utils": "^2.4.11",
Expand Down
27 changes: 27 additions & 0 deletions playwright/e2e/details.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { expect, mergeTests } from '@playwright/test'
import { test as editorTest } from '../support/fixtures/editor.ts'
import { test as uploadFileTest } from '../support/fixtures/upload-file.ts'

const test = mergeTests(editorTest, uploadFileTest)

test('inserts and removes details', async ({ editor, open }) => {
await open()
await editor.type('content')
await editor.content.press('ControlOrMeta+a')

await editor.clickMenu('Blocks', 'Details')
await expect(editor.details).toBeVisible()

await editor.type('summary')
await expect(editor.details.locator('summary')).toContainText('summary')
await expect(editor.details.locator('.details-content')).toContainText('content')

await editor.clickMenu('Blocks', 'Details')
await expect(editor.details).not.toBeVisible()
await expect(editor.content).toContainText('content')
})
41 changes: 41 additions & 0 deletions playwright/e2e/footnotes.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { expect, mergeTests } from '@playwright/test'
import { test as editorTest } from '../support/fixtures/editor.ts'
import { test as uploadFileTest } from '../support/fixtures/upload-file.ts'

const test = mergeTests(editorTest, uploadFileTest)

test.describe('renders footnotes', () => {
test.use({
fileContent: 'Foo[^bar] baz\n\n[^bar]: footnote\n',
})

test('shows reference and footnote from Markdown', async ({ editor, open }) => {
await open()
await expect(editor.getFootnoteReference('bar')).toBeVisible()
await expect(editor.getFootnoteReference('bar').locator('a')).toHaveText('1')
await expect(editor.getFootnote('bar')).toContainText('footnote')
})
})

test('inserts footnote via keyboard shortcut', async ({ editor, open }) => {
await open()
await editor.type('Some text')
await editor.press('ControlOrMeta+Shift+F')
await expect(editor.getFootnoteReference('1')).toBeVisible()
await expect(editor.getFootnote('1')).toBeVisible()

await editor.type('footnote')
await expect(editor.getFootnote('1')).toContainText('footnote')
})

test('inserts footnote via [^label] input rule', async ({ editor, open }) => {
await open()
await editor.type('hello[^bar]')
await expect(editor.getFootnoteReference('bar')).toBeVisible()
await expect(editor.getFootnote('bar')).toBeVisible()
})
11 changes: 11 additions & 0 deletions playwright/support/sections/EditorSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export class EditorSection {
public readonly sessionList: Locator
public readonly suggestionsContainer: Locator
public readonly suggestions: Locator
public readonly details: Locator
public readonly footnoteReferences: Locator
public readonly footnotesSection: Locator

constructor(public readonly page: Page) {
this.el = this.page.locator('.editor').first()
Expand All @@ -34,6 +37,9 @@ export class EditorSection {
this.sessionList = this.el.locator('.session-list')
this.suggestionsContainer = this.page.locator('.container-suggestions')
this.suggestions = this.page.locator('.tippy-box .suggestion-list')
this.details = this.el.locator('div[data-text-el="details"]')
this.footnoteReferences = this.el.locator('sup[data-type="footnote-reference"]')
this.footnotesSection = this.el.locator('section[data-type="footnotes"]')
}

public async type(keys: string): Promise<void> {
Expand All @@ -56,6 +62,8 @@ export class EditorSection {

public getMenuItem(name: string): Locator {
return this.el.getByRole('menuitem', { name })
.or(this.el.getByRole('menuitemcheckbox', { name }))
.or(this.el.getByRole('menuitemradio', { name }))
}

public async clickMenu(menu: string, item: string): Promise<void> {
Expand All @@ -74,4 +82,7 @@ export class EditorSection {

getHeading = (options: object = {}) => this.content.getByRole('heading', options)
getSuggestion = (name: string) => this.suggestions.getByText(name)

getFootnoteReference = (id: string) => this.footnoteReferences.locator(`:scope[data-reference-id="${id}"]`)
getFootnote = (id: string) => this.footnotesSection.locator(`[data-reference-id="${id}"]`)
}
15 changes: 14 additions & 1 deletion src/components/Editor/FloatingButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
<DragHandle
:editor="editor"
class="floating-buttons"
:class="{ heading: isHeadingNode }"
:class="{
heading: isHeadingNode,
hidden: isHidden,
}"
:onNodeChange="onNodeChange">
<NcButton
variant="tertiary-no-background"
Expand Down Expand Up @@ -40,6 +43,8 @@ import DragVerticalIcon from 'vue-material-design-icons/DragVertical.vue'
import PlusIcon from 'vue-material-design-icons/Plus.vue'
import { useEditor } from '../../composables/useEditor.ts'

const IGNORE_NODES = ['footnote', 'footnotes']

export default {
name: 'FloatingButtons',

Expand All @@ -66,6 +71,10 @@ export default {
isHeadingNode() {
return this.node?.type.name === 'heading'
},

isHidden() {
return IGNORE_NODES.includes(this.node?.type.name)
},
},

methods: {
Expand Down Expand Up @@ -103,6 +112,10 @@ export default {
&.heading {
left: calc(-34px - 14px) !important;
}

&.hidden {
display: none;
}
}

.drag-button {
Expand Down
15 changes: 14 additions & 1 deletion src/components/HelpModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,20 @@
</td>
</tr>
<tr>
<td>{{ t('text', 'Insert emoji') }}</td>
<td>{{ t('text', 'Footnote') }}</td>
<td>
<code>[^{{ t('text', 'label') }}]</code>
</td>
<td v-if="!isMobileCached">
<kbd>{{ ctrlOrModKey }}</kbd>
+
<kbd>{{ t('text', 'Shift') }}</kbd>
+
<kbd>F</kbd>
</td>
</tr>
<tr>
<td>{{ t('text', 'Emoji') }}</td>
<td>
<code>:{{ t('text', 'emoji') }}</code>
</td>
Expand Down
28 changes: 22 additions & 6 deletions src/components/Menu/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import AssistantAction from './AssistantAction.vue'
import EmojiPickerAction from './EmojiPickerAction.vue'
import { isMobileDevice } from '../../helpers/isMobileDevice.js'
import {
Asterisk,
CodeBrackets,
CodeTags,
Danger,
Expand Down Expand Up @@ -414,6 +415,19 @@ export function getMenuEntries(isRichWorkspace: boolean): MenuEntry[] {
key: 'blocks-separator',
isSeparator: true,
},
{
key: 'details',
label: t('text', 'Details'),
isActive: 'details',
icon: UnfoldMoreHorizontal,
action: (command) => {
return command.toggleDetails()
},
},
{
key: 'blocks-separator-2',
isSeparator: true,
},
{
key: 'math-inline',
// TRANSLATORS Inline level math/science formula menu item, eg "something [the formula] something"
Expand Down Expand Up @@ -449,7 +463,7 @@ export function getMenuEntries(isRichWorkspace: boolean): MenuEntry[] {
},
},
{
key: 'math-separator',
key: 'block-separator-3',
isSeparator: true,
},
{
Expand Down Expand Up @@ -502,12 +516,14 @@ export function getMenuEntries(isRichWorkspace: boolean): MenuEntry[] {
priority: 15,
},
{
key: 'details',
label: t('text', 'Details'),
isActive: 'details',
icon: UnfoldMoreHorizontal,
key: 'footnote',
label: t('text', 'Footnote'),
keyChar: 'f',
keyModifiers: [MODIFIERS.Mod, MODIFIERS.Shift],
isActive: 'footnote',
icon: Asterisk,
action: (command) => {
return command.toggleDetails()
return command.insertFootnote()
},
priority: 16,
},
Expand Down
2 changes: 2 additions & 0 deletions src/components/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import MDI_AlignHorizontalRight from 'vue-material-design-icons/AlignHorizontalR
import MDI_AlphabeticalVariant from 'vue-material-design-icons/AlphabeticalVariant.vue'
import MDI_Undo from 'vue-material-design-icons/ArrowULeftTop.vue'
import MDI_Redo from 'vue-material-design-icons/ArrowURightTop.vue'
import MDI_Asterisk from 'vue-material-design-icons/Asterisk.vue'
import MDI_Check from 'vue-material-design-icons/Check.vue'
import MDI_Positive from 'vue-material-design-icons/CheckboxMarkedCircle.vue'
import MDI_CircleMedium from 'vue-material-design-icons/CircleMedium.vue'
Expand Down Expand Up @@ -101,6 +102,7 @@ export const AlphabeticalVariant = makeIcon(MDI_AlphabeticalVariant)
export const AlignHorizontalCenter = makeIcon(MDI_AlignHorizontalCenter)
export const AlignHorizontalLeft = makeIcon(MDI_AlignHorizontalLeft)
export const AlignHorizontalRight = makeIcon(MDI_AlignHorizontalRight)
export const Asterisk = makeIcon(MDI_Asterisk)
export const Close = makeIcon(MDI_Close)
export const Check = makeIcon(MDI_Check)
export const CodeBrackets = makeIcon(MDI_CodeBrackets)
Expand Down
Loading
Loading