@thangph2146/lexical-editor 0.0.3 → 0.0.5

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 (100) hide show
  1. package/dist/editor-x/editor.cjs +724 -435
  2. package/dist/editor-x/editor.cjs.map +1 -1
  3. package/dist/editor-x/editor.css +1391 -1091
  4. package/dist/editor-x/editor.css.map +1 -1
  5. package/dist/editor-x/editor.js +728 -439
  6. package/dist/editor-x/editor.js.map +1 -1
  7. package/dist/index.cjs +760 -472
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.css +1391 -1091
  10. package/dist/index.css.map +1 -1
  11. package/dist/index.js +763 -475
  12. package/dist/index.js.map +1 -1
  13. package/package.json +1 -1
  14. package/src/components/lexical-editor.tsx +138 -123
  15. package/src/editor-ui/content-editable.tsx +3 -3
  16. package/src/editor-x/editor.tsx +16 -3
  17. package/src/editor-x/plugins.tsx +385 -380
  18. package/src/nodes/list-with-color-node.tsx +160 -160
  19. package/src/plugins/autocomplete-plugin.tsx +2574 -2574
  20. package/src/plugins/context-menu-plugin.tsx +239 -9
  21. package/src/plugins/floating-text-format-plugin.tsx +84 -92
  22. package/src/plugins/images-plugin.tsx +4 -4
  23. package/src/plugins/list-color-plugin.tsx +178 -178
  24. package/src/plugins/tab-focus-plugin.tsx +66 -66
  25. package/src/plugins/table-column-resizer-plugin.tsx +329 -190
  26. package/src/plugins/toolbar/block-format/block-format-data.tsx +4 -0
  27. package/src/plugins/toolbar/block-format/format-bulleted-list.tsx +40 -40
  28. package/src/plugins/toolbar/block-format/format-list-with-marker.tsx +74 -74
  29. package/src/plugins/toolbar/block-format/format-numbered-list.tsx +40 -40
  30. package/src/plugins/toolbar/block-format-toolbar-plugin.tsx +118 -117
  31. package/src/plugins/toolbar/element-format-toolbar-plugin.tsx +37 -53
  32. package/src/plugins/toolbar/font-format-toolbar-plugin.tsx +8 -15
  33. package/src/plugins/toolbar/font-size-toolbar-plugin.tsx +2 -3
  34. package/src/plugins/toolbar/history-toolbar-plugin.tsx +2 -5
  35. package/src/plugins/toolbar/subsuper-toolbar-plugin.tsx +15 -23
  36. package/src/themes/_mixins.scss +158 -10
  37. package/src/themes/_variables.scss +168 -0
  38. package/src/themes/core/_code.scss +59 -0
  39. package/src/themes/core/_images.scss +80 -0
  40. package/src/themes/core/_lists.scss +214 -0
  41. package/src/themes/core/_misc.scss +46 -0
  42. package/src/themes/core/_reset.scss +119 -0
  43. package/src/themes/core/_tables.scss +145 -0
  44. package/src/themes/core/_text.scss +35 -0
  45. package/src/themes/core/_typography.scss +73 -0
  46. package/src/themes/editor-theme copy.scss +763 -0
  47. package/src/themes/editor-theme.scss +9 -621
  48. package/src/themes/editor-theme.ts +118 -118
  49. package/src/themes/plugins/_auto-embed.scss +11 -0
  50. package/src/themes/plugins/_color-picker.scss +103 -0
  51. package/src/themes/plugins/_draggable-block.scss +32 -0
  52. package/src/themes/plugins/_floating-link-editor.scss +47 -0
  53. package/src/themes/plugins/_floating-toolbars.scss +61 -0
  54. package/src/themes/plugins/_image-resizer.scss +38 -0
  55. package/src/themes/plugins/_image.scss +57 -0
  56. package/src/themes/plugins/_layout.scss +39 -0
  57. package/src/themes/plugins/_list-color.scss +23 -0
  58. package/src/themes/plugins/_mentions.scss +21 -0
  59. package/src/themes/plugins/_menus-and-pickers.scss +153 -0
  60. package/src/themes/plugins/_table.scss +20 -0
  61. package/src/themes/plugins/_toolbar.scss +36 -0
  62. package/src/themes/plugins/_tree-view.scss +11 -0
  63. package/src/themes/plugins copy.scss +656 -0
  64. package/src/themes/plugins.scss +20 -1165
  65. package/src/themes/ui-components/_animations.scss +31 -0
  66. package/src/themes/ui-components/_backgrounds.scss +27 -0
  67. package/src/themes/ui-components/_borders.scss +20 -0
  68. package/src/themes/ui-components/_button.scss +176 -0
  69. package/src/themes/ui-components/_checkbox.scss +14 -0
  70. package/src/themes/ui-components/_cursors.scss +31 -0
  71. package/src/themes/ui-components/_dialog.scss +86 -0
  72. package/src/themes/ui-components/_display-sizing.scss +100 -0
  73. package/src/themes/ui-components/_flex.scss +124 -0
  74. package/src/themes/ui-components/_form-layout.scss +15 -0
  75. package/src/themes/ui-components/_icons.scss +23 -0
  76. package/src/themes/ui-components/_input.scss +86 -0
  77. package/src/themes/ui-components/_label.scss +19 -0
  78. package/src/themes/ui-components/_loader.scss +9 -0
  79. package/src/themes/ui-components/_margins-paddings.scss +45 -0
  80. package/src/themes/ui-components/_popover.scss +16 -0
  81. package/src/themes/ui-components/_positioning.scss +73 -0
  82. package/src/themes/ui-components/_rounded.scss +19 -0
  83. package/src/themes/ui-components/_scroll-area.scss +11 -0
  84. package/src/themes/ui-components/_select.scss +110 -0
  85. package/src/themes/ui-components/_separator.scss +19 -0
  86. package/src/themes/ui-components/_shadow.scss +15 -0
  87. package/src/themes/ui-components/_tabs.scss +46 -0
  88. package/src/themes/ui-components/_text-utilities.scss +48 -0
  89. package/src/themes/ui-components/_toggle-toolbar.scss +128 -0
  90. package/src/themes/ui-components/_toggle.scss +80 -0
  91. package/src/themes/ui-components/_typography.scss +22 -0
  92. package/src/themes/ui-components copy.scss +1335 -0
  93. package/src/themes/ui-components.scss +27 -937
  94. package/src/transformers/markdown-list-transformer.ts +51 -51
  95. package/src/ui/button.tsx +11 -2
  96. package/src/ui/collapsible.tsx +1 -1
  97. package/src/ui/dialog.tsx +2 -2
  98. package/src/ui/flex.tsx +4 -4
  99. package/src/ui/popover.tsx +1 -1
  100. 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