@blocklet/editor 2.0.19 → 2.0.21
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/lib/components/SelectionPopper.js +0 -1
- package/lib/ext/Aide/Aide.js +2 -0
- package/lib/ext/Aide/Input.js +1 -1
- package/lib/ext/SafeAreaPlugin.d.ts +4 -0
- package/lib/ext/SafeAreaPlugin.js +21 -0
- package/lib/main/editor.js +1 -0
- package/lib/main/nodes/ImageComponent.js +2 -0
- package/package.json +3 -3
package/lib/ext/Aide/Aide.js
CHANGED
|
@@ -6,11 +6,13 @@ import Output from './Output';
|
|
|
6
6
|
import Templates from './Templates';
|
|
7
7
|
import Menu from './Menu';
|
|
8
8
|
import ExternalTemplates from './external-templates';
|
|
9
|
+
import { useSafeArea } from '../SafeAreaPlugin';
|
|
9
10
|
export function Aide(props) {
|
|
10
11
|
const { status, mode, reset, available } = useAideContext();
|
|
11
12
|
const handleClickAway = (e) => {
|
|
12
13
|
reset();
|
|
13
14
|
};
|
|
15
|
+
useSafeArea({ enabled: available && status !== 'initial', size: '360px' });
|
|
14
16
|
if (!available || status === 'initial') {
|
|
15
17
|
return null;
|
|
16
18
|
}
|
package/lib/ext/Aide/Input.js
CHANGED
|
@@ -29,7 +29,7 @@ export default function Input({ prepend, ...rest }) {
|
|
|
29
29
|
justifyContent: 'center',
|
|
30
30
|
alighItems: 'center',
|
|
31
31
|
width: 36,
|
|
32
|
-
}, children: _jsx(Box, { component: "i", className: "iconify", "data-icon": "bi:stars", "data-height": "16px", sx: { color: 'grey.600' } }) }), prepend, status === 'activated' && (_jsxs(_Fragment, { children: [_jsx(Box, { component: "input", type: "text", value: input, onChange: (e) => setInput(e.target.value), onKeyDown: handleOnKeyDown,
|
|
32
|
+
}, children: _jsx(Box, { component: "i", className: "iconify", "data-icon": "bi:stars", "data-height": "16px", sx: { color: 'grey.600' } }) }), prepend, status === 'activated' && (_jsxs(_Fragment, { children: [_jsx(Box, { component: "input", type: "text", value: input, onChange: (e) => setInput(e.target.value), onKeyDown: handleOnKeyDown, ref: (ref) => ref && ref.focus({ preventScroll: true }), sx: { flex: '1 1 auto', height: '100%', border: 0, outline: 'none' } }), _jsx(Box, { onClick: submit, sx: {
|
|
33
33
|
display: 'flex',
|
|
34
34
|
justifyContent: 'center',
|
|
35
35
|
alighItems: 'center',
|
|
@@ -33,3 +33,24 @@ export function SafeAreaPlugin({ size = '30vh' }) {
|
|
|
33
33
|
}, [editor]);
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
|
+
export function useSafeArea({ enabled, size = '30vh' }) {
|
|
37
|
+
const [editor] = useLexicalComposerContext();
|
|
38
|
+
const originalValue = useRef();
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const cleanup = editor.registerRootListener((rootElement, prevRootElement) => {
|
|
41
|
+
if (rootElement !== null && editor.isEditable() && enabled) {
|
|
42
|
+
if (originalValue.current === undefined) {
|
|
43
|
+
originalValue.current = rootElement.style.paddingBottom;
|
|
44
|
+
}
|
|
45
|
+
rootElement.style.paddingBottom = normalizeCssSize(size);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return () => {
|
|
49
|
+
const rootElement = editor.getRootElement();
|
|
50
|
+
if (rootElement && originalValue.current !== undefined) {
|
|
51
|
+
rootElement.style.paddingBottom = originalValue.current;
|
|
52
|
+
}
|
|
53
|
+
cleanup();
|
|
54
|
+
};
|
|
55
|
+
}, [editor, enabled]);
|
|
56
|
+
}
|
package/lib/main/editor.js
CHANGED
|
@@ -36,6 +36,7 @@ import { ImageAnnotation, ImageAnnotationView, ImageEnhancer } from '../ui/Image
|
|
|
36
36
|
import { useImageDisplayWidth } from '../hooks/hooks';
|
|
37
37
|
import { useMediumZoom } from '../hooks/medium-zoom';
|
|
38
38
|
import { FrameMockup, isDeviceFrame } from '../ui/FrameMockup';
|
|
39
|
+
import { useSafeArea } from '../../ext/SafeAreaPlugin';
|
|
39
40
|
const imageCache = new Set();
|
|
40
41
|
// Min size that require user confirm to upload image
|
|
41
42
|
const REQUIRE_CONFIRM_UPLOAD_SIZE = 10 << 20;
|
|
@@ -209,6 +210,7 @@ export default function ImageComponent({ file, src, altText, nodeKey, width, hei
|
|
|
209
210
|
const [objectUrl] = useState(() => file && URL.createObjectURL(file));
|
|
210
211
|
const [error, setError] = useState();
|
|
211
212
|
const [loading, setLoading] = useState(false);
|
|
213
|
+
useSafeArea({ enabled: draggable, size: '80px' });
|
|
212
214
|
const config = useEditorConfig();
|
|
213
215
|
const uploadImage = useCallback(async () => {
|
|
214
216
|
if (!config.uploader?.upload) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/editor",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.21",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npm run storybook",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@arcblock/ux": "^2.10.1",
|
|
41
41
|
"@blocklet/embed": "^0.1.11",
|
|
42
42
|
"@blocklet/pages-kit": "^0.2.348",
|
|
43
|
-
"@blocklet/pdf": "2.0.
|
|
43
|
+
"@blocklet/pdf": "2.0.21",
|
|
44
44
|
"@excalidraw/excalidraw": "^0.14.2",
|
|
45
45
|
"@iconify/iconify": "^3.0.1",
|
|
46
46
|
"@iconify/icons-tabler": "^1.2.95",
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"react": "*",
|
|
114
114
|
"react-dom": "*"
|
|
115
115
|
},
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "d40327315284d06df0bf441d613b8c6dd475531b"
|
|
117
117
|
}
|