@crystallize/design-system 1.6.1 → 1.8.0
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/CHANGELOG.md +13 -0
- package/dist/index.css +53 -332
- package/dist/index.d.ts +15 -8
- package/dist/index.js +1736 -4555
- package/dist/index.mjs +1655 -2339
- package/package.json +1 -1
- package/src/action-menu/action-item-separator.tsx +14 -0
- package/src/action-menu/action-item.tsx +2 -2
- package/src/action-menu/action-menu.css +8 -0
- package/src/action-menu/action-menu.tsx +2 -1
- package/src/dropdown-menu/dropdown-menu-root.tsx +3 -1
- package/src/dropdown-menu/index.ts +5 -2
- package/src/iconography/subscription-contracts.tsx +4 -4
- package/src/iconography/subscription-plans.tsx +5 -5
- package/src/rich-text-editor/model/crystallize-to-lexical.ts +12 -1
- package/src/rich-text-editor/model/lexical-to-crystallize.ts +38 -38
- package/src/rich-text-editor/nodes/BaseNodes.ts +0 -7
- package/src/rich-text-editor/nodes/TableCellNodes.ts +0 -7
- package/src/rich-text-editor/plugins/ActionsPlugin/index.tsx +13 -2
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/CopyButton/index.tsx +3 -2
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.tsx +0 -1
- package/src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.css +17 -17
- package/src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +1 -1
- package/src/rich-text-editor/plugins/MaxLengthPlugin/index.tsx +2 -7
- package/src/rich-text-editor/plugins/TableActionMenuPlugin/index.tsx +80 -149
- package/src/rich-text-editor/plugins/ToolbarPlugin/index.tsx +2 -2
- package/src/rich-text-editor/plugins/ToolbarPlugin/insert-table.tsx +55 -0
- package/src/rich-text-editor/rich-text-editor.css +10 -322
- package/src/rich-text-editor/rich-text-editor.stories.tsx +35 -5
- package/src/rich-text-editor/rich-text-editor.tsx +6 -39
- package/src/rich-text-editor/tests/rich-text-editor-code.test.tsx +10 -6
- package/src/rich-text-editor/tests/rich-text-editor-model-conversions.test.tsx +19 -7
- package/src/rich-text-editor/themes/CrystallizeRTEditorTheme.css +3 -11
- package/dist/TableComponent-I2YOOYOU.css +0 -281
- package/dist/TableComponent-QINOO453.mjs +0 -1377
- package/dist/chevron-down-3FRWSIKS.svg +0 -1
- package/dist/chunk-VUXQZRSP.mjs +0 -737
- package/dist/markdown-4BGQNLLT.svg +0 -1
- package/src/rich-text-editor/nodes/KeywordNode.ts +0 -73
- package/src/rich-text-editor/nodes/TableComponent.tsx +0 -1547
- package/src/rich-text-editor/nodes/TableNode.tsx +0 -398
- package/src/rich-text-editor/plugins/ComponentPickerPlugin/index.tsx +0 -320
- package/src/rich-text-editor/plugins/DragDropPastePlugin/index.ts +0 -40
- package/src/rich-text-editor/plugins/MarkdownShortcutPlugin/index.tsx +0 -16
- package/src/rich-text-editor/plugins/MarkdownTransformers/index.ts +0 -195
- package/src/rich-text-editor/plugins/SpeechToTextPlugin/index.ts +0 -113
- package/src/rich-text-editor/plugins/TableCellResizer/index.css +0 -12
- package/src/rich-text-editor/plugins/TableCellResizer/index.tsx +0 -386
- package/src/rich-text-editor/plugins/TablePlugin.tsx +0 -190
- package/src/rich-text-editor/plugins/TreeViewPlugin/index.tsx +0 -25
- package/src/rich-text-editor/plugins/TypingPerfPlugin/index.ts +0 -117
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
import { cx } from 'class-variance-authority';
|
|
3
|
+
|
|
4
|
+
import { DropdownMenu } from '../dropdown-menu';
|
|
5
|
+
|
|
6
|
+
type SeparatorProps = HTMLAttributes<HTMLLIElement>;
|
|
7
|
+
|
|
8
|
+
export function Separator({ className }: SeparatorProps) {
|
|
9
|
+
return (
|
|
10
|
+
<DropdownMenu.Item className={cx(className, 'c-action-menu-item-separator')}>
|
|
11
|
+
<hr />
|
|
12
|
+
</DropdownMenu.Item>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { cx } from 'class-variance-authority';
|
|
2
1
|
import type { HTMLAttributes } from 'react';
|
|
2
|
+
import { cx } from 'class-variance-authority';
|
|
3
3
|
|
|
4
4
|
import { DropdownMenu } from '../dropdown-menu';
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ type ItemProps = HTMLAttributes<HTMLLIElement> & {
|
|
|
9
9
|
|
|
10
10
|
export function Item({ children, className, onSelect }: ItemProps) {
|
|
11
11
|
return (
|
|
12
|
-
<DropdownMenu.Item onClick={onSelect} className={cx(className, 'c-action-menu-item')}>
|
|
12
|
+
<DropdownMenu.Item onClick={onSelect} className={cx(className, ['c-action-menu-item'])}>
|
|
13
13
|
{children}
|
|
14
14
|
</DropdownMenu.Item>
|
|
15
15
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import { DropdownMenu } from '../dropdown-menu';
|
|
4
|
-
|
|
5
4
|
import { Item } from './action-item';
|
|
5
|
+
import { Separator } from './action-item-separator';
|
|
6
6
|
|
|
7
7
|
type ActionMenuProps = {
|
|
8
8
|
children: ReactNode;
|
|
@@ -23,3 +23,4 @@ export function ActionMenu({ children, tabIndex }: ActionMenuProps) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
ActionMenu.Item = Item;
|
|
26
|
+
ActionMenu.Separator = Separator;
|
|
@@ -6,6 +6,7 @@ type DropdownMenuRootProps = DropdownMenuPrimitive.MenuContentProps & {
|
|
|
6
6
|
content: ReactNode;
|
|
7
7
|
alignContent?: 'start' | 'center' | 'end';
|
|
8
8
|
disabled?: boolean;
|
|
9
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
export function DropdownMenuRoot({
|
|
@@ -13,10 +14,11 @@ export function DropdownMenuRoot({
|
|
|
13
14
|
content,
|
|
14
15
|
alignContent = 'start',
|
|
15
16
|
disabled,
|
|
17
|
+
onOpenChange,
|
|
16
18
|
...delegated
|
|
17
19
|
}: DropdownMenuRootProps) {
|
|
18
20
|
return (
|
|
19
|
-
<DropdownMenuPrimitive.Root>
|
|
21
|
+
<DropdownMenuPrimitive.Root onOpenChange={onOpenChange}>
|
|
20
22
|
<DropdownMenuPrimitive.Trigger disabled={disabled} asChild>
|
|
21
23
|
{children}
|
|
22
24
|
</DropdownMenuPrimitive.Trigger>
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Portal, Separator } from '@radix-ui/react-dropdown-menu';
|
|
2
|
+
|
|
2
3
|
import { DropdownMenuItem } from './dropdown-menu-item';
|
|
3
4
|
import { DropdownMenuLabel } from './dropdown-menu-label';
|
|
4
|
-
|
|
5
|
+
import { DropdownMenuRoot } from './dropdown-menu-root';
|
|
5
6
|
import './dropdown-menu.css';
|
|
6
7
|
|
|
7
8
|
export const DropdownMenu = {
|
|
8
9
|
Root: DropdownMenuRoot,
|
|
9
10
|
Item: DropdownMenuItem,
|
|
10
11
|
Label: DropdownMenuLabel,
|
|
12
|
+
Separator,
|
|
13
|
+
Portal,
|
|
11
14
|
};
|
|
@@ -16,13 +16,13 @@ export const SubscriptionContracts = forwardRef<SubscriptionContractsRef, Subscr
|
|
|
16
16
|
fill="#528693"
|
|
17
17
|
fillRule="evenodd"
|
|
18
18
|
d="m17.908 6.324.425-.424a1.2 1.2 0 0 1 .351.848V18.5a1.2 1.2 0 0 1-1.2 1.2h-10.8a1.2 1.2 0 0 1-1.2-1.2V3.7a1.2 1.2 0 0 1 1.2-1.2h7.751a1.2 1.2 0 0 1 .85.351L18.332 5.9l-.425.424ZM17.484 19.1h-10.8a.6.6 0 0 1-.6-.6V3.7a.6.6 0 0 1 .6-.6h7.751a.6.6 0 0 1 .425.176l3.048 3.048a.6.6 0 0 1 .176.424V18.5a.6.6 0 0 1-.6.6Z"
|
|
19
|
-
|
|
19
|
+
clipRule="evenodd"
|
|
20
20
|
/>
|
|
21
21
|
<path
|
|
22
22
|
fill="#528693"
|
|
23
23
|
fillRule="evenodd"
|
|
24
24
|
d="M14.784 2.9v2.6a.7.7 0 0 0 .7.7h3v.6h-3a1.3 1.3 0 0 1-1.3-1.3V2.9h.6Z"
|
|
25
|
-
|
|
25
|
+
clipRule="evenodd"
|
|
26
26
|
/>
|
|
27
27
|
<path
|
|
28
28
|
fill="#fff"
|
|
@@ -32,7 +32,7 @@ export const SubscriptionContracts = forwardRef<SubscriptionContractsRef, Subscr
|
|
|
32
32
|
fill="#528693"
|
|
33
33
|
fillRule="evenodd"
|
|
34
34
|
d="M18.784 8.7c.633.738.8 2.173-.702 1.857l-4.498-1.256.02-.068c.044-.157.095-.31.146-.463l.014-.042.022-.065c.066-.195.133-.39.191-.595l-.698.222h-.002l-2.17.689-.603.19a1328.391 1328.391 0 0 1 1.109 1.528l.592.816.434.597.387-1.163c.412.092.893.223 1.408.364 2.386.653 5.528 1.513 6.178-.438.267-.803-.066-1.58-1.228-2.678-.18-.17-.38-.348-.6-.534V8.7Zm-5.363 2.96-.213.64a.6.6 0 0 1-1.055.163 3823.073 3823.073 0 0 1-2.135-2.94.6.6 0 0 1 .304-.925l2.772-.88.702-.222a.6.6 0 0 1 .758.736c-.062.22-.133.429-.198.62l-.01.029-.003.009 3.88 1.084c.287.057.391.01.403.004a.153.153 0 0 0 .015-.05.84.84 0 0 0-.055-.385 1.44 1.44 0 0 0-.257-.453l-.145-.168V6.367l.988.836c.836.707 1.437 1.334 1.78 1.943.364.643.443 1.273.229 1.917-.272.817-.88 1.271-1.6 1.473-.687.192-1.49.162-2.272.05-.791-.111-1.622-.316-2.384-.52-.23-.061-.453-.122-.666-.18-.297-.082-.577-.159-.838-.226Z"
|
|
35
|
-
|
|
35
|
+
clipRule="evenodd"
|
|
36
36
|
/>
|
|
37
37
|
<path
|
|
38
38
|
fill="#fff"
|
|
@@ -42,7 +42,7 @@ export const SubscriptionContracts = forwardRef<SubscriptionContractsRef, Subscr
|
|
|
42
42
|
fill="#528693"
|
|
43
43
|
fillRule="evenodd"
|
|
44
44
|
d="M5.394 11.779c-.55.463-.755 1.17.298 1.563l4.473 1.343.02-.068c.046-.157.085-.313.123-.47l.01-.043.017-.067c.048-.2.096-.4.156-.604l.472.56.003.003c.49.582.975 1.16 1.465 1.74l.407.485-.587.233-1.167.464-.937.373-.685.273.294-1.19c-.397-.143-.873-.288-1.384-.445-2.366-.724-5.48-1.677-4.987-3.673.15-.606.57-1.026 1.409-1.328.18-.064.38-.124.6-.178v1.029Zm3.647 4.987-.162.654a.6.6 0 0 0 .804.701 3603.743 3603.743 0 0 0 3.377-1.343.6.6 0 0 0 .237-.944l-1.872-2.224-.474-.564a.6.6 0 0 0-1.035.216c-.065.22-.116.434-.164.63l-.007.03-.002.01-3.859-1.159c-.195-.075-.285-.146-.322-.185a.133.133 0 0 1-.02-.028v-.003a.335.335 0 0 1 .037-.092.913.913 0 0 1 .201-.227l.214-.18V9.984l-.744.184c-.662.163-1.208.38-1.623.697-.434.33-.7.747-.824 1.247-.207.836.063 1.545.564 2.1.478.53 1.174.934 1.893 1.258.729.328 1.54.6 2.293.835l.66.203c.294.09.572.175.828.258Z"
|
|
45
|
-
|
|
45
|
+
clipRule="evenodd"
|
|
46
46
|
/>
|
|
47
47
|
</svg>
|
|
48
48
|
);
|
|
@@ -15,20 +15,20 @@ export const SubscriptionPlans = forwardRef<SubscriptionPlansRef, SubscriptionPl
|
|
|
15
15
|
fill="#528693"
|
|
16
16
|
fillRule="evenodd"
|
|
17
17
|
d="M6.397 4.627h11.09a1.6 1.6 0 0 1 1.6 1.6v11a1.6 1.6 0 0 1-1.6 1.6H6.398a1.6 1.6 0 0 1-1.6-1.6v-11a1.6 1.6 0 0 1 1.6-1.6Zm0 .6h11.09a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H6.398a1 1 0 0 1-1-1v-11a1 1 0 0 1 1-1Z"
|
|
18
|
-
|
|
18
|
+
clipRule="evenodd"
|
|
19
19
|
/>
|
|
20
20
|
<path fill="#fff" d="M5.397 6.227a1 1 0 0 1 1-1h11.09a1 1 0 0 1 1 1v1.455H5.398V6.227Z" />
|
|
21
21
|
<path
|
|
22
22
|
fill="#528693"
|
|
23
23
|
fillRule="evenodd"
|
|
24
24
|
d="M19.088 8.282H4.797V6.227a1.6 1.6 0 0 1 1.6-1.6h11.09a1.6 1.6 0 0 1 1.6 1.6v2.055ZM6.397 5.227a1 1 0 0 0-1 1v1.455h13.09V6.227a1 1 0 0 0-1-1H6.398Z"
|
|
25
|
-
|
|
25
|
+
clipRule="evenodd"
|
|
26
26
|
/>
|
|
27
27
|
<path
|
|
28
28
|
fill="#528693"
|
|
29
29
|
fillRule="evenodd"
|
|
30
30
|
d="M8.352 4v1.227h-1V4a.5.5 0 0 1 1 0ZM16.533 4v1.227h-1V4a.5.5 0 1 1 1 0ZM12.443 4v1.227h-1V4a.5.5 0 1 1 1 0Z"
|
|
31
|
-
|
|
31
|
+
clipRule="evenodd"
|
|
32
32
|
/>
|
|
33
33
|
<path
|
|
34
34
|
fill="#fff"
|
|
@@ -38,7 +38,7 @@ export const SubscriptionPlans = forwardRef<SubscriptionPlansRef, SubscriptionPl
|
|
|
38
38
|
fill="#528693"
|
|
39
39
|
fillRule="evenodd"
|
|
40
40
|
d="M19.076 10.782c.633.738.8 2.173-.702 1.857l-4.498-1.256.02-.068c.044-.157.095-.31.146-.463l.014-.042.023-.065c.066-.194.132-.39.19-.595l-.697.221-.003.001-2.17.689-.603.19a1504.34 1504.34 0 0 1 1.109 1.528l.593.816.433.597.388-1.163c.412.092.892.223 1.407.364 2.387.653 5.528 1.513 6.178-.438.267-.803-.066-1.58-1.228-2.678-.18-.17-.38-.348-.6-.534v1.039Zm-5.363 2.96-.213.64a.6.6 0 0 1-1.054.163l-1.027-1.414-1.109-1.527a.6.6 0 0 1 .305-.924l2.771-.88.702-.222a.6.6 0 0 1 .759.736c-.063.22-.134.429-.199.62l-.01.029-.003.009 3.88 1.084c.287.058.392.01.403.004a.156.156 0 0 0 .015-.05.84.84 0 0 0-.055-.385 1.44 1.44 0 0 0-.257-.453l-.145-.168V8.449l.988.836c.836.707 1.437 1.334 1.781 1.943.363.643.442 1.273.228 1.917-.272.816-.879 1.271-1.6 1.473-.686.192-1.49.162-2.272.05-.791-.111-1.622-.316-2.384-.52-.23-.061-.452-.122-.666-.18a59.482 59.482 0 0 0-.838-.226Z"
|
|
41
|
-
|
|
41
|
+
clipRule="evenodd"
|
|
42
42
|
/>
|
|
43
43
|
<path
|
|
44
44
|
fill="#fff"
|
|
@@ -48,7 +48,7 @@ export const SubscriptionPlans = forwardRef<SubscriptionPlansRef, SubscriptionPl
|
|
|
48
48
|
fill="#528693"
|
|
49
49
|
fillRule="evenodd"
|
|
50
50
|
d="M4.806 11.607c-.55.462-.756 1.17.298 1.562l4.472 1.343.02-.068a10.141 10.141 0 0 0 .15-.58c.049-.199.097-.4.157-.604l.472.56.002.003 1.465 1.741.408.484-.588.234-1.166.464-.937.373-.686.272.295-1.19c-.398-.143-.874-.288-1.384-.444-2.367-.724-5.48-1.677-4.987-3.673.15-.607.569-1.027 1.409-1.328.18-.065.38-.124.6-.179v1.03Zm3.647 4.986-.162.654a.6.6 0 0 0 .804.702l1.624-.646 1.753-.698a.6.6 0 0 0 .237-.944l-1.873-2.224-.474-.563a.6.6 0 0 0-1.034.216c-.065.219-.117.434-.164.63l-.007.03-.002.009-3.859-1.158c-.195-.075-.286-.147-.322-.186a.136.136 0 0 1-.021-.027v-.004l.004-.018a.333.333 0 0 1 .033-.073.913.913 0 0 1 .202-.227l.214-.18V9.81l-.744.184c-.662.164-1.208.381-1.624.697-.433.33-.7.748-.824 1.248-.206.835.063 1.544.565 2.1.478.529 1.173.934 1.893 1.258.728.328 1.54.599 2.293.834.227.071.448.139.66.203.294.09.571.175.828.258Z"
|
|
51
|
-
|
|
51
|
+
clipRule="evenodd"
|
|
52
52
|
/>
|
|
53
53
|
</svg>
|
|
54
54
|
);
|
|
@@ -118,7 +118,8 @@ export function composeInitialState({ richText }: { richText: CrystallizeRichTex
|
|
|
118
118
|
lexicalNode = $createTableRowNode();
|
|
119
119
|
break;
|
|
120
120
|
}
|
|
121
|
-
case 'table-cell':
|
|
121
|
+
case 'table-cell':
|
|
122
|
+
case 'table-head-cell': {
|
|
122
123
|
// ** colSpan / rowSpan has not yet been implemented **
|
|
123
124
|
// const colSpanFromMeta = metadata?.colSpan;
|
|
124
125
|
// const colSpanParsed =
|
|
@@ -136,6 +137,16 @@ export function composeInitialState({ richText }: { richText: CrystallizeRichTex
|
|
|
136
137
|
);
|
|
137
138
|
break;
|
|
138
139
|
}
|
|
140
|
+
case 'preformatted': {
|
|
141
|
+
/**
|
|
142
|
+
* We do not deal with this tag. It should just be skipped.
|
|
143
|
+
*/
|
|
144
|
+
lexicalNode = lexicalParent;
|
|
145
|
+
if (children) {
|
|
146
|
+
children.forEach(n => handleNode({ crystallizeContentNode: n, lexicalParent }));
|
|
147
|
+
}
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
139
150
|
}
|
|
140
151
|
|
|
141
152
|
if (!insertedTextContent && typeof textContent === 'string') {
|
|
@@ -4,9 +4,10 @@ import {
|
|
|
4
4
|
$isLineBreakNode,
|
|
5
5
|
$isParagraphNode,
|
|
6
6
|
$isTextNode,
|
|
7
|
-
EditorState,
|
|
8
|
-
ElementNode,
|
|
9
7
|
TextNode,
|
|
8
|
+
type ElementNode,
|
|
9
|
+
type EditorState,
|
|
10
|
+
LexicalEditor,
|
|
10
11
|
} from 'lexical';
|
|
11
12
|
import { $isCodeNode } from '@lexical/code';
|
|
12
13
|
import { $isLinkNode } from '@lexical/link';
|
|
@@ -15,11 +16,7 @@ import { $isHorizontalRuleNode } from '@lexical/react/LexicalHorizontalRuleNode'
|
|
|
15
16
|
import { $isHeadingNode, $isQuoteNode, HeadingTagType } from '@lexical/rich-text';
|
|
16
17
|
import { $isTableCellNode, $isTableNode, $isTableRowNode } from '@lexical/table';
|
|
17
18
|
|
|
18
|
-
import type {
|
|
19
|
-
CrystallizeRichTextNode,
|
|
20
|
-
CrystallizeRichText,
|
|
21
|
-
CrystallizeRichTextCodeNodes,
|
|
22
|
-
} from '../types/crystallize-rich-text-types';
|
|
19
|
+
import type { CrystallizeRichTextNode, CrystallizeRichText } from '../types/crystallize-rich-text-types';
|
|
23
20
|
import type { CrystallizeRichTextHeadingTypes } from '../types/crystallize-rich-text-types/headings';
|
|
24
21
|
|
|
25
22
|
const headingMapper: Record<HeadingTagType, CrystallizeRichTextHeadingTypes> = {
|
|
@@ -31,7 +28,12 @@ const headingMapper: Record<HeadingTagType, CrystallizeRichTextHeadingTypes> = {
|
|
|
31
28
|
h6: 'heading6',
|
|
32
29
|
};
|
|
33
30
|
|
|
34
|
-
export function lexicalToCrystallizeRichText({
|
|
31
|
+
export function lexicalToCrystallizeRichText({
|
|
32
|
+
editorState,
|
|
33
|
+
}: {
|
|
34
|
+
editor?: LexicalEditor;
|
|
35
|
+
editorState: EditorState;
|
|
36
|
+
}): CrystallizeRichText {
|
|
35
37
|
const crystallizeRichText: CrystallizeRichTextNode['children'] = [];
|
|
36
38
|
|
|
37
39
|
editorState.read(() => {
|
|
@@ -96,27 +98,6 @@ export function lexicalToCrystallizeRichText({ editorState }: { editorState: Edi
|
|
|
96
98
|
type: 'quote',
|
|
97
99
|
};
|
|
98
100
|
}
|
|
99
|
-
// Table
|
|
100
|
-
else if ($isTableNode(lexicalNode)) {
|
|
101
|
-
crystallizeNode = {
|
|
102
|
-
kind: 'block',
|
|
103
|
-
type: 'table',
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
// Table row
|
|
107
|
-
else if ($isTableRowNode(lexicalNode)) {
|
|
108
|
-
crystallizeNode = {
|
|
109
|
-
kind: 'block',
|
|
110
|
-
type: 'table-row',
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
// Table cell
|
|
114
|
-
else if ($isTableCellNode(lexicalNode)) {
|
|
115
|
-
crystallizeNode = {
|
|
116
|
-
kind: 'inline',
|
|
117
|
-
type: 'table-cell',
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
101
|
// Line break
|
|
121
102
|
else if ($isLineBreakNode(lexicalNode)) {
|
|
122
103
|
crystallizeNode = {
|
|
@@ -126,17 +107,37 @@ export function lexicalToCrystallizeRichText({ editorState }: { editorState: Edi
|
|
|
126
107
|
}
|
|
127
108
|
// Code
|
|
128
109
|
else if ($isCodeNode(lexicalNode)) {
|
|
129
|
-
const language = lexicalNode.getLanguage();
|
|
130
110
|
crystallizeNode = {
|
|
131
111
|
kind: 'block',
|
|
132
|
-
type: '
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
112
|
+
type: 'preformatted',
|
|
113
|
+
children: [
|
|
114
|
+
{
|
|
115
|
+
type: 'code',
|
|
116
|
+
kind: 'block',
|
|
117
|
+
textContent: lexicalNode.getTextContent(),
|
|
118
|
+
metadata: {
|
|
119
|
+
language: lexicalNode.getLanguage(),
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
} as CrystallizeRichTextNode;
|
|
138
124
|
|
|
139
125
|
innerContentsIsTakenCareOf = true;
|
|
126
|
+
} else if ($isTableNode(lexicalNode)) {
|
|
127
|
+
crystallizeNode = {
|
|
128
|
+
kind: 'block',
|
|
129
|
+
type: 'table',
|
|
130
|
+
};
|
|
131
|
+
} else if ($isTableRowNode(lexicalNode)) {
|
|
132
|
+
crystallizeNode = {
|
|
133
|
+
kind: 'block',
|
|
134
|
+
type: 'table-row',
|
|
135
|
+
};
|
|
136
|
+
} else if ($isTableCellNode(lexicalNode)) {
|
|
137
|
+
crystallizeNode = {
|
|
138
|
+
kind: 'inline',
|
|
139
|
+
type: lexicalNode.hasHeader() ? 'table-head-cell' : 'table-cell',
|
|
140
|
+
};
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
if (crystallizeNode) {
|
|
@@ -176,8 +177,7 @@ export function lexicalToCrystallizeRichText({ editorState }: { editorState: Edi
|
|
|
176
177
|
children.forEach(childNode => {
|
|
177
178
|
if ($isElementNode(childNode)) {
|
|
178
179
|
handleNode(childNode, parentChildrenToUse);
|
|
179
|
-
}
|
|
180
|
-
if ($isHorizontalRuleNode(childNode)) {
|
|
180
|
+
} else if ($isHorizontalRuleNode(childNode)) {
|
|
181
181
|
parentChildrenToUse.push({
|
|
182
182
|
kind: 'block',
|
|
183
183
|
type: 'horizontal-line',
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
import { Klass, LexicalNode, LineBreakNode } from 'lexical';
|
|
10
10
|
import { CodeHighlightNode, CodeNode } from '@lexical/code';
|
|
11
|
-
import { HashtagNode } from '@lexical/hashtag';
|
|
12
11
|
import { AutoLinkNode, LinkNode } from '@lexical/link';
|
|
13
12
|
import { ListItemNode, ListNode } from '@lexical/list';
|
|
14
13
|
import { MarkNode } from '@lexical/mark';
|
|
@@ -17,25 +16,19 @@ import { HorizontalRuleNode } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
|
17
16
|
import { HeadingNode, QuoteNode } from '@lexical/rich-text';
|
|
18
17
|
import { TableCellNode, TableNode, TableRowNode } from '@lexical/table';
|
|
19
18
|
|
|
20
|
-
import { KeywordNode } from './KeywordNode';
|
|
21
|
-
import { TableNode as NewTableNode } from './TableNode';
|
|
22
|
-
|
|
23
19
|
export const BaseNodes: Array<Klass<LexicalNode>> = [
|
|
24
20
|
HeadingNode,
|
|
25
21
|
ListNode,
|
|
26
22
|
ListItemNode,
|
|
27
23
|
QuoteNode,
|
|
28
24
|
CodeNode,
|
|
29
|
-
NewTableNode,
|
|
30
25
|
TableNode,
|
|
31
26
|
TableCellNode,
|
|
32
27
|
TableRowNode,
|
|
33
|
-
HashtagNode,
|
|
34
28
|
CodeHighlightNode,
|
|
35
29
|
AutoLinkNode,
|
|
36
30
|
LinkNode,
|
|
37
31
|
OverflowNode,
|
|
38
|
-
KeywordNode,
|
|
39
32
|
HorizontalRuleNode,
|
|
40
33
|
MarkNode,
|
|
41
34
|
LineBreakNode,
|
|
@@ -8,24 +8,17 @@
|
|
|
8
8
|
|
|
9
9
|
import type { Klass, LexicalNode } from 'lexical';
|
|
10
10
|
import { CodeHighlightNode, CodeNode } from '@lexical/code';
|
|
11
|
-
import { HashtagNode } from '@lexical/hashtag';
|
|
12
11
|
import { AutoLinkNode, LinkNode } from '@lexical/link';
|
|
13
12
|
import { ListItemNode, ListNode } from '@lexical/list';
|
|
14
13
|
import { HeadingNode, QuoteNode } from '@lexical/rich-text';
|
|
15
14
|
|
|
16
|
-
// import { AutocompleteNode } from './AutocompleteNode';
|
|
17
|
-
import { KeywordNode } from './KeywordNode';
|
|
18
|
-
|
|
19
15
|
export const BaseNodes: Array<Klass<LexicalNode>> = [
|
|
20
16
|
HeadingNode,
|
|
21
17
|
ListNode,
|
|
22
18
|
ListItemNode,
|
|
23
19
|
QuoteNode,
|
|
24
20
|
CodeNode,
|
|
25
|
-
HashtagNode,
|
|
26
21
|
CodeHighlightNode,
|
|
27
22
|
AutoLinkNode,
|
|
28
23
|
LinkNode,
|
|
29
|
-
// AutocompleteNode,
|
|
30
|
-
KeywordNode,
|
|
31
24
|
];
|
|
@@ -14,7 +14,17 @@ import { ActionMenu } from '../../../action-menu';
|
|
|
14
14
|
import { lexicalToCrystallizeRichText } from '../../model/lexical-to-crystallize';
|
|
15
15
|
import type { CrystallizeRichTextActionMenuItem } from '../../types/types';
|
|
16
16
|
|
|
17
|
-
async function
|
|
17
|
+
async function copyJson(editor: LexicalEditor) {
|
|
18
|
+
const json = lexicalToCrystallizeRichText({ editor, editorState: editor.getEditorState() });
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
await navigator.clipboard.writeText(JSON.stringify(json, null, 1));
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.warn('Copy failed', error);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function exportJson(editor: LexicalEditor) {
|
|
18
28
|
const json = lexicalToCrystallizeRichText({ editorState: editor.getEditorState() });
|
|
19
29
|
|
|
20
30
|
const blob = new Blob([JSON.stringify(json, null, 1)], {
|
|
@@ -56,7 +66,8 @@ export default function ActionsPlugin({
|
|
|
56
66
|
{actionItem.title}
|
|
57
67
|
</ActionMenu.Item>
|
|
58
68
|
))}
|
|
59
|
-
<ActionMenu.Item onSelect={() =>
|
|
69
|
+
<ActionMenu.Item onSelect={() => copyJson(editor)}>Copy JSON</ActionMenu.Item>
|
|
70
|
+
<ActionMenu.Item onSelect={() => exportJson(editor)}>Export JSON</ActionMenu.Item>
|
|
60
71
|
<ActionMenu.Item
|
|
61
72
|
className="danger"
|
|
62
73
|
onSelect={() => {
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
import { $getNearestNodeFromDOMNode, $getSelection, $setSelection, LexicalEditor } from 'lexical';
|
|
8
|
+
|
|
10
9
|
import * as React from 'react';
|
|
11
10
|
import { useState } from 'react';
|
|
11
|
+
import { $getNearestNodeFromDOMNode, $getSelection, $setSelection, LexicalEditor } from 'lexical';
|
|
12
12
|
import { useDebouncedCallback } from 'use-debounce';
|
|
13
|
+
import { $isCodeNode } from '@lexical/code';
|
|
13
14
|
|
|
14
15
|
interface Props {
|
|
15
16
|
editor: LexicalEditor;
|
package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.tsx
CHANGED
|
@@ -22,7 +22,6 @@ const PRETTIER_PARSER_MODULES = {
|
|
|
22
22
|
css: () => import('prettier/parser-postcss'),
|
|
23
23
|
html: () => import('prettier/parser-html'),
|
|
24
24
|
js: () => import('prettier/parser-babel'),
|
|
25
|
-
markdown: () => import('prettier/parser-markdown'),
|
|
26
25
|
} as const;
|
|
27
26
|
|
|
28
27
|
type LanguagesType = keyof typeof PRETTIER_PARSER_MODULES;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.floating-text-format-popup {
|
|
1
|
+
.c-floating-text-format-popup {
|
|
2
2
|
vertical-align: middle;
|
|
3
3
|
background-color: #fff;
|
|
4
4
|
transition: opacity 0.5s;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
@apply absolute top-0 left-0 z-10 flex rounded-md bg-white p-1 opacity-0 shadow-md;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
.floating-text-format-popup button.popup-item {
|
|
11
|
+
.c-floating-text-format-popup button.popup-item {
|
|
12
12
|
border: 0;
|
|
13
13
|
display: flex;
|
|
14
14
|
background: none;
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
vertical-align: middle;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
.floating-text-format-popup button.popup-item:disabled {
|
|
21
|
+
.c-floating-text-format-popup button.popup-item:disabled {
|
|
22
22
|
cursor: not-allowed;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
.floating-text-format-popup button.popup-item.spaced {
|
|
25
|
+
.c-floating-text-format-popup button.popup-item.spaced {
|
|
26
26
|
margin-right: 2px;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
.floating-text-format-popup button.popup-item i.format {
|
|
29
|
+
.c-floating-text-format-popup button.popup-item i.format {
|
|
30
30
|
background-size: contain;
|
|
31
31
|
display: inline-block;
|
|
32
32
|
height: 18px;
|
|
@@ -37,23 +37,23 @@
|
|
|
37
37
|
opacity: 0.6;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
.floating-text-format-popup button.popup-item:disabled i.format {
|
|
40
|
+
.c-floating-text-format-popup button.popup-item:disabled i.format {
|
|
41
41
|
opacity: 0.2;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.floating-text-format-popup button.popup-item.active {
|
|
44
|
+
.c-floating-text-format-popup button.popup-item.active {
|
|
45
45
|
background-color: rgba(223, 232, 250, 0.3);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
.floating-text-format-popup button.popup-item.active i {
|
|
48
|
+
.c-floating-text-format-popup button.popup-item.active i {
|
|
49
49
|
opacity: 1;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
.floating-text-format-popup .popup-item:hover:not([disabled]) {
|
|
52
|
+
.c-floating-text-format-popup .popup-item:hover:not([disabled]) {
|
|
53
53
|
background-color: #eee;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
.floating-text-format-popup select.popup-item {
|
|
56
|
+
.c-floating-text-format-popup select.popup-item {
|
|
57
57
|
border: 0;
|
|
58
58
|
display: flex;
|
|
59
59
|
background: none;
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
text-overflow: ellipsis;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
.floating-text-format-popup select.code-language {
|
|
71
|
+
.c-floating-text-format-popup select.code-language {
|
|
72
72
|
text-transform: capitalize;
|
|
73
73
|
width: 130px;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
.floating-text-format-popup .popup-item .text {
|
|
76
|
+
.c-floating-text-format-popup .popup-item .text {
|
|
77
77
|
display: flex;
|
|
78
78
|
line-height: 20px;
|
|
79
79
|
width: 200px;
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
text-align: left;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
.floating-text-format-popup .popup-item .icon {
|
|
90
|
+
.c-floating-text-format-popup .popup-item .icon {
|
|
91
91
|
display: flex;
|
|
92
92
|
width: 20px;
|
|
93
93
|
height: 20px;
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
background-size: contain;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
.floating-text-format-popup i.chevron-down {
|
|
100
|
+
.c-floating-text-format-popup i.chevron-down {
|
|
101
101
|
margin-top: 3px;
|
|
102
102
|
width: 16px;
|
|
103
103
|
height: 16px;
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
user-select: none;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
.floating-text-format-popup i.chevron-down.inside {
|
|
108
|
+
.c-floating-text-format-popup i.chevron-down.inside {
|
|
109
109
|
width: 16px;
|
|
110
110
|
height: 16px;
|
|
111
111
|
display: flex;
|
|
@@ -115,14 +115,14 @@
|
|
|
115
115
|
pointer-events: none;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
.floating-text-format-popup .divider {
|
|
118
|
+
.c-floating-text-format-popup .divider {
|
|
119
119
|
width: 1px;
|
|
120
120
|
background-color: #eee;
|
|
121
121
|
margin: 0 4px;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
@media (max-width: 1024px) {
|
|
125
|
-
.floating-text-format-popup button.insert-comment {
|
|
125
|
+
.c-floating-text-format-popup button.insert-comment {
|
|
126
126
|
display: none;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
@@ -131,7 +131,7 @@ function TextFormatFloatingToolbar({
|
|
|
131
131
|
}, [editor, updateTextFormatFloatingToolbar]);
|
|
132
132
|
|
|
133
133
|
return (
|
|
134
|
-
<div ref={popupCharStylesEditorRef} className="floating-text-format-popup gap-0.5">
|
|
134
|
+
<div ref={popupCharStylesEditorRef} className="c-floating-text-format-popup gap-0.5">
|
|
135
135
|
{editor.isEditable() && (
|
|
136
136
|
<>
|
|
137
137
|
<IconButton
|
|
@@ -28,14 +28,9 @@ export function MaxLengthPlugin({ maxLength }: { maxLength: number }): null {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const prevTextContent = toText(lexicalToCrystallizeRichText({ editorState: prevEditorState }));
|
|
31
|
+
const prevTextContent = toText(lexicalToCrystallizeRichText({ editor, editorState: prevEditorState }));
|
|
32
|
+
const textContent = toText(lexicalToCrystallizeRichText({ editor, editorState }));
|
|
32
33
|
|
|
33
|
-
// const editorState = rootNode.get
|
|
34
|
-
// createState
|
|
35
|
-
const textContent = toText(lexicalToCrystallizeRichText({ editorState }));
|
|
36
|
-
|
|
37
|
-
// const prevTextContent = prevEditorState.read(() => rootNode.getTextContent());
|
|
38
|
-
// const textContent = rootNode.getTextContent();
|
|
39
34
|
if (prevTextContent !== textContent) {
|
|
40
35
|
const textLength = textContent.length;
|
|
41
36
|
const delCount = textLength - maxLength;
|