@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.
Files changed (101) hide show
  1. package/README.md +47 -0
  2. package/dist/editor-x/editor.cjs +732 -443
  3. package/dist/editor-x/editor.cjs.map +1 -1
  4. package/dist/editor-x/editor.css +1418 -1120
  5. package/dist/editor-x/editor.css.map +1 -1
  6. package/dist/editor-x/editor.d.cts +2 -1
  7. package/dist/editor-x/editor.d.ts +2 -1
  8. package/dist/editor-x/editor.js +736 -447
  9. package/dist/editor-x/editor.js.map +1 -1
  10. package/dist/index.cjs +772 -482
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.css +1418 -1120
  13. package/dist/index.css.map +1 -1
  14. package/dist/index.d.cts +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +775 -485
  17. package/dist/index.js.map +1 -1
  18. package/package.json +86 -84
  19. package/src/components/lexical-editor.tsx +140 -123
  20. package/src/editor-x/editor.tsx +20 -5
  21. package/src/editor-x/plugins.tsx +385 -380
  22. package/src/nodes/list-with-color-node.tsx +160 -160
  23. package/src/plugins/autocomplete-plugin.tsx +2574 -2574
  24. package/src/plugins/context-menu-plugin.tsx +239 -9
  25. package/src/plugins/floating-text-format-plugin.tsx +84 -92
  26. package/src/plugins/images-plugin.tsx +4 -4
  27. package/src/plugins/list-color-plugin.tsx +178 -178
  28. package/src/plugins/tab-focus-plugin.tsx +66 -66
  29. package/src/plugins/table-column-resizer-plugin.tsx +329 -190
  30. package/src/plugins/toolbar/block-format/block-format-data.tsx +4 -0
  31. package/src/plugins/toolbar/block-format/format-bulleted-list.tsx +40 -40
  32. package/src/plugins/toolbar/block-format/format-list-with-marker.tsx +74 -74
  33. package/src/plugins/toolbar/block-format/format-numbered-list.tsx +40 -40
  34. package/src/plugins/toolbar/block-format-toolbar-plugin.tsx +118 -117
  35. package/src/plugins/toolbar/element-format-toolbar-plugin.tsx +37 -53
  36. package/src/plugins/toolbar/font-format-toolbar-plugin.tsx +8 -15
  37. package/src/plugins/toolbar/font-size-toolbar-plugin.tsx +2 -3
  38. package/src/plugins/toolbar/history-toolbar-plugin.tsx +2 -5
  39. package/src/plugins/toolbar/subsuper-toolbar-plugin.tsx +15 -23
  40. package/src/themes/_mixins.scss +158 -10
  41. package/src/themes/_variables.scss +168 -0
  42. package/src/themes/core/_code.scss +59 -0
  43. package/src/themes/core/_images.scss +80 -0
  44. package/src/themes/core/_lists.scss +214 -0
  45. package/src/themes/core/_misc.scss +46 -0
  46. package/src/themes/core/_reset.scss +119 -0
  47. package/src/themes/core/_tables.scss +145 -0
  48. package/src/themes/core/_text.scss +35 -0
  49. package/src/themes/core/_typography.scss +73 -0
  50. package/src/themes/editor-theme.scss +9 -623
  51. package/src/themes/editor-theme.ts +118 -118
  52. package/src/themes/plugins/_auto-embed.scss +11 -0
  53. package/src/themes/plugins/_color-picker.scss +103 -0
  54. package/src/themes/plugins/_draggable-block.scss +32 -0
  55. package/src/themes/plugins/_floating-link-editor.scss +47 -0
  56. package/src/themes/plugins/_floating-toolbars.scss +61 -0
  57. package/src/themes/plugins/_image-resizer.scss +38 -0
  58. package/src/themes/plugins/_image.scss +57 -0
  59. package/src/themes/plugins/_layout.scss +39 -0
  60. package/src/themes/plugins/_list-color.scss +23 -0
  61. package/src/themes/plugins/_mentions.scss +21 -0
  62. package/src/themes/plugins/_menus-and-pickers.scss +153 -0
  63. package/src/themes/plugins/_table.scss +20 -0
  64. package/src/themes/plugins/_toolbar.scss +36 -0
  65. package/src/themes/plugins/_tree-view.scss +11 -0
  66. package/src/themes/plugins.scss +20 -1165
  67. package/src/themes/ui-components/_animations.scss +31 -0
  68. package/src/themes/ui-components/_backgrounds.scss +27 -0
  69. package/src/themes/ui-components/_borders.scss +20 -0
  70. package/src/themes/ui-components/_button.scss +176 -0
  71. package/src/themes/ui-components/_checkbox.scss +14 -0
  72. package/src/themes/ui-components/_cursors.scss +31 -0
  73. package/src/themes/ui-components/_dialog.scss +86 -0
  74. package/src/themes/ui-components/_display-sizing.scss +100 -0
  75. package/src/themes/ui-components/_flex.scss +124 -0
  76. package/src/themes/ui-components/_form-layout.scss +15 -0
  77. package/src/themes/ui-components/_icons.scss +23 -0
  78. package/src/themes/ui-components/_input.scss +86 -0
  79. package/src/themes/ui-components/_label.scss +19 -0
  80. package/src/themes/ui-components/_loader.scss +9 -0
  81. package/src/themes/ui-components/_margins-paddings.scss +45 -0
  82. package/src/themes/ui-components/_popover.scss +16 -0
  83. package/src/themes/ui-components/_positioning.scss +73 -0
  84. package/src/themes/ui-components/_rounded.scss +19 -0
  85. package/src/themes/ui-components/_scroll-area.scss +11 -0
  86. package/src/themes/ui-components/_select.scss +110 -0
  87. package/src/themes/ui-components/_separator.scss +19 -0
  88. package/src/themes/ui-components/_shadow.scss +15 -0
  89. package/src/themes/ui-components/_tabs.scss +46 -0
  90. package/src/themes/ui-components/_text-utilities.scss +48 -0
  91. package/src/themes/ui-components/_toggle-toolbar.scss +128 -0
  92. package/src/themes/ui-components/_toggle.scss +80 -0
  93. package/src/themes/ui-components/_typography.scss +22 -0
  94. package/src/themes/ui-components.scss +27 -937
  95. package/src/transformers/markdown-list-transformer.ts +51 -51
  96. package/src/ui/button.tsx +11 -2
  97. package/src/ui/collapsible.tsx +1 -1
  98. package/src/ui/dialog.tsx +2 -2
  99. package/src/ui/flex.tsx +4 -4
  100. package/src/ui/popover.tsx +1 -1
  101. 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
  )
@@ -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<any>, { onClick: handleClick, ...props })
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<any>, {
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<any>, {
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-flex--items-${align}`,
27
- justify && `editor-flex--justify-${justify}`,
28
- direction && `editor-flex--flex-${direction}`,
29
- wrap && `editor-flex--flex-${wrap}`,
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 }}
@@ -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<any>, {
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
@@ -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<any>, {
11
+ return React.cloneElement(child as React.ReactElement<React.HTMLAttributes<HTMLElement>>, {
12
12
  ...props,
13
- className: cn((child as React.ReactElement<any>).props.className, "editor-tooltip-trigger")
13
+ className: cn((child as React.ReactElement<React.HTMLAttributes<HTMLElement>>).props.className, "editor-tooltip-trigger")
14
14
  })
15
15
  }
16
16