@os-design/editor 1.0.259 → 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/{types/Editor → Editor}/Toolbar.d.ts +1 -2
- 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 +6 -0
- 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 +6 -0
- 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/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 +0 -7
- package/dist/types/Editor/blocks/Figure.d.ts.map +0 -1
- package/dist/types/Editor/blocks/FigureCaption.d.ts +0 -7
- 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}/ToolbarButton.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/blocks/types.d.ts +0 -0
- /package/dist/{types/Editor → Editor}/styles/overrideDraftJsStyles.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
|
+
{"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"}
|
|
@@ -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"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
import { clr } from '@os-design/theming';
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
5
3
|
const overrideDraftJsStyles = p => css`
|
|
6
4
|
.DraftEditor-root {
|
|
7
5
|
width: 100%;
|
|
@@ -16,5 +14,4 @@ const overrideDraftJsStyles = p => css`
|
|
|
16
14
|
margin: 0 0 ${p.theme.paragraphMarginBottom}em;
|
|
17
15
|
}
|
|
18
16
|
`;
|
|
19
|
-
export default overrideDraftJsStyles;
|
|
20
|
-
//# sourceMappingURL=overrideDraftJsStyles.js.map
|
|
17
|
+
export default overrideDraftJsStyles;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addNewBlockAt.d.ts","sourceRoot":"","sources":["../../../src/Editor/utils/addNewBlockAt.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,WAAW,EAAU,MAAM,UAAU,CAAC;AAG3E,QAAA,MAAM,aAAa,gBACJ,WAAW,iBACT,MAAM,wBAEf,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KACxB,WAgDF,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -32,5 +32,4 @@ const addNewBlockAt = (editorState, pivotBlockKey, type = 'unstyled', data = {}
|
|
|
32
32
|
});
|
|
33
33
|
return EditorState.push(editorState, nextContentState, 'split-block');
|
|
34
34
|
};
|
|
35
|
-
export default addNewBlockAt;
|
|
36
|
-
//# sourceMappingURL=addNewBlockAt.js.map
|
|
35
|
+
export default addNewBlockAt;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changeBlock.d.ts","sourceRoot":"","sources":["../../../src/Editor/utils/changeBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,WAAW,EAAE,MAAM,UAAU,CAAC;AAEnE,QAAA,MAAM,WAAW,gBACF,WAAW,SACjB,YAAY,QACb,MAAM,SACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KACxB,WAUF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -12,5 +12,4 @@ const changeBlock = (editorState, block, type, data = {} // eslint-disable-line
|
|
|
12
12
|
});
|
|
13
13
|
return EditorState.push(editorState, nextContentState, 'change-block-type');
|
|
14
14
|
};
|
|
15
|
-
export default changeBlock;
|
|
16
|
-
//# sourceMappingURL=changeBlock.js.map
|
|
15
|
+
export default changeBlock;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createContentEditorState.d.ts","sourceRoot":"","sources":["../../../src/Editor/utils/createContentEditorState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGrD,QAAA,MAAM,wBAAwB,iBAAkB,YAAY,KAAG,WACC,CAAC;AAEjE,eAAe,wBAAwB,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { EditorState } from 'draft-js';
|
|
2
2
|
import createDecorator from './createDecorator';
|
|
3
3
|
const createContentEditorState = contentState => EditorState.createWithContent(contentState, createDecorator());
|
|
4
|
-
export default createContentEditorState;
|
|
5
|
-
//# sourceMappingURL=createContentEditorState.js.map
|
|
4
|
+
export default createContentEditorState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDecorator.d.ts","sourceRoot":"","sources":["../../../src/Editor/utils/createDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C,QAAA,MAAM,eAAe,QAAO,kBACa,CAAC;AAE1C,eAAe,eAAe,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CompositeDecorator } from 'draft-js';
|
|
2
2
|
import linkDecorator from '../decorators/linkDecorator';
|
|
3
3
|
const createDecorator = () => new CompositeDecorator([linkDecorator]);
|
|
4
|
-
export default createDecorator;
|
|
5
|
-
//# sourceMappingURL=createDecorator.js.map
|
|
4
|
+
export default createDecorator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEmptyEditorState.d.ts","sourceRoot":"","sources":["../../../src/Editor/utils/createEmptyEditorState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,QAAA,MAAM,sBAAsB,QAAO,WACS,CAAC;AAE7C,eAAe,sBAAsB,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { EditorState } from 'draft-js';
|
|
2
2
|
import createDecorator from './createDecorator';
|
|
3
3
|
const createEmptyEditorState = () => EditorState.createEmpty(createDecorator());
|
|
4
|
-
export default createEmptyEditorState;
|
|
5
|
-
//# sourceMappingURL=createEmptyEditorState.js.map
|
|
4
|
+
export default createEmptyEditorState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultStyleToolbarItems.d.ts","sourceRoot":"","sources":["../../../src/Editor/utils/defaultStyleToolbarItems.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;CACvB;AAMD,QAAA,MAAM,wBAAwB,EAAE,gBAAgB,EAO/C,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
import { Bold, FontSize, Link as LinkIcon, OrderedList, UnorderedList } from '@os-design/icons';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
5
|
const FontSizeSmall = styled(FontSize)`
|
|
5
6
|
transform: scale(0.7);
|
|
6
7
|
`;
|
|
7
8
|
const defaultStyleToolbarItems = [{
|
|
8
9
|
name: 'header-two',
|
|
9
10
|
type: 'block',
|
|
10
|
-
icon: /*#__PURE__*/
|
|
11
|
+
icon: /*#__PURE__*/_jsx(FontSize, {})
|
|
11
12
|
}, {
|
|
12
13
|
name: 'header-three',
|
|
13
14
|
type: 'block',
|
|
14
|
-
icon: /*#__PURE__*/
|
|
15
|
+
icon: /*#__PURE__*/_jsx(FontSizeSmall, {})
|
|
15
16
|
}, {
|
|
16
17
|
name: 'BOLD',
|
|
17
18
|
type: 'inline',
|
|
18
|
-
icon: /*#__PURE__*/
|
|
19
|
+
icon: /*#__PURE__*/_jsx(Bold, {})
|
|
19
20
|
}, {
|
|
20
21
|
name: 'unordered-list-item',
|
|
21
22
|
type: 'block',
|
|
22
|
-
icon: /*#__PURE__*/
|
|
23
|
+
icon: /*#__PURE__*/_jsx(UnorderedList, {})
|
|
23
24
|
}, {
|
|
24
25
|
name: 'ordered-list-item',
|
|
25
26
|
type: 'block',
|
|
26
|
-
icon: /*#__PURE__*/
|
|
27
|
+
icon: /*#__PURE__*/_jsx(OrderedList, {})
|
|
27
28
|
}, {
|
|
28
29
|
name: 'LINK',
|
|
29
30
|
type: 'inline',
|
|
30
|
-
icon: /*#__PURE__*/
|
|
31
|
+
icon: /*#__PURE__*/_jsx(LinkIcon, {})
|
|
31
32
|
}];
|
|
32
|
-
export default defaultStyleToolbarItems;
|
|
33
|
-
//# sourceMappingURL=defaultStyleToolbarItems.js.map
|
|
33
|
+
export default defaultStyleToolbarItems;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCurrentBlock.d.ts","sourceRoot":"","sources":["../../../src/Editor/utils/getCurrentBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAErD,QAAA,MAAM,eAAe,gBAAiB,WAAW,KAAG,YAInD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -3,5 +3,4 @@ const getCurrentBlock = editorState => {
|
|
|
3
3
|
const contentState = editorState.getCurrentContent();
|
|
4
4
|
return contentState.getBlockForKey(selectionState.getStartKey());
|
|
5
5
|
};
|
|
6
|
-
export default getCurrentBlock;
|
|
7
|
-
//# sourceMappingURL=getCurrentBlock.js.map
|
|
6
|
+
export default getCurrentBlock;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSelectedBlockElement.d.ts","sourceRoot":"","sources":["../../../src/Editor/utils/getSelectedBlockElement.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,uBAAuB,QAAO,OAAO,GAAG,IAY7C,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSelectionRange.d.ts","sourceRoot":"","sources":["../../../src/Editor/utils/getSelectionRange.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,iBAAiB,QAAO,KAAK,GAAG,IAIrC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setLink.d.ts","sourceRoot":"","sources":["../../../src/Editor/utils/setLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAa,MAAM,UAAU,CAAC;AAElD,QAAA,MAAM,OAAO,gBAAiB,WAAW,OAAO,MAAM,KAAG,WAiBxD,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../../../src/Editor/utils/transformers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,2BAA2B,gBACzB,WAAW,KACvB,MAOF,CAAC;AAEF,eAAO,MAAM,4BAA4B,gBAC1B,WAAW,KACvB,MAIQ,CAAC"}
|
|
@@ -2,5 +2,4 @@ export const editorStateToFirstParagraph = editorState => {
|
|
|
2
2
|
const firstUnstyledBlock = editorState.getCurrentContent().getBlocksAsArray().find(block => block.getType() === 'unstyled');
|
|
3
3
|
return firstUnstyledBlock ? firstUnstyledBlock.getText() : '';
|
|
4
4
|
};
|
|
5
|
-
export const editorStateToMetaDescription = editorState => editorStateToFirstParagraph(editorState).slice(0, 200).replace(/^(.*[.?!])(.*)/, '$1').trim();
|
|
6
|
-
//# sourceMappingURL=transformers.js.map
|
|
5
|
+
export const editorStateToMetaDescription = editorState => editorStateToFirstParagraph(editorState).slice(0, 200).replace(/^(.*[.?!])(.*)/, '$1').trim();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsetLink.d.ts","sourceRoot":"","sources":["../../../src/Editor/utils/unsetLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAa,MAAM,UAAU,CAAC;AAElD,QAAA,MAAM,SAAS,gBAAiB,WAAW,KAAG,WAM7C,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type InputSkeletonProps } from '@os-design/core';
|
|
2
|
+
export type EditorSkeletonProps = InputSkeletonProps;
|
|
3
|
+
/**
|
|
4
|
+
* Provides an editor placeholder while a user waits for the content to load.
|
|
5
|
+
*/
|
|
6
|
+
declare const EditorSkeleton: import("react").ForwardRefExoticComponent<Omit<import("@os-design/core").SkeletonProps, "width"> & import("@os-design/styles").WithSize & import("react").RefAttributes<HTMLDivElement>>;
|
|
7
|
+
export default EditorSkeleton;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/EditorSkeleton/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGzE,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAMrD;;GAEG;AACH,QAAA,MAAM,cAAc,0LAEnB,CAAC;AAIF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import { InputSkeleton } from '@os-design/core';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
const StyledEditorSkeleton = styled(InputSkeleton)`
|
|
6
|
+
height: ${p => p.theme.editorMinHeight}em;
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Provides an editor placeholder while a user waits for the content to load.
|
|
11
|
+
*/
|
|
12
|
+
const EditorSkeleton = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/_jsx(StyledEditorSkeleton, {
|
|
13
|
+
...props,
|
|
14
|
+
ref: ref
|
|
15
|
+
}));
|
|
16
|
+
EditorSkeleton.displayName = 'EditorSkeleton';
|
|
17
|
+
export default EditorSkeleton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AAC9F,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC1F,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AAC9F,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE7D,cAAc,UAAU,CAAC;AACzB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
|
@@ -12,5 +12,4 @@ export { default as EditorSkeleton } from './EditorSkeleton';
|
|
|
12
12
|
export * from './Editor';
|
|
13
13
|
export * from './Editor/utils/transformers';
|
|
14
14
|
export * from './Editor/blocks/types';
|
|
15
|
-
export * from './EditorSkeleton';
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
15
|
+
export * from './EditorSkeleton';
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@os-design/editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.261",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": "git@gitlab.com:os-team/libs/os-design.git",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"types": "dist/
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
11
|
"src",
|
|
@@ -20,9 +20,8 @@
|
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"scripts": {
|
|
22
22
|
"clean": "rimraf dist",
|
|
23
|
-
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx --out-dir dist
|
|
24
|
-
"build:
|
|
25
|
-
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
|
|
23
|
+
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx --out-dir dist",
|
|
24
|
+
"build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly --declaration --declarationDir dist",
|
|
26
25
|
"build": "yarn clean && npm-run-all 'build:*'",
|
|
27
26
|
"ncu": "ncu -u '/^(?!(immutable)$).*$/'"
|
|
28
27
|
},
|
|
@@ -30,11 +29,11 @@
|
|
|
30
29
|
"access": "public"
|
|
31
30
|
},
|
|
32
31
|
"dependencies": {
|
|
33
|
-
"@os-design/core": "^1.0.
|
|
34
|
-
"@os-design/icons": "^1.0.
|
|
35
|
-
"@os-design/styles": "^1.0.
|
|
36
|
-
"@os-design/theming": "^1.0.
|
|
37
|
-
"@os-design/utils": "^1.0.
|
|
32
|
+
"@os-design/core": "^1.0.256",
|
|
33
|
+
"@os-design/icons": "^1.0.60",
|
|
34
|
+
"@os-design/styles": "^1.0.57",
|
|
35
|
+
"@os-design/theming": "^1.0.53",
|
|
36
|
+
"@os-design/utils": "^1.0.77",
|
|
38
37
|
"draft-js": "^0.11.7"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
@@ -50,5 +49,5 @@
|
|
|
50
49
|
"react": ">=18",
|
|
51
50
|
"react-dom": ">=18"
|
|
52
51
|
},
|
|
53
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "86a83e87297a07afe132782ca2c95023b7139276"
|
|
54
53
|
}
|
package/src/@types/emotion.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import '@emotion/react';
|
|
|
2
2
|
import { Theme as BaseTheme } from '@os-design/theming';
|
|
3
3
|
|
|
4
4
|
declare module '@emotion/react' {
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
6
6
|
export interface Theme extends BaseTheme {}
|
|
7
7
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
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, { useCallback } from 'react';
|
|
4
4
|
import Toolbar from './Toolbar';
|
|
5
5
|
import ToolbarButton from './ToolbarButton';
|
|
6
|
-
import { BlockToolbarItem } from './blocks/types';
|
|
6
|
+
import type { BlockToolbarItem } from './blocks/types';
|
|
7
7
|
import getCurrentBlock from './utils/getCurrentBlock';
|
|
8
8
|
|
|
9
9
|
interface BlockToolbarProps extends Omit<PopoverProps, 'onChange'> {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PopoverProps } from '@os-design/core';
|
|
1
|
+
import type { PopoverProps } from '@os-design/core';
|
|
2
2
|
import { EditorState, RichUtils } from 'draft-js';
|
|
3
3
|
import React, { useCallback, useMemo } from 'react';
|
|
4
4
|
import Toolbar from './Toolbar';
|
|
5
5
|
import ToolbarButton from './ToolbarButton';
|
|
6
|
-
import { StyleToolbarItem } from './utils/defaultStyleToolbarItems';
|
|
6
|
+
import type { StyleToolbarItem } from './utils/defaultStyleToolbarItems';
|
|
7
7
|
import setLink from './utils/setLink';
|
|
8
8
|
import unsetLink from './utils/unsetLink';
|
|
9
9
|
|
|
@@ -33,7 +33,6 @@ const StyleToolbar: React.FC<StyleToolbarProps> = ({
|
|
|
33
33
|
onChange(unsetLink(value));
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
// eslint-disable-next-line no-alert
|
|
37
36
|
const url = prompt('Paste or type a link');
|
|
38
37
|
if (!url) return;
|
|
39
38
|
onChange(setLink(value, url));
|
|
@@ -9,7 +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 { BlockProps, BlockToolbarItem } from './types';
|
|
12
|
+
import type { BlockProps, BlockToolbarItem } from './types';
|
|
13
13
|
|
|
14
14
|
const widthStyles = (p) =>
|
|
15
15
|
p.width &&
|
|
@@ -6,7 +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 { BlockProps, BlockToolbarItem } from './types';
|
|
9
|
+
import type { BlockProps, BlockToolbarItem } from './types';
|
|
10
10
|
|
|
11
11
|
const VideoBlock: React.FC<BlockProps> = (props) => {
|
|
12
12
|
const { block } = props;
|
|
@@ -48,7 +48,6 @@ const videoTypes = [
|
|
|
48
48
|
];
|
|
49
49
|
|
|
50
50
|
const detectVideo = (url: string) => {
|
|
51
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
52
51
|
for (const { re, getUrl } of videoTypes) {
|
|
53
52
|
const groups = url.match(re);
|
|
54
53
|
if (groups && groups[1]) return getUrl(groups[1]);
|
|
@@ -63,7 +62,6 @@ const videoBlock: BlockToolbarItem = {
|
|
|
63
62
|
component: VideoBlock,
|
|
64
63
|
icon: <VideoIcon />,
|
|
65
64
|
onClick: ({ value, onChange }) => {
|
|
66
|
-
// eslint-disable-next-line no-alert
|
|
67
65
|
const url = prompt('Insert a link to YouTube or RuTube');
|
|
68
66
|
if (!url) return;
|
|
69
67
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EditorProps as DraftEditorProps, EditorState } from 'draft-js';
|
|
1
|
+
import { type EditorProps as DraftEditorProps, EditorState } from 'draft-js';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import addNewBlockAt from '../utils/addNewBlockAt';
|
|
4
4
|
import getCurrentBlock from '../utils/getCurrentBlock';
|
package/src/Editor/index.tsx
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
import styled from '@emotion/styled';
|
|
3
3
|
import { InputContainer } from '@os-design/core';
|
|
4
|
-
import { WithSize } from '@os-design/styles';
|
|
4
|
+
import type { WithSize } from '@os-design/styles';
|
|
5
5
|
import { useForwardedRef, useForwardedState } from '@os-design/utils';
|
|
6
6
|
import {
|
|
7
7
|
Editor as DraftEditor,
|
|
8
|
-
EditorProps as DraftEditorProps,
|
|
8
|
+
type EditorProps as DraftEditorProps,
|
|
9
9
|
EditorState,
|
|
10
10
|
} from 'draft-js';
|
|
11
|
-
import
|
|
11
|
+
import { forwardRef, useCallback, useState } from 'react';
|
|
12
12
|
import BlockToolbar from './BlockToolbar';
|
|
13
13
|
import StyleToolbar from './StyleToolbar';
|
|
14
|
-
import { BlockToolbarItem } from './blocks/types';
|
|
14
|
+
import type { BlockToolbarItem } from './blocks/types';
|
|
15
15
|
import useBlockToolbarProps from './hooks/useBlockToolbarProps';
|
|
16
16
|
import usePastedTextHandler from './hooks/usePastedTextHandler';
|
|
17
17
|
import useReturnHandler from './hooks/useReturnHandler';
|
|
@@ -20,7 +20,7 @@ import defaultDraftJsStyles from './styles/defaultDraftJsStyles';
|
|
|
20
20
|
import overrideDraftJsStyles from './styles/overrideDraftJsStyles';
|
|
21
21
|
import createEmptyEditorState from './utils/createEmptyEditorState';
|
|
22
22
|
import defaultStyleToolbarItems, {
|
|
23
|
-
StyleToolbarItem,
|
|
23
|
+
type StyleToolbarItem,
|
|
24
24
|
} from './utils/defaultStyleToolbarItems';
|
|
25
25
|
|
|
26
26
|
export interface EditorProps
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
|
-
import { InputSkeleton, InputSkeletonProps } from '@os-design/core';
|
|
3
|
-
import
|
|
2
|
+
import { InputSkeleton, type InputSkeletonProps } from '@os-design/core';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
4
|
|
|
5
5
|
export type EditorSkeletonProps = InputSkeletonProps;
|
|
6
6
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"emotion.d.js","names":["require"],"sources":["../../../src/@types/emotion.d.ts"],"sourcesContent":["import '@emotion/react';\nimport { Theme as BaseTheme } from '@os-design/theming';\n\ndeclare module '@emotion/react' {\n // eslint-disable-next-line @typescript-eslint/no-empty-interface\n export interface Theme extends BaseTheme {}\n}\n"],"mappings":";;AAAAA,OAAA","ignoreList":[]}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports["default"] = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _Toolbar = _interopRequireDefault(require("./Toolbar"));
|
|
10
|
-
var _ToolbarButton = _interopRequireDefault(require("./ToolbarButton"));
|
|
11
|
-
var _getCurrentBlock = _interopRequireDefault(require("./utils/getCurrentBlock"));
|
|
12
|
-
var _excluded = ["items", "value", "onChange", "setReadOnly"];
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
16
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
17
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
|
18
|
-
var BlockToolbar = function BlockToolbar(_ref) {
|
|
19
|
-
var items = _ref.items,
|
|
20
|
-
value = _ref.value,
|
|
21
|
-
onChange = _ref.onChange,
|
|
22
|
-
setReadOnly = _ref.setReadOnly,
|
|
23
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
-
var clickHandler = (0, _react.useCallback)(function (_ref2) {
|
|
25
|
-
var onClick = _ref2.onClick;
|
|
26
|
-
var currentBlock = (0, _getCurrentBlock["default"])(value);
|
|
27
|
-
if (currentBlock.getType() !== 'unstyled' || currentBlock.getLength() > 0) return;
|
|
28
|
-
onClick({
|
|
29
|
-
value: value,
|
|
30
|
-
onChange: onChange,
|
|
31
|
-
setReadOnly: setReadOnly
|
|
32
|
-
});
|
|
33
|
-
}, [value, onChange, setReadOnly]);
|
|
34
|
-
return /*#__PURE__*/_react["default"].createElement(_Toolbar["default"], rest, items.map(function (item) {
|
|
35
|
-
return /*#__PURE__*/_react["default"].createElement(_ToolbarButton["default"], {
|
|
36
|
-
key: item.type,
|
|
37
|
-
onClick: function onClick() {
|
|
38
|
-
return clickHandler(item);
|
|
39
|
-
}
|
|
40
|
-
}, item.icon);
|
|
41
|
-
}));
|
|
42
|
-
};
|
|
43
|
-
var _default = exports["default"] = BlockToolbar;
|
|
44
|
-
//# sourceMappingURL=BlockToolbar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BlockToolbar.js","names":["_react","_interopRequireWildcard","require","_Toolbar","_interopRequireDefault","_ToolbarButton","_getCurrentBlock","_excluded","obj","__esModule","_getRequireWildcardCache","e","WeakMap","r","t","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_objectWithoutProperties","source","excluded","target","_objectWithoutPropertiesLoose","key","getOwnPropertySymbols","sourceSymbolKeys","length","indexOf","prototype","propertyIsEnumerable","BlockToolbar","_ref","items","value","onChange","setReadOnly","rest","clickHandler","useCallback","_ref2","onClick","currentBlock","getCurrentBlock","getType","getLength","createElement","map","item","type","icon","_default","exports"],"sources":["../../../src/Editor/BlockToolbar.tsx"],"sourcesContent":["import { PopoverProps } from '@os-design/core';\nimport { EditorState } from 'draft-js';\nimport React, { useCallback } from 'react';\nimport Toolbar from './Toolbar';\nimport ToolbarButton from './ToolbarButton';\nimport { BlockToolbarItem } from './blocks/types';\nimport getCurrentBlock from './utils/getCurrentBlock';\n\ninterface BlockToolbarProps extends Omit<PopoverProps, 'onChange'> {\n items: BlockToolbarItem[];\n value: EditorState;\n onChange: (value: EditorState) => void;\n setReadOnly: (readOnly: boolean) => void;\n}\n\nconst BlockToolbar: React.FC<BlockToolbarProps> = ({\n items,\n value,\n onChange,\n setReadOnly,\n ...rest\n}) => {\n const clickHandler = useCallback<(item: BlockToolbarItem) => void>(\n ({ onClick }) => {\n const currentBlock = getCurrentBlock(value);\n if (currentBlock.getType() !== 'unstyled' || currentBlock.getLength() > 0)\n return;\n onClick({\n value,\n onChange,\n setReadOnly,\n });\n },\n [value, onChange, setReadOnly]\n );\n\n return (\n <Toolbar {...rest}>\n {items.map((item) => (\n <ToolbarButton key={item.type} onClick={() => clickHandler(item)}>\n {item.icon}\n </ToolbarButton>\n ))}\n </Toolbar>\n );\n};\n\nexport default BlockToolbar;\n"],"mappings":";;;;;;;AAEA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,cAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,gBAAA,GAAAF,sBAAA,CAAAF,OAAA;AAAsD,IAAAK,SAAA;AAAA,SAAAH,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,gBAAAA,GAAA;AAAA,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAF,UAAA,SAAAE,CAAA,eAAAA,CAAA,gBAAAI,OAAA,CAAAJ,CAAA,0BAAAA,CAAA,sBAAAA,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAE,GAAA,CAAAL,CAAA,UAAAG,CAAA,CAAAG,GAAA,CAAAN,CAAA,OAAAO,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAb,CAAA,oBAAAa,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAa,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAZ,CAAA,EAAAa,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAb,CAAA,CAAAa,CAAA,YAAAN,CAAA,cAAAP,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAc,GAAA,CAAAjB,CAAA,EAAAO,CAAA,GAAAA,CAAA;AAAA,SAAAW,yBAAAC,MAAA,EAAAC,QAAA,QAAAD,MAAA,yBAAAE,MAAA,GAAAC,6BAAA,CAAAH,MAAA,EAAAC,QAAA,OAAAG,GAAA,EAAAP,CAAA,MAAAN,MAAA,CAAAc,qBAAA,QAAAC,gBAAA,GAAAf,MAAA,CAAAc,qBAAA,CAAAL,MAAA,QAAAH,CAAA,MAAAA,CAAA,GAAAS,gBAAA,CAAAC,MAAA,EAAAV,CAAA,MAAAO,GAAA,GAAAE,gBAAA,CAAAT,CAAA,OAAAI,QAAA,CAAAO,OAAA,CAAAJ,GAAA,uBAAAb,MAAA,CAAAkB,SAAA,CAAAC,oBAAA,CAAAd,IAAA,CAAAI,MAAA,EAAAI,GAAA,aAAAF,MAAA,CAAAE,GAAA,IAAAJ,MAAA,CAAAI,GAAA,cAAAF,MAAA;AAAA,SAAAC,8BAAAH,MAAA,EAAAC,QAAA,QAAAD,MAAA,yBAAAE,MAAA,gBAAAE,GAAA,IAAAJ,MAAA,QAAAT,MAAA,CAAAkB,SAAA,CAAAd,cAAA,CAAAC,IAAA,CAAAI,MAAA,EAAAI,GAAA,SAAAH,QAAA,CAAAO,OAAA,CAAAJ,GAAA,kBAAAF,MAAA,CAAAE,GAAA,IAAAJ,MAAA,CAAAI,GAAA,cAAAF,MAAA;AAStD,IAAMS,YAAyC,GAAG,SAA5CA,YAAyCA,CAAAC,IAAA,EAMzC;EAAA,IALJC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IACRC,WAAW,GAAAJ,IAAA,CAAXI,WAAW;IACRC,IAAI,GAAAlB,wBAAA,CAAAa,IAAA,EAAAnC,SAAA;EAEP,IAAMyC,YAAY,GAAG,IAAAC,kBAAW,EAC9B,UAAAC,KAAA,EAAiB;IAAA,IAAdC,OAAO,GAAAD,KAAA,CAAPC,OAAO;IACR,IAAMC,YAAY,GAAG,IAAAC,2BAAe,EAACT,KAAK,CAAC;IAC3C,IAAIQ,YAAY,CAACE,OAAO,CAAC,CAAC,KAAK,UAAU,IAAIF,YAAY,CAACG,SAAS,CAAC,CAAC,GAAG,CAAC,EACvE;IACFJ,OAAO,CAAC;MACNP,KAAK,EAALA,KAAK;MACLC,QAAQ,EAARA,QAAQ;MACRC,WAAW,EAAXA;IACF,CAAC,CAAC;EACJ,CAAC,EACD,CAACF,KAAK,EAAEC,QAAQ,EAAEC,WAAW,CAC/B,CAAC;EAED,oBACE9C,MAAA,YAAAwD,aAAA,CAACrD,QAAA,WAAO,EAAK4C,IAAI,EACdJ,KAAK,CAACc,GAAG,CAAC,UAACC,IAAI;IAAA,oBACd1D,MAAA,YAAAwD,aAAA,CAACnD,cAAA,WAAa;MAAC6B,GAAG,EAAEwB,IAAI,CAACC,IAAK;MAACR,OAAO,EAAE,SAAAA,QAAA;QAAA,OAAMH,YAAY,CAACU,IAAI,CAAC;MAAA;IAAC,GAC9DA,IAAI,CAACE,IACO,CAAC;EAAA,CACjB,CACM,CAAC;AAEd,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEarB,YAAY","ignoreList":[]}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports["default"] = void 0;
|
|
8
|
-
var _draftJs = require("draft-js");
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _Toolbar = _interopRequireDefault(require("./Toolbar"));
|
|
11
|
-
var _ToolbarButton = _interopRequireDefault(require("./ToolbarButton"));
|
|
12
|
-
var _setLink = _interopRequireDefault(require("./utils/setLink"));
|
|
13
|
-
var _unsetLink = _interopRequireDefault(require("./utils/unsetLink"));
|
|
14
|
-
var _excluded = ["items", "value", "onChange"];
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
17
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
18
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
19
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
|
20
|
-
var StyleToolbar = function StyleToolbar(_ref) {
|
|
21
|
-
var items = _ref.items,
|
|
22
|
-
value = _ref.value,
|
|
23
|
-
_ref$onChange = _ref.onChange,
|
|
24
|
-
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
25
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
-
var currentBlockType = (0, _react.useMemo)(function () {
|
|
27
|
-
return _draftJs.RichUtils.getCurrentBlockType(value);
|
|
28
|
-
}, [value]);
|
|
29
|
-
var currentBlockContainsLink = (0, _react.useMemo)(function () {
|
|
30
|
-
return _draftJs.RichUtils.currentBlockContainsLink(value);
|
|
31
|
-
}, [value]);
|
|
32
|
-
var toggleLink = (0, _react.useCallback)(function () {
|
|
33
|
-
if (currentBlockContainsLink) {
|
|
34
|
-
onChange((0, _unsetLink["default"])(value));
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
// eslint-disable-next-line no-alert
|
|
38
|
-
var url = prompt('Paste or type a link');
|
|
39
|
-
if (!url) return;
|
|
40
|
-
onChange((0, _setLink["default"])(value, url));
|
|
41
|
-
}, [currentBlockContainsLink, value, onChange]);
|
|
42
|
-
var clickHandler = (0, _react.useCallback)(function (item) {
|
|
43
|
-
if (item.type === 'inline') {
|
|
44
|
-
onChange(_draftJs.RichUtils.toggleInlineStyle(value, item.name));
|
|
45
|
-
} else if (item.type === 'block') {
|
|
46
|
-
onChange(_draftJs.RichUtils.toggleBlockType(value, item.name));
|
|
47
|
-
}
|
|
48
|
-
}, [value, onChange]);
|
|
49
|
-
if (items.length === 0) return null;
|
|
50
|
-
return /*#__PURE__*/_react["default"].createElement(_Toolbar["default"], rest, items.map(function (item) {
|
|
51
|
-
var isLink = item.name === 'LINK' && item.type === 'inline';
|
|
52
|
-
var active = isLink ? currentBlockContainsLink : value.getCurrentInlineStyle().has(item.name) || currentBlockType === item.name;
|
|
53
|
-
var onClick = isLink ? toggleLink : function () {
|
|
54
|
-
return clickHandler(item);
|
|
55
|
-
};
|
|
56
|
-
return /*#__PURE__*/_react["default"].createElement(_ToolbarButton["default"], {
|
|
57
|
-
key: item.name,
|
|
58
|
-
active: active,
|
|
59
|
-
onClick: onClick
|
|
60
|
-
}, item.icon);
|
|
61
|
-
}));
|
|
62
|
-
};
|
|
63
|
-
StyleToolbar.displayName = 'StyleToolbar';
|
|
64
|
-
var _default = exports["default"] = StyleToolbar;
|
|
65
|
-
//# sourceMappingURL=StyleToolbar.js.map
|