@toptal/picasso-rich-text-editor 4.2.0 → 5.0.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/LexicalEditor/hooks/useOnFocus/index.d.ts +1 -1
- package/LexicalEditor/hooks/useOnFocus/index.js +1 -1
- package/LexicalEditor/hooks/useOnFocus/index.js.map +1 -1
- package/LexicalEditor/hooks/useOnFocus/{useOnFocus.js → use-on-focus.js} +1 -1
- package/LexicalEditor/hooks/useOnFocus/use-on-focus.js.map +1 -0
- package/LexicalEditor/hooks/useTypographyClasses/index.d.ts +1 -1
- package/LexicalEditor/hooks/useTypographyClasses/index.js +1 -1
- package/LexicalEditor/hooks/useTypographyClasses/index.js.map +1 -1
- package/LexicalEditor/hooks/useTypographyClasses/{useTypographyClasses.js → use-typography-classes.js} +1 -1
- package/LexicalEditor/hooks/useTypographyClasses/use-typography-classes.js.map +1 -0
- package/LexicalEditor/styles.d.ts +1 -1
- package/LexicalEditor/styles.js +10 -3
- package/LexicalEditor/styles.js.map +1 -1
- package/LexicalEditor/utils/{cleanupHtmlOutput.js → cleanup-html-output.js} +3 -1
- package/LexicalEditor/utils/cleanup-html-output.js.map +1 -0
- package/LexicalEditor/utils/{cleanupHtmlOutput.test.js → cleanup-html-output.test.js} +14 -2
- package/LexicalEditor/utils/cleanup-html-output.test.js.map +1 -0
- package/LexicalEditor/utils/{createLexicalTheme.js → create-lexical-theme.js} +3 -1
- package/LexicalEditor/utils/create-lexical-theme.js.map +1 -0
- package/LexicalEditor/utils/{getDomValue.js → get-dom-value.js} +1 -1
- package/LexicalEditor/utils/get-dom-value.js.map +1 -0
- package/LexicalEditor/utils/{getDomValue.test.js → get-dom-value.test.js} +2 -2
- package/LexicalEditor/utils/get-dom-value.test.js.map +1 -0
- package/LexicalEditor/utils/{getLexicalNode.js → get-lexical-node.js} +1 -1
- package/LexicalEditor/utils/get-lexical-node.js.map +1 -0
- package/LexicalEditor/utils/{getSelectedNode.js → get-selected-node.js} +1 -1
- package/LexicalEditor/utils/get-selected-node.js.map +1 -0
- package/LexicalEditor/utils/hasChildDOMNodeTag.d.ts +2 -0
- package/LexicalEditor/utils/hasChildDOMNodeTag.js +12 -0
- package/LexicalEditor/utils/hasChildDOMNodeTag.js.map +1 -0
- package/LexicalEditor/utils/hasChildDOMNodeTag.test.js +39 -0
- package/LexicalEditor/utils/hasChildDOMNodeTag.test.js.map +1 -0
- package/LexicalEditor/utils/index.d.ts +9 -8
- package/LexicalEditor/utils/index.js +9 -8
- package/LexicalEditor/utils/index.js.map +1 -1
- package/LexicalEditor/utils/{registerLexicalEvents.js → register-lexical-events.js} +1 -1
- package/LexicalEditor/utils/register-lexical-events.js.map +1 -0
- package/LexicalEditor/utils/{registerLexicalEvents.test.js → register-lexical-events.test.js} +2 -2
- package/LexicalEditor/utils/register-lexical-events.test.js.map +1 -0
- package/LexicalEditor/utils/{setEditorValue.js → set-editor-value.js} +2 -2
- package/LexicalEditor/utils/set-editor-value.js.map +1 -0
- package/LexicalEditor/utils/{synchronizeToolbarState.d.ts → synchronize-toolbar-state.d.ts} +1 -1
- package/LexicalEditor/utils/{synchronizeToolbarState.js → synchronize-toolbar-state.js} +3 -3
- package/LexicalEditor/utils/synchronize-toolbar-state.js.map +1 -0
- package/LexicalEditor/utils/{synchronizeToolbarState.test.js → synchronize-toolbar-state.test.js} +7 -7
- package/LexicalEditor/utils/synchronize-toolbar-state.test.js.map +1 -0
- package/LexicalEditor/utils/{toolbarState.js → toolbar-state.js} +1 -1
- package/LexicalEditor/utils/toolbar-state.js.map +1 -0
- package/LexicalEditorToolbarPlugin/LexicalEditorToolbarPlugin.js +16 -2
- package/LexicalEditorToolbarPlugin/LexicalEditorToolbarPlugin.js.map +1 -1
- package/RichText/components/CodeBlock.d.ts +6 -0
- package/RichText/components/CodeBlock.js +10 -0
- package/RichText/components/CodeBlock.js.map +1 -0
- package/RichText/components/index.d.ts +2 -0
- package/RichText/components/index.js +2 -0
- package/RichText/components/index.js.map +1 -1
- package/RichText/components/styles.d.ts +4 -10
- package/RichText/components/styles.js +17 -0
- package/RichText/components/styles.js.map +1 -1
- package/RichText/hooks/useRichText/useRichText.js +2 -2
- package/RichText/hooks/useRichText/useRichText.js.map +1 -1
- package/RichText/types.d.ts +1 -1
- package/RichTextEditor/hooks/useTypographyClasses/index.d.ts +1 -1
- package/RichTextEditor/hooks/useTypographyClasses/index.js +1 -1
- package/RichTextEditor/hooks/useTypographyClasses/index.js.map +1 -1
- package/RichTextEditor/hooks/useTypographyClasses/{useTypographyClasses.js → use-typography-classes.js} +1 -1
- package/RichTextEditor/hooks/useTypographyClasses/use-typography-classes.js.map +1 -0
- package/RichTextEditor/store/toolbar/{actionTypes.js → action-types.js} +1 -1
- package/RichTextEditor/store/toolbar/action-types.js.map +1 -0
- package/RichTextEditor/store/toolbar/actions.js +1 -1
- package/RichTextEditor/store/toolbar/actions.js.map +1 -1
- package/RichTextEditor/store/toolbar/index.d.ts +2 -2
- package/RichTextEditor/store/toolbar/index.js +2 -2
- package/RichTextEditor/store/toolbar/index.js.map +1 -1
- package/RichTextEditor/store/toolbar/{initialState.js → initial-state.js} +1 -1
- package/RichTextEditor/store/toolbar/initial-state.js.map +1 -0
- package/RichTextEditor/store/toolbar/reducer.js +2 -2
- package/RichTextEditor/store/toolbar/reducer.js.map +1 -1
- package/RichTextEditor/store/toolbar/types.d.ts +1 -1
- package/RichTextEditor/styles.js +1 -1
- package/RichTextEditor/styles.js.map +1 -1
- package/RichTextEditorToolbar/RichTextEditorToolbar.js +5 -4
- package/RichTextEditorToolbar/RichTextEditorToolbar.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/plugins/CodeBlockPlugin/CodeBlockButton.d.ts +6 -0
- package/plugins/CodeBlockPlugin/CodeBlockButton.js +98 -0
- package/plugins/CodeBlockPlugin/CodeBlockButton.js.map +1 -0
- package/plugins/CodeBlockPlugin/CodeBlockPlugin.d.ts +8 -0
- package/plugins/CodeBlockPlugin/CodeBlockPlugin.js +43 -0
- package/plugins/CodeBlockPlugin/CodeBlockPlugin.js.map +1 -0
- package/plugins/CodeBlockPlugin/index.d.ts +1 -0
- package/plugins/CodeBlockPlugin/index.js +2 -0
- package/plugins/CodeBlockPlugin/index.js.map +1 -0
- package/plugins/CodeBlockPlugin/nodes/CodeBlockNode.d.ts +18 -0
- package/plugins/CodeBlockPlugin/nodes/CodeBlockNode.js +135 -0
- package/plugins/CodeBlockPlugin/nodes/CodeBlockNode.js.map +1 -0
- package/plugins/CodeBlockPlugin/nodes/CodeBlockTextNode.d.ts +14 -0
- package/plugins/CodeBlockPlugin/nodes/CodeBlockTextNode.js +43 -0
- package/plugins/CodeBlockPlugin/nodes/CodeBlockTextNode.js.map +1 -0
- package/plugins/CodeBlockPlugin/nodes/index.d.ts +8 -0
- package/plugins/CodeBlockPlugin/nodes/index.js +15 -0
- package/plugins/CodeBlockPlugin/nodes/index.js.map +1 -0
- package/plugins/CodeBlockPlugin/utils/getFirstCodeNodeOfLine.d.ts +4 -0
- package/plugins/CodeBlockPlugin/utils/getFirstCodeNodeOfLine.js +12 -0
- package/plugins/CodeBlockPlugin/utils/getFirstCodeNodeOfLine.js.map +1 -0
- package/plugins/CodeBlockPlugin/utils/getFirstCodeNodeOfLine.test.d.ts +1 -0
- package/plugins/CodeBlockPlugin/utils/getFirstCodeNodeOfLine.test.js +66 -0
- package/plugins/CodeBlockPlugin/utils/getFirstCodeNodeOfLine.test.js.map +1 -0
- package/plugins/CodeBlockPlugin/utils/index.d.ts +1 -0
- package/plugins/CodeBlockPlugin/utils/index.js +2 -0
- package/plugins/CodeBlockPlugin/utils/index.js.map +1 -0
- package/plugins/CodePlugin/CodeButton.js +3 -2
- package/plugins/CodePlugin/CodeButton.js.map +1 -1
- package/plugins/HeadingsReplacementPlugin/utils/index.d.ts +1 -1
- package/plugins/HeadingsReplacementPlugin/utils/index.js +1 -1
- package/plugins/HeadingsReplacementPlugin/utils/index.js.map +1 -1
- package/plugins/HeadingsReplacementPlugin/utils/{replaceHeadingNodes.js → replace-heading-nodes.js} +1 -1
- package/plugins/HeadingsReplacementPlugin/utils/replace-heading-nodes.js.map +1 -0
- package/plugins/HeadingsReplacementPlugin/utils/replace-heading-nodes.test.d.ts +1 -0
- package/plugins/HeadingsReplacementPlugin/utils/{replaceHeadingNodes.test.js → replace-heading-nodes.test.js} +2 -2
- package/plugins/HeadingsReplacementPlugin/utils/replace-heading-nodes.test.js.map +1 -0
- package/plugins/ImagePlugin/components/ImagePluginButton/ImagePluginButton.js +2 -2
- package/plugins/ImagePlugin/components/ImagePluginButton/ImagePluginButton.js.map +1 -1
- package/plugins/LinkPlugin/LinkPluginButton.js +4 -3
- package/plugins/LinkPlugin/LinkPluginButton.js.map +1 -1
- package/plugins/api.d.ts +2 -0
- package/plugins/api.js +10 -3
- package/plugins/api.js.map +1 -1
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +1 -0
- package/plugins/index.js.map +1 -1
- package/utils/html-to-hast.js +1 -0
- package/utils/html-to-hast.js.map +1 -1
- package/LexicalEditor/hooks/useOnFocus/useOnFocus.js.map +0 -1
- package/LexicalEditor/hooks/useTypographyClasses/useTypographyClasses.js.map +0 -1
- package/LexicalEditor/utils/cleanupHtmlOutput.js.map +0 -1
- package/LexicalEditor/utils/cleanupHtmlOutput.test.js.map +0 -1
- package/LexicalEditor/utils/createLexicalTheme.js.map +0 -1
- package/LexicalEditor/utils/getDomValue.js.map +0 -1
- package/LexicalEditor/utils/getDomValue.test.js.map +0 -1
- package/LexicalEditor/utils/getLexicalNode.js.map +0 -1
- package/LexicalEditor/utils/getSelectedNode.js.map +0 -1
- package/LexicalEditor/utils/registerLexicalEvents.js.map +0 -1
- package/LexicalEditor/utils/registerLexicalEvents.test.js.map +0 -1
- package/LexicalEditor/utils/setEditorValue.js.map +0 -1
- package/LexicalEditor/utils/synchronizeToolbarState.js.map +0 -1
- package/LexicalEditor/utils/synchronizeToolbarState.test.js.map +0 -1
- package/LexicalEditor/utils/toolbarState.js.map +0 -1
- package/RichTextEditor/hooks/useTypographyClasses/useTypographyClasses.js.map +0 -1
- package/RichTextEditor/store/toolbar/actionTypes.js.map +0 -1
- package/RichTextEditor/store/toolbar/initialState.js.map +0 -1
- package/plugins/HeadingsReplacementPlugin/utils/replaceHeadingNodes.js.map +0 -1
- package/plugins/HeadingsReplacementPlugin/utils/replaceHeadingNodes.test.js.map +0 -1
- /package/LexicalEditor/hooks/useOnFocus/{useOnFocus.d.ts → use-on-focus.d.ts} +0 -0
- /package/LexicalEditor/hooks/useTypographyClasses/{useTypographyClasses.d.ts → use-typography-classes.d.ts} +0 -0
- /package/LexicalEditor/utils/{cleanupHtmlOutput.d.ts → cleanup-html-output.d.ts} +0 -0
- /package/LexicalEditor/utils/{cleanupHtmlOutput.test.d.ts → cleanup-html-output.test.d.ts} +0 -0
- /package/LexicalEditor/utils/{createLexicalTheme.d.ts → create-lexical-theme.d.ts} +0 -0
- /package/LexicalEditor/utils/{getDomValue.d.ts → get-dom-value.d.ts} +0 -0
- /package/LexicalEditor/utils/{getDomValue.test.d.ts → get-dom-value.test.d.ts} +0 -0
- /package/LexicalEditor/utils/{getLexicalNode.d.ts → get-lexical-node.d.ts} +0 -0
- /package/LexicalEditor/utils/{getSelectedNode.d.ts → get-selected-node.d.ts} +0 -0
- /package/LexicalEditor/utils/{registerLexicalEvents.test.d.ts → hasChildDOMNodeTag.test.d.ts} +0 -0
- /package/LexicalEditor/utils/{registerLexicalEvents.d.ts → register-lexical-events.d.ts} +0 -0
- /package/LexicalEditor/utils/{synchronizeToolbarState.test.d.ts → register-lexical-events.test.d.ts} +0 -0
- /package/LexicalEditor/utils/{setEditorValue.d.ts → set-editor-value.d.ts} +0 -0
- /package/{plugins/HeadingsReplacementPlugin/utils/replaceHeadingNodes.test.d.ts → LexicalEditor/utils/synchronize-toolbar-state.test.d.ts} +0 -0
- /package/LexicalEditor/utils/{toolbarState.d.ts → toolbar-state.d.ts} +0 -0
- /package/RichTextEditor/hooks/useTypographyClasses/{useTypographyClasses.d.ts → use-typography-classes.d.ts} +0 -0
- /package/RichTextEditor/store/toolbar/{actionTypes.d.ts → action-types.d.ts} +0 -0
- /package/RichTextEditor/store/toolbar/{initialState.d.ts → initial-state.d.ts} +0 -0
- /package/plugins/HeadingsReplacementPlugin/utils/{replaceHeadingNodes.d.ts → replace-heading-nodes.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/RichText/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/RichText/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { Theme } from '@material-ui/core/styles';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
borderRadius: string;
|
|
7
|
-
padding: string;
|
|
8
|
-
fontSize: string;
|
|
9
|
-
fontFamily: string;
|
|
10
|
-
};
|
|
11
|
-
declare const _default: (theme: Theme) => import("@material-ui/styles").StyleRules<{}, "code">;
|
|
2
|
+
import type { CSSProperties } from '@material-ui/core/styles/withStyles';
|
|
3
|
+
export declare const codeStyles: ({ palette, typography }: Theme) => CSSProperties;
|
|
4
|
+
export declare const codeBlockStyles: ({ palette, sizes, typography, }: Theme) => CSSProperties;
|
|
5
|
+
declare const _default: (theme: Theme) => import("@material-ui/styles").StyleRules<{}, "code" | "codeBlock">;
|
|
12
6
|
export default _default;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createStyles } from '@material-ui/core/styles';
|
|
2
|
+
import { rem } from '@toptal/picasso-shared';
|
|
2
3
|
export const codeStyles = ({ palette, typography }) => ({
|
|
3
4
|
color: palette.red.main,
|
|
4
5
|
backgroundColor: palette.grey.lighter,
|
|
@@ -7,8 +8,24 @@ export const codeStyles = ({ palette, typography }) => ({
|
|
|
7
8
|
padding: '1px 0.25rem',
|
|
8
9
|
fontSize: typography.fontSizes.xsmall,
|
|
9
10
|
fontFamily: 'monospace',
|
|
11
|
+
textWrap: 'wrap',
|
|
12
|
+
wordBreak: 'break-word',
|
|
13
|
+
});
|
|
14
|
+
export const codeBlockStyles = ({ palette, sizes, typography, }) => ({
|
|
15
|
+
backgroundColor: palette.grey.lighter,
|
|
16
|
+
borderRadius: sizes.borderRadius.small,
|
|
17
|
+
padding: '0.25rem 0.5rem',
|
|
18
|
+
display: 'block',
|
|
19
|
+
fontFamily: 'monospace',
|
|
20
|
+
fontSize: typography.fontSizes.xxsmall,
|
|
21
|
+
lineHeight: rem('18px'),
|
|
22
|
+
color: palette.common.black,
|
|
23
|
+
textWrap: 'wrap',
|
|
24
|
+
wordBreak: 'break-word',
|
|
25
|
+
margin: 0,
|
|
10
26
|
});
|
|
11
27
|
export default (theme) => createStyles({
|
|
12
28
|
code: codeStyles(theme),
|
|
29
|
+
codeBlock: codeBlockStyles(theme),
|
|
13
30
|
});
|
|
14
31
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/RichText/components/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAA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EAAE,UAAU,CAAC,KAAK,CAAC;IACvB,SAAS,EAAE,eAAe,CAAC,KAAK,CAAC;CAClC,CAAC,CAAA"}
|
|
@@ -16,9 +16,8 @@ import Container from '@toptal/picasso/Container';
|
|
|
16
16
|
import List from '@toptal/picasso/List';
|
|
17
17
|
import ListItem from '@toptal/picasso/ListItem';
|
|
18
18
|
import Link from '@toptal/picasso/Link';
|
|
19
|
-
import { Emoji, Image } from '../../components';
|
|
19
|
+
import { Emoji, Image, Code, CodeBlock } from '../../components';
|
|
20
20
|
import { isCustomEmoji } from '../../../utils';
|
|
21
|
-
import Code from '../../components/Code';
|
|
22
21
|
// List internaly passes another props to ListItem
|
|
23
22
|
const Li = (_a) => {
|
|
24
23
|
var { children } = _a, props = __rest(_a, ["children"]);
|
|
@@ -51,6 +50,7 @@ const componentMap = {
|
|
|
51
50
|
a: A,
|
|
52
51
|
img: Img,
|
|
53
52
|
code: Code,
|
|
53
|
+
pre: CodeBlock,
|
|
54
54
|
};
|
|
55
55
|
const picassoMapper = (child) => {
|
|
56
56
|
var _a, _b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRichText.js","sourceRoot":"","sources":["../../../../src/RichText/hooks/useRichText/useRichText.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,GAAG,MAAM,qBAAqB,CAAA;AAErC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACrE,OAAO,UAAU,MAAM,4BAA4B,CAAA;AACnD,OAAO,SAAS,MAAM,2BAA2B,CAAA;AACjD,OAAO,IAAI,MAAM,sBAAsB,CAAA;AACvC,OAAO,QAAQ,MAAM,0BAA0B,CAAA;AAC/C,OAAO,IAAI,MAAM,sBAAsB,CAAA;AAGvC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"useRichText.js","sourceRoot":"","sources":["../../../../src/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4,7 +4,7 @@ export declare type TextType = {
|
|
|
4
4
|
};
|
|
5
5
|
export declare type ElementType = {
|
|
6
6
|
type: 'element';
|
|
7
|
-
tagName: 'p' | 'h3' | 'strong' | 'em' | 'ul' | 'ol' | 'li' | 'br' | 'a' | 'img' | 'code';
|
|
7
|
+
tagName: 'p' | 'h3' | 'strong' | 'em' | 'ul' | 'ol' | 'li' | 'br' | 'a' | 'img' | 'code' | 'pre';
|
|
8
8
|
properties: {};
|
|
9
9
|
children: ASTChildType[];
|
|
10
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './
|
|
1
|
+
export { default } from './use-typography-classes';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from './
|
|
1
|
+
export { default } from './use-typography-classes';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/hooks/useTypographyClasses/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/hooks/useTypographyClasses/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-typography-classes.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/hooks/useTypographyClasses/use-typography-classes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAG1E,MAAM,0BAA0B,GAAG,UAAU,CAAQ,gBAAgB,EAAE;IACrE,IAAI,EAAE,sBAAsB;CAC7B,CAAC,CAAA;AAEF,MAAM,oBAAoB,GAAG,CAAC,OAA0B,EAAU,EAAE;IAClE,MAAM,OAAO,GAAG,0BAA0B,EAAE,CAAA;IAE5C,OAAO,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACjD,CAAC,CAAA;AAED,eAAe,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-types.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/store/toolbar/action-types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,kBAAkB;IACxB,MAAM,EAAE,oBAAoB;IAC5B,MAAM,EAAE,oBAAoB;IAC5B,IAAI,EAAE,kBAAkB;IACxB,QAAQ,EAAE,sBAAsB;IAChC,WAAW,EAAE,sBAAsB;IACnC,IAAI,EAAE,cAAc;CACZ,CAAA;AAEV,eAAe,WAAW,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import actionTypes from './
|
|
1
|
+
import actionTypes from './action-types';
|
|
2
2
|
const setBold = (dispatch) => (payload) => dispatch({ type: actionTypes.bold, payload });
|
|
3
3
|
const setItalic = (dispatch) => (payload) => dispatch({ type: actionTypes.italic, payload });
|
|
4
4
|
const setHeader = (dispatch) => (payload) => dispatch({ type: actionTypes.header, payload });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/store/toolbar/actions.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/store/toolbar/actions.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,gBAAgB,CAAA;AAWxC,MAAM,OAAO,GACX,CAAC,QAAqC,EAAE,EAAE,CAC1C,CAAC,OAAqC,EAAE,EAAE,CACxC,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;AAEjD,MAAM,SAAS,GACb,CAAC,QAAuC,EAAE,EAAE,CAC5C,CAAC,OAAuC,EAAE,EAAE,CAC1C,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;AAEnD,MAAM,SAAS,GACb,CAAC,QAAuC,EAAE,EAAE,CAC5C,CAAC,OAAuC,EAAE,EAAE,CAC1C,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;AAEnD,MAAM,OAAO,GACX,CAAC,QAAqC,EAAE,EAAE,CAC1C,CAAC,OAAqC,EAAE,EAAE,CACxC,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;AAEjD,MAAM,OAAO,GACX,CAAC,QAAqC,EAAE,EAAE,CAC1C,CAAC,OAAqC,EAAE,EAAE,CACxC,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;AAEjD,MAAM,WAAW,GAAG,CAAC,QAA+B,EAAE,EAAE,CAAC,CAAC,OAAgB,EAAE,EAAE,CAC5E,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;AAEnD,MAAM,WAAW,GAAG,CAAC,QAAmC,EAAE,EAAE,CAAC,GAAG,EAAE,CAChE,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,WAAW,EAAE,CAAC,CAAA;AAE7C,MAAM,OAAO,GAAG;IACd,OAAO;IACP,SAAS;IACT,SAAS;IACT,OAAO;IACP,OAAO;IACP,WAAW;IACX,WAAW;CACZ,CAAA;AAED,eAAe,OAAO,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import actions from './actions';
|
|
2
2
|
import reducer from './reducer';
|
|
3
|
-
import initialState from './
|
|
4
|
-
import actionTypes from './
|
|
3
|
+
import initialState from './initial-state';
|
|
4
|
+
import actionTypes from './action-types';
|
|
5
5
|
export * from './types';
|
|
6
6
|
export { actions, actionTypes, reducer, initialState };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import actions from './actions';
|
|
2
2
|
import reducer from './reducer';
|
|
3
|
-
import initialState from './
|
|
4
|
-
import actionTypes from './
|
|
3
|
+
import initialState from './initial-state';
|
|
4
|
+
import actionTypes from './action-types';
|
|
5
5
|
export * from './types';
|
|
6
6
|
export { actions, actionTypes, reducer, initialState };
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/store/toolbar/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,YAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/store/toolbar/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,OAAO,MAAM,WAAW,CAAA;AAC/B,OAAO,YAAY,MAAM,iBAAiB,CAAA;AAC1C,OAAO,WAAW,MAAM,gBAAgB,CAAA;AAExC,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initial-state.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/store/toolbar/initial-state.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAqB;IACrC,MAAM,EAAE;QACN,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,EAAE;KACT;IACD,QAAQ,EAAE,IAAI;CACf,CAAA;AAED,eAAe,YAAY,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import actionTypes from './
|
|
2
|
-
import initialState from './
|
|
1
|
+
import actionTypes from './action-types';
|
|
2
|
+
import initialState from './initial-state';
|
|
3
3
|
const reducer = (state = initialState, action) => {
|
|
4
4
|
switch (action.type) {
|
|
5
5
|
case actionTypes.bold:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/store/toolbar/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,
|
|
1
|
+
{"version":3,"file":"reducer.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/store/toolbar/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,gBAAgB,CAAA;AAExC,OAAO,YAAY,MAAM,iBAAiB,CAAA;AAE1C,MAAM,OAAO,GAAuB,CAAC,KAAK,GAAG,YAAY,EAAE,MAAM,EAAE,EAAE;IACnE,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,WAAW,CAAC,IAAI;YACnB,uCACK,KAAK,KACR,MAAM,kCAAO,KAAK,CAAC,MAAM,KAAE,IAAI,EAAE,MAAM,CAAC,OAAO,OAChD;QACH,KAAK,WAAW,CAAC,MAAM;YACrB,uCACK,KAAK,KACR,MAAM,kCAAO,KAAK,CAAC,MAAM,KAAE,MAAM,EAAE,MAAM,CAAC,OAAO,OAClD;QACH,KAAK,WAAW,CAAC,MAAM;YACrB,uCACK,KAAK,KACR,MAAM,kCAAO,KAAK,CAAC,MAAM,KAAE,MAAM,EAAE,MAAM,CAAC,OAAO,OAClD;QACH,KAAK,WAAW,CAAC,IAAI;YACnB,uCACK,KAAK,KACR,MAAM,kCAAO,KAAK,CAAC,MAAM,KAAE,IAAI,EAAE,MAAM,CAAC,OAAO,OAChD;QACH,KAAK,WAAW,CAAC,IAAI;YACnB,uCACK,KAAK,KACR,MAAM,kCAAO,KAAK,CAAC,MAAM,KAAE,IAAI,EAAE,MAAM,CAAC,OAAO,OAChD;QACH,KAAK,WAAW,CAAC,QAAQ;YACvB,uCACK,KAAK,KACR,QAAQ,EAAE,MAAM,CAAC,OAAO,IACzB;QAEH,KAAK,WAAW,CAAC,WAAW;YAC1B,uCACK,KAAK,KACR,MAAM,EAAE,YAAY,CAAC,MAAM,IAC5B;QAEH;YACE,OAAO,KAAK,CAAA;KACf;AACH,CAAC,CAAA;AAED,eAAe,OAAO,CAAA"}
|
package/RichTextEditor/styles.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { outline } from '@toptal/picasso-shared';
|
|
2
2
|
import { createStyles } from '@material-ui/core/styles';
|
|
3
|
-
import highlightAutofillStyles from '@toptal/picasso/InputBase/
|
|
3
|
+
import highlightAutofillStyles from '@toptal/picasso/InputBase/highlight-styles';
|
|
4
4
|
export default (theme) => {
|
|
5
5
|
const { palette, sizes } = theme;
|
|
6
6
|
return createStyles(Object.assign({ editorWrapper: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/RichTextEditor/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,uBAAuB,MAAM,
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/RichTextEditor/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,uBAAuB,MAAM,4CAA4C,CAAA;AAEhF,eAAe,CAAC,KAAY,EAAE,EAAE;IAC9B,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,CAAA;IAEhC,OAAO,YAAY,iBACjB,aAAa,EAAE;YACb,QAAQ,EAAE,UAAU;YACpB,YAAY,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK;YACtC,MAAM,EAAE,aAAa,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE;YAC1C,OAAO,EAAE,OAAO;YAEhB,oCAAoC,EAAE;gBACpC,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK;aAChC;SACF,EAED,QAAQ,EAAE;YACR,aAAa,EAAE,MAAM;YACrB,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO;YAChC,MAAM,EAAE,aAAa,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE;SAC7C,EAED,KAAK,EAAE;YACL,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI;YAC7B,WAAW,kBACT,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,IAC1B,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAC7B;SACF,EAED,OAAO,kBACL,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,IAC5B,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAG/B,uBAAuB,CAAC,KAAK,CAAC,EACjC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { Bold16, Container, Italic16, ListOrdered16, ListUnordered16, Select, }
|
|
|
3
3
|
import { useMultipleForwardRefs } from '@toptal/picasso/utils';
|
|
4
4
|
import cx from 'classnames';
|
|
5
5
|
import React, { forwardRef } from 'react';
|
|
6
|
-
import { useToolbarPortalRegister } from '../plugins/api';
|
|
6
|
+
import { useRTEPluginContext, useToolbarPortalRegister } from '../plugins/api';
|
|
7
7
|
import TextEditorButton from '../RichTextEditorButton';
|
|
8
8
|
import styles from './styles';
|
|
9
9
|
const useStyles = makeStyles(styles, {
|
|
@@ -13,9 +13,10 @@ export const ALLOWED_HEADER_TYPE = '3';
|
|
|
13
13
|
export const RichTextEditorToolbar = forwardRef(function RichTextEditorToolbar(props, ref) {
|
|
14
14
|
const { disabled, format, onBoldClick, onItalicClick, onHeaderChange, onUnorderedClick, onOrderedClick, testIds, id, } = props;
|
|
15
15
|
const { setToolbarPortalEl } = useToolbarPortalRegister();
|
|
16
|
+
const { disabledFormatting } = useRTEPluginContext();
|
|
16
17
|
const toolbarRef = useMultipleForwardRefs([ref, setToolbarPortalEl]);
|
|
17
18
|
const classes = useStyles(props);
|
|
18
|
-
const
|
|
19
|
+
const isInlineFormattingDisabled = disabled || disabledFormatting;
|
|
19
20
|
return (React.createElement(Container, { ref: toolbarRef, id: `${id}toolbar`, className: classes.toolbar },
|
|
20
21
|
React.createElement(Container, { className: cx(classes.group, {
|
|
21
22
|
groupDisabled: disabled,
|
|
@@ -25,8 +26,8 @@ export const RichTextEditorToolbar = forwardRef(function RichTextEditorToolbar(p
|
|
|
25
26
|
{ value: '', text: 'normal' },
|
|
26
27
|
], size: 'small', menuWidth: '123px', className: classes.select, disabled: disabled, "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.headerSelect })),
|
|
27
28
|
React.createElement(Container, { className: classes.group },
|
|
28
|
-
React.createElement(TextEditorButton, { icon: React.createElement(Bold16, null), onClick: onBoldClick, active:
|
|
29
|
-
React.createElement(TextEditorButton, { icon: React.createElement(Italic16, null), onClick: onItalicClick, active:
|
|
29
|
+
React.createElement(TextEditorButton, { icon: React.createElement(Bold16, null), onClick: onBoldClick, active: isInlineFormattingDisabled ? false : format.bold, disabled: isInlineFormattingDisabled, "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.boldButton }),
|
|
30
|
+
React.createElement(TextEditorButton, { icon: React.createElement(Italic16, null), onClick: onItalicClick, active: isInlineFormattingDisabled ? false : format.italic, disabled: isInlineFormattingDisabled, "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.italicButton })),
|
|
30
31
|
React.createElement(Container, { className: classes.group },
|
|
31
32
|
React.createElement(TextEditorButton, { icon: React.createElement(ListUnordered16, null), onClick: onUnorderedClick, active: format.list === 'bullet', disabled: disabled, "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.unorderedListButton }),
|
|
32
33
|
React.createElement(TextEditorButton, { icon: React.createElement(ListOrdered16, null), onClick: onOrderedClick, active: format.list === 'ordered', disabled: disabled, "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.orderedListButton }))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditorToolbar.js","sourceRoot":"","sources":["../../src/RichTextEditorToolbar/RichTextEditorToolbar.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EACL,MAAM,EACN,SAAS,EACT,QAAQ,EACR,aAAa,EACb,eAAe,EACf,MAAM,GACP,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"RichTextEditorToolbar.js","sourceRoot":"","sources":["../../src/RichTextEditorToolbar/RichTextEditorToolbar.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EACL,MAAM,EACN,SAAS,EACT,QAAQ,EACR,aAAa,EACb,eAAe,EACf,MAAM,GACP,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AAC9E,OAAO,gBAAgB,MAAM,yBAAyB,CAAA;AACtD,OAAO,MAAM,MAAM,UAAU,C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AAC,CACF,CAAA;AAED,qBAAqB,CAAC,YAAY,GAAG;IACnC,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE;QACN,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,EAAE;KACX;IACD,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;IACvB,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,gBAAgB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC1B,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;CACzB,CAAA;AAED,qBAAqB,CAAC,WAAW,GAAG,uBAAuB,CAAA;AAE3D,eAAe,qBAAqB,CAAA"}
|
package/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export { default as RichTextEditor } from './RichTextEditor';
|
|
|
2
2
|
export type { RichTextEditorProps, RichTextEditorChangeHandler, } from './RichTextEditor';
|
|
3
3
|
export { default as RichText } from './RichText';
|
|
4
4
|
export type { RichTextProps, ASTType } from './RichText';
|
|
5
|
-
export { ImagePlugin, EmojiPlugin, LinkPlugin, CodePlugin } from './plugins';
|
|
5
|
+
export { ImagePlugin, EmojiPlugin, LinkPlugin, CodePlugin, CodeBlockPlugin, } from './plugins';
|
|
6
6
|
export type { UploadedImage, CustomEmoji, CustomEmojiGroup } from './plugins';
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as RichTextEditor } from './RichTextEditor';
|
|
2
2
|
export { default as RichText } from './RichText';
|
|
3
|
-
export { ImagePlugin, EmojiPlugin, LinkPlugin, CodePlugin } from './plugins';
|
|
3
|
+
export { ImagePlugin, EmojiPlugin, LinkPlugin, CodePlugin, CodeBlockPlugin, } from './plugins';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAK5D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEhD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAK5D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAA;AAEhD,OAAO,EACL,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,eAAe,GAChB,MAAM,WAAW,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/picasso-rich-text-editor",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Picasso rich text editor",
|
|
5
5
|
"author": "Toptal",
|
|
6
6
|
"homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso-rich-text-editor#readme",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"url": "https://github.com/toptal/picasso/issues"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@toptal/picasso": "^37.
|
|
26
|
+
"@toptal/picasso": "^37.3.0",
|
|
27
27
|
"@toptal/picasso-shared": "^12.0.0",
|
|
28
28
|
"@material-ui/core": "4.12.4",
|
|
29
29
|
"@lexical/utils": "0.11.2",
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { CodeBlock16 } from '@toptal/picasso';
|
|
2
|
+
import React, { useCallback, useState } from 'react';
|
|
3
|
+
import { $createLineBreakNode, $createParagraphNode, $getSelection, $isElementNode, $isRangeSelection, ElementNode, } from 'lexical';
|
|
4
|
+
import { $getNearestNodeOfType } from '@lexical/utils';
|
|
5
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
6
|
+
import { $setBlocksType } from '@lexical/selection';
|
|
7
|
+
import { useRTEPluginContext, useRTEUpdate } from '../api';
|
|
8
|
+
import RichTextEditorButton from '../../RichTextEditorButton';
|
|
9
|
+
import { $createCodeBlockTextNode, $createCodeBlockNode, $isCodeBlockNode, } from './nodes';
|
|
10
|
+
import { getSelectedNode } from '../../LexicalEditor/utils';
|
|
11
|
+
// go up through the tree and find the nearest block node (paragraph, heading, list, etc)
|
|
12
|
+
const getParentBlockNode = (node) => {
|
|
13
|
+
if (!node) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const elementNode = $getNearestNodeOfType(node, ElementNode);
|
|
17
|
+
if (!elementNode) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
if (elementNode.isInline()) {
|
|
21
|
+
return getParentBlockNode(elementNode.getParent());
|
|
22
|
+
}
|
|
23
|
+
return elementNode;
|
|
24
|
+
};
|
|
25
|
+
const getBlockNodesInSelection = () => {
|
|
26
|
+
const selection = $getSelection();
|
|
27
|
+
if (!$isRangeSelection(selection)) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
let blockNodesInSelection = selection
|
|
31
|
+
.getNodes()
|
|
32
|
+
.filter($isElementNode)
|
|
33
|
+
.filter(node => node.isInline() === false);
|
|
34
|
+
const isBlockNodesEmpty = blockNodesInSelection.length === 0;
|
|
35
|
+
if (isBlockNodesEmpty) {
|
|
36
|
+
const selectedNode = getSelectedNode(selection);
|
|
37
|
+
const blockNode = getParentBlockNode(selectedNode);
|
|
38
|
+
if (!blockNode) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
blockNodesInSelection = [blockNode];
|
|
42
|
+
}
|
|
43
|
+
return blockNodesInSelection;
|
|
44
|
+
};
|
|
45
|
+
const appendTextToCodeBlock = (node, codeBlock, isLast) => {
|
|
46
|
+
const text = node.getTextContent();
|
|
47
|
+
if (text) {
|
|
48
|
+
codeBlock.append($createCodeBlockTextNode(text));
|
|
49
|
+
}
|
|
50
|
+
if (!isLast) {
|
|
51
|
+
codeBlock.append($createLineBreakNode());
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const replaceChildrenNodesWithRawText = (selection) => {
|
|
55
|
+
$setBlocksType(selection, () => $createParagraphNode());
|
|
56
|
+
const codeBlock = $createCodeBlockNode();
|
|
57
|
+
const blockNodesInSelection = getBlockNodesInSelection();
|
|
58
|
+
if (blockNodesInSelection.length === 0) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
blockNodesInSelection.forEach((node, index) => {
|
|
62
|
+
const isLast = index === blockNodesInSelection.length - 1;
|
|
63
|
+
appendTextToCodeBlock(node, codeBlock, isLast);
|
|
64
|
+
if (isLast) {
|
|
65
|
+
node.insertAfter(codeBlock);
|
|
66
|
+
}
|
|
67
|
+
node.remove();
|
|
68
|
+
});
|
|
69
|
+
codeBlock.select();
|
|
70
|
+
};
|
|
71
|
+
const CodeBlockButton = ({ 'data-testid': testId }) => {
|
|
72
|
+
const [isButtonActive, setButtonActive] = useState(false);
|
|
73
|
+
const [editor] = useLexicalComposerContext();
|
|
74
|
+
const { disabled, focused } = useRTEPluginContext();
|
|
75
|
+
const handleClick = useCallback(() => {
|
|
76
|
+
editor.update(() => {
|
|
77
|
+
const selection = $getSelection();
|
|
78
|
+
if ($isRangeSelection(selection)) {
|
|
79
|
+
if (isButtonActive) {
|
|
80
|
+
return $setBlocksType(selection, () => $createParagraphNode());
|
|
81
|
+
}
|
|
82
|
+
replaceChildrenNodesWithRawText(selection);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}, [editor, isButtonActive]);
|
|
86
|
+
useRTEUpdate(() => {
|
|
87
|
+
const selection = $getSelection();
|
|
88
|
+
if ($isRangeSelection(selection)) {
|
|
89
|
+
const node = getSelectedNode(selection);
|
|
90
|
+
const parent = node.getParent();
|
|
91
|
+
const isCodeBlockSelected = $isCodeBlockNode(parent) || $isCodeBlockNode(node);
|
|
92
|
+
setButtonActive(isCodeBlockSelected);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return (React.createElement(RichTextEditorButton, { icon: React.createElement(CodeBlock16, null), onClick: handleClick, active: isButtonActive, disabled: disabled || !focused, "data-testid": testId }));
|
|
96
|
+
};
|
|
97
|
+
export default CodeBlockButton;
|
|
98
|
+
//# sourceMappingURL=CodeBlockButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeBlockButton.js","sourceRoot":"","sources":["../../../src/plugins/CodeBlockPlugin/CodeBlockButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,WAAW,GACZ,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAA;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEnD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAC1D,OAAO,oBAAoB,MAAM,4BAA4B,CAAA;AAE7D,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAM3D,yFAAyF;AACzF,MAAM,kBAAkB,GAAG,CAAC,IAAwB,EAAsB,EAAE;IAC1E,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,WAAW,GAAG,qBAAqB,CAAC,IAAI,EAAE,WAAW,CAAC,CA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AAoB,EAAE,CAAC,CAAA;iBAC/D;gBAED,+BAA+B,CAAC,SAAS,CAAC,CAAA;aAC3C;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;IAE5B,YAAY,CAAC,GAAG,EAAE;QAChB,MAAM,SAAS,GAAG,aAAa,EAAE,CAAA;QAEjC,IAAI,iBAAiB,CAAC,SAAS,CAAC,EAAE;YAChC,MAAM,IAAI,GAAG,eAAe,CAAC,SAAS,CAAC,CAAA;YACvC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAA;YAC/B,MAAM,mBAAmB,GACvB,gBAAgB,CAAC,MAAM,CAAC,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAA;YAEpD,eAAe,CAAC,mBAAmB,CAAC,CAAA;SACrC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,CACL,oBAAC,oBAAoB,IACnB,IAAI,EAAE,oBAAC,WAAW,OAAG,EACrB,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,QAAQ,IAAI,CAAC,OAAO,iBACjB,MAAM,GACnB,CACH,CAAA;AACH,CAAC,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
+
import { mergeRegister } from '@lexical/utils';
|
|
4
|
+
import { $createTextNode, TextNode } from 'lexical';
|
|
5
|
+
import { RTEPluginMeta, Toolbar } from '../api';
|
|
6
|
+
import CodeBlockButton from './CodeBlockButton';
|
|
7
|
+
import { $isCodeBlockNode, CodeBlockNode, $createCodeBlockTextNode, CodeBlockTextNode, } from './nodes';
|
|
8
|
+
const PLUGIN_NAME = 'code-block';
|
|
9
|
+
const textNodeTransform = (node) => {
|
|
10
|
+
// Since CodeNode has flat children structure we only need to check
|
|
11
|
+
// if node's parent is a code node and run highlighting if so
|
|
12
|
+
const parentNode = node.getParent();
|
|
13
|
+
if ($isCodeBlockNode(parentNode)) {
|
|
14
|
+
const text = node.getTextContent();
|
|
15
|
+
const codeTextNode = $createCodeBlockTextNode(text);
|
|
16
|
+
node.replace(codeTextNode);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
// when code block is converted to paragraph
|
|
20
|
+
const codeBlockTextNodeTransform = (node) => {
|
|
21
|
+
const parentNode = node.getParent();
|
|
22
|
+
if ($isCodeBlockNode(parentNode)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
node.replace($createTextNode(node.__text));
|
|
26
|
+
};
|
|
27
|
+
const CodeBlockPlugin = ({ testIds = {} }) => {
|
|
28
|
+
const [editor] = useLexicalComposerContext();
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
return mergeRegister(editor.registerNodeTransform(TextNode, textNodeTransform), editor.registerNodeTransform(CodeBlockTextNode, codeBlockTextNodeTransform));
|
|
31
|
+
}, [editor]);
|
|
32
|
+
return (React.createElement(React.Fragment, null,
|
|
33
|
+
React.createElement(Toolbar, { keyName: PLUGIN_NAME },
|
|
34
|
+
React.createElement(CodeBlockButton, { "data-testid": testIds.button }))));
|
|
35
|
+
};
|
|
36
|
+
CodeBlockPlugin[RTEPluginMeta] = {
|
|
37
|
+
name: PLUGIN_NAME,
|
|
38
|
+
lexical: {
|
|
39
|
+
nodes: [CodeBlockNode, CodeBlockTextNode],
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export default CodeBlockPlugin;
|
|
43
|
+
//# sourceMappingURL=CodeBlockPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeBlockPlugin.js","sourceRoot":"","sources":["../../../src/plugins/CodeBlockPlugin/CodeBlockPlugin.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE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AC,QAAQ,EAAE,iBAAiB,CAAC,EACzD,MAAM,CAAC,qBAAqB,CAC1B,iBAAiB,EACjB,0BAA0B,CAC3B,CACF,CAAA;IACH,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;IAEZ,OAAO,CACL;QACE,oBAAC,OAAO,IAAC,OAAO,EAAE,WAAW;YAC3B,oBAAC,eAAe,mBAAc,OAAO,CAAC,MAAM,GAAI,CACxC,CACT,CACJ,CAAA;AACH,CAAC,CAAA;AAED,eAAe,CAAC,aAAa,CAAC,GAAG;IAC/B,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE;QACP,KAAK,EAAE,CAAC,aAAa,EAAE,iBAAiB,CAAC;KAC1C;CACF,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, Props } from './CodeBlockPlugin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/CodeBlockPlugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAS,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DOMConversionMap, DOMExportOutput, EditorConfig, NodeKey, ParagraphNode, RangeSelection, SerializedElementNode } from 'lexical';
|
|
2
|
+
import { ElementNode } from 'lexical';
|
|
3
|
+
import type { CodeBlockTextNode } from '../nodes';
|
|
4
|
+
export declare class CodeBlockNode extends ElementNode {
|
|
5
|
+
static getType(): string;
|
|
6
|
+
static clone(node: CodeBlockNode): CodeBlockNode;
|
|
7
|
+
constructor(key?: NodeKey);
|
|
8
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
9
|
+
updateDOM(): boolean;
|
|
10
|
+
exportDOM(): DOMExportOutput;
|
|
11
|
+
static importDOM(): DOMConversionMap | null;
|
|
12
|
+
static importJSON(serializedNode: SerializedElementNode): CodeBlockNode;
|
|
13
|
+
exportJSON(): SerializedElementNode;
|
|
14
|
+
canIndent(): boolean;
|
|
15
|
+
extractWithChild(): boolean;
|
|
16
|
+
insertNewAfter(selection: RangeSelection, restoreSelection?: boolean): null | ParagraphNode | CodeBlockTextNode;
|
|
17
|
+
collapseAtStart(): boolean;
|
|
18
|
+
}
|