@contentful/field-editor-rich-text 3.11.0 → 3.12.0

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.
@@ -96,6 +96,14 @@ function HyperlinkModal(props) {
96
96
  const [linkType, setLinkType] = _react.useState(props.linkType ?? defaultLinkType);
97
97
  const [linkTarget, setLinkTarget] = _react.useState(props.linkTarget ?? '');
98
98
  const [linkEntity, setLinkEntity] = _react.useState(props.linkEntity ?? null);
99
+ const linkTargetInputRef = _react.useRef(null);
100
+ _react.useEffect(()=>{
101
+ if (linkType === _richtexttypes.INLINES.HYPERLINK && linkTargetInputRef.current) {
102
+ linkTargetInputRef.current.focus();
103
+ }
104
+ }, [
105
+ linkType
106
+ ]);
99
107
  function isLinkComplete() {
100
108
  const isRegularLink = linkType === _richtexttypes.INLINES.HYPERLINK;
101
109
  if (isRegularLink) {
@@ -172,6 +180,7 @@ function HyperlinkModal(props) {
172
180
  id: "linkTarget",
173
181
  isRequired: true
174
182
  }, _react.createElement(_f36components.FormControl.Label, null, "Link target"), _react.createElement(_f36components.TextInput, {
183
+ ref: linkTargetInputRef,
175
184
  name: "linkTarget",
176
185
  value: linkTarget,
177
186
  onChange: (event)=>{
@@ -34,6 +34,14 @@ export function HyperlinkModal(props) {
34
34
  const [linkType, setLinkType] = React.useState(props.linkType ?? defaultLinkType);
35
35
  const [linkTarget, setLinkTarget] = React.useState(props.linkTarget ?? '');
36
36
  const [linkEntity, setLinkEntity] = React.useState(props.linkEntity ?? null);
37
+ const linkTargetInputRef = React.useRef(null);
38
+ React.useEffect(()=>{
39
+ if (linkType === INLINES.HYPERLINK && linkTargetInputRef.current) {
40
+ linkTargetInputRef.current.focus();
41
+ }
42
+ }, [
43
+ linkType
44
+ ]);
37
45
  function isLinkComplete() {
38
46
  const isRegularLink = linkType === INLINES.HYPERLINK;
39
47
  if (isRegularLink) {
@@ -110,6 +118,7 @@ export function HyperlinkModal(props) {
110
118
  id: "linkTarget",
111
119
  isRequired: true
112
120
  }, React.createElement(FormControl.Label, null, "Link target"), React.createElement(TextInput, {
121
+ ref: linkTargetInputRef,
113
122
  name: "linkTarget",
114
123
  value: linkTarget,
115
124
  onChange: (event)=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-rich-text",
3
- "version": "3.11.0",
3
+ "version": "3.12.0",
4
4
  "source": "./src/index.tsx",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -81,5 +81,5 @@
81
81
  "prism-react-renderer": "2.0.5",
82
82
  "react": ">=16.14.0"
83
83
  },
84
- "gitHead": "d9b40e59aa2b23fec2a9679c13496d8c8838cf10"
84
+ "gitHead": "277d527c724264183021838773059048750f9266"
85
85
  }