From 4cb048f0fcece771e1873a109c743c1611472aec Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Tue, 21 Nov 2023 19:32:50 +0800 Subject: [PATCH] feat: add customize prompt for items --- README.md | 2 ++ components/editor/diff/diff.js | 2 ++ components/editor/live-editor.jsx | 4 ++++ 3 files changed, 8 insertions(+) create mode 100644 components/editor/diff/diff.js diff --git a/README.md b/README.md index e9c969e..e0abd37 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ Todos like: [https://codesandbox.io/s/prosemirror-diff-nuhiiq](https://codesandbox.io/s/prosemirror-diff-nuhiiq) - Change Diff [https://github.com/chenyuncai/tiptap-track-change-extension](https://github.com/chenyuncai/tiptap-track-change-extension) +- [ ] Customize prompt + - [ ] Variable: `$beforeCursor`, `$afterCursor`, `$selection`, `$similarChunk`, `$relatedChunk` - [ ] Component code search - Similar chunk in browser. - [ ] DSL for units diff --git a/components/editor/diff/diff.js b/components/editor/diff/diff.js new file mode 100644 index 0000000..e3da66a --- /dev/null +++ b/components/editor/diff/diff.js @@ -0,0 +1,2 @@ +// diff format + diff --git a/components/editor/live-editor.jsx b/components/editor/live-editor.jsx index 71dd9b4..b4f89a5 100644 --- a/components/editor/live-editor.jsx +++ b/components/editor/live-editor.jsx @@ -15,6 +15,10 @@ const md = new MarkdownIt() const CustomCommands = Extension.create({ addCommands: () => { return { + // for examples: $selection, $beforeCursor + variable: (variableName, variableValue) => ({ tr, commands }) => { + console.log('variable', variableName, variableValue) + }, getSelectedText: () => ({ editor }) => { const { from, to, empty } = editor.state.selection