@innoviatech/lexical-text-editor 1.0.6 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -36
- package/dist/components/ContentPreview.d.ts +1 -1
- package/dist/components/HeadingSelectionList.d.ts +1 -1
- package/dist/components/LexicalTextEditor.d.ts +1 -1
- package/dist/components/common/Dialog.d.ts +9 -0
- package/dist/components/common/Popover.d.ts +21 -0
- package/dist/components/common/Tooltip.d.ts +10 -0
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical-editor.css +1 -0
- package/dist/nodes/ExtendedTextNode.d.ts +11 -0
- package/dist/nodes/ImageNode.d.ts +10 -14
- package/dist/plugins/YoutubePlugin.d.ts +1 -0
- package/editor_screenshot.png +0 -0
- package/innoviatech-lexical-text-editor-2.0.0.tgz +0 -0
- package/package.json +20 -16
- package/rollup.config.js +3 -4
- package/src/components/AlignmentSelectionList.tsx +41 -24
- package/src/components/ColorPicker.tsx +7 -21
- package/src/components/ContentPreview.tsx +26 -20
- package/src/components/DropdownList.tsx +39 -24
- package/src/components/HeadingSelectionList.tsx +48 -32
- package/src/components/ImageComponent.tsx +52 -19
- package/src/components/InsertDropdownList.tsx +1 -1
- package/src/components/LexicalTextEditor.tsx +33 -28
- package/src/components/LinkModal.tsx +42 -45
- package/src/components/common/Dialog.tsx +47 -0
- package/src/components/common/Popover.tsx +87 -0
- package/src/components/common/Tooltip.tsx +43 -0
- package/src/components/ui/command.tsx +0 -1
- package/src/nodes/ExtendedTextNode.tsx +174 -0
- package/src/nodes/ImageNode.tsx +87 -48
- package/src/plugins/ColorPlugin.tsx +19 -14
- package/src/plugins/ImagePlugin.tsx +79 -84
- package/src/plugins/ListPlugin.tsx +20 -38
- package/src/plugins/ToolbarPlugin.tsx +76 -78
- package/src/plugins/VideoPlugin.tsx +46 -55
- package/src/plugins/YoutubePlugin.tsx +83 -0
- package/src/styles/lexical-editor.css +961 -3
- package/dist/style.css +0 -3
- package/postcss.config.js +0 -6
- package/src/assets/react.svg +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.lexical-text-editor *{box-sizing:border-box;font-family:inherit;height:fit-content}.lexical-text-editor button{background:transparent;border:1px solid transparent;cursor:pointer}.lexical-text-editor a{color:#646cff;font-weight:500;text-decoration:inherit}.lexical-text-editor a:hover{color:#535bf2}.lexical-text-editor{background-color:#fff;border:1px solid #e5e7eb;border-radius:.5rem;color:#000;font-size:16px!important;padding-bottom:.5rem;scrollbar-color:#9ca3af transparent;scrollbar-width:thin}.lexical-text-editor input{background-color:#fff;color:#000;outline:none}.link-editor-buttons input{stroke:#000;background-color:#220909;color:#000;outline:none}.lexical-text-editor input:focus{border:1px solid #676666}.lexical-toolbar-wrapper{align-items:center;display:flex;flex-wrap:wrap;gap:6px;justify-content:center;row-gap:12px}.lexical-toolbar-wrapper.useScroll{flex-wrap:nowrap}.lexical-text-editor::-webkit-scrollbar{width:6px}.lexical-text-editor::-webkit-scrollbar-track{background:transparent}.lexical-text-editor::-webkit-scrollbar-thumb{background-color:#9ca3af;border-radius:3px}.lexical-text-editor::-webkit-scrollbar-thumb:hover{background-color:#6b7280}.lexical-text-editor [contenteditable=true]{outline:none}.lexical-text-editor h1{font-size:32px;font-weight:700;margin:8px 0}.lexical-text-editor h2{font-size:28.8px;font-weight:700;margin:8px 0}.lexical-text-editor h3{font-size:25.6px;font-weight:700;margin:3.2px 0}.lexical-text-editor h4{font-size:22.4px;font-weight:700;margin:3.2px 0}.lexical-text-editor h5{font-size:19.2px;font-weight:700;margin:3.2px 0}.lexical-text-editor h6{font-size:16px;font-weight:700;margin:3.2px 0}.scrollbar-thin{scrollbar-color:#a5acb6 transparent;scrollbar-width:thin}.scrollbar-thin::-webkit-scrollbar{height:4px;width:4px}.scrollbar-thin::-webkit-scrollbar-track{background:transparent}.scrollbar-thin::-webkit-scrollbar-thumb{background-color:#a5acb6;border-radius:9999px}.lexical-editor-container{box-sizing:border-box;position:relative}.lexical-toolbar-container{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;padding-left:.5rem;padding-right:.5rem}.lexical-editor-inner{height:100%;position:relative}.lexical-content-editable{background-color:#fff;box-sizing:border-box;color:#000;font-size:14px;height:100%;outline:0;overflow:auto;padding:8px;scrollbar-color:#9ca3af transparent;scrollbar-width:thin;text-align:start;width:100%}.lexical-placeholder{color:#999;font-size:14px;left:10px;pointer-events:none;position:absolute;top:8px;user-select:none}.lexical-content-editable::-webkit-scrollbar{height:8px;width:8px}.lexical-content-editable::-webkit-scrollbar-track{background:#f1f1f1;border-radius:4px}.lexical-content-editable::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:4px}.lexical-content-editable::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.lexical-bold{font-weight:700}.lexical-underline{text-decoration:underline}.lexical-italic{font-style:italic}.lexical-strikethrough{text-decoration:line-through}.lexical-underline-strikethrough{text-decoration:underline line-through}.lexical-uppercase{text-transform:uppercase}.lexical-lowercase{text-transform:lowercase}.lexical-capitalize{text-transform:capitalize}.lexical-code{background-color:#f3f4f6;border:1px solid #d1d5db;border-radius:.25rem;color:#000;font-family:monospace;font-size:.875rem;padding:0 .25rem}.lexical-paragraph{margin-bottom:.5rem}.lexical-list-ul{list-style-type:disc}.lexical-list-ol,.lexical-list-ul{list-style-position:inside;padding-left:1.5rem}.lexical-list-ol{list-style-type:decimal}.lexical-listitem{margin-bottom:.25rem}.lexical-quote{background-color:#f9fafb;border-bottom-right-radius:.25rem;border-left:4px solid #9ca3af;border-top-right-radius:.25rem;color:#374151;font-style:italic;padding-bottom:.5rem;padding-left:1rem;padding-top:.5rem}.lexical-link{color:#2563eb;text-decoration:underline}.lexical-link:hover{color:#1e40af}.lexical-text-editor .lexical-btn{align-items:center;background:#fff;border:none;border-radius:6px;color:#4b5563;cursor:pointer;display:inline-flex;font-size:14px;font-weight:500;gap:8px;height:32px;justify-content:flex-start;outline:none;padding:8px 12px;transition:all .15s ease;user-select:none;white-space:nowrap;width:100%}.lexical-text-editor .lexical-btn svg{flex-shrink:0;height:16px;pointer-events:none;width:16px}.lexical-text-editor .lexical-btn svg[class*=size-]{height:auto;width:auto}.lexical-text-editor .lexical-btn .label{margin-left:8px}.lexical-text-editor .lexical-btn.toolbar{background:#fff;color:#4b5563}.lexical-text-editor .lexical-btn.toolbar:hover{background:rgba(241,245,249,.8)}.lexical-text-editor .lexical-btn.toolbar-active{background:#f1f5f9;color:#111827}.lexical-text-editor .lexical-btn:disabled{opacity:.5;pointer-events:none}.lexical-text-editor .size-8{height:32px!important;width:32px!important}.lexical-text-editor .toolbar{align-items:center;background-color:#fff;border-radius:8px;color:#374151;cursor:pointer;display:inline-flex;justify-content:flex-start;transition:background .15s ease,border-color .15s ease}.lexical-text-editor .toolbar.icon{align-items:center;display:inline-flex;justify-content:center!important}.lexical-text-editor .toolbar:hover:not(:disabled){background-color:#f3f4f6}.lexical-text-editor .toolbarActive{align-items:center;background-color:#eef2ff;border-radius:.5rem;cursor:pointer;display:inline-flex;justify-content:center;padding:0}.lexical-text-editor button:disabled{background-color:#f9fafb;cursor:not-allowed;opacity:.5}.lexical-text-editor .popover-root{display:inline-block;position:relative}.lexical-text-editor .popover-trigger{display:inline-block}.lexical-text-editor .popover-content{animation:popoverFadeIn .15s ease;background:#fff;border-radius:6px;box-shadow:0 2px 6px rgba(0,0,0,.12),0 0 0 1px rgba(0,0,0,.04);padding:8px;position:absolute;top:calc(100% + 4px);z-index:9999}.lexical-text-editor .popover-content.align-start{left:0}.lexical-text-editor .popover-content.align-center{left:50%;transform:translateX(-50%)}.lexical-text-editor .popover-content.align-end{right:0}@keyframes popoverFadeIn{0%{opacity:0;transform:translateY(-3px)}to{opacity:1;transform:translateY(0)}}.lexical-text-editor .heading-select{display:inline-block;position:relative}.lexical-text-editor .heading-trigger{background-color:#fff;border:1px solid #e5e7eb;height:32px;justify-content:space-between;padding:8px}.lexical-text-editor .heading-trigger .chevron{transition:transform .15s ease}.lexical-text-editor .heading-trigger .chevron.rotated{transform:rotate(180deg)}.lexical-text-editor .heading-dropdown{animation:dropdownFadeIn .15s ease;background:#fff;border-radius:6px;box-shadow:0 2px 6px rgba(0,0,0,.12),0 0 0 1px rgba(0,0,0,.04);display:flex;flex-direction:column;gap:4px;left:0;padding:8px;position:absolute;top:calc(100% + 4px);width:max-content;z-index:9999}@keyframes dropdownFadeIn{0%{opacity:0;transform:translateY(-3px)}to{opacity:1;transform:translateY(0)}}.color-picker-wrapper{display:inline-block;position:relative}.toolbar:hover:not(:disabled){background-color:#f3f4f6}.lexical-color-popover{border-radius:.5rem;margin-top:10px;opacity:0;pointer-events:none;transform:scale(.95) translateY(-4px);transform-origin:top left;transition:opacity .15s ease,transform .15s ease;z-index:99}.lexical-color-popover.open{opacity:1;pointer-events:auto;transform:scale(1) translateY(0)}.lexical-text-editor-dialog{.lte-icon-btn{align-items:center;background:none;border:none;border-radius:4px;cursor:pointer;display:flex;padding:6px}.lte-icon-btn:hover{background:#e5e5e5}.lte-outline-btn{background:#f8f8f8;border:1px solid #ccc;border-radius:4px;color:#000;cursor:pointer;font-size:14px;margin:0 auto;padding:8px 12px;width:fit-content}.lte-outline-btn:hover{background:#eee}.lte-primary-btn{background-color:#2563eb!important;border:none;border-radius:4px;color:#fff;cursor:pointer;padding:8px 14px}.lte-primary-btn:hover{background:#1d4ed8}.lte-primary-btn:disabled{cursor:not-allowed;opacity:.5}.lte-input{background-color:#fff;border:1px solid #d0d0d0;border-radius:4px;padding:8px 10px;width:100%}.lte-divider{align-items:center;color:#777;display:flex;font-size:13px;margin:12px 0}.lte-divider:after,.lte-divider:before{background:#ccc;content:"";flex:1;height:1px}.lte-divider span{padding:0 8px}.lte-file-name{color:#666;font-size:13px}.lte-dialog-overlay{align-items:center;background:rgba(0,0,0,.5);display:flex;inset:0;justify-content:center;position:fixed;z-index:50}.lte-dialog{background:#fff;border-radius:8px;margin:10px;max-width:420px;padding:20px;position:relative;width:100%}.lte-dialog.preview{max-width:1024px;width:100%}.lte-dialog-header{color:#333;font-size:18px;font-weight:600;margin-bottom:10px}.lte-dialog-body{display:flex;flex-direction:column;gap:12px;padding:10px 0}.lte-dialog-footer{display:flex;justify-content:flex-end;margin-top:12px}.lte-dialog-close{background:none;border:none;color:#000;cursor:pointer;font-size:26px;opacity:.7;outline:none;padding:0;position:absolute;right:18px;top:10px}.lte-dialog-close:hover{opacity:1}.lte-hidden{display:none}}.lexical-text-editor .lte-toolbar-btn{align-items:center;background:#fff;border:1px solid #e5e7eb;border-radius:6px;cursor:pointer;display:flex;gap:4px;padding:6px 10px;transition:.15s ease;user-select:none}.lexical-text-editor .lte-toolbar-btn:hover{background:#f3f4f6}.lexical-text-editor .lte-toolbar-btn-active{background:#e0e7ff;border-color:#6366f1}.lexical-text-editor .lte-preview-container{background:#fff;border:1px solid #e5e7eb;border-radius:8px;max-height:80vh;min-height:400px;overflow-y:auto;padding:2vw;width:100%}.lexical-text-editor .lte-preview-title{border-bottom:2px solid #e5e7eb;font-size:15px;font-weight:600;margin-bottom:14px;padding-bottom:6px;text-align:start}.lexical-text-editor-html-preview{line-height:1.6;max-width:none;text-align:start}.lexical-text-editor-link.link-editor-container{align-items:center;background:#fff;border:1px solid #e5e7eb;border-radius:12px;bottom:-50px;box-shadow:0 4px 12px rgba(0,0,0,.12);display:flex;gap:8px;padding:6px 10px;position:absolute;right:20px;z-index:99}@media (min-width:640px){.lexical-text-editor-link.link-editor-container{bottom:-60px;padding:8px 14px}}.lexical-text-editor-link .link-editor-input-wrapper{flex:1;min-width:200px}.lexical-text-editor-link .link-editor-input{background-color:#fff;border:1px solid #d1d5db;border-radius:6px;font-size:14px;height:32px;outline:none;padding:4px 8px;width:100%}.lexical-text-editor-link .link-editor-input:focus{border-color:#2563eb}.lexical-text-editor-link .link-editor-url{color:#2563eb;display:block;font-size:14px;max-width:100%;overflow:hidden;text-align:start;text-decoration:underline;text-overflow:ellipsis;white-space:nowrap}.lexical-text-editor-link .link-editor-buttons{display:flex;gap:4px}.lexical-text-editor-link .link-editor-btn{align-items:center;background:transparent;border:none;border-radius:6px;cursor:pointer;display:flex;height:32px;justify-content:center;transition:background .2s ease;width:32px}.lexical-text-editor-link .link-editor-btn:hover{background:#f3f4f6}.Lexical-Tooltip-Wrapper{display:inline-block;position:relative}.Lexical-Tooltip-Tip{background:#5a5a5a;border-radius:4px;color:#fff;font-family:sans-serif;font-size:12px;left:50%;line-height:1;padding:8px 12px;position:absolute;transform:translateX(-50%);transition:all .5s;white-space:nowrap;z-index:100}.Lexical-Tooltip-Tip:before{border:6px solid transparent;content:" ";height:0;left:50%;margin-left:-6px;pointer-events:none;position:absolute;width:0}.Lexical-Tooltip-Tip.top{top:-35px}.Lexical-Tooltip-Tip.top:before{border-top-color:#5a5a5a;top:100%}.Lexical-Tooltip-Tip.right{left:calc(100% + 30px);top:50%;transform:translateX(0) translateY(-50%)}.Lexical-Tooltip-Tip.right:before{border-right-color:#5a5a5a;left:-6px;top:50%;transform:translateX(0) translateY(-50%)}.Lexical-Tooltip-Tip.bottom{bottom:-35px}.Lexical-Tooltip-Tip.bottom:before{border-bottom-color:#5a5a5a;bottom:100%}.Lexical-Tooltip-Tip.left{left:auto;right:calc(100% + 30px);top:50%;transform:translateX(0) translateY(-50%)}.Lexical-Tooltip-Tip.left:before{border-left-color:#5a5a5a;left:auto;right:-12px;top:50%;transform:translateX(0) translateY(-50%)}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DOMConversionMap, NodeKey, TextNode, SerializedTextNode, LexicalNode } from 'lexical';
|
|
2
|
+
export declare class ExtendedTextNode extends TextNode {
|
|
3
|
+
constructor(text: string, key?: NodeKey);
|
|
4
|
+
static getType(): string;
|
|
5
|
+
static clone(node: ExtendedTextNode): ExtendedTextNode;
|
|
6
|
+
static importDOM(): DOMConversionMap | null;
|
|
7
|
+
static importJSON(serializedNode: SerializedTextNode): ExtendedTextNode;
|
|
8
|
+
isSimpleText(): boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function $createExtendedTextNode(text?: string): ExtendedTextNode;
|
|
11
|
+
export declare function $isExtendedTextNode(node: LexicalNode | null | undefined): node is ExtendedTextNode;
|
|
@@ -9,35 +9,31 @@ export interface SerializedImageNode {
|
|
|
9
9
|
width?: number | "inherit";
|
|
10
10
|
height?: number | "inherit";
|
|
11
11
|
}
|
|
12
|
-
export
|
|
12
|
+
export type ImageNodePayload = {
|
|
13
|
+
src: string;
|
|
13
14
|
altText: string;
|
|
14
|
-
height?: number;
|
|
15
15
|
maxWidth?: number;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
16
|
+
width?: number | "inherit";
|
|
17
|
+
height?: number | "inherit";
|
|
18
|
+
};
|
|
19
|
+
export declare const $createImageNode: (payload: ImageNodePayload) => ImageNode;
|
|
19
20
|
export declare class ImageNode extends DecoratorNode<JSX.Element> {
|
|
20
21
|
__src: string;
|
|
21
22
|
__altText: string;
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
__width?: number | "inherit";
|
|
24
|
+
__height?: number | "inherit";
|
|
24
25
|
__maxWidth: number;
|
|
25
|
-
constructor({ src, altText, maxWidth, width, height, key, }?: {
|
|
26
|
-
src?: string;
|
|
27
|
-
altText?: string;
|
|
28
|
-
maxWidth?: number;
|
|
29
|
-
width?: "inherit" | number;
|
|
30
|
-
height?: "inherit" | number;
|
|
26
|
+
constructor({ src, altText, maxWidth, width, height, key, }?: ImageNodePayload & {
|
|
31
27
|
key?: NodeKey;
|
|
32
28
|
});
|
|
33
29
|
static getType(): string;
|
|
34
30
|
static clone(node: ImageNode): ImageNode;
|
|
35
31
|
createDOM(): HTMLElement;
|
|
32
|
+
updateDOM(prevNode: ImageNode): boolean;
|
|
36
33
|
exportDOM(): DOMExportOutput;
|
|
37
34
|
static importDOM(): DOMConversionMap | null;
|
|
38
35
|
exportJSON(): SerializedImageNode;
|
|
39
36
|
static importJSON(serializedNode: SerializedImageNode): ImageNode;
|
|
40
37
|
updateDimensions(width: number, height: number): void;
|
|
41
|
-
updateDOM(): boolean;
|
|
42
38
|
decorate(): JSX.Element;
|
|
43
39
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function YoutubePlugin(): import("react/jsx-runtime").JSX.Element;
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@innoviatech/lexical-text-editor",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
"require": "./dist/index.js",
|
|
17
17
|
"types": "./dist/index.d.ts"
|
|
18
18
|
},
|
|
19
|
-
"./style.css":
|
|
19
|
+
"./style.css": {
|
|
20
|
+
"import": "./dist/lexical-editor.css",
|
|
21
|
+
"require": "./dist/lexical-editor.css"
|
|
22
|
+
}
|
|
20
23
|
},
|
|
21
24
|
"scripts": {
|
|
22
25
|
"build": "rollup -c",
|
|
@@ -24,31 +27,32 @@
|
|
|
24
27
|
"prepublishOnly": "npm run build"
|
|
25
28
|
},
|
|
26
29
|
"peerDependencies": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"lexical": "^0.36.2",
|
|
30
|
+
"@lexical/code": "^0.36.2",
|
|
31
|
+
"@lexical/link": "^0.36.2",
|
|
32
|
+
"@lexical/list": "^0.36.2",
|
|
30
33
|
"@lexical/react": "^0.36.2",
|
|
31
34
|
"@lexical/rich-text": "^0.36.2",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
+
"lexical": "^0.36.2",
|
|
36
|
+
"react": ">=18",
|
|
37
|
+
"react-color": "^2.19.3",
|
|
38
|
+
"react-dom": ">=18",
|
|
39
|
+
"react-icons": "^5.5.0"
|
|
35
40
|
},
|
|
36
41
|
"devDependencies": {
|
|
37
42
|
"@rollup/plugin-commonjs": "^28.0.0",
|
|
38
43
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
39
44
|
"@rollup/plugin-terser": "^0.4.0",
|
|
40
45
|
"@rollup/plugin-typescript": "^12.0.0",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"rollup-plugin-dts": "^6.1.0",
|
|
44
|
-
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
45
|
-
"rollup-plugin-postcss": "^4.0.2",
|
|
46
|
+
"@types/react": "^18.0.0",
|
|
47
|
+
"@types/react-dom": "^18.0.0",
|
|
46
48
|
"autoprefixer": "^10.4.0",
|
|
47
49
|
"postcss": "^8.4.0",
|
|
48
|
-
"tailwindcss": "^3.3.0",
|
|
49
50
|
"react": "^18.0.0",
|
|
50
51
|
"react-dom": "^18.0.0",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
52
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
53
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
54
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
55
|
+
"tslib": "^2.6.0",
|
|
56
|
+
"typescript": "^5.0.0"
|
|
53
57
|
}
|
|
54
58
|
}
|
package/rollup.config.js
CHANGED
|
@@ -31,11 +31,10 @@ export default [
|
|
|
31
31
|
}),
|
|
32
32
|
commonjs(),
|
|
33
33
|
postcss({
|
|
34
|
-
extract: '
|
|
34
|
+
extract: 'lexical-editor.css',
|
|
35
35
|
minimize: true,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
36
|
+
inject: false,
|
|
37
|
+
modules: false
|
|
39
38
|
}),
|
|
40
39
|
typescript({
|
|
41
40
|
tsconfig: './tsconfig.json',
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Popover,
|
|
4
|
-
PopoverContent,
|
|
5
|
-
PopoverTrigger,
|
|
6
|
-
} from "./ui/popover"
|
|
1
|
+
|
|
2
|
+
|
|
7
3
|
import { RICH_ALIGNMENT_OPTIONS, RichTextAction } from "../constants/index";
|
|
8
4
|
|
|
9
|
-
import { useState } from "react"
|
|
5
|
+
import { useRef, useState } from "react"
|
|
10
6
|
import { HiChevronDown } from "react-icons/hi2";
|
|
7
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./common/Popover";
|
|
11
8
|
|
|
12
9
|
interface Props {
|
|
13
10
|
onAction: (id: RichTextAction) => void;
|
|
@@ -18,26 +15,46 @@ interface Props {
|
|
|
18
15
|
export function AlignmentSelectionList({ onAction, alignmentSelectionMap }: Props) {
|
|
19
16
|
const activeAlignment = RICH_ALIGNMENT_OPTIONS.find(h => alignmentSelectionMap[h.id])
|
|
20
17
|
const [isOpen, setIsOpen] = useState(false)
|
|
18
|
+
const triggerRef = useRef<HTMLDivElement | null>(null);
|
|
19
|
+
const contentRef = useRef<HTMLDivElement | null>(null);
|
|
21
20
|
return (
|
|
22
|
-
<Popover open={isOpen} onOpenChange={
|
|
23
|
-
<PopoverTrigger
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
<Popover open={isOpen} onOpenChange={setIsOpen}>
|
|
22
|
+
<PopoverTrigger triggerRef={triggerRef}>
|
|
23
|
+
|
|
24
|
+
<button
|
|
25
|
+
className={`lexical-btn heading-trigger ${isOpen ? "toolbar-active" : "toolbar"}`}
|
|
26
|
+
onClick={() => setIsOpen((prev) => !prev)}
|
|
27
|
+
style={{
|
|
28
|
+
minWidth: 146
|
|
29
|
+
}}
|
|
26
30
|
>
|
|
27
|
-
{activeAlignment?.icon}
|
|
28
|
-
|
|
31
|
+
{activeAlignment?.icon}
|
|
32
|
+
<span>{activeAlignment?.label}</span>
|
|
33
|
+
<HiChevronDown className={`chevron ${isOpen ? "rotated" : ""}`} />
|
|
34
|
+
</button>
|
|
29
35
|
</PopoverTrigger>
|
|
30
|
-
<PopoverContent align="start"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
<PopoverContent open={isOpen} align="start" onClose={() => setIsOpen(false)} contentRef={contentRef}>
|
|
37
|
+
<div
|
|
38
|
+
style={{
|
|
39
|
+
display: 'flex', flexDirection: 'column', gap: 5
|
|
40
|
+
}}>
|
|
41
|
+
{
|
|
42
|
+
RICH_ALIGNMENT_OPTIONS.map(({ id, label, icon }) => (
|
|
43
|
+
<button
|
|
44
|
+
key={id}
|
|
45
|
+
className={`lexical-btn ${alignmentSelectionMap[id] ? "toolbar-active" : "toolbar"
|
|
46
|
+
}`}
|
|
47
|
+
onClick={() => {
|
|
48
|
+
onAction(id);
|
|
49
|
+
setIsOpen(false)
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
{icon}
|
|
53
|
+
<span className="label">{label}</span>
|
|
54
|
+
</button>
|
|
55
|
+
))
|
|
56
|
+
}
|
|
57
|
+
</div>
|
|
41
58
|
</PopoverContent>
|
|
42
59
|
</Popover>
|
|
43
60
|
)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
1
|
import { useState, useRef, useEffect } from "react";
|
|
3
2
|
import { SketchPicker } from "react-color";
|
|
4
|
-
import { Button } from "./ui/button";
|
|
5
3
|
import { createPortal } from "react-dom";
|
|
4
|
+
|
|
6
5
|
interface ColorPickerProps {
|
|
7
6
|
color: string;
|
|
8
7
|
onChange: (color: string) => void;
|
|
@@ -14,7 +13,6 @@ export default function ColorPicker({ color, onChange, icon }: ColorPickerProps)
|
|
|
14
13
|
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
15
14
|
const popoverRef = useRef<HTMLDivElement>(null);
|
|
16
15
|
|
|
17
|
-
// Close popover on outside click
|
|
18
16
|
useEffect(() => {
|
|
19
17
|
const handleClickOutside = (event: MouseEvent) => {
|
|
20
18
|
if (
|
|
@@ -30,33 +28,23 @@ export default function ColorPicker({ color, onChange, icon }: ColorPickerProps)
|
|
|
30
28
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
31
29
|
}, []);
|
|
32
30
|
|
|
33
|
-
// Prevent popover from stealing text selection focus
|
|
34
31
|
const preventFocus = (e: React.MouseEvent) => e.preventDefault();
|
|
35
32
|
|
|
36
33
|
return (
|
|
37
|
-
<div className="
|
|
38
|
-
<
|
|
34
|
+
<div className="color-picker-wrapper">
|
|
35
|
+
<button
|
|
39
36
|
ref={triggerRef}
|
|
40
|
-
|
|
41
|
-
size="icon"
|
|
42
|
-
className="rounded-md text-gray-700 hover:bg-gray-200"
|
|
43
|
-
aria-label="Change Color"
|
|
37
|
+
className={`size-8 lexical-btn ${open ? "toolbarActive" : "toolbar"} icon`}
|
|
44
38
|
onClick={() => setOpen((prev) => !prev)}
|
|
45
39
|
>
|
|
46
40
|
{icon}
|
|
47
|
-
</
|
|
41
|
+
</button>
|
|
48
42
|
|
|
49
43
|
{open &&
|
|
50
44
|
createPortal(
|
|
51
45
|
<div
|
|
52
46
|
ref={popoverRef}
|
|
53
|
-
className={`
|
|
54
|
-
absolute z-50 p-2 bg-transparent rounded-md select-none
|
|
55
|
-
transition-all duration-200
|
|
56
|
-
origin-top-left w-fit
|
|
57
|
-
${open ? "opacity-100 scale-100 translate-y-0"
|
|
58
|
-
: "opacity-0 scale-95 -translate-y-2 pointer-events-none"
|
|
59
|
-
}`}
|
|
47
|
+
className={`lexical-color-popover ${open ? "open" : ""}`}
|
|
60
48
|
style={{
|
|
61
49
|
top: triggerRef.current?.getBoundingClientRect().bottom,
|
|
62
50
|
left: triggerRef.current?.getBoundingClientRect().left,
|
|
@@ -68,13 +56,11 @@ export default function ColorPicker({ color, onChange, icon }: ColorPickerProps)
|
|
|
68
56
|
color={color}
|
|
69
57
|
onChangeComplete={(c: any) => {
|
|
70
58
|
onChange(c.hex);
|
|
71
|
-
// setOpen(false);
|
|
72
59
|
}}
|
|
73
60
|
/>
|
|
74
61
|
</div>,
|
|
75
62
|
document.body
|
|
76
|
-
)
|
|
77
|
-
}
|
|
63
|
+
)}
|
|
78
64
|
</div>
|
|
79
65
|
);
|
|
80
66
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "./ui/dialog";
|
|
3
|
-
import { Button } from "./ui/button";
|
|
4
1
|
import { useState } from "react";
|
|
5
2
|
import { VscPreview } from "react-icons/vsc";
|
|
3
|
+
import RawDialog from "./common/Dialog";
|
|
6
4
|
|
|
7
5
|
type HtmlPreviewProps = {
|
|
8
6
|
value: string;
|
|
@@ -11,7 +9,7 @@ type HtmlPreviewProps = {
|
|
|
11
9
|
export function HtmlPreview({ value }: HtmlPreviewProps) {
|
|
12
10
|
return (
|
|
13
11
|
<div
|
|
14
|
-
className="
|
|
12
|
+
className="lexical-text-editor-html-preview"
|
|
15
13
|
dangerouslySetInnerHTML={{ __html: value }}
|
|
16
14
|
/>
|
|
17
15
|
);
|
|
@@ -22,24 +20,32 @@ type ContentPreviewDialogProps = {
|
|
|
22
20
|
triggerLabel?: string;
|
|
23
21
|
};
|
|
24
22
|
|
|
25
|
-
export default function ContentPreviewDialog({
|
|
26
|
-
|
|
23
|
+
export default function ContentPreviewDialog({
|
|
24
|
+
value,
|
|
25
|
+
triggerLabel = "Preview",
|
|
26
|
+
}: ContentPreviewDialogProps) {
|
|
27
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
27
28
|
return (
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
<div className="lexical-text-editor-dialog">
|
|
30
|
+
{/* Trigger button */}
|
|
31
|
+
|
|
32
|
+
<button
|
|
33
|
+
className={`lexical-btn heading-trigger ${isOpen ? "toolbar-active" : "toolbar"}`}
|
|
34
|
+
onClick={() => setIsOpen((prev) => !prev)}
|
|
35
|
+
>
|
|
36
|
+
<VscPreview size={18} />
|
|
37
|
+
<span>{triggerLabel}</span>
|
|
38
|
+
</button>
|
|
39
|
+
|
|
40
|
+
{/* Dialog */}
|
|
41
|
+
<RawDialog open={isOpen} onClose={() => setIsOpen(false)} forPreview>
|
|
42
|
+
<div className="lte-dialog-header">Content Preview</div>
|
|
43
|
+
|
|
44
|
+
<div className="lte-preview-container">
|
|
45
|
+
<div className="lte-preview-title">CONTENT</div>
|
|
40
46
|
<HtmlPreview value={value} />
|
|
41
47
|
</div>
|
|
42
|
-
</
|
|
43
|
-
</
|
|
48
|
+
</RawDialog>
|
|
49
|
+
</div>
|
|
44
50
|
);
|
|
45
51
|
}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { Button } from "./ui/button"
|
|
2
|
-
import {
|
|
3
|
-
Popover,
|
|
4
|
-
PopoverContent,
|
|
5
|
-
PopoverTrigger,
|
|
6
|
-
} from "./ui/popover"
|
|
7
1
|
import { RICH_TEXT_FORMAT_OPTIONS, RichTextAction } from "../constants/index";
|
|
8
|
-
import { useState } from "react"
|
|
2
|
+
import { useRef, useState } from "react"
|
|
9
3
|
import { HiChevronDown } from "react-icons/hi2";
|
|
4
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./common/Popover";
|
|
10
5
|
|
|
11
6
|
interface Props {
|
|
12
7
|
onAction: (id: RichTextAction) => void,
|
|
@@ -16,26 +11,46 @@ interface Props {
|
|
|
16
11
|
}
|
|
17
12
|
export function DropdownList({ onAction, selectionMap }: Props) {
|
|
18
13
|
const [isOpen, setIsOpen] = useState(false)
|
|
14
|
+
const triggerRef = useRef<HTMLDivElement | null>(null);
|
|
15
|
+
const contentRef = useRef<HTMLDivElement | null>(null);
|
|
19
16
|
return (
|
|
20
|
-
<Popover open={isOpen} onOpenChange={
|
|
21
|
-
<PopoverTrigger
|
|
22
|
-
<
|
|
23
|
-
|
|
17
|
+
<Popover open={isOpen} onOpenChange={setIsOpen}>
|
|
18
|
+
<PopoverTrigger triggerRef={triggerRef}>
|
|
19
|
+
<button
|
|
20
|
+
className={`lexical-btn heading-trigger ${isOpen ? "toolbar-active" : "toolbar"}`}
|
|
21
|
+
onClick={() => setIsOpen((prev) => !prev)}
|
|
24
22
|
>
|
|
25
|
-
<span>Aa</span>
|
|
26
|
-
|
|
23
|
+
<span>Aa</span>
|
|
24
|
+
<HiChevronDown className={`chevron ${isOpen ? "rotated" : ""}`} />
|
|
25
|
+
</button>
|
|
27
26
|
</PopoverTrigger>
|
|
28
|
-
<PopoverContent
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
<PopoverContent open={isOpen} align="start" onClose={() => setIsOpen(false)} contentRef={contentRef}>
|
|
28
|
+
<div
|
|
29
|
+
style={{
|
|
30
|
+
display: 'flex', flexDirection: 'column', gap: 5
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
{
|
|
34
|
+
RICH_TEXT_FORMAT_OPTIONS.map(({ id, label, icon }) => (
|
|
35
|
+
<button
|
|
36
|
+
key={id}
|
|
37
|
+
className={`lexical-btn ${selectionMap[id] ? "toolbar-active" : "toolbar"
|
|
38
|
+
}`}
|
|
39
|
+
onClick={() => {
|
|
40
|
+
onAction(id);
|
|
41
|
+
setIsOpen(false)
|
|
42
|
+
}}
|
|
43
|
+
style={{
|
|
44
|
+
minWidth: 130
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
{icon}
|
|
48
|
+
<span className="label">{label}</span>
|
|
49
|
+
</button>
|
|
50
|
+
))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
</div>
|
|
39
54
|
</PopoverContent>
|
|
40
55
|
</Popover>
|
|
41
56
|
)
|
|
@@ -1,45 +1,61 @@
|
|
|
1
|
-
import { Button } from "./ui/button"
|
|
2
|
-
import {
|
|
3
|
-
Popover,
|
|
4
|
-
PopoverContent,
|
|
5
|
-
PopoverTrigger,
|
|
6
|
-
} from "./ui/popover"
|
|
7
1
|
import { HEADINGS } from "../constants/index";
|
|
8
|
-
import { type HeadingTagType } from
|
|
9
|
-
|
|
10
|
-
import { useState } from "react"
|
|
2
|
+
import { type HeadingTagType } from "@lexical/rich-text";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
11
4
|
import { HiChevronDown } from "react-icons/hi2";
|
|
5
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./common/Popover";
|
|
6
|
+
|
|
12
7
|
|
|
13
8
|
interface Props {
|
|
14
|
-
updateHeading: (heading: HeadingTagType | "normal") => void
|
|
15
|
-
headingSelectionMap: {
|
|
16
|
-
[id: string]: boolean;
|
|
17
|
-
}
|
|
9
|
+
updateHeading: (heading: HeadingTagType | "normal") => void;
|
|
10
|
+
headingSelectionMap: { [id: string]: boolean };
|
|
18
11
|
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
19
15
|
export function HeadingSelectionList({ updateHeading, headingSelectionMap }: Props) {
|
|
20
|
-
const activeHeading = HEADINGS.find(h => headingSelectionMap[h.id])
|
|
21
|
-
const [
|
|
16
|
+
const activeHeading = HEADINGS.find((h) => headingSelectionMap[h.id]);
|
|
17
|
+
const [open, setOpen] = useState(false);
|
|
18
|
+
const triggerRef = useRef<HTMLDivElement | null>(null);
|
|
19
|
+
const contentRef = useRef<HTMLDivElement | null>(null);
|
|
20
|
+
|
|
22
21
|
return (
|
|
23
|
-
<Popover open={
|
|
24
|
-
<PopoverTrigger
|
|
25
|
-
<
|
|
26
|
-
|
|
22
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
23
|
+
<PopoverTrigger triggerRef={triggerRef}>
|
|
24
|
+
<button
|
|
25
|
+
className={`lexical-btn heading-trigger ${open ? "toolbar-active" : "toolbar"}`}
|
|
26
|
+
onClick={() => setOpen((prev) => !prev)}
|
|
27
|
+
style={{
|
|
28
|
+
minWidth: 132
|
|
29
|
+
}}
|
|
27
30
|
>
|
|
28
|
-
{activeHeading?.icon}
|
|
29
|
-
|
|
31
|
+
{activeHeading?.icon}
|
|
32
|
+
<span>{activeHeading?.label}</span>
|
|
33
|
+
<HiChevronDown className={`chevron ${open ? "rotated" : ""}`} />
|
|
34
|
+
</button>
|
|
30
35
|
</PopoverTrigger>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
<PopoverContent open={open} align="start" onClose={() => setOpen(false)} contentRef={contentRef}>
|
|
38
|
+
<div
|
|
39
|
+
style={{
|
|
40
|
+
display: 'flex', flexDirection: 'column', gap: 5
|
|
41
|
+
}}>
|
|
42
|
+
{HEADINGS.map(({ id, label, icon }) => (
|
|
43
|
+
<button
|
|
44
|
+
key={id}
|
|
45
|
+
className={`lexical-btn ${headingSelectionMap[id] ? "toolbar-active" : "toolbar"
|
|
46
|
+
}`}
|
|
47
|
+
onClick={() => {
|
|
48
|
+
updateHeading(id as HeadingTagType | "normal");
|
|
49
|
+
setOpen(false);
|
|
50
|
+
}}
|
|
37
51
|
>
|
|
38
|
-
{icon}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
52
|
+
{icon}
|
|
53
|
+
<span className="label">{label}</span>
|
|
54
|
+
</button>
|
|
55
|
+
))}
|
|
56
|
+
</div>
|
|
42
57
|
</PopoverContent>
|
|
43
58
|
</Popover>
|
|
44
|
-
|
|
59
|
+
|
|
60
|
+
);
|
|
45
61
|
}
|