@squiz/formatted-text-editor 1.35.1-alpha.23 → 1.35.1-alpha.24
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/Editor/Editor.js +6 -0
- package/package.json +4 -4
- package/src/Editor/Editor.tsx +8 -1
package/lib/Editor/Editor.js
CHANGED
@@ -58,6 +58,12 @@ const Editor = ({ content, editable = true, onChange, children, isFocused = fals
|
|
58
58
|
onChange?.(parameter);
|
59
59
|
};
|
60
60
|
const { isEditorFocused, handleFocus, handleBlur } = (0, useFocus_1.default)(isFocused);
|
61
|
+
// On initial load, check if we need to focus the actual text content
|
62
|
+
(0, react_1.useEffect)(() => {
|
63
|
+
if (isFocused) {
|
64
|
+
manager.view.dom.focus();
|
65
|
+
}
|
66
|
+
}, []);
|
61
67
|
return (react_1.default.createElement("div", { className: "squiz-fte-scope" },
|
62
68
|
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
69
|
react_1.default.createElement(react_2.Remirror, { manager: manager, state: state, editable: editable, onChange: handleChange, placeholder: "Write something", label: "Text editor" },
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@squiz/formatted-text-editor",
|
3
|
-
"version": "1.35.1-alpha.
|
3
|
+
"version": "1.35.1-alpha.24",
|
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.
|
24
|
-
"@squiz/resource-browser": "1.35.1-alpha.
|
23
|
+
"@squiz/dx-json-schema-lib": "1.35.1-alpha.24",
|
24
|
+
"@squiz/resource-browser": "1.35.1-alpha.24",
|
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": "
|
78
|
+
"gitHead": "a0cdd85b7eb8ee15a882d57f0c89fb84c13e4e04"
|
79
79
|
}
|
package/src/Editor/Editor.tsx
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useContext, useCallback, ReactNode } from 'react';
|
1
|
+
import React, { useContext, useCallback, ReactNode, useEffect } from 'react';
|
2
2
|
import { EditorComponent, Remirror, useRemirror, useEditorEvent } from '@remirror/react';
|
3
3
|
import { RemirrorContentType, RemirrorEventListener, Extension } from '@remirror/core';
|
4
4
|
import { ClipboardEventHandler } from '@remirror/extension-events/dist-types/events-extension';
|
@@ -47,6 +47,13 @@ const Editor = ({ content, editable = true, onChange, children, isFocused = fals
|
|
47
47
|
|
48
48
|
const { isEditorFocused, handleFocus, handleBlur } = useEditorFocus(isFocused);
|
49
49
|
|
50
|
+
// On initial load, check if we need to focus the actual text content
|
51
|
+
useEffect(() => {
|
52
|
+
if (isFocused) {
|
53
|
+
manager.view.dom.focus();
|
54
|
+
}
|
55
|
+
}, []);
|
56
|
+
|
50
57
|
return (
|
51
58
|
<div className="squiz-fte-scope">
|
52
59
|
<div
|