@os-design/editor 1.0.309 → 1.0.311
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/Editor/ToolbarButton.d.ts +1 -1
- package/dist/Editor/ToolbarButton.d.ts.map +1 -1
- package/dist/Editor/blocks/Figure.d.ts.map +1 -1
- package/dist/Editor/blocks/FigureCaption.d.ts.map +1 -1
- package/dist/Editor/hooks/useBlockToolbarProps.d.ts.map +1 -1
- package/dist/Editor/hooks/useBlockToolbarProps.js +1 -0
- package/dist/Editor/hooks/useStyleToolbarProps.d.ts.map +1 -1
- package/dist/Editor/hooks/useStyleToolbarProps.js +3 -2
- package/dist/Editor/index.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/Editor/ToolbarButton.tsx +1 -1
- package/src/Editor/hooks/useBlockToolbarProps.ts +1 -0
- package/src/Editor/hooks/useStyleToolbarProps.ts +3 -2
- package/src/Editor/index.tsx +1 -2
|
@@ -1 +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;
|
|
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,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAC5D,UAAU,kBAAmB,SAAQ,cAAc;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAqCD,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAE/C,CAAC;AAIF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Figure.d.ts","sourceRoot":"","sources":["../../../src/Editor/blocks/Figure.tsx"],"names":[],"mappings":"AAEA,QAAA,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"Figure.d.ts","sourceRoot":"","sources":["../../../src/Editor/blocks/Figure.tsx"],"names":[],"mappings":"AAEA,QAAA,MAAM,MAAM;;;mGAGX,CAAC;AAIF,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FigureCaption.d.ts","sourceRoot":"","sources":["../../../src/Editor/blocks/FigureCaption.tsx"],"names":[],"mappings":"AAGA,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"FigureCaption.d.ts","sourceRoot":"","sources":["../../../src/Editor/blocks/FigureCaption.tsx"],"names":[],"mappings":"AAGA,QAAA,MAAM,aAAa;;;mGAWlB,CAAC;AAIF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +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,GACxB,OAAO,WAAW,EAClB,MAAM,OAAO,KACZ,
|
|
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,GACxB,OAAO,WAAW,EAClB,MAAM,OAAO,KACZ,uBAgDF,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -15,6 +15,7 @@ const useBlockToolbarProps = (value, show) => {
|
|
|
15
15
|
if (!show || !value) return;
|
|
16
16
|
const selectedBlockElement = getSelectedBlockElement();
|
|
17
17
|
if (!selectedBlockElement) {
|
|
18
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
18
19
|
setVisible(false);
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
@@ -1 +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,GAAI,OAAO,WAAW,KAAG,
|
|
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,GAAI,OAAO,WAAW,KAAG,uBAgClD,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RichUtils } from 'draft-js';
|
|
2
|
-
import {
|
|
2
|
+
import { useLayoutEffect, useState } from 'react';
|
|
3
3
|
import getSelectionRange from '../utils/getSelectionRange.js';
|
|
4
4
|
/**
|
|
5
5
|
* Updates the visibility of the style toolbar
|
|
@@ -12,7 +12,7 @@ const useStyleToolbarProps = value => {
|
|
|
12
12
|
height: 0
|
|
13
13
|
});
|
|
14
14
|
const [visible, setVisible] = useState(false);
|
|
15
|
-
|
|
15
|
+
useLayoutEffect(() => {
|
|
16
16
|
if (!value) return;
|
|
17
17
|
const selectionRange = getSelectionRange();
|
|
18
18
|
|
|
@@ -20,6 +20,7 @@ const useStyleToolbarProps = value => {
|
|
|
20
20
|
// or the selection range is collapsed,
|
|
21
21
|
// or the selected text is in an atomic block.
|
|
22
22
|
if (!selectionRange || value.getSelection().isCollapsed() || RichUtils.getCurrentBlockType(value).startsWith('atomic')) {
|
|
23
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
23
24
|
setVisible(false);
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
@@ -1 +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,mBAAmB,CAAC;AAQ1D,OAAiC,EAC/B,KAAK,gBAAgB,EACtB,MAAM,qCAAqC,CAAC;AAE7C,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,gBAAgB,EAAE,aAAa,GAAG,UAAU,CAAC,
|
|
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,mBAAmB,CAAC;AAQ1D,OAAiC,EAC/B,KAAK,gBAAgB,EACtB,MAAM,qCAAqC,CAAC;AAE7C,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,gBAAgB,EAAE,aAAa,GAAG,UAAU,CAAC,EAAE,QAAQ;IACpE;;;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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@os-design/editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.311",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": "git@gitlab.com:os-team/libs/os-design.git",
|
|
6
6
|
"type": "module",
|
|
@@ -19,35 +19,35 @@
|
|
|
19
19
|
],
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"scripts": {
|
|
22
|
-
"clean": "
|
|
22
|
+
"clean": "rm -r dist",
|
|
23
23
|
"build:esm": "cross-env BABEL_ENV=esm babel src --root-mode upward --extensions .ts,.tsx --out-dir dist",
|
|
24
24
|
"build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly --declaration --declarationDir dist",
|
|
25
25
|
"build": "yarn clean && npm-run-all 'build:*'",
|
|
26
|
-
"ncu": "ncu -u
|
|
26
|
+
"ncu": "ncu -u"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@os-design/core": "^1.0.
|
|
33
|
-
"@os-design/icons": "^1.0.
|
|
34
|
-
"@os-design/styles": "^1.0.
|
|
35
|
-
"@os-design/theming": "^1.0.
|
|
36
|
-
"@os-design/utils": "^1.0.
|
|
32
|
+
"@os-design/core": "^1.0.306",
|
|
33
|
+
"@os-design/icons": "^1.0.75",
|
|
34
|
+
"@os-design/styles": "^1.0.72",
|
|
35
|
+
"@os-design/theming": "^1.0.67",
|
|
36
|
+
"@os-design/utils": "^1.0.97",
|
|
37
37
|
"draft-js": "^0.11.7"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@emotion/react": ">=11",
|
|
41
41
|
"@emotion/styled": ">=11",
|
|
42
|
-
"@types/draft-js": "^0.11.
|
|
43
|
-
"immutable": "^5.
|
|
42
|
+
"@types/draft-js": "^0.11.20",
|
|
43
|
+
"immutable": "^5.1.5"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@emotion/react": ">=11",
|
|
47
47
|
"@emotion/styled": ">=11",
|
|
48
48
|
"immutable": "~3.7.4",
|
|
49
|
-
"react": "
|
|
50
|
-
"react-dom": "
|
|
49
|
+
"react": "19",
|
|
50
|
+
"react-dom": "19"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "83ca5af2bb91d07d64440f87b7ab23f5100daa02"
|
|
53
53
|
}
|
|
@@ -5,7 +5,7 @@ import { clr } from '@os-design/theming';
|
|
|
5
5
|
import { omitEmotionProps } from '@os-design/utils';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
type JsxButtonProps = JSX.IntrinsicElements['button'];
|
|
8
|
+
type JsxButtonProps = React.JSX.IntrinsicElements['button'];
|
|
9
9
|
interface ToolbarButtonProps extends JsxButtonProps {
|
|
10
10
|
active?: boolean;
|
|
11
11
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EditorState, RichUtils } from 'draft-js';
|
|
2
|
-
import {
|
|
2
|
+
import { useLayoutEffect, useState } from 'react';
|
|
3
3
|
import getSelectionRange from '../utils/getSelectionRange.js';
|
|
4
4
|
|
|
5
5
|
interface Rect {
|
|
@@ -26,7 +26,7 @@ const useStyleToolbarProps = (value: EditorState): UseStyleToolbarPropsRes => {
|
|
|
26
26
|
});
|
|
27
27
|
const [visible, setVisible] = useState(false);
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
useLayoutEffect(() => {
|
|
30
30
|
if (!value) return;
|
|
31
31
|
const selectionRange = getSelectionRange();
|
|
32
32
|
|
|
@@ -38,6 +38,7 @@ const useStyleToolbarProps = (value: EditorState): UseStyleToolbarPropsRes => {
|
|
|
38
38
|
value.getSelection().isCollapsed() ||
|
|
39
39
|
RichUtils.getCurrentBlockType(value).startsWith('atomic')
|
|
40
40
|
) {
|
|
41
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
41
42
|
setVisible(false);
|
|
42
43
|
return;
|
|
43
44
|
}
|
package/src/Editor/index.tsx
CHANGED
|
@@ -24,8 +24,7 @@ import defaultStyleToolbarItems, {
|
|
|
24
24
|
} from './utils/defaultStyleToolbarItems.js';
|
|
25
25
|
|
|
26
26
|
export interface EditorProps
|
|
27
|
-
extends Omit<DraftEditorProps, 'editorState' | 'onChange'>,
|
|
28
|
-
WithSize {
|
|
27
|
+
extends Omit<DraftEditorProps, 'editorState' | 'onChange'>, WithSize {
|
|
29
28
|
/**
|
|
30
29
|
* Whether the editor is disabled.
|
|
31
30
|
* @default false
|