@squiz/formatted-text-editor 1.35.1-alpha.19 → 1.35.1-alpha.20

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.
@@ -5,6 +5,7 @@ type EditorProps = {
5
5
  onChange?: RemirrorEventListener<Extension>;
6
6
  editable?: boolean;
7
7
  children?: ReactNode;
8
+ isFocused?: boolean;
8
9
  };
9
- declare const Editor: ({ content, editable, onChange, children }: EditorProps) => JSX.Element;
10
+ declare const Editor: ({ content, editable, onChange, children, isFocused }: EditorProps) => JSX.Element;
10
11
  export default Editor;
@@ -46,7 +46,7 @@ const WrappedEditor = () => {
46
46
  (0, react_2.useEditorEvent)('paste', preventImagePaste);
47
47
  return react_1.default.createElement(react_2.EditorComponent, null);
48
48
  };
49
- const Editor = ({ content, editable = true, onChange, children }) => {
49
+ const Editor = ({ content, editable = true, onChange, children, isFocused = false }) => {
50
50
  const { manager, state, setState } = (0, react_2.useRemirror)({
51
51
  extensions: (0, Extensions_1.createExtensions)((0, react_1.useContext)(EditorContext_1.EditorContext)),
52
52
  content,
@@ -57,7 +57,7 @@ const Editor = ({ content, editable = true, onChange, children }) => {
57
57
  setState(parameter.state);
58
58
  onChange?.(parameter);
59
59
  };
60
- const { isEditorFocused, handleFocus, handleBlur } = (0, useFocus_1.default)();
60
+ const { isEditorFocused, handleFocus, handleBlur } = (0, useFocus_1.default)(isFocused);
61
61
  return (react_1.default.createElement("div", { className: "squiz-fte-scope" },
62
62
  react_1.default.createElement("div", { onBlur: handleBlur, onFocus: handleFocus, className: (0, clsx_1.default)('remirror-theme formatted-text-editor', !editable && 'formatted-text-editor--is-disabled') },
63
63
  react_1.default.createElement(react_2.Remirror, { manager: manager, state: state, editable: editable, onChange: handleChange, placeholder: "Write something", label: "Text editor" },
@@ -1,4 +1,4 @@
1
- declare const useEditorFocus: () => {
1
+ declare const useEditorFocus: (isFocused: boolean) => {
2
2
  isEditorFocused: boolean;
3
3
  handleFocus: () => void;
4
4
  handleBlur: () => void;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const react_1 = require("react");
4
- const useEditorFocus = () => {
5
- const [isEditorFocused, setIsEditorFocused] = (0, react_1.useState)(false);
4
+ const useEditorFocus = (isFocused) => {
5
+ const [isEditorFocused, setIsEditorFocused] = (0, react_1.useState)(isFocused);
6
6
  const handleFocus = (0, react_1.useCallback)(() => {
7
7
  setIsEditorFocused(true);
8
8
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/formatted-text-editor",
3
- "version": "1.35.1-alpha.19",
3
+ "version": "1.35.1-alpha.20",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "scripts": {
@@ -20,8 +20,8 @@
20
20
  "@headlessui/react": "1.7.11",
21
21
  "@mui/icons-material": "5.11.16",
22
22
  "@remirror/react": "2.0.25",
23
- "@squiz/dx-json-schema-lib": "1.35.1-alpha.19",
24
- "@squiz/resource-browser": "1.35.1-alpha.19",
23
+ "@squiz/dx-json-schema-lib": "1.35.1-alpha.20",
24
+ "@squiz/resource-browser": "1.35.1-alpha.20",
25
25
  "clsx": "1.2.1",
26
26
  "react-hook-form": "7.43.2",
27
27
  "react-image-size": "2.0.0",
@@ -75,5 +75,5 @@
75
75
  "volta": {
76
76
  "node": "18.15.0"
77
77
  },
78
- "gitHead": "ba42b99e3436caf08abd1b367ea10edfcdf6b8c5"
78
+ "gitHead": "396845eead32496e1a0297790fb3488c4dd85f2a"
79
79
  }
@@ -13,6 +13,7 @@ type EditorProps = {
13
13
  onChange?: RemirrorEventListener<Extension>;
14
14
  editable?: boolean;
15
15
  children?: ReactNode;
16
+ isFocused?: boolean;
16
17
  };
17
18
 
18
19
  const WrappedEditor = () => {
@@ -31,7 +32,7 @@ const WrappedEditor = () => {
31
32
  return <EditorComponent />;
32
33
  };
33
34
 
34
- const Editor = ({ content, editable = true, onChange, children }: EditorProps) => {
35
+ const Editor = ({ content, editable = true, onChange, children, isFocused = false }: EditorProps) => {
35
36
  const { manager, state, setState } = useRemirror({
36
37
  extensions: createExtensions(useContext(EditorContext)),
37
38
  content,
@@ -44,7 +45,7 @@ const Editor = ({ content, editable = true, onChange, children }: EditorProps) =
44
45
  onChange?.(parameter);
45
46
  };
46
47
 
47
- const { isEditorFocused, handleFocus, handleBlur } = useEditorFocus();
48
+ const { isEditorFocused, handleFocus, handleBlur } = useEditorFocus(isFocused);
48
49
 
49
50
  return (
50
51
  <div className="squiz-fte-scope">
@@ -1,7 +1,7 @@
1
1
  import { useState, useCallback } from 'react';
2
2
 
3
- const useEditorFocus = () => {
4
- const [isEditorFocused, setIsEditorFocused] = useState(false);
3
+ const useEditorFocus = (isFocused: boolean) => {
4
+ const [isEditorFocused, setIsEditorFocused] = useState(isFocused);
5
5
 
6
6
  const handleFocus = useCallback(() => {
7
7
  setIsEditorFocused(true);