@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.
@@ -28,7 +28,6 @@ function InternalRangePopper({ range, placement, children, sx, ...rest }) {
28
28
  }, [range]);
29
29
  const { update, styles, attributes } = usePopper(virtualElement, popperElement, {
30
30
  placement,
31
- strategy: 'fixed',
32
31
  modifiers: [
33
32
  {
34
33
  name: 'offset',
@@ -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
  }
@@ -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, autoFocus: true, sx: { flex: '1 1 auto', height: '100%', border: 0, outline: 'none' } }), _jsx(Box, { onClick: submit, sx: {
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',
@@ -6,3 +6,7 @@
6
6
  export declare function SafeAreaPlugin({ size }: {
7
7
  size?: number | string;
8
8
  }): null;
9
+ export declare function useSafeArea({ enabled, size }: {
10
+ enabled: boolean;
11
+ size?: number | string;
12
+ }): void;
@@ -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
+ }
@@ -119,6 +119,7 @@ export default function Editor({ children, placeholder, onChange, autoFocus = tr
119
119
  const EditorContent = styled.div `
120
120
  position: relative;
121
121
  .be-editable {
122
+ transition: padding-bottom 0.2s;
122
123
  code {
123
124
  white-space: pre-wrap;
124
125
  }
@@ -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.19",
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.19",
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": "4a8d186451ac45b2654a71e9693d150a53efcc5c"
116
+ "gitHead": "d40327315284d06df0bf441d613b8c6dd475531b"
117
117
  }