diff --git a/README.md b/README.md index 48d5ce1..c5daf03 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,12 @@ Todos - [x] Tiptap: [track-change-extension](https://github.com/chenyuncai/tiptap-track-change-extension) - [ ] ProseMirror Change: [Changeset](https://github.com/ProseMirror/prosemirror-changeset) - [ ] [@remirror/extension-diff](https://github.com/remirror/remirror/tree/main/packages/remirror__extension-diff) - - [ ] More plugins for - Intelli: [https://github.com/ueberdosis/tiptap/issues/819](https://github.com/ueberdosis/tiptap/issues/819) +- [ ] More plugins for Intelli: [https://github.com/ueberdosis/tiptap/issues/819](https://github.com/ueberdosis/tiptap/issues/819) + - [ ] Sidebar Intellij [Microsoft 365](https://techcommunity.microsoft.com/t5/microsoft-365-blog/introducing-new-ai-enhancements-in-microsoft-365-new-features/ba-p/3643499) + - [ ] Correction text + - [ ] Grammarly + - [ ] Text Prediction + - [ ] Similarity - [ ] LLM Connection - [ ] OpenAI - [ ] Others ? diff --git a/components/editor/live-editor.jsx b/components/editor/live-editor.jsx index 81839af..8e82e1d 100644 --- a/components/editor/live-editor.jsx +++ b/components/editor/live-editor.jsx @@ -1,17 +1,22 @@ +import React from 'react' + +import { EditorContent, useEditor } from '@tiptap/react' import { Color } from '@tiptap/extension-color' import ListItem from '@tiptap/extension-list-item' import TextStyle from '@tiptap/extension-text-style' -import { EditorContent, useEditor } from '@tiptap/react' import StarterKit from '@tiptap/starter-kit' -import React from 'react' -import { MenuBar } from './menu-bar' + +import * as Accordion from '@radix-ui/react-accordion' import MarkdownIt from 'markdown-it' + +import { MenuBar } from './menu-bar' import { MenuBubble } from './intelli/menu/menu-bubble' import { createSlashExtension } from './intelli/slash-extension' import { CommandFunctions } from './action/command-functions' import { createAiBlock } from './intelli/ai-block-extension' import TrackChangeExtension from './diff/track-change-extension' +import { ChevronDownIcon } from '@radix-ui/react-icons' const md = new MarkdownIt() @@ -73,6 +78,7 @@ Chinese text for testing grammar and spellings, select long text to see the menu 虽世殊事异,所以兴怀,其致一也。后之览者,亦将有感于斯文。 ` + const LiveEditor = () => { const editor = useEditor({ extensions, @@ -84,22 +90,80 @@ const LiveEditor = () => { }, }) - return ( -
-
- Scene: (Todo) - - - - -
-
- {editor && } - - {editor && } + return (
+
+
+ Scene: (Todo) + + + + +
+
+ {editor && } + + {editor && } +
+ + {editor && }
) } +const Sidebar = () => { + return +} + +const AccordionTrigger = React.forwardRef(({ children, className, ...props }, forwardedRef) => ( + + + {children} + + + +)) + +const AccordionContent = React.forwardRef(({ children, className, ...props }, forwardedRef) => ( + +
{children}
+
+)) + export default LiveEditor \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5b1afe2..51d7fd2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "dependencies": { "@radix-ui/colors": "^3.0.0", "@radix-ui/popper": "^0.1.0", + "@radix-ui/react-accordion": "^1.1.2", "@radix-ui/react-dropdown-menu": "^2.0.6", "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-popover": "^1.0.7", @@ -385,6 +386,37 @@ "@babel/runtime": "^7.13.10" } }, + "node_modules/@radix-ui/react-accordion": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@radix-ui/react-accordion/-/react-accordion-1.1.2.tgz", + "integrity": "sha512-fDG7jcoNKVjSK6yfmuAs0EnPDro0WMXIhMtXdTBWqEioVW206ku+4Lw07e+13lUkFkpoEQ2PdeMIAGpdqEAmDg==", + "dependencies": { + "@babel/runtime": "^7.13.10", + "@radix-ui/primitive": "1.0.1", + "@radix-ui/react-collapsible": "1.0.3", + "@radix-ui/react-collection": "1.0.3", + "@radix-ui/react-compose-refs": "1.0.1", + "@radix-ui/react-context": "1.0.1", + "@radix-ui/react-direction": "1.0.1", + "@radix-ui/react-id": "1.0.1", + "@radix-ui/react-primitive": "1.0.3", + "@radix-ui/react-use-controllable-state": "1.0.1" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0", + "react-dom": "^16.8 || ^17.0 || ^18.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-arrow": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@radix-ui/react-arrow/-/react-arrow-1.0.3.tgz", @@ -408,6 +440,36 @@ } } }, + "node_modules/@radix-ui/react-collapsible": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-collapsible/-/react-collapsible-1.0.3.tgz", + "integrity": "sha512-UBmVDkmR6IvDsloHVN+3rtx4Mi5TFvylYXpluuv0f37dtaz3H99bp8No0LGXRigVpl3UAT4l9j6bIchh42S/Gg==", + "dependencies": { + "@babel/runtime": "^7.13.10", + "@radix-ui/primitive": "1.0.1", + "@radix-ui/react-compose-refs": "1.0.1", + "@radix-ui/react-context": "1.0.1", + "@radix-ui/react-id": "1.0.1", + "@radix-ui/react-presence": "1.0.1", + "@radix-ui/react-primitive": "1.0.3", + "@radix-ui/react-use-controllable-state": "1.0.1", + "@radix-ui/react-use-layout-effect": "1.0.1" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0", + "react-dom": "^16.8 || ^17.0 || ^18.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-collection": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.0.3.tgz", diff --git a/package.json b/package.json index 7111a6d..8176aa4 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "dependencies": { "@radix-ui/colors": "^3.0.0", "@radix-ui/popper": "^0.1.0", + "@radix-ui/react-accordion": "^1.1.2", "@radix-ui/react-dropdown-menu": "^2.0.6", "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-popover": "^1.0.7", diff --git a/styles/global.css b/styles/global.css index 8f85929..8fc5030 100644 --- a/styles/global.css +++ b/styles/global.css @@ -331,6 +331,102 @@ input { cursor: default; } +.AccordionRoot { + border-radius: 6px; + width: 300px; + background-color: var(--mauve-6); + box-shadow: 0 2px 10px var(--black-a4); +} + +.AccordionItem { + overflow: hidden; + margin-top: 1px; +} + +.AccordionItem:first-child { + margin-top: 0; + border-top-left-radius: 4px; + border-top-right-radius: 4px; +} + +.AccordionItem:last-child { + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; +} + +.AccordionItem:focus-within { + position: relative; + z-index: 1; + box-shadow: 0 0 0 2px var(--mauve-12); +} + +.AccordionHeader { + display: flex; +} + +.AccordionTrigger { + font-family: inherit; + background-color: transparent; + padding: 0 20px; + height: 45px; + flex: 1; + display: flex; + align-items: center; + justify-content: space-between; + font-size: 15px; + line-height: 1; + color: var(--violet-11); + box-shadow: 0 1px 0 var(--mauve-6); + background-color: white; +} + +.AccordionTrigger:hover { + background-color: var(--mauve-2); +} + +.AccordionContent { + overflow: hidden; + font-size: 15px; + color: var(--mauve-11); + background-color: var(--mauve-2); +} +.AccordionContent[data-state='open'] { + animation: slideDown 300ms cubic-bezier(0.87, 0, 0.13, 1); +} +.AccordionContent[data-state='closed'] { + animation: slideUp 300ms cubic-bezier(0.87, 0, 0.13, 1); +} + +.AccordionContentText { + padding: 15px 20px; +} + +.AccordionChevron { + color: var(--violet-10); + transition: transform 300ms cubic-bezier(0.87, 0, 0.13, 1); +} +.AccordionTrigger[data-state='open'] > .AccordionChevron { + transform: rotate(180deg); +} + +@keyframes slideDown { + from { + height: 0; + } + to { + height: var(--radix-accordion-content-height); + } +} + +@keyframes slideUp { + from { + height: var(--radix-accordion-content-height); + } + to { + height: 0; + } +} + .is-active { background-color: var(--violet-3); }