@os-design/editor 1.0.260 → 1.0.261
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/dist/@types/emotion.d.js +1 -0
- package/dist/{types/Editor → Editor}/BlockToolbar.d.ts +2 -2
- package/dist/Editor/BlockToolbar.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/BlockToolbar.js +9 -6
- package/dist/{types/Editor → Editor}/StyleToolbar.d.ts +2 -2
- package/dist/Editor/StyleToolbar.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/StyleToolbar.js +15 -13
- package/dist/Editor/Toolbar.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/Toolbar.js +1 -2
- package/dist/Editor/ToolbarButton.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/ToolbarButton.js +6 -6
- package/dist/Editor/blocks/Figure.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/blocks/Figure.js +1 -2
- package/dist/Editor/blocks/FigureCaption.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/blocks/FigureCaption.js +1 -2
- package/dist/{types/Editor → Editor}/blocks/imageBlock.d.ts +1 -1
- package/dist/Editor/blocks/imageBlock.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/blocks/imageBlock.js +18 -11
- package/dist/Editor/blocks/types.d.ts.map +1 -0
- package/dist/Editor/blocks/types.js +1 -0
- package/dist/{types/Editor → Editor}/blocks/videoBlock.d.ts +1 -1
- package/dist/Editor/blocks/videoBlock.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/blocks/videoBlock.js +13 -9
- package/dist/Editor/decorators/linkDecorator.d.ts +4 -0
- package/dist/Editor/decorators/linkDecorator.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/decorators/linkDecorator.js +6 -6
- package/dist/{types/Editor → Editor}/hooks/useBlockToolbarProps.d.ts +3 -0
- package/dist/Editor/hooks/useBlockToolbarProps.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/hooks/useBlockToolbarProps.js +1 -2
- package/dist/{types/Editor → Editor}/hooks/usePastedTextHandler.d.ts +4 -1
- package/dist/Editor/hooks/usePastedTextHandler.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/hooks/usePastedTextHandler.js +1 -2
- package/dist/{types/Editor → Editor}/hooks/useReturnHandler.d.ts +4 -1
- package/dist/Editor/hooks/useReturnHandler.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/hooks/useReturnHandler.js +1 -2
- package/dist/{types/Editor → Editor}/hooks/useStyleToolbarProps.d.ts +3 -0
- package/dist/Editor/hooks/useStyleToolbarProps.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/hooks/useStyleToolbarProps.js +1 -2
- package/dist/Editor/index.d.ts +42 -0
- package/dist/Editor/index.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/index.js +41 -37
- package/dist/Editor/styles/defaultDraftJsStyles.d.ts +7 -0
- package/dist/Editor/styles/defaultDraftJsStyles.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/styles/defaultDraftJsStyles.js +1 -2
- package/dist/{types/Editor → Editor}/styles/overrideDraftJsStyles.d.ts +1 -1
- package/dist/Editor/styles/overrideDraftJsStyles.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/styles/overrideDraftJsStyles.js +1 -4
- package/dist/Editor/utils/addNewBlockAt.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/utils/addNewBlockAt.js +1 -2
- package/dist/Editor/utils/changeBlock.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/utils/changeBlock.js +1 -2
- package/dist/Editor/utils/createContentEditorState.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/utils/createContentEditorState.js +1 -2
- package/dist/Editor/utils/createDecorator.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/utils/createDecorator.js +1 -2
- package/dist/Editor/utils/createEmptyEditorState.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/utils/createEmptyEditorState.js +1 -2
- package/dist/Editor/utils/defaultStyleToolbarItems.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/utils/defaultStyleToolbarItems.js +8 -8
- package/dist/Editor/utils/getCurrentBlock.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/utils/getCurrentBlock.js +1 -2
- package/dist/Editor/utils/getSelectedBlockElement.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/utils/getSelectedBlockElement.js +1 -2
- package/dist/Editor/utils/getSelectionRange.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/utils/getSelectionRange.js +1 -2
- package/dist/Editor/utils/setLink.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/utils/setLink.js +1 -2
- package/dist/Editor/utils/transformers.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/utils/transformers.js +1 -2
- package/dist/Editor/utils/unsetLink.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/utils/unsetLink.js +1 -2
- package/dist/EditorSkeleton/index.d.ts +8 -0
- package/dist/EditorSkeleton/index.d.ts.map +1 -0
- package/dist/EditorSkeleton/index.js +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/{esm/index.js → index.js} +1 -2
- package/package.json +12 -13
- package/src/@types/emotion.d.ts +1 -1
- package/src/Editor/BlockToolbar.tsx +2 -2
- package/src/Editor/StyleToolbar.tsx +2 -3
- package/src/Editor/blocks/imageBlock.tsx +1 -1
- package/src/Editor/blocks/videoBlock.tsx +1 -3
- package/src/Editor/decorators/linkDecorator.tsx +1 -2
- package/src/Editor/hooks/usePastedTextHandler.ts +2 -2
- package/src/Editor/hooks/useReturnHandler.ts +1 -1
- package/src/Editor/index.tsx +5 -5
- package/src/Editor/styles/overrideDraftJsStyles.ts +0 -1
- package/src/EditorSkeleton/index.tsx +2 -2
- package/dist/cjs/@types/emotion.d.js +0 -4
- package/dist/cjs/@types/emotion.d.js.map +0 -1
- package/dist/cjs/Editor/BlockToolbar.js +0 -44
- package/dist/cjs/Editor/BlockToolbar.js.map +0 -1
- package/dist/cjs/Editor/StyleToolbar.js +0 -65
- package/dist/cjs/Editor/StyleToolbar.js.map +0 -1
- package/dist/cjs/Editor/Toolbar.js +0 -18
- package/dist/cjs/Editor/Toolbar.js.map +0 -1
- package/dist/cjs/Editor/ToolbarButton.js +0 -47
- package/dist/cjs/Editor/ToolbarButton.js.map +0 -1
- package/dist/cjs/Editor/blocks/Figure.js +0 -16
- package/dist/cjs/Editor/blocks/Figure.js.map +0 -1
- package/dist/cjs/Editor/blocks/FigureCaption.js +0 -21
- package/dist/cjs/Editor/blocks/FigureCaption.js.map +0 -1
- package/dist/cjs/Editor/blocks/imageBlock.js +0 -156
- package/dist/cjs/Editor/blocks/imageBlock.js.map +0 -1
- package/dist/cjs/Editor/blocks/types.js +0 -2
- package/dist/cjs/Editor/blocks/types.js.map +0 -1
- package/dist/cjs/Editor/blocks/videoBlock.js +0 -82
- package/dist/cjs/Editor/blocks/videoBlock.js.map +0 -1
- package/dist/cjs/Editor/decorators/linkDecorator.js +0 -29
- package/dist/cjs/Editor/decorators/linkDecorator.js.map +0 -1
- package/dist/cjs/Editor/hooks/useBlockToolbarProps.js +0 -69
- package/dist/cjs/Editor/hooks/useBlockToolbarProps.js.map +0 -1
- package/dist/cjs/Editor/hooks/usePastedTextHandler.js +0 -26
- package/dist/cjs/Editor/hooks/usePastedTextHandler.js.map +0 -1
- package/dist/cjs/Editor/hooks/useReturnHandler.js +0 -27
- package/dist/cjs/Editor/hooks/useReturnHandler.js.map +0 -1
- package/dist/cjs/Editor/hooks/useStyleToolbarProps.js +0 -56
- package/dist/cjs/Editor/hooks/useStyleToolbarProps.js.map +0 -1
- package/dist/cjs/Editor/index.js +0 -156
- package/dist/cjs/Editor/index.js.map +0 -1
- package/dist/cjs/Editor/styles/defaultDraftJsStyles.js +0 -16
- package/dist/cjs/Editor/styles/defaultDraftJsStyles.js.map +0 -1
- package/dist/cjs/Editor/styles/overrideDraftJsStyles.js +0 -16
- package/dist/cjs/Editor/styles/overrideDraftJsStyles.js.map +0 -1
- package/dist/cjs/Editor/utils/addNewBlockAt.js +0 -48
- package/dist/cjs/Editor/utils/addNewBlockAt.js.map +0 -1
- package/dist/cjs/Editor/utils/changeBlock.js +0 -22
- package/dist/cjs/Editor/utils/changeBlock.js.map +0 -1
- package/dist/cjs/Editor/utils/createContentEditorState.js +0 -14
- package/dist/cjs/Editor/utils/createContentEditorState.js.map +0 -1
- package/dist/cjs/Editor/utils/createDecorator.js +0 -14
- package/dist/cjs/Editor/utils/createDecorator.js.map +0 -1
- package/dist/cjs/Editor/utils/createEmptyEditorState.js +0 -14
- package/dist/cjs/Editor/utils/createEmptyEditorState.js.map +0 -1
- package/dist/cjs/Editor/utils/defaultStyleToolbarItems.js +0 -40
- package/dist/cjs/Editor/utils/defaultStyleToolbarItems.js.map +0 -1
- package/dist/cjs/Editor/utils/getCurrentBlock.js +0 -13
- package/dist/cjs/Editor/utils/getCurrentBlock.js.map +0 -1
- package/dist/cjs/Editor/utils/getSelectedBlockElement.js +0 -20
- package/dist/cjs/Editor/utils/getSelectedBlockElement.js.map +0 -1
- package/dist/cjs/Editor/utils/getSelectionRange.js +0 -13
- package/dist/cjs/Editor/utils/getSelectionRange.js.map +0 -1
- package/dist/cjs/Editor/utils/setLink.js +0 -22
- package/dist/cjs/Editor/utils/setLink.js.map +0 -1
- package/dist/cjs/Editor/utils/transformers.js +0 -16
- package/dist/cjs/Editor/utils/transformers.js.map +0 -1
- package/dist/cjs/Editor/utils/unsetLink.js +0 -15
- package/dist/cjs/Editor/utils/unsetLink.js.map +0 -1
- package/dist/cjs/EditorSkeleton/index.js +0 -31
- package/dist/cjs/EditorSkeleton/index.js.map +0 -1
- package/dist/cjs/index.js +0 -146
- package/dist/cjs/index.js.map +0 -1
- package/dist/esm/@types/emotion.d.js +0 -2
- package/dist/esm/@types/emotion.d.js.map +0 -1
- package/dist/esm/Editor/BlockToolbar.js.map +0 -1
- package/dist/esm/Editor/StyleToolbar.js.map +0 -1
- package/dist/esm/Editor/Toolbar.js.map +0 -1
- package/dist/esm/Editor/ToolbarButton.js.map +0 -1
- package/dist/esm/Editor/blocks/Figure.js.map +0 -1
- package/dist/esm/Editor/blocks/FigureCaption.js.map +0 -1
- package/dist/esm/Editor/blocks/imageBlock.js.map +0 -1
- package/dist/esm/Editor/blocks/types.js +0 -2
- package/dist/esm/Editor/blocks/types.js.map +0 -1
- package/dist/esm/Editor/blocks/videoBlock.js.map +0 -1
- package/dist/esm/Editor/decorators/linkDecorator.js.map +0 -1
- package/dist/esm/Editor/hooks/useBlockToolbarProps.js.map +0 -1
- package/dist/esm/Editor/hooks/usePastedTextHandler.js.map +0 -1
- package/dist/esm/Editor/hooks/useReturnHandler.js.map +0 -1
- package/dist/esm/Editor/hooks/useStyleToolbarProps.js.map +0 -1
- package/dist/esm/Editor/index.js.map +0 -1
- package/dist/esm/Editor/styles/defaultDraftJsStyles.js.map +0 -1
- package/dist/esm/Editor/styles/overrideDraftJsStyles.js.map +0 -1
- package/dist/esm/Editor/utils/addNewBlockAt.js.map +0 -1
- package/dist/esm/Editor/utils/changeBlock.js.map +0 -1
- package/dist/esm/Editor/utils/createContentEditorState.js.map +0 -1
- package/dist/esm/Editor/utils/createDecorator.js.map +0 -1
- package/dist/esm/Editor/utils/createEmptyEditorState.js.map +0 -1
- package/dist/esm/Editor/utils/defaultStyleToolbarItems.js.map +0 -1
- package/dist/esm/Editor/utils/getCurrentBlock.js.map +0 -1
- package/dist/esm/Editor/utils/getSelectedBlockElement.js.map +0 -1
- package/dist/esm/Editor/utils/getSelectionRange.js.map +0 -1
- package/dist/esm/Editor/utils/setLink.js.map +0 -1
- package/dist/esm/Editor/utils/transformers.js.map +0 -1
- package/dist/esm/Editor/utils/unsetLink.js.map +0 -1
- package/dist/esm/EditorSkeleton/index.js +0 -17
- package/dist/esm/EditorSkeleton/index.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/types/Editor/BlockToolbar.d.ts.map +0 -1
- package/dist/types/Editor/StyleToolbar.d.ts.map +0 -1
- package/dist/types/Editor/Toolbar.d.ts.map +0 -1
- package/dist/types/Editor/ToolbarButton.d.ts.map +0 -1
- package/dist/types/Editor/blocks/Figure.d.ts.map +0 -1
- package/dist/types/Editor/blocks/FigureCaption.d.ts.map +0 -1
- package/dist/types/Editor/blocks/imageBlock.d.ts.map +0 -1
- package/dist/types/Editor/blocks/types.d.ts.map +0 -1
- package/dist/types/Editor/blocks/videoBlock.d.ts.map +0 -1
- package/dist/types/Editor/decorators/linkDecorator.d.ts +0 -4
- package/dist/types/Editor/decorators/linkDecorator.d.ts.map +0 -1
- package/dist/types/Editor/hooks/useBlockToolbarProps.d.ts.map +0 -1
- package/dist/types/Editor/hooks/usePastedTextHandler.d.ts.map +0 -1
- package/dist/types/Editor/hooks/useReturnHandler.d.ts.map +0 -1
- package/dist/types/Editor/hooks/useStyleToolbarProps.d.ts.map +0 -1
- package/dist/types/Editor/index.d.ts +0 -16
- package/dist/types/Editor/index.d.ts.map +0 -1
- package/dist/types/Editor/styles/defaultDraftJsStyles.d.ts +0 -3
- package/dist/types/Editor/styles/defaultDraftJsStyles.d.ts.map +0 -1
- package/dist/types/Editor/styles/overrideDraftJsStyles.d.ts.map +0 -1
- package/dist/types/Editor/utils/addNewBlockAt.d.ts.map +0 -1
- package/dist/types/Editor/utils/changeBlock.d.ts.map +0 -1
- package/dist/types/Editor/utils/createContentEditorState.d.ts.map +0 -1
- package/dist/types/Editor/utils/createDecorator.d.ts.map +0 -1
- package/dist/types/Editor/utils/createEmptyEditorState.d.ts.map +0 -1
- package/dist/types/Editor/utils/defaultStyleToolbarItems.d.ts.map +0 -1
- package/dist/types/Editor/utils/getCurrentBlock.d.ts.map +0 -1
- package/dist/types/Editor/utils/getSelectedBlockElement.d.ts.map +0 -1
- package/dist/types/Editor/utils/getSelectionRange.d.ts.map +0 -1
- package/dist/types/Editor/utils/setLink.d.ts.map +0 -1
- package/dist/types/Editor/utils/transformers.d.ts.map +0 -1
- package/dist/types/Editor/utils/unsetLink.d.ts.map +0 -1
- package/dist/types/EditorSkeleton/index.d.ts +0 -6
- package/dist/types/EditorSkeleton/index.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- /package/dist/{types/Editor → Editor}/Toolbar.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/ToolbarButton.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/blocks/Figure.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/blocks/FigureCaption.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/blocks/types.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/utils/addNewBlockAt.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/utils/changeBlock.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/utils/createContentEditorState.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/utils/createDecorator.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/utils/createEmptyEditorState.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/utils/defaultStyleToolbarItems.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/utils/getCurrentBlock.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/utils/getSelectedBlockElement.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/utils/getSelectionRange.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/utils/setLink.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/utils/transformers.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/utils/unsetLink.d.ts +0 -0
- /package/dist/{types/index.d.ts → index.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@emotion/react';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PopoverProps } from '@os-design/core';
|
|
1
|
+
import type { PopoverProps } from '@os-design/core';
|
|
2
2
|
import { EditorState } from 'draft-js';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { BlockToolbarItem } from './blocks/types';
|
|
4
|
+
import type { BlockToolbarItem } from './blocks/types';
|
|
5
5
|
interface BlockToolbarProps extends Omit<PopoverProps, 'onChange'> {
|
|
6
6
|
items: BlockToolbarItem[];
|
|
7
7
|
value: EditorState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockToolbar.d.ts","sourceRoot":"","sources":["../../src/Editor/BlockToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAsB,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,UAAU,iBAAkB,SAAQ,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC;IAChE,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA8B7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -2,6 +2,7 @@ import React, { useCallback } from 'react';
|
|
|
2
2
|
import Toolbar from './Toolbar';
|
|
3
3
|
import ToolbarButton from './ToolbarButton';
|
|
4
4
|
import getCurrentBlock from './utils/getCurrentBlock';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
const BlockToolbar = ({
|
|
6
7
|
items,
|
|
7
8
|
value,
|
|
@@ -20,10 +21,12 @@ const BlockToolbar = ({
|
|
|
20
21
|
setReadOnly
|
|
21
22
|
});
|
|
22
23
|
}, [value, onChange, setReadOnly]);
|
|
23
|
-
return /*#__PURE__*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
return /*#__PURE__*/_jsx(Toolbar, {
|
|
25
|
+
...rest,
|
|
26
|
+
children: items.map(item => /*#__PURE__*/_jsx(ToolbarButton, {
|
|
27
|
+
onClick: () => clickHandler(item),
|
|
28
|
+
children: item.icon
|
|
29
|
+
}, item.type))
|
|
30
|
+
});
|
|
27
31
|
};
|
|
28
|
-
export default BlockToolbar;
|
|
29
|
-
//# sourceMappingURL=BlockToolbar.js.map
|
|
32
|
+
export default BlockToolbar;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PopoverProps } from '@os-design/core';
|
|
1
|
+
import type { PopoverProps } from '@os-design/core';
|
|
2
2
|
import { EditorState } from 'draft-js';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { StyleToolbarItem } from './utils/defaultStyleToolbarItems';
|
|
4
|
+
import type { StyleToolbarItem } from './utils/defaultStyleToolbarItems';
|
|
5
5
|
interface StyleToolbarProps extends Omit<PopoverProps, 'onChange'> {
|
|
6
6
|
items: StyleToolbarItem[];
|
|
7
7
|
value: EditorState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StyleToolbar.d.ts","sourceRoot":"","sources":["../../src/Editor/StyleToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAa,MAAM,UAAU,CAAC;AAClD,OAAO,KAA+B,MAAM,OAAO,CAAC;AAGpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAIzE,UAAU,iBAAkB,SAAQ,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC;IAChE,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CACxC;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAyD7C,CAAC;AAIF,eAAe,YAAY,CAAC"}
|
|
@@ -4,6 +4,7 @@ import Toolbar from './Toolbar';
|
|
|
4
4
|
import ToolbarButton from './ToolbarButton';
|
|
5
5
|
import setLink from './utils/setLink';
|
|
6
6
|
import unsetLink from './utils/unsetLink';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
8
|
const StyleToolbar = ({
|
|
8
9
|
items,
|
|
9
10
|
value,
|
|
@@ -17,7 +18,6 @@ const StyleToolbar = ({
|
|
|
17
18
|
onChange(unsetLink(value));
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
|
-
// eslint-disable-next-line no-alert
|
|
21
21
|
const url = prompt('Paste or type a link');
|
|
22
22
|
if (!url) return;
|
|
23
23
|
onChange(setLink(value, url));
|
|
@@ -30,17 +30,19 @@ const StyleToolbar = ({
|
|
|
30
30
|
}
|
|
31
31
|
}, [value, onChange]);
|
|
32
32
|
if (items.length === 0) return null;
|
|
33
|
-
return /*#__PURE__*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
return /*#__PURE__*/_jsx(Toolbar, {
|
|
34
|
+
...rest,
|
|
35
|
+
children: items.map(item => {
|
|
36
|
+
const isLink = item.name === 'LINK' && item.type === 'inline';
|
|
37
|
+
const active = isLink ? currentBlockContainsLink : value.getCurrentInlineStyle().has(item.name) || currentBlockType === item.name;
|
|
38
|
+
const onClick = isLink ? toggleLink : () => clickHandler(item);
|
|
39
|
+
return /*#__PURE__*/_jsx(ToolbarButton, {
|
|
40
|
+
active: active,
|
|
41
|
+
onClick: onClick,
|
|
42
|
+
children: item.icon
|
|
43
|
+
}, item.name);
|
|
44
|
+
})
|
|
45
|
+
});
|
|
43
46
|
};
|
|
44
47
|
StyleToolbar.displayName = 'StyleToolbar';
|
|
45
|
-
export default StyleToolbar;
|
|
46
|
-
//# sourceMappingURL=StyleToolbar.js.map
|
|
48
|
+
export default StyleToolbar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/Editor/Toolbar.tsx"],"names":[],"mappings":"AAIA,QAAA,MAAM,OAAO;;UASZ,CAAC;AAIF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolbarButton.d.ts","sourceRoot":"","sources":["../../src/Editor/ToolbarButton.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,KAAK,cAAc,GAAG,GAAG,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AACtD,UAAU,kBAAmB,SAAQ,cAAc;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAqCD,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAW/C,CAAC;AAIF,eAAe,aAAa,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
1
|
import { css } from '@emotion/react';
|
|
3
2
|
import styled from '@emotion/styled';
|
|
4
3
|
import { resetButtonStyles, transitionStyles } from '@os-design/styles';
|
|
5
4
|
import { clr } from '@os-design/theming';
|
|
6
5
|
import { omitEmotionProps } from '@os-design/utils';
|
|
7
6
|
import React from 'react';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
const activeStyles = p => p.active && css`
|
|
9
9
|
background-color: ${clr(p.theme.editorToolbarButtonColorBgActive)};
|
|
10
10
|
`;
|
|
@@ -35,12 +35,12 @@ const StyledToolbarButton = styled('button', omitEmotionProps('active'))`
|
|
|
35
35
|
const ToolbarButton = ({
|
|
36
36
|
onMouseDown = () => {},
|
|
37
37
|
...rest
|
|
38
|
-
}) => /*#__PURE__*/
|
|
38
|
+
}) => /*#__PURE__*/_jsx(StyledToolbarButton, {
|
|
39
39
|
onMouseDown: e => {
|
|
40
40
|
onMouseDown(e);
|
|
41
41
|
e.preventDefault();
|
|
42
|
-
}
|
|
43
|
-
|
|
42
|
+
},
|
|
43
|
+
...rest
|
|
44
|
+
});
|
|
44
45
|
ToolbarButton.displayName = 'ToolbarButton';
|
|
45
|
-
export default ToolbarButton;
|
|
46
|
-
//# sourceMappingURL=ToolbarButton.js.map
|
|
46
|
+
export default ToolbarButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Figure.d.ts","sourceRoot":"","sources":["../../../src/Editor/blocks/Figure.tsx"],"names":[],"mappings":"AAEA,QAAA,MAAM,MAAM;;SAQ8Z,MAAO,WAAW;mGAL3b,CAAC;AAIF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FigureCaption.d.ts","sourceRoot":"","sources":["../../../src/Editor/blocks/FigureCaption.tsx"],"names":[],"mappings":"AAGA,QAAA,MAAM,aAAa;;SAgB0H,MAAO,WAAW;mGAL9J,CAAC;AAIF,eAAe,aAAa,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlockToolbarItem } from './types';
|
|
1
|
+
import type { BlockToolbarItem } from './types';
|
|
2
2
|
export declare const IMAGE_BLOCK = "atomic:image";
|
|
3
3
|
declare const imageBlock: (onImageUpload: (file: File) => Promise<string>) => BlockToolbarItem;
|
|
4
4
|
export default imageBlock;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imageBlock.d.ts","sourceRoot":"","sources":["../../../src/Editor/blocks/imageBlock.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAc,gBAAgB,EAAE,MAAM,SAAS,CAAC;AA2F5D,eAAO,MAAM,WAAW,iBAAiB,CAAC;AAE1C,QAAA,MAAM,UAAU,kBACC,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,KAC7C,gBAgDD,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -9,6 +9,7 @@ import changeBlock from '../utils/changeBlock';
|
|
|
9
9
|
import getCurrentBlock from '../utils/getCurrentBlock';
|
|
10
10
|
import Figure from './Figure';
|
|
11
11
|
import FigureCaption from './FigureCaption';
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
13
|
const widthStyles = p => p.width && css`
|
|
13
14
|
width: ${p.width}px;
|
|
14
15
|
`;
|
|
@@ -62,20 +63,27 @@ const ImageBlock = props => {
|
|
|
62
63
|
}, []);
|
|
63
64
|
useEvent(typeof window !== 'undefined' ? window : undefined, 'resize', updateWidth);
|
|
64
65
|
if (!src) return null;
|
|
65
|
-
return /*#__PURE__*/
|
|
66
|
-
width: width
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
return /*#__PURE__*/_jsxs(ImageFigure, {
|
|
67
|
+
width: width,
|
|
68
|
+
children: [loading && /*#__PURE__*/_jsx(Mask, {
|
|
69
|
+
children: /*#__PURE__*/_jsx(LoadingIcon, {})
|
|
70
|
+
}), /*#__PURE__*/_jsx(Image, {
|
|
71
|
+
src: src.startsWith('blob:') ? src : `${src}-1024`,
|
|
72
|
+
alt: block.getText(),
|
|
73
|
+
onLoad: updateWidth,
|
|
74
|
+
ref: imageRef
|
|
75
|
+
}), !loading && /*#__PURE__*/_jsx(FigureCaption, {
|
|
76
|
+
children: /*#__PURE__*/_jsx(EditorBlock, {
|
|
77
|
+
...props
|
|
78
|
+
})
|
|
79
|
+
})]
|
|
80
|
+
});
|
|
73
81
|
};
|
|
74
82
|
export const IMAGE_BLOCK = 'atomic:image';
|
|
75
83
|
const imageBlock = onImageUpload => ({
|
|
76
84
|
type: IMAGE_BLOCK,
|
|
77
85
|
component: ImageBlock,
|
|
78
|
-
icon: /*#__PURE__*/
|
|
86
|
+
icon: /*#__PURE__*/_jsx(Picture, {}),
|
|
79
87
|
onClick: ({
|
|
80
88
|
value,
|
|
81
89
|
onChange,
|
|
@@ -125,5 +133,4 @@ const imageBlock = onImageUpload => ({
|
|
|
125
133
|
input.click();
|
|
126
134
|
}
|
|
127
135
|
});
|
|
128
|
-
export default imageBlock;
|
|
129
|
-
//# sourceMappingURL=imageBlock.js.map
|
|
136
|
+
export default imageBlock;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Editor/blocks/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,UAAW,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACrD,KAAK,EAAE,YAAY,CAAC;CACrB;AAGD,MAAM,WAAW,4BAA6B,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACvE,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;IAChC,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC;IACzB,OAAO,EAAE,CAAC,KAAK,EAAE,4BAA4B,KAAK,IAAI,CAAC;CACxD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"videoBlock.d.ts","sourceRoot":"","sources":["../../../src/Editor/blocks/videoBlock.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAc,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAiD5D,eAAO,MAAM,WAAW,iBAAiB,CAAC;AAE1C,QAAA,MAAM,UAAU,EAAE,gBAkBjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -6,6 +6,7 @@ import changeBlock from '../utils/changeBlock';
|
|
|
6
6
|
import getCurrentBlock from '../utils/getCurrentBlock';
|
|
7
7
|
import Figure from './Figure';
|
|
8
8
|
import FigureCaption from './FigureCaption';
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
const VideoBlock = props => {
|
|
10
11
|
const {
|
|
11
12
|
block
|
|
@@ -13,10 +14,16 @@ const VideoBlock = props => {
|
|
|
13
14
|
const data = block.getData();
|
|
14
15
|
const src = data.get('src');
|
|
15
16
|
if (!src) return null;
|
|
16
|
-
return /*#__PURE__*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
return /*#__PURE__*/_jsxs(Figure, {
|
|
18
|
+
children: [/*#__PURE__*/_jsx(Video, {
|
|
19
|
+
src: src,
|
|
20
|
+
title: block.getText()
|
|
21
|
+
}), /*#__PURE__*/_jsx(FigureCaption, {
|
|
22
|
+
children: /*#__PURE__*/_jsx(EditorBlock, {
|
|
23
|
+
...props
|
|
24
|
+
})
|
|
25
|
+
})]
|
|
26
|
+
});
|
|
20
27
|
};
|
|
21
28
|
const videoTypes = [
|
|
22
29
|
/**
|
|
@@ -39,7 +46,6 @@ const videoTypes = [
|
|
|
39
46
|
getUrl: id => `https://rutube.ru/play/embed/${id}`
|
|
40
47
|
}];
|
|
41
48
|
const detectVideo = url => {
|
|
42
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
43
49
|
for (const {
|
|
44
50
|
re,
|
|
45
51
|
getUrl
|
|
@@ -53,12 +59,11 @@ export const VIDEO_BLOCK = 'atomic:video';
|
|
|
53
59
|
const videoBlock = {
|
|
54
60
|
type: VIDEO_BLOCK,
|
|
55
61
|
component: VideoBlock,
|
|
56
|
-
icon: /*#__PURE__*/
|
|
62
|
+
icon: /*#__PURE__*/_jsx(VideoIcon, {}),
|
|
57
63
|
onClick: ({
|
|
58
64
|
value,
|
|
59
65
|
onChange
|
|
60
66
|
}) => {
|
|
61
|
-
// eslint-disable-next-line no-alert
|
|
62
67
|
const url = prompt('Insert a link to YouTube or RuTube');
|
|
63
68
|
if (!url) return;
|
|
64
69
|
const src = detectVideo(url);
|
|
@@ -70,5 +75,4 @@ const videoBlock = {
|
|
|
70
75
|
onChange(nextEditorState);
|
|
71
76
|
}
|
|
72
77
|
};
|
|
73
|
-
export default videoBlock;
|
|
74
|
-
//# sourceMappingURL=videoBlock.js.map
|
|
78
|
+
export default videoBlock;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkDecorator.d.ts","sourceRoot":"","sources":["../../../src/Editor/decorators/linkDecorator.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,QAAA,MAAM,aAAa,EAAE,cAcpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Link } from '@os-design/core';
|
|
2
|
-
import
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
const linkDecorator = {
|
|
4
4
|
strategy: (contentBlock, callback, contentState) => contentBlock.findEntityRanges(character => {
|
|
5
5
|
const entityKey = character.getEntity();
|
|
@@ -13,10 +13,10 @@ const linkDecorator = {
|
|
|
13
13
|
const {
|
|
14
14
|
url
|
|
15
15
|
} = contentState.getEntity(entityKey).getData();
|
|
16
|
-
return /*#__PURE__*/
|
|
17
|
-
href: url
|
|
18
|
-
|
|
16
|
+
return /*#__PURE__*/_jsx(Link, {
|
|
17
|
+
href: url,
|
|
18
|
+
children: children
|
|
19
|
+
});
|
|
19
20
|
}
|
|
20
21
|
};
|
|
21
|
-
export default linkDecorator;
|
|
22
|
-
//# sourceMappingURL=linkDecorator.js.map
|
|
22
|
+
export default linkDecorator;
|
|
@@ -9,6 +9,9 @@ interface UseBlockToolbarPropsRes {
|
|
|
9
9
|
trigger: Rect;
|
|
10
10
|
visible: boolean;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Updates the visibility of the block toolbar.
|
|
14
|
+
*/
|
|
12
15
|
declare const useBlockToolbarProps: (value: EditorState, show: boolean) => UseBlockToolbarPropsRes;
|
|
13
16
|
export default useBlockToolbarProps;
|
|
14
17
|
//# sourceMappingURL=useBlockToolbarProps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBlockToolbarProps.d.ts","sourceRoot":"","sources":["../../../src/Editor/hooks/useBlockToolbarProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIvC,UAAU,IAAI;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,uBAAuB;IAC/B,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,QAAA,MAAM,oBAAoB,UACjB,WAAW,QACZ,OAAO,KACZ,uBA+CF,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { EditorProps as DraftEditorProps, EditorState } from 'draft-js';
|
|
1
|
+
import { type EditorProps as DraftEditorProps, EditorState } from 'draft-js';
|
|
2
2
|
type UsePastedTextHandlerRes = Exclude<DraftEditorProps['handlePastedText'], undefined>;
|
|
3
|
+
/**
|
|
4
|
+
* Pastes only text if the current block is atomic.
|
|
5
|
+
*/
|
|
3
6
|
declare const usePastedTextHandler: (onChange: (value: EditorState) => void, handler: UsePastedTextHandlerRes) => UsePastedTextHandlerRes;
|
|
4
7
|
export default usePastedTextHandler;
|
|
5
8
|
//# sourceMappingURL=usePastedTextHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePastedTextHandler.d.ts","sourceRoot":"","sources":["../../../src/Editor/hooks/usePastedTextHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,IAAI,gBAAgB,EAEpC,WAAW,EAGZ,MAAM,UAAU,CAAC;AAGlB,KAAK,uBAAuB,GAAG,OAAO,CACpC,gBAAgB,CAAC,kBAAkB,CAAC,EACpC,SAAS,CACV,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,oBAAoB,aACd,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,WAC7B,uBAAuB,KAC/B,uBAwBA,CAAC;AAEJ,eAAe,oBAAoB,CAAC"}
|
|
@@ -14,5 +14,4 @@ const usePastedTextHandler = (onChange, handler) => useCallback((text, html, edi
|
|
|
14
14
|
}
|
|
15
15
|
return handler(text, html, editorState);
|
|
16
16
|
}, [onChange, handler]);
|
|
17
|
-
export default usePastedTextHandler;
|
|
18
|
-
//# sourceMappingURL=usePastedTextHandler.js.map
|
|
17
|
+
export default usePastedTextHandler;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { EditorProps as DraftEditorProps, EditorState } from 'draft-js';
|
|
1
|
+
import { type EditorProps as DraftEditorProps, EditorState } from 'draft-js';
|
|
2
2
|
type UseReturnHandlerRes = NonNullable<DraftEditorProps['handleReturn']>;
|
|
3
|
+
/**
|
|
4
|
+
* Adds a new unstyled block if the user presses the return key.
|
|
5
|
+
*/
|
|
3
6
|
declare const useReturnHandler: (onChange: (value: EditorState) => void, handler: UseReturnHandlerRes) => UseReturnHandlerRes;
|
|
4
7
|
export default useReturnHandler;
|
|
5
8
|
//# sourceMappingURL=useReturnHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReturnHandler.d.ts","sourceRoot":"","sources":["../../../src/Editor/hooks/useReturnHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,IAAI,gBAAgB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAK7E,KAAK,mBAAmB,GAAG,WAAW,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC;AAEzE;;GAEG;AACH,QAAA,MAAM,gBAAgB,aACV,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,WAC7B,mBAAmB,KAC3B,mBAqBA,CAAC;AAEJ,eAAe,gBAAgB,CAAC"}
|
|
@@ -14,5 +14,4 @@ const useReturnHandler = (onChange, handler) => useCallback((e, editorState) =>
|
|
|
14
14
|
}
|
|
15
15
|
return handler(e, editorState);
|
|
16
16
|
}, [onChange, handler]);
|
|
17
|
-
export default useReturnHandler;
|
|
18
|
-
//# sourceMappingURL=useReturnHandler.js.map
|
|
17
|
+
export default useReturnHandler;
|
|
@@ -9,6 +9,9 @@ interface UseStyleToolbarPropsRes {
|
|
|
9
9
|
trigger: Rect;
|
|
10
10
|
visible: boolean;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Updates the visibility of the style toolbar
|
|
14
|
+
*/
|
|
12
15
|
declare const useStyleToolbarProps: (value: EditorState) => UseStyleToolbarPropsRes;
|
|
13
16
|
export default useStyleToolbarProps;
|
|
14
17
|
//# sourceMappingURL=useStyleToolbarProps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStyleToolbarProps.d.ts","sourceRoot":"","sources":["../../../src/Editor/hooks/useStyleToolbarProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAa,MAAM,UAAU,CAAC;AAIlD,UAAU,IAAI;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,uBAAuB;IAC/B,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,QAAA,MAAM,oBAAoB,UAAW,WAAW,KAAG,uBA+BlD,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { WithSize } from '@os-design/styles';
|
|
2
|
+
import { Editor as DraftEditor, type EditorProps as DraftEditorProps, EditorState } from 'draft-js';
|
|
3
|
+
import type { BlockToolbarItem } from './blocks/types';
|
|
4
|
+
import { type StyleToolbarItem } from './utils/defaultStyleToolbarItems';
|
|
5
|
+
export interface EditorProps extends Omit<DraftEditorProps, 'editorState' | 'onChange'>, WithSize {
|
|
6
|
+
/**
|
|
7
|
+
* Whether the editor is disabled.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Available styles in the toolbar.
|
|
13
|
+
* @default undefined
|
|
14
|
+
*/
|
|
15
|
+
styleToolbarItems?: StyleToolbarItem[];
|
|
16
|
+
/**
|
|
17
|
+
* Available blocks in the toolbar.
|
|
18
|
+
* @default undefined
|
|
19
|
+
*/
|
|
20
|
+
blockToolbarItems?: BlockToolbarItem[];
|
|
21
|
+
/**
|
|
22
|
+
* The editor state.
|
|
23
|
+
* @default undefined
|
|
24
|
+
*/
|
|
25
|
+
value?: EditorState;
|
|
26
|
+
/**
|
|
27
|
+
* The default value.
|
|
28
|
+
* @default undefined
|
|
29
|
+
*/
|
|
30
|
+
defaultValue?: EditorState;
|
|
31
|
+
/**
|
|
32
|
+
* The change event handler.
|
|
33
|
+
* @default undefined
|
|
34
|
+
*/
|
|
35
|
+
onChange?: (value: EditorState) => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Rich text editor based on the Draft.js.
|
|
39
|
+
*/
|
|
40
|
+
declare const Editor: import("react").ForwardRefExoticComponent<EditorProps & import("react").RefAttributes<DraftEditor>>;
|
|
41
|
+
export default Editor;
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Editor/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EACL,MAAM,IAAI,WAAW,EACrB,KAAK,WAAW,IAAI,gBAAgB,EACpC,WAAW,EACZ,MAAM,UAAU,CAAC;AAIlB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAQvD,OAAiC,EAC/B,KAAK,gBAAgB,EACtB,MAAM,kCAAkC,CAAC;AAE1C,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,gBAAgB,EAAE,aAAa,GAAG,UAAU,CAAC,EACxD,QAAQ;IACV;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACvC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACvC;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CACzC;AAqBD;;GAEG;AACH,QAAA,MAAM,MAAM,qGAiHX,CAAC;AAIF,eAAe,MAAM,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
1
|
import { css } from '@emotion/react';
|
|
3
2
|
import styled from '@emotion/styled';
|
|
4
3
|
import { InputContainer } from '@os-design/core';
|
|
5
4
|
import { useForwardedRef, useForwardedState } from '@os-design/utils';
|
|
6
5
|
import { Editor as DraftEditor, EditorState } from 'draft-js';
|
|
7
|
-
import
|
|
6
|
+
import { forwardRef, useCallback, useState } from 'react';
|
|
8
7
|
import BlockToolbar from './BlockToolbar';
|
|
9
8
|
import StyleToolbar from './StyleToolbar';
|
|
10
9
|
import useBlockToolbarProps from './hooks/useBlockToolbarProps';
|
|
@@ -15,6 +14,7 @@ import defaultDraftJsStyles from './styles/defaultDraftJsStyles';
|
|
|
15
14
|
import overrideDraftJsStyles from './styles/overrideDraftJsStyles';
|
|
16
15
|
import createEmptyEditorState from './utils/createEmptyEditorState';
|
|
17
16
|
import defaultStyleToolbarItems from './utils/defaultStyleToolbarItems';
|
|
17
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
18
|
const disabledStyles = p => p.disabled && css`
|
|
19
19
|
cursor: not-allowed;
|
|
20
20
|
`;
|
|
@@ -81,40 +81,44 @@ const Editor = /*#__PURE__*/forwardRef(({
|
|
|
81
81
|
// Custom handlers
|
|
82
82
|
const returnHandler = useReturnHandler(setForwardedValue, handleReturn);
|
|
83
83
|
const pastedTextHandler = usePastedTextHandler(setForwardedValue, handlePastedText);
|
|
84
|
-
return /*#__PURE__*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
84
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
85
|
+
children: [/*#__PURE__*/_jsx(Container, {
|
|
86
|
+
disabled: disabled,
|
|
87
|
+
size: size,
|
|
88
|
+
tabIndex: !disabled ? 0 : -1,
|
|
89
|
+
role: !disabled ? 'textbox' : undefined,
|
|
90
|
+
onFocus: () => {
|
|
91
|
+
if (disabled || !editorRef.current) return;
|
|
92
|
+
editorRef.current.focus();
|
|
93
|
+
},
|
|
94
|
+
children: /*#__PURE__*/_jsx(DraftEditor, {
|
|
95
|
+
onChange: setEditorState,
|
|
96
|
+
blockRendererFn: blockRenderer,
|
|
97
|
+
handleReturn: returnHandler,
|
|
98
|
+
handlePastedText: pastedTextHandler,
|
|
99
|
+
readOnly: readOnly || innerReadOnly || disabled,
|
|
100
|
+
stripPastedStyles: true,
|
|
101
|
+
...rest,
|
|
102
|
+
editorState: forwardedValue || defaultValue,
|
|
103
|
+
ref: mergedEditorRef
|
|
104
|
+
})
|
|
105
|
+
}), /*#__PURE__*/_jsx(StyleToolbar, {
|
|
106
|
+
...styleToolbarProps,
|
|
107
|
+
size: size,
|
|
108
|
+
items: styleToolbarItems,
|
|
109
|
+
value: forwardedValue || defaultValue,
|
|
110
|
+
onChange: setForwardedValue
|
|
111
|
+
}), /*#__PURE__*/_jsx(BlockToolbar, {
|
|
112
|
+
...blockToolbarProps,
|
|
113
|
+
placement: "right",
|
|
114
|
+
gap: 2.5,
|
|
115
|
+
size: size,
|
|
116
|
+
items: blockToolbarItems,
|
|
117
|
+
value: forwardedValue || defaultValue,
|
|
118
|
+
onChange: setForwardedValue,
|
|
119
|
+
setReadOnly: setInnerReadOnly
|
|
120
|
+
})]
|
|
121
|
+
});
|
|
117
122
|
});
|
|
118
123
|
Editor.displayName = 'Editor';
|
|
119
|
-
export default Editor;
|
|
120
|
-
//# sourceMappingURL=index.js.map
|
|
124
|
+
export default Editor;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Draft.js styles.
|
|
3
|
+
* The original styles located in `node_modules/draft-js/dist/Draft.css`.
|
|
4
|
+
*/
|
|
5
|
+
declare const defaultDraftJsStyles: import("@emotion/utils").SerializedStyles;
|
|
6
|
+
export default defaultDraftJsStyles;
|
|
7
|
+
//# sourceMappingURL=defaultDraftJsStyles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultDraftJsStyles.d.ts","sourceRoot":"","sources":["../../../src/Editor/styles/defaultDraftJsStyles.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,QAAA,MAAM,oBAAoB,2CA0KzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const overrideDraftJsStyles: (p: any) => import("@emotion/
|
|
1
|
+
declare const overrideDraftJsStyles: (p: any) => import("@emotion/utils").SerializedStyles;
|
|
2
2
|
export default overrideDraftJsStyles;
|
|
3
3
|
//# sourceMappingURL=overrideDraftJsStyles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overrideDraftJsStyles.d.ts","sourceRoot":"","sources":["../../../src/Editor/styles/overrideDraftJsStyles.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,qBAAqB,uDAa1B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|