diff --git a/playwright/e2e/input-rules.spec.ts b/playwright/e2e/input-rules.spec.ts new file mode 100644 index 00000000000..3cebc251bbc --- /dev/null +++ b/playwright/e2e/input-rules.spec.ts @@ -0,0 +1,20 @@ +/** + * SPDX-FileCopyrightText: 2025 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' +import { test as uploadFileTest } from '../support/fixtures/upload-file' + +const test = mergeTests(editorTest, uploadFileTest) + +test('applies code mark input rule with preceding character (#5483)', async ({ + editor, + open, +}) => { + await open() + await editor.type('hello inline (`code`)') + await expect(editor.el.locator('code')).toHaveText('code') + await expect(editor.el.locator('p').first()).toHaveText('hello inline (code)') +}) diff --git a/src/marks/Code.ts b/src/marks/Code.ts index 58c85b33651..d54e4bf5cb6 100644 --- a/src/marks/Code.ts +++ b/src/marks/Code.ts @@ -3,11 +3,42 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +import { markInputRule, markPasteRule } from '@tiptap/core' import TipTapCode from '@tiptap/extension-code' +/** + * Regular expressions to match inline code blocks enclosed in backticks. + * Reverts upstream PR https://github.com/ueberdosis/tiptap/pull/5916 which + * introduced isuee https://github.com/nextcloud/text/issues/5483. + */ +export const inputRegex = /(?