@selfcommunity/react-ui 0.7.0-alpha.315 → 0.7.0-alpha.316

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.
@@ -19,7 +19,6 @@ const LexicalLinkPlugin_1 = require("@lexical/react/LexicalLinkPlugin");
19
19
  const ApiPlugin_1 = tslib_1.__importDefault(require("./plugins/ApiPlugin"));
20
20
  const ToolbarPlugin_1 = tslib_1.__importDefault(require("./plugins/ToolbarPlugin"));
21
21
  const LexicalListPlugin_1 = require("@lexical/react/LexicalListPlugin");
22
- const useMediaQuery_1 = tslib_1.__importDefault(require("@mui/material/useMediaQuery"));
23
22
  const FloatingLinkPlugin_1 = tslib_1.__importDefault(require("./plugins/FloatingLinkPlugin"));
24
23
  const OnBlurPlugin_1 = tslib_1.__importDefault(require("./plugins/OnBlurPlugin"));
25
24
  const OnFocusPlugin_1 = tslib_1.__importDefault(require("./plugins/OnFocusPlugin"));
@@ -110,7 +109,6 @@ const Editor = (inProps, ref) => {
110
109
  const apiRef = (0, react_1.useRef)();
111
110
  // MEMO
112
111
  const theme = (0, material_1.useTheme)();
113
- const isMobile = (0, useMediaQuery_1.default)(theme.breakpoints.down('md'));
114
112
  // HANDLERS
115
113
  const handleChange = (value) => {
116
114
  onChange && onChange(value);
@@ -7,6 +7,16 @@ const lexical_1 = require("lexical");
7
7
  const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
8
8
  const useLexicalNodeSelection_1 = require("@lexical/react/useLexicalNodeSelection");
9
9
  const utils_1 = require("@lexical/utils");
10
+ /**
11
+ * Limit the width of an image
12
+ * Used to compute the padding-bottom of the div that wrap the img
13
+ */
14
+ const IMAGE_WIDTH_THRESHOLD = 500;
15
+ /**
16
+ * Calc aspect-ratio of image
17
+ * @param width
18
+ * @param height
19
+ */
10
20
  function getAspectRatio(width, height) {
11
21
  return width / height;
12
22
  }
@@ -25,7 +35,7 @@ function useSuspenseImage(src) {
25
35
  }
26
36
  function LazyImage({ altText, className, imageRef, src, width, height }) {
27
37
  useSuspenseImage(src);
28
- const aspectRatio = getAspectRatio(width, height);
38
+ const aspectRatio = getAspectRatio(IMAGE_WIDTH_THRESHOLD, height);
29
39
  return (react_1.default.createElement("div", { draggable: false, className: className, style: { position: 'relative', paddingBottom: `${100 / aspectRatio}%` } },
30
40
  react_1.default.createElement("img", { src: src, alt: altText, ref: imageRef, style: {
31
41
  position: 'absolute',
@@ -170,7 +180,7 @@ class ImageNode extends lexical_1.DecoratorNode {
170
180
  return { element };
171
181
  }
172
182
  decorate() {
173
- return (react_1.default.createElement(ImageComponent, { src: this.__src, altText: this.__altText, width: this.__width, height: this.__height, nodeKey: this.getKey() }));
183
+ return react_1.default.createElement(ImageComponent, { src: this.__src, altText: this.__altText, width: this.__width, height: this.__height, nodeKey: this.getKey() });
174
184
  }
175
185
  static importJSON(serializedNode) {
176
186
  const { altText, height, width, src } = serializedNode;
@@ -16,7 +16,6 @@ import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
16
16
  import ApiPlugin from './plugins/ApiPlugin';
17
17
  import ToolbarPlugin from './plugins/ToolbarPlugin';
18
18
  import { ListPlugin } from '@lexical/react/LexicalListPlugin';
19
- import useMediaQuery from '@mui/material/useMediaQuery';
20
19
  import FloatingLinkPlugin from './plugins/FloatingLinkPlugin';
21
20
  import OnBlurPlugin from './plugins/OnBlurPlugin';
22
21
  import OnFocusPlugin from './plugins/OnFocusPlugin';
@@ -107,7 +106,6 @@ const Editor = (inProps, ref) => {
107
106
  const apiRef = useRef();
108
107
  // MEMO
109
108
  const theme = useTheme();
110
- const isMobile = useMediaQuery(theme.breakpoints.down('md'));
111
109
  // HANDLERS
112
110
  const handleChange = (value) => {
113
111
  onChange && onChange(value);
@@ -1,8 +1,18 @@
1
1
  import React, { Suspense, useCallback, useEffect, useRef } from 'react';
2
- import { $getNodeByKey, $getSelection, $isNodeSelection, $setSelection, CLICK_COMMAND, COMMAND_PRIORITY_LOW, DecoratorNode, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, SELECTION_CHANGE_COMMAND, TextNode, } from 'lexical';
2
+ import { $getNodeByKey, $getSelection, $isNodeSelection, $setSelection, CLICK_COMMAND, COMMAND_PRIORITY_LOW, DecoratorNode, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, SELECTION_CHANGE_COMMAND, TextNode } from 'lexical';
3
3
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
4
4
  import { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection';
5
5
  import { mergeRegister } from '@lexical/utils';
6
+ /**
7
+ * Limit the width of an image
8
+ * Used to compute the padding-bottom of the div that wrap the img
9
+ */
10
+ const IMAGE_WIDTH_THRESHOLD = 500;
11
+ /**
12
+ * Calc aspect-ratio of image
13
+ * @param width
14
+ * @param height
15
+ */
6
16
  function getAspectRatio(width, height) {
7
17
  return width / height;
8
18
  }
@@ -21,7 +31,7 @@ function useSuspenseImage(src) {
21
31
  }
22
32
  function LazyImage({ altText, className, imageRef, src, width, height }) {
23
33
  useSuspenseImage(src);
24
- const aspectRatio = getAspectRatio(width, height);
34
+ const aspectRatio = getAspectRatio(IMAGE_WIDTH_THRESHOLD, height);
25
35
  return (React.createElement("div", { draggable: false, className: className, style: { position: 'relative', paddingBottom: `${100 / aspectRatio}%` } },
26
36
  React.createElement("img", { src: src, alt: altText, ref: imageRef, style: {
27
37
  position: 'absolute',
@@ -166,7 +176,7 @@ export class ImageNode extends DecoratorNode {
166
176
  return { element };
167
177
  }
168
178
  decorate() {
169
- return (React.createElement(ImageComponent, { src: this.__src, altText: this.__altText, width: this.__width, height: this.__height, nodeKey: this.getKey() }));
179
+ return React.createElement(ImageComponent, { src: this.__src, altText: this.__altText, width: this.__width, height: this.__height, nodeKey: this.getKey() });
170
180
  }
171
181
  static importJSON(serializedNode) {
172
182
  const { altText, height, width, src } = serializedNode;