@os-design/editor 1.0.260 → 1.0.262
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 +12 -9
- 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 +19 -17
- 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 +22 -15
- 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 +17 -13
- 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 +2 -3
- 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 +3 -4
- 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 +2 -3
- package/dist/Editor/index.d.ts +42 -0
- package/dist/Editor/index.d.ts.map +1 -0
- package/dist/{esm/Editor → Editor}/index.js +51 -47
- 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 +2 -3
- package/dist/Editor/utils/createDecorator.d.ts.map +1 -0
- package/dist/Editor/utils/createDecorator.js +4 -0
- package/dist/Editor/utils/createEmptyEditorState.d.ts.map +1 -0
- package/dist/Editor/utils/createEmptyEditorState.js +4 -0
- 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 +2 -3
- 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/index.js +15 -0
- 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 +0 -5
- package/dist/esm/Editor/utils/createDecorator.js.map +0 -1
- package/dist/esm/Editor/utils/createEmptyEditorState.js +0 -5
- 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 +0 -16
- 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
|
@@ -1,20 +1,20 @@
|
|
|
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
|
|
8
|
-
import BlockToolbar from
|
|
9
|
-
import StyleToolbar from
|
|
10
|
-
import useBlockToolbarProps from
|
|
11
|
-
import usePastedTextHandler from
|
|
12
|
-
import useReturnHandler from
|
|
13
|
-
import useStyleToolbarProps from
|
|
14
|
-
import defaultDraftJsStyles from
|
|
15
|
-
import overrideDraftJsStyles from
|
|
16
|
-
import createEmptyEditorState from
|
|
17
|
-
import defaultStyleToolbarItems from
|
|
6
|
+
import { forwardRef, useCallback, useState } from 'react';
|
|
7
|
+
import BlockToolbar from "./BlockToolbar.js";
|
|
8
|
+
import StyleToolbar from "./StyleToolbar.js";
|
|
9
|
+
import useBlockToolbarProps from "./hooks/useBlockToolbarProps.js";
|
|
10
|
+
import usePastedTextHandler from "./hooks/usePastedTextHandler.js";
|
|
11
|
+
import useReturnHandler from "./hooks/useReturnHandler.js";
|
|
12
|
+
import useStyleToolbarProps from "./hooks/useStyleToolbarProps.js";
|
|
13
|
+
import defaultDraftJsStyles from "./styles/defaultDraftJsStyles.js";
|
|
14
|
+
import overrideDraftJsStyles from "./styles/overrideDraftJsStyles.js";
|
|
15
|
+
import createEmptyEditorState from "./utils/createEmptyEditorState.js";
|
|
16
|
+
import defaultStyleToolbarItems from "./utils/defaultStyleToolbarItems.js";
|
|
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"}
|
|
@@ -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
|
-
import createDecorator from
|
|
2
|
+
import createDecorator from "./createDecorator.js";
|
|
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"}
|
|
@@ -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"}
|
|
@@ -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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import getSelectionRange from
|
|
1
|
+
import getSelectionRange from "./getSelectionRange.js";
|
|
2
2
|
const getSelectedBlockElement = () => {
|
|
3
3
|
const selectionRange = getSelectionRange();
|
|
4
4
|
if (!selectionRange) return null;
|
|
@@ -9,5 +9,4 @@ const getSelectedBlockElement = () => {
|
|
|
9
9
|
} while (node != null);
|
|
10
10
|
return null;
|
|
11
11
|
};
|
|
12
|
-
export default getSelectedBlockElement;
|
|
13
|
-
//# sourceMappingURL=getSelectedBlockElement.js.map
|
|
12
|
+
export default getSelectedBlockElement;
|
|
@@ -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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { default as Editor } from "./Editor/index.js";
|
|
2
|
+
export { default as addNewBlockAt } from "./Editor/utils/addNewBlockAt.js";
|
|
3
|
+
export { default as changeBlock } from "./Editor/utils/changeBlock.js";
|
|
4
|
+
export { default as createContentEditorState } from "./Editor/utils/createContentEditorState.js";
|
|
5
|
+
export { default as createDecorator } from "./Editor/utils/createDecorator.js";
|
|
6
|
+
export { default as createEmptyEditorState } from "./Editor/utils/createEmptyEditorState.js";
|
|
7
|
+
export { default as defaultStyleToolbarItems } from "./Editor/utils/defaultStyleToolbarItems.js";
|
|
8
|
+
export { default as getCurrentBlock } from "./Editor/utils/getCurrentBlock.js";
|
|
9
|
+
export { default as imageBlock } from "./Editor/blocks/imageBlock.js";
|
|
10
|
+
export { default as videoBlock } from "./Editor/blocks/videoBlock.js";
|
|
11
|
+
export { default as EditorSkeleton } from "./EditorSkeleton/index.js";
|
|
12
|
+
export * from "./Editor/index.js";
|
|
13
|
+
export * from "./Editor/utils/transformers.js";
|
|
14
|
+
export * from "./Editor/blocks/types.js";
|
|
15
|
+
export * from "./EditorSkeleton/index.js";
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@os-design/editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.262",
|
|
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.257",
|
|
33
|
+
"@os-design/icons": "^1.0.61",
|
|
34
|
+
"@os-design/styles": "^1.0.58",
|
|
35
|
+
"@os-design/theming": "^1.0.54",
|
|
36
|
+
"@os-design/utils": "^1.0.78",
|
|
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": "211f9e5f1ecca50454cc7415359de5a4d950c7b1"
|
|
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":[]}
|