diff --git a/.yarn/patches/@tiptap-extension-code-patch-5e999c6f1b.patch b/.yarn/patches/@tiptap-extension-code-patch-5e999c6f1b.patch new file mode 100644 index 0000000000..4edd14fb74 --- /dev/null +++ b/.yarn/patches/@tiptap-extension-code-patch-5e999c6f1b.patch @@ -0,0 +1,29 @@ +diff --git a/dist/index.cjs b/dist/index.cjs +index e4106894f67ff68b78e4e7485b7beb24570f91c0..5f610691f63882c51a2583462da04d1a7532a235 100644 +--- a/dist/index.cjs ++++ b/dist/index.cjs +@@ -29,8 +29,8 @@ module.exports = __toCommonJS(index_exports); + + // src/code.ts + var import_core = require("@tiptap/core"); +-var inputRegex = /(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/; +-var pasteRegex = /(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g; ++var inputRegex = /(?:^|[^`])(`([^`]+)`)(?!`)$/; ++var pasteRegex = /(?:^|[^`])(`([^`]+)`)(?!`)/g; + var Code = import_core.Mark.create({ + name: "code", + addOptions() { +diff --git a/dist/index.js b/dist/index.js +index 3736cac514b979438a808705931636ae04b06d16..4b3e72200bd38d3d5f06464d9fafe1c068b22992 100644 +--- a/dist/index.js ++++ b/dist/index.js +@@ -1,7 +1,7 @@ + // src/code.ts + import { Mark, markInputRule, markPasteRule, mergeAttributes } from "@tiptap/core"; +-var inputRegex = /(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/; +-var pasteRegex = /(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g; ++var inputRegex = /(?:^|[^`])(`([^`]+)`)(?!`)$/; ++var pasteRegex = /(?:^|[^`])(`([^`]+)`)(?!`)/g; + var Code = Mark.create({ + name: "code", + addOptions() { diff --git a/package.json b/package.json index f10757ff25..71c8b75625 100644 --- a/package.json +++ b/package.json @@ -169,7 +169,7 @@ "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.3.0", "@testing-library/user-event": "^14.6.1", - "@tiptap/extension-code": "patch:@tiptap/extension-code@npm%3A3.9.0#~/.yarn/patches/@tiptap-extension-code-npm-3.9.0-1fad1fecd8.patch", + "@tiptap/extension-code": "patch:@tiptap/extension-code@patch%3A@tiptap/extension-code@npm%253A3.9.0%23~/.yarn/patches/@tiptap-extension-code-npm-3.9.0-1fad1fecd8.patch%3A%3Aversion=3.9.0&hash=86c3dd#~/.yarn/patches/@tiptap-extension-code-patch-5e999c6f1b.patch", "@tiptap/extension-code-block": "^3.9.0", "@tiptap/extension-collaboration": "^3.9.0", "@tiptap/extension-drag-handle": "^3.9.0", @@ -398,7 +398,8 @@ "@img/sharp-linux-arm64": "0.34.3", "@img/sharp-linux-x64": "0.34.3", "@img/sharp-win32-x64": "0.34.3", - "openai@npm:5.12.2": "npm:@cherrystudio/openai@6.5.0" + "openai@npm:5.12.2": "npm:@cherrystudio/openai@6.5.0", + "@tiptap/extension-code@npm:^3.9.0": "patch:@tiptap/extension-code@patch%3A@tiptap/extension-code@npm%253A3.9.0%23~/.yarn/patches/@tiptap-extension-code-npm-3.9.0-1fad1fecd8.patch%3A%3Aversion=3.9.0&hash=86c3dd#~/.yarn/patches/@tiptap-extension-code-patch-5e999c6f1b.patch" }, "packageManager": "yarn@4.9.1", "lint-staged": { diff --git a/src/renderer/src/components/RichEditor/useRichEditor.ts b/src/renderer/src/components/RichEditor/useRichEditor.ts index fceb76c1cd..5776aa92ac 100644 --- a/src/renderer/src/components/RichEditor/useRichEditor.ts +++ b/src/renderer/src/components/RichEditor/useRichEditor.ts @@ -60,6 +60,16 @@ const SourceLineAttribute = Extension.create({ } }) +// Create extension to disable marks on split (Enter key) +const DisableMarksOnSplit = Extension.create({ + name: 'disableMarksOnSplit', + addKeyboardShortcuts() { + return { + Enter: () => this.editor.commands.splitBlock({ keepMarks: false }) + } + } +}) + export interface UseRichEditorOptions { /** Initial markdown content */ initialContent?: string @@ -202,6 +212,7 @@ export const useRichEditor = (options: UseRichEditorOptions = {}): UseRichEditor } }), SourceLineAttribute, + DisableMarksOnSplit, StarterKit.configure({ heading: { levels: [1, 2, 3, 4, 5, 6] diff --git a/yarn.lock b/yarn.lock index bc7bb409a0..6221321f2e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11609,7 +11609,7 @@ __metadata: languageName: node linkType: hard -"@tiptap/extension-code@patch:@tiptap/extension-code@npm%3A3.9.0#~/.yarn/patches/@tiptap-extension-code-npm-3.9.0-1fad1fecd8.patch": +"@tiptap/extension-code@patch:@tiptap/extension-code@npm%3A3.9.0#~/.yarn/patches/@tiptap-extension-code-npm-3.9.0-1fad1fecd8.patch::version=3.9.0&hash=86c3dd": version: 3.9.0 resolution: "@tiptap/extension-code@patch:@tiptap/extension-code@npm%3A3.9.0#~/.yarn/patches/@tiptap-extension-code-npm-3.9.0-1fad1fecd8.patch::version=3.9.0&hash=86c3dd" peerDependencies: @@ -11618,6 +11618,15 @@ __metadata: languageName: node linkType: hard +"@tiptap/extension-code@patch:@tiptap/extension-code@patch%3A@tiptap/extension-code@npm%253A3.9.0%23~/.yarn/patches/@tiptap-extension-code-npm-3.9.0-1fad1fecd8.patch%3A%3Aversion=3.9.0&hash=86c3dd#~/.yarn/patches/@tiptap-extension-code-patch-5e999c6f1b.patch": + version: 3.9.0 + resolution: "@tiptap/extension-code@patch:@tiptap/extension-code@patch%3A@tiptap/extension-code@npm%253A3.9.0%23~/.yarn/patches/@tiptap-extension-code-npm-3.9.0-1fad1fecd8.patch%3A%3Aversion=3.9.0&hash=86c3dd#~/.yarn/patches/@tiptap-extension-code-patch-5e999c6f1b.patch::version=3.9.0&hash=4d897f" + peerDependencies: + "@tiptap/core": ^3.9.0 + checksum: 10c0/d3886c7bcd2270fb1ca8d63b2cf45ce32375050a043f01c2aa7c517f57f461359ba1d2c3d489759c46a056fc4eaf1f4840ede3033f7621c5cd89b52cd23d740c + languageName: node + linkType: hard + "@tiptap/extension-collaboration@npm:^3.9.0": version: 3.9.0 resolution: "@tiptap/extension-collaboration@npm:3.9.0" @@ -13989,7 +13998,7 @@ __metadata: "@testing-library/jest-dom": "npm:^6.6.3" "@testing-library/react": "npm:^16.3.0" "@testing-library/user-event": "npm:^14.6.1" - "@tiptap/extension-code": "patch:@tiptap/extension-code@npm%3A3.9.0#~/.yarn/patches/@tiptap-extension-code-npm-3.9.0-1fad1fecd8.patch" + "@tiptap/extension-code": "patch:@tiptap/extension-code@patch%3A@tiptap/extension-code@npm%253A3.9.0%23~/.yarn/patches/@tiptap-extension-code-npm-3.9.0-1fad1fecd8.patch%3A%3Aversion=3.9.0&hash=86c3dd#~/.yarn/patches/@tiptap-extension-code-patch-5e999c6f1b.patch" "@tiptap/extension-code-block": "npm:^3.9.0" "@tiptap/extension-collaboration": "npm:^3.9.0" "@tiptap/extension-drag-handle": "npm:^3.9.0"