@thangph2146/lexical-editor 0.0.4 → 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 (99) hide show
  1. package/dist/editor-x/editor.cjs +721 -432
  2. package/dist/editor-x/editor.cjs.map +1 -1
  3. package/dist/editor-x/editor.css +1418 -1120
  4. package/dist/editor-x/editor.css.map +1 -1
  5. package/dist/editor-x/editor.js +725 -436
  6. package/dist/editor-x/editor.js.map +1 -1
  7. package/dist/index.cjs +757 -469
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.css +1418 -1120
  10. package/dist/index.css.map +1 -1
  11. package/dist/index.js +760 -472
  12. package/dist/index.js.map +1 -1
  13. package/package.json +3 -3
  14. package/src/components/lexical-editor.tsx +138 -123
  15. package/src/editor-x/editor.tsx +16 -3
  16. package/src/editor-x/plugins.tsx +385 -380
  17. package/src/nodes/list-with-color-node.tsx +160 -160
  18. package/src/plugins/autocomplete-plugin.tsx +2574 -2574
  19. package/src/plugins/context-menu-plugin.tsx +239 -9
  20. package/src/plugins/floating-text-format-plugin.tsx +84 -92
  21. package/src/plugins/images-plugin.tsx +4 -4
  22. package/src/plugins/list-color-plugin.tsx +178 -178
  23. package/src/plugins/tab-focus-plugin.tsx +66 -66
  24. package/src/plugins/table-column-resizer-plugin.tsx +329 -190
  25. package/src/plugins/toolbar/block-format/block-format-data.tsx +4 -0
  26. package/src/plugins/toolbar/block-format/format-bulleted-list.tsx +40 -40
  27. package/src/plugins/toolbar/block-format/format-list-with-marker.tsx +74 -74
  28. package/src/plugins/toolbar/block-format/format-numbered-list.tsx +40 -40
  29. package/src/plugins/toolbar/block-format-toolbar-plugin.tsx +118 -117
  30. package/src/plugins/toolbar/element-format-toolbar-plugin.tsx +37 -53
  31. package/src/plugins/toolbar/font-format-toolbar-plugin.tsx +8 -15
  32. package/src/plugins/toolbar/font-size-toolbar-plugin.tsx +2 -3
  33. package/src/plugins/toolbar/history-toolbar-plugin.tsx +2 -5
  34. package/src/plugins/toolbar/subsuper-toolbar-plugin.tsx +15 -23
  35. package/src/themes/_mixins.scss +158 -10
  36. package/src/themes/_variables.scss +168 -0
  37. package/src/themes/core/_code.scss +59 -0
  38. package/src/themes/core/_images.scss +80 -0
  39. package/src/themes/core/_lists.scss +214 -0
  40. package/src/themes/core/_misc.scss +46 -0
  41. package/src/themes/core/_reset.scss +119 -0
  42. package/src/themes/core/_tables.scss +145 -0
  43. package/src/themes/core/_text.scss +35 -0
  44. package/src/themes/core/_typography.scss +73 -0
  45. package/src/themes/editor-theme copy.scss +763 -0
  46. package/src/themes/editor-theme.scss +9 -623
  47. package/src/themes/editor-theme.ts +118 -118
  48. package/src/themes/plugins/_auto-embed.scss +11 -0
  49. package/src/themes/plugins/_color-picker.scss +103 -0
  50. package/src/themes/plugins/_draggable-block.scss +32 -0
  51. package/src/themes/plugins/_floating-link-editor.scss +47 -0
  52. package/src/themes/plugins/_floating-toolbars.scss +61 -0
  53. package/src/themes/plugins/_image-resizer.scss +38 -0
  54. package/src/themes/plugins/_image.scss +57 -0
  55. package/src/themes/plugins/_layout.scss +39 -0
  56. package/src/themes/plugins/_list-color.scss +23 -0
  57. package/src/themes/plugins/_mentions.scss +21 -0
  58. package/src/themes/plugins/_menus-and-pickers.scss +153 -0
  59. package/src/themes/plugins/_table.scss +20 -0
  60. package/src/themes/plugins/_toolbar.scss +36 -0
  61. package/src/themes/plugins/_tree-view.scss +11 -0
  62. package/src/themes/plugins copy.scss +656 -0
  63. package/src/themes/plugins.scss +20 -1165
  64. package/src/themes/ui-components/_animations.scss +31 -0
  65. package/src/themes/ui-components/_backgrounds.scss +27 -0
  66. package/src/themes/ui-components/_borders.scss +20 -0
  67. package/src/themes/ui-components/_button.scss +176 -0
  68. package/src/themes/ui-components/_checkbox.scss +14 -0
  69. package/src/themes/ui-components/_cursors.scss +31 -0
  70. package/src/themes/ui-components/_dialog.scss +86 -0
  71. package/src/themes/ui-components/_display-sizing.scss +100 -0
  72. package/src/themes/ui-components/_flex.scss +124 -0
  73. package/src/themes/ui-components/_form-layout.scss +15 -0
  74. package/src/themes/ui-components/_icons.scss +23 -0
  75. package/src/themes/ui-components/_input.scss +86 -0
  76. package/src/themes/ui-components/_label.scss +19 -0
  77. package/src/themes/ui-components/_loader.scss +9 -0
  78. package/src/themes/ui-components/_margins-paddings.scss +45 -0
  79. package/src/themes/ui-components/_popover.scss +16 -0
  80. package/src/themes/ui-components/_positioning.scss +73 -0
  81. package/src/themes/ui-components/_rounded.scss +19 -0
  82. package/src/themes/ui-components/_scroll-area.scss +11 -0
  83. package/src/themes/ui-components/_select.scss +110 -0
  84. package/src/themes/ui-components/_separator.scss +19 -0
  85. package/src/themes/ui-components/_shadow.scss +15 -0
  86. package/src/themes/ui-components/_tabs.scss +46 -0
  87. package/src/themes/ui-components/_text-utilities.scss +48 -0
  88. package/src/themes/ui-components/_toggle-toolbar.scss +128 -0
  89. package/src/themes/ui-components/_toggle.scss +80 -0
  90. package/src/themes/ui-components/_typography.scss +22 -0
  91. package/src/themes/ui-components copy.scss +1335 -0
  92. package/src/themes/ui-components.scss +27 -937
  93. package/src/transformers/markdown-list-transformer.ts +51 -51
  94. package/src/ui/button.tsx +11 -2
  95. package/src/ui/collapsible.tsx +1 -1
  96. package/src/ui/dialog.tsx +2 -2
  97. package/src/ui/flex.tsx +4 -4
  98. package/src/ui/popover.tsx +1 -1
  99. package/src/ui/tooltip.tsx +2 -2
@@ -1,160 +1,160 @@
1
- "use client"
2
-
3
- import type { DOMExportOutput, EditorConfig, LexicalEditor } from "lexical"
4
- import {
5
- ListNode,
6
- type ListType,
7
- type SerializedListNode,
8
- } from "@lexical/list"
9
- import type { LexicalNode, LexicalUpdateJSON, NodeKey } from "lexical"
10
- import { $applyNodeReplacement } from "lexical"
11
-
12
- export type SerializedListWithColorNode = Omit<SerializedListNode, "type"> & {
13
- type: "listwithcolor"
14
- listColor?: string
15
- markerType?: string
16
- }
17
-
18
- const LIST_WITH_COLOR_TYPE = "listwithcolor"
19
-
20
- function applyListAttributesToDom(dom: HTMLElement, color?: string, markerType?: string): void {
21
- if (color) {
22
- dom.style.setProperty("--list-marker-color", color, "important")
23
- dom.setAttribute("data-list-color", color)
24
- } else {
25
- dom.style.removeProperty("--list-marker-color")
26
- dom.removeAttribute("data-list-color")
27
- }
28
- if (markerType) {
29
- dom.setAttribute("data-list-marker", markerType)
30
- } else {
31
- dom.removeAttribute("data-list-marker")
32
- }
33
- }
34
-
35
- export class ListWithColorNode extends ListNode {
36
- __listColor?: string
37
- __markerType?: string
38
-
39
- constructor(listType?: ListType, start?: number, key?: NodeKey) {
40
- super(listType, start, key)
41
- }
42
-
43
- static getType(): "listwithcolor" {
44
- return LIST_WITH_COLOR_TYPE
45
- }
46
-
47
- override getType(): "listwithcolor" {
48
- return LIST_WITH_COLOR_TYPE
49
- }
50
-
51
- static override clone(node: ListWithColorNode, key?: NodeKey): ListWithColorNode {
52
- const listType = node.getListType()
53
- const start = node.getStart()
54
- const sameKey = key ?? node.getKey()
55
- const cloned = new ListWithColorNode(listType, start, sameKey)
56
- if (node.__listColor) cloned.__listColor = node.__listColor
57
- if (node.__markerType) cloned.__markerType = node.__markerType
58
- return cloned
59
- }
60
-
61
- static override importJSON(
62
- serializedNode: SerializedListWithColorNode
63
- ): ListWithColorNode {
64
- const { listType, start, listColor, markerType } = serializedNode
65
- const node = new ListWithColorNode(listType, start)
66
- if (listColor != null) node.__listColor = listColor
67
- if (markerType != null) node.__markerType = markerType
68
- return node
69
- }
70
-
71
- override afterCloneFrom(prevNode: ListWithColorNode): void {
72
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Lexical ListNode.afterCloneFrom(prevNode: this) không chấp nhận subtype
73
- super.afterCloneFrom(prevNode as any)
74
- this.__listColor = prevNode.__listColor
75
- this.__markerType = prevNode.__markerType
76
- }
77
-
78
- getListColor(): string | undefined {
79
- return this.getLatest().__listColor
80
- }
81
-
82
- setListColor(color: string | undefined): this {
83
- const writable = this.getWritable()
84
- writable.__listColor = color
85
- return this
86
- }
87
-
88
- getMarkerType(): string | undefined {
89
- return this.getLatest().__markerType
90
- }
91
-
92
- setMarkerType(markerType: string | undefined): this {
93
- const writable = this.getWritable()
94
- writable.__markerType = markerType
95
- return this
96
- }
97
-
98
- override createDOM(config: EditorConfig, _editor?: LexicalEditor): HTMLElement {
99
- const dom = super.createDOM(config, _editor)
100
- applyListAttributesToDom(dom, this.__listColor, this.__markerType)
101
- return dom
102
- }
103
-
104
- override updateDOM(
105
- prevNode: ListWithColorNode,
106
- dom: HTMLElement,
107
- config: EditorConfig
108
- ): boolean {
109
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Lexical ListNode.updateDOM(prevNode: this)
110
- const isUpdated = super.updateDOM(prevNode as any, dom, config)
111
- if (
112
- prevNode.__listColor !== this.__listColor ||
113
- prevNode.__markerType !== this.__markerType
114
- ) {
115
- applyListAttributesToDom(dom, this.__listColor, this.__markerType)
116
- }
117
- return isUpdated
118
- }
119
-
120
- override updateFromJSON(
121
- serializedNode: LexicalUpdateJSON<SerializedListWithColorNode>
122
- ): this {
123
- super.updateFromJSON(serializedNode)
124
- const { listColor, markerType } = serializedNode as SerializedListWithColorNode
125
- if (listColor !== undefined) this.setListColor(listColor)
126
- if (markerType !== undefined) this.setMarkerType(markerType)
127
- return this
128
- }
129
-
130
- override exportDOM(editor: LexicalEditor): DOMExportOutput {
131
- const output = super.exportDOM(editor)
132
- if (output.element && output.element instanceof HTMLElement) {
133
- applyListAttributesToDom(output.element, this.__listColor, this.__markerType)
134
- }
135
- return output
136
- }
137
-
138
- override exportJSON(): SerializedListWithColorNode {
139
- const json = super.exportJSON() as SerializedListWithColorNode
140
- json.type = LIST_WITH_COLOR_TYPE
141
- if (this.__listColor) json.listColor = this.__listColor
142
- if (this.__markerType) json.markerType = this.__markerType
143
- return json
144
- }
145
- }
146
-
147
- export function $createListWithColorNode(
148
- listType?: ListType,
149
- start?: number
150
- ): ListWithColorNode {
151
- return $applyNodeReplacement(
152
- new ListWithColorNode(listType, start)
153
- ) as ListWithColorNode
154
- }
155
-
156
- export function $isListWithColorNode(
157
- node: LexicalNode | null | undefined
158
- ): node is ListWithColorNode {
159
- return node instanceof ListWithColorNode
160
- }
1
+ "use client"
2
+
3
+ import type { DOMExportOutput, EditorConfig, LexicalEditor } from "lexical"
4
+ import {
5
+ ListNode,
6
+ type ListType,
7
+ type SerializedListNode,
8
+ } from "@lexical/list"
9
+ import type { LexicalNode, LexicalUpdateJSON, NodeKey } from "lexical"
10
+ import { $applyNodeReplacement } from "lexical"
11
+
12
+ export type SerializedListWithColorNode = Omit<SerializedListNode, "type"> & {
13
+ type: "listwithcolor"
14
+ listColor?: string
15
+ markerType?: string
16
+ }
17
+
18
+ const LIST_WITH_COLOR_TYPE = "listwithcolor"
19
+
20
+ function applyListAttributesToDom(dom: HTMLElement, color?: string, markerType?: string): void {
21
+ if (color) {
22
+ dom.style.setProperty("--list-marker-color", color, "important")
23
+ dom.setAttribute("data-list-color", color)
24
+ } else {
25
+ dom.style.removeProperty("--list-marker-color")
26
+ dom.removeAttribute("data-list-color")
27
+ }
28
+ if (markerType) {
29
+ dom.setAttribute("data-list-marker", markerType)
30
+ } else {
31
+ dom.removeAttribute("data-list-marker")
32
+ }
33
+ }
34
+
35
+ export class ListWithColorNode extends ListNode {
36
+ __listColor?: string
37
+ __markerType?: string
38
+
39
+ constructor(listType?: ListType, start?: number, key?: NodeKey) {
40
+ super(listType, start, key)
41
+ }
42
+
43
+ static getType(): "listwithcolor" {
44
+ return LIST_WITH_COLOR_TYPE
45
+ }
46
+
47
+ override getType(): "listwithcolor" {
48
+ return LIST_WITH_COLOR_TYPE
49
+ }
50
+
51
+ static override clone(node: ListWithColorNode, key?: NodeKey): ListWithColorNode {
52
+ const listType = node.getListType()
53
+ const start = node.getStart()
54
+ const sameKey = key ?? node.getKey()
55
+ const cloned = new ListWithColorNode(listType, start, sameKey)
56
+ if (node.__listColor) cloned.__listColor = node.__listColor
57
+ if (node.__markerType) cloned.__markerType = node.__markerType
58
+ return cloned
59
+ }
60
+
61
+ static override importJSON(
62
+ serializedNode: SerializedListWithColorNode
63
+ ): ListWithColorNode {
64
+ const { listType, start, listColor, markerType } = serializedNode
65
+ const node = new ListWithColorNode(listType, start)
66
+ if (listColor != null) node.__listColor = listColor
67
+ if (markerType != null) node.__markerType = markerType
68
+ return node
69
+ }
70
+
71
+ override afterCloneFrom(prevNode: ListWithColorNode): void {
72
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Lexical ListNode.afterCloneFrom(prevNode: this) không chấp nhận subtype
73
+ super.afterCloneFrom(prevNode as any)
74
+ this.__listColor = prevNode.__listColor
75
+ this.__markerType = prevNode.__markerType
76
+ }
77
+
78
+ getListColor(): string | undefined {
79
+ return this.getLatest().__listColor
80
+ }
81
+
82
+ setListColor(color: string | undefined): this {
83
+ const writable = this.getWritable()
84
+ writable.__listColor = color
85
+ return this
86
+ }
87
+
88
+ getMarkerType(): string | undefined {
89
+ return this.getLatest().__markerType
90
+ }
91
+
92
+ setMarkerType(markerType: string | undefined): this {
93
+ const writable = this.getWritable()
94
+ writable.__markerType = markerType
95
+ return this
96
+ }
97
+
98
+ override createDOM(config: EditorConfig, _editor?: LexicalEditor): HTMLElement {
99
+ const dom = super.createDOM(config, _editor)
100
+ applyListAttributesToDom(dom, this.__listColor, this.__markerType)
101
+ return dom
102
+ }
103
+
104
+ override updateDOM(
105
+ prevNode: ListWithColorNode,
106
+ dom: HTMLElement,
107
+ config: EditorConfig
108
+ ): boolean {
109
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Lexical ListNode.updateDOM(prevNode: this)
110
+ const isUpdated = super.updateDOM(prevNode as any, dom, config)
111
+ if (
112
+ prevNode.__listColor !== this.__listColor ||
113
+ prevNode.__markerType !== this.__markerType
114
+ ) {
115
+ applyListAttributesToDom(dom, this.__listColor, this.__markerType)
116
+ }
117
+ return isUpdated
118
+ }
119
+
120
+ override updateFromJSON(
121
+ serializedNode: LexicalUpdateJSON<SerializedListWithColorNode>
122
+ ): this {
123
+ super.updateFromJSON(serializedNode)
124
+ const { listColor, markerType } = serializedNode as SerializedListWithColorNode
125
+ if (listColor !== undefined) this.setListColor(listColor)
126
+ if (markerType !== undefined) this.setMarkerType(markerType)
127
+ return this
128
+ }
129
+
130
+ override exportDOM(editor: LexicalEditor): DOMExportOutput {
131
+ const output = super.exportDOM(editor)
132
+ if (output.element && output.element instanceof HTMLElement) {
133
+ applyListAttributesToDom(output.element, this.__listColor, this.__markerType)
134
+ }
135
+ return output
136
+ }
137
+
138
+ override exportJSON(): SerializedListWithColorNode {
139
+ const json = super.exportJSON() as SerializedListWithColorNode
140
+ json.type = LIST_WITH_COLOR_TYPE
141
+ if (this.__listColor) json.listColor = this.__listColor
142
+ if (this.__markerType) json.markerType = this.__markerType
143
+ return json
144
+ }
145
+ }
146
+
147
+ export function $createListWithColorNode(
148
+ listType?: ListType,
149
+ start?: number
150
+ ): ListWithColorNode {
151
+ return $applyNodeReplacement(
152
+ new ListWithColorNode(listType, start)
153
+ ) as ListWithColorNode
154
+ }
155
+
156
+ export function $isListWithColorNode(
157
+ node: LexicalNode | null | undefined
158
+ ): node is ListWithColorNode {
159
+ return node instanceof ListWithColorNode
160
+ }