@thangph2146/lexical-editor 0.0.4 → 0.0.6
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 +47 -0
- package/dist/editor-x/editor.cjs +732 -443
- package/dist/editor-x/editor.cjs.map +1 -1
- package/dist/editor-x/editor.css +1418 -1120
- package/dist/editor-x/editor.css.map +1 -1
- package/dist/editor-x/editor.d.cts +2 -1
- package/dist/editor-x/editor.d.ts +2 -1
- package/dist/editor-x/editor.js +736 -447
- package/dist/editor-x/editor.js.map +1 -1
- package/dist/index.cjs +772 -482
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1418 -1120
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +775 -485
- package/dist/index.js.map +1 -1
- package/package.json +86 -84
- package/src/components/lexical-editor.tsx +140 -123
- package/src/editor-x/editor.tsx +20 -5
- package/src/editor-x/plugins.tsx +385 -380
- package/src/nodes/list-with-color-node.tsx +160 -160
- package/src/plugins/autocomplete-plugin.tsx +2574 -2574
- package/src/plugins/context-menu-plugin.tsx +239 -9
- package/src/plugins/floating-text-format-plugin.tsx +84 -92
- package/src/plugins/images-plugin.tsx +4 -4
- package/src/plugins/list-color-plugin.tsx +178 -178
- package/src/plugins/tab-focus-plugin.tsx +66 -66
- package/src/plugins/table-column-resizer-plugin.tsx +329 -190
- package/src/plugins/toolbar/block-format/block-format-data.tsx +4 -0
- package/src/plugins/toolbar/block-format/format-bulleted-list.tsx +40 -40
- package/src/plugins/toolbar/block-format/format-list-with-marker.tsx +74 -74
- package/src/plugins/toolbar/block-format/format-numbered-list.tsx +40 -40
- package/src/plugins/toolbar/block-format-toolbar-plugin.tsx +118 -117
- package/src/plugins/toolbar/element-format-toolbar-plugin.tsx +37 -53
- package/src/plugins/toolbar/font-format-toolbar-plugin.tsx +8 -15
- package/src/plugins/toolbar/font-size-toolbar-plugin.tsx +2 -3
- package/src/plugins/toolbar/history-toolbar-plugin.tsx +2 -5
- package/src/plugins/toolbar/subsuper-toolbar-plugin.tsx +15 -23
- package/src/themes/_mixins.scss +158 -10
- package/src/themes/_variables.scss +168 -0
- package/src/themes/core/_code.scss +59 -0
- package/src/themes/core/_images.scss +80 -0
- package/src/themes/core/_lists.scss +214 -0
- package/src/themes/core/_misc.scss +46 -0
- package/src/themes/core/_reset.scss +119 -0
- package/src/themes/core/_tables.scss +145 -0
- package/src/themes/core/_text.scss +35 -0
- package/src/themes/core/_typography.scss +73 -0
- package/src/themes/editor-theme.scss +9 -623
- package/src/themes/editor-theme.ts +118 -118
- package/src/themes/plugins/_auto-embed.scss +11 -0
- package/src/themes/plugins/_color-picker.scss +103 -0
- package/src/themes/plugins/_draggable-block.scss +32 -0
- package/src/themes/plugins/_floating-link-editor.scss +47 -0
- package/src/themes/plugins/_floating-toolbars.scss +61 -0
- package/src/themes/plugins/_image-resizer.scss +38 -0
- package/src/themes/plugins/_image.scss +57 -0
- package/src/themes/plugins/_layout.scss +39 -0
- package/src/themes/plugins/_list-color.scss +23 -0
- package/src/themes/plugins/_mentions.scss +21 -0
- package/src/themes/plugins/_menus-and-pickers.scss +153 -0
- package/src/themes/plugins/_table.scss +20 -0
- package/src/themes/plugins/_toolbar.scss +36 -0
- package/src/themes/plugins/_tree-view.scss +11 -0
- package/src/themes/plugins.scss +20 -1165
- package/src/themes/ui-components/_animations.scss +31 -0
- package/src/themes/ui-components/_backgrounds.scss +27 -0
- package/src/themes/ui-components/_borders.scss +20 -0
- package/src/themes/ui-components/_button.scss +176 -0
- package/src/themes/ui-components/_checkbox.scss +14 -0
- package/src/themes/ui-components/_cursors.scss +31 -0
- package/src/themes/ui-components/_dialog.scss +86 -0
- package/src/themes/ui-components/_display-sizing.scss +100 -0
- package/src/themes/ui-components/_flex.scss +124 -0
- package/src/themes/ui-components/_form-layout.scss +15 -0
- package/src/themes/ui-components/_icons.scss +23 -0
- package/src/themes/ui-components/_input.scss +86 -0
- package/src/themes/ui-components/_label.scss +19 -0
- package/src/themes/ui-components/_loader.scss +9 -0
- package/src/themes/ui-components/_margins-paddings.scss +45 -0
- package/src/themes/ui-components/_popover.scss +16 -0
- package/src/themes/ui-components/_positioning.scss +73 -0
- package/src/themes/ui-components/_rounded.scss +19 -0
- package/src/themes/ui-components/_scroll-area.scss +11 -0
- package/src/themes/ui-components/_select.scss +110 -0
- package/src/themes/ui-components/_separator.scss +19 -0
- package/src/themes/ui-components/_shadow.scss +15 -0
- package/src/themes/ui-components/_tabs.scss +46 -0
- package/src/themes/ui-components/_text-utilities.scss +48 -0
- package/src/themes/ui-components/_toggle-toolbar.scss +128 -0
- package/src/themes/ui-components/_toggle.scss +80 -0
- package/src/themes/ui-components/_typography.scss +22 -0
- package/src/themes/ui-components.scss +27 -937
- package/src/transformers/markdown-list-transformer.ts +51 -51
- package/src/ui/button.tsx +11 -2
- package/src/ui/collapsible.tsx +1 -1
- package/src/ui/dialog.tsx +2 -2
- package/src/ui/flex.tsx +4 -4
- package/src/ui/popover.tsx +1 -1
- package/src/ui/tooltip.tsx +2 -2
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
$createListItemNode,
|
|
3
|
-
$isListItemNode,
|
|
4
|
-
$isListNode,
|
|
5
|
-
ListItemNode,
|
|
6
|
-
ListNode,
|
|
7
|
-
} from "@lexical/list"
|
|
8
|
-
import { ElementTransformer } from "@lexical/markdown"
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
$createListWithColorNode,
|
|
12
|
-
$isListWithColorNode,
|
|
13
|
-
ListWithColorNode,
|
|
14
|
-
} from "../nodes/list-with-color-node"
|
|
15
|
-
|
|
16
|
-
export const UNORDERED_LIST: ElementTransformer = {
|
|
17
|
-
dependencies: [ListWithColorNode, ListNode, ListItemNode],
|
|
18
|
-
export: (node) => {
|
|
19
|
-
if (!$isListNode(node) || node.getListType() !== "bullet") {
|
|
20
|
-
return null
|
|
21
|
-
}
|
|
22
|
-
const marker = $isListWithColorNode(node) ? node.getMarkerType() || "-" : "-"
|
|
23
|
-
const children = node.getChildren()
|
|
24
|
-
const output = []
|
|
25
|
-
for (const child of children) {
|
|
26
|
-
if ($isListItemNode(child)) {
|
|
27
|
-
output.push(`${marker} ${child.getTextContent()}`)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return output.join("\n")
|
|
31
|
-
},
|
|
32
|
-
regExp: /^(\s*)([*+-])\s/,
|
|
33
|
-
replace: (parentNode, _children, match, isImport) => {
|
|
34
|
-
const marker = match[2]
|
|
35
|
-
const list = $createListWithColorNode("bullet")
|
|
36
|
-
|
|
37
|
-
if (marker === "-" || marker === "+") {
|
|
38
|
-
list.setMarkerType(marker)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (isImport || parentNode.getNextSibling() != null) {
|
|
42
|
-
parentNode.replace(list)
|
|
43
|
-
} else {
|
|
44
|
-
parentNode.insertBefore(list)
|
|
45
|
-
}
|
|
46
|
-
const item = $createListItemNode()
|
|
47
|
-
list.append(item)
|
|
48
|
-
item.select()
|
|
49
|
-
},
|
|
50
|
-
type: "element",
|
|
51
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
$createListItemNode,
|
|
3
|
+
$isListItemNode,
|
|
4
|
+
$isListNode,
|
|
5
|
+
ListItemNode,
|
|
6
|
+
ListNode,
|
|
7
|
+
} from "@lexical/list"
|
|
8
|
+
import { ElementTransformer } from "@lexical/markdown"
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
$createListWithColorNode,
|
|
12
|
+
$isListWithColorNode,
|
|
13
|
+
ListWithColorNode,
|
|
14
|
+
} from "../nodes/list-with-color-node"
|
|
15
|
+
|
|
16
|
+
export const UNORDERED_LIST: ElementTransformer = {
|
|
17
|
+
dependencies: [ListWithColorNode, ListNode, ListItemNode],
|
|
18
|
+
export: (node) => {
|
|
19
|
+
if (!$isListNode(node) || node.getListType() !== "bullet") {
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
const marker = $isListWithColorNode(node) ? node.getMarkerType() || "-" : "-"
|
|
23
|
+
const children = node.getChildren()
|
|
24
|
+
const output = []
|
|
25
|
+
for (const child of children) {
|
|
26
|
+
if ($isListItemNode(child)) {
|
|
27
|
+
output.push(`${marker} ${child.getTextContent()}`)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return output.join("\n")
|
|
31
|
+
},
|
|
32
|
+
regExp: /^(\s*)([*+-])\s/,
|
|
33
|
+
replace: (parentNode, _children, match, isImport) => {
|
|
34
|
+
const marker = match[2]
|
|
35
|
+
const list = $createListWithColorNode("bullet")
|
|
36
|
+
|
|
37
|
+
if (marker === "-" || marker === "+") {
|
|
38
|
+
list.setMarkerType(marker)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (isImport || parentNode.getNextSibling() != null) {
|
|
42
|
+
parentNode.replace(list)
|
|
43
|
+
} else {
|
|
44
|
+
parentNode.insertBefore(list)
|
|
45
|
+
}
|
|
46
|
+
const item = $createListItemNode()
|
|
47
|
+
list.append(item)
|
|
48
|
+
item.select()
|
|
49
|
+
},
|
|
50
|
+
type: "element",
|
|
51
|
+
}
|
package/src/ui/button.tsx
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import * as React from "react"
|
|
2
2
|
import { cn } from "../lib/utils"
|
|
3
|
+
import { Loader2 } from "lucide-react"
|
|
3
4
|
|
|
4
5
|
export interface ButtonProps
|
|
5
6
|
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
6
7
|
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link"
|
|
7
8
|
size?: "default" | "sm" | "md" | "lg" | "icon"
|
|
9
|
+
isLoading?: boolean
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
11
|
-
({ className, variant = "default", size = "default", type = "button", ...props }, ref) => {
|
|
13
|
+
({ className, variant = "default", size = "default", type = "button", isLoading, disabled, children, ...props }, ref) => {
|
|
12
14
|
return (
|
|
13
15
|
<button
|
|
14
16
|
type={type}
|
|
@@ -16,11 +18,18 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
16
18
|
"editor-btn",
|
|
17
19
|
variant !== "default" && `editor-btn--${variant}`,
|
|
18
20
|
size !== "default" && `editor-btn--size-${size}`,
|
|
21
|
+
isLoading && "editor-btn--loading",
|
|
19
22
|
className
|
|
20
23
|
)}
|
|
24
|
+
disabled={isLoading || disabled}
|
|
21
25
|
ref={ref}
|
|
22
26
|
{...props}
|
|
23
|
-
|
|
27
|
+
>
|
|
28
|
+
{isLoading && <Loader2 className="editor-btn__loader editor-animate-spin" size={16} />}
|
|
29
|
+
<span className={cn("editor-btn__content", isLoading && "editor-opacity-0")}>
|
|
30
|
+
{children}
|
|
31
|
+
</span>
|
|
32
|
+
</button>
|
|
24
33
|
)
|
|
25
34
|
}
|
|
26
35
|
)
|
package/src/ui/collapsible.tsx
CHANGED
|
@@ -43,7 +43,7 @@ export function CollapsibleTrigger({ children, asChild, ...props }: React.HTMLAt
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
if (asChild && React.isValidElement(children)) {
|
|
46
|
-
return React.cloneElement(children as React.ReactElement<
|
|
46
|
+
return React.cloneElement(children as React.ReactElement<React.HTMLAttributes<HTMLElement>>, { onClick: handleClick, ...props })
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return (
|
package/src/ui/dialog.tsx
CHANGED
|
@@ -34,7 +34,7 @@ export function DialogTrigger({ asChild, children, className, ...props }: React.
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
if (asChild && React.isValidElement(children)) {
|
|
37
|
-
return React.cloneElement(children as React.ReactElement<
|
|
37
|
+
return React.cloneElement(children as React.ReactElement<React.HTMLAttributes<HTMLElement>>, {
|
|
38
38
|
onClick: handleClick,
|
|
39
39
|
...props
|
|
40
40
|
})
|
|
@@ -58,7 +58,7 @@ export function DialogClose({ asChild, children, className, ...props }: React.HT
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
if (asChild && React.isValidElement(children)) {
|
|
61
|
-
return React.cloneElement(children as React.ReactElement<
|
|
61
|
+
return React.cloneElement(children as React.ReactElement<React.HTMLAttributes<HTMLElement>>, {
|
|
62
62
|
onClick: handleClick,
|
|
63
63
|
...props
|
|
64
64
|
})
|
package/src/ui/flex.tsx
CHANGED
|
@@ -23,10 +23,10 @@ export const Flex = React.forwardRef<HTMLDivElement, FlexProps>(
|
|
|
23
23
|
ref={ref}
|
|
24
24
|
className={cn(
|
|
25
25
|
"editor-flex",
|
|
26
|
-
align && `editor-
|
|
27
|
-
justify && `editor-
|
|
28
|
-
direction && `editor-flex
|
|
29
|
-
wrap && `editor-flex
|
|
26
|
+
align && `editor-items-${align}`,
|
|
27
|
+
justify && `editor-justify-${justify}`,
|
|
28
|
+
direction && `editor-flex-${direction}`,
|
|
29
|
+
wrap && `editor-flex-${wrap}`,
|
|
30
30
|
className
|
|
31
31
|
)}
|
|
32
32
|
style={{ ...gapStyle, ...style }}
|
package/src/ui/popover.tsx
CHANGED
|
@@ -50,7 +50,7 @@ export function PopoverTrigger({ children, asChild, ...props }: React.HTMLAttrib
|
|
|
50
50
|
|
|
51
51
|
if (asChild && React.isValidElement(children)) {
|
|
52
52
|
// eslint-disable-next-line react-hooks/refs
|
|
53
|
-
return React.cloneElement(children as React.ReactElement<
|
|
53
|
+
return React.cloneElement(children as React.ReactElement<React.HTMLAttributes<HTMLElement> & { ref?: React.Ref<HTMLElement> }>, {
|
|
54
54
|
ref: triggerRef,
|
|
55
55
|
onClick: handleClick,
|
|
56
56
|
...props
|
package/src/ui/tooltip.tsx
CHANGED
|
@@ -8,9 +8,9 @@ export const Tooltip = ({ children }: { children: React.ReactNode, disableHovera
|
|
|
8
8
|
export const TooltipTrigger = ({ asChild, children, ...props }: React.HTMLAttributes<HTMLElement> & { asChild?: boolean, children: React.ReactNode }) => {
|
|
9
9
|
const child = asChild ? React.Children.only(children) : children
|
|
10
10
|
if (!React.isValidElement(child)) return null
|
|
11
|
-
return React.cloneElement(child as React.ReactElement<
|
|
11
|
+
return React.cloneElement(child as React.ReactElement<React.HTMLAttributes<HTMLElement>>, {
|
|
12
12
|
...props,
|
|
13
|
-
className: cn((child as React.ReactElement<
|
|
13
|
+
className: cn((child as React.ReactElement<React.HTMLAttributes<HTMLElement>>).props.className, "editor-tooltip-trigger")
|
|
14
14
|
})
|
|
15
15
|
}
|
|
16
16
|
|