@contentful/field-editor-rich-text 4.10.0 → 4.10.1

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.
@@ -23,6 +23,7 @@ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
23
23
  const _f36components = require("@contentful/f36-components");
24
24
  const _f36tokens = /*#__PURE__*/ _interop_require_default(require("@contentful/f36-tokens"));
25
25
  const _fieldeditorreference = require("@contentful/field-editor-reference");
26
+ const _core = require("@lingui/core");
26
27
  const _emotion = require("emotion");
27
28
  const _proptypes = /*#__PURE__*/ _interop_require_default(require("prop-types"));
28
29
  const _FetchingWrappedAssetCard = require("../../plugins/shared/FetchingWrappedAssetCard");
@@ -147,7 +148,10 @@ class HyperlinkDialog extends (_React_Component = _react.Component) {
147
148
  variant: "secondary",
148
149
  testId: "cancel-cta",
149
150
  size: "small"
150
- }, "Cancel"), /*#__PURE__*/ _react.createElement(_f36components.Button, {
151
+ }, _core.i18n._({
152
+ id: "FieldEditors.RichText.HyperlinkDialog.Cancel",
153
+ message: "Cancel"
154
+ })), /*#__PURE__*/ _react.createElement(_f36components.Button, {
151
155
  type: "submit",
152
156
  variant: "positive",
153
157
  onClick: this.handleSubmit,
@@ -163,7 +167,10 @@ class HyperlinkDialog extends (_React_Component = _react.Component) {
163
167
  return /*#__PURE__*/ _react.createElement(_f36components.Form, null, hideText ? null : /*#__PURE__*/ _react.createElement(_f36components.FormControl, {
164
168
  id: "link-text",
165
169
  isRequired: true
166
- }, /*#__PURE__*/ _react.createElement(_f36components.FormControl.Label, null, "Link text"), /*#__PURE__*/ _react.createElement(_f36components.TextInput, {
170
+ }, /*#__PURE__*/ _react.createElement(_f36components.FormControl.Label, null, _core.i18n._({
171
+ id: "FieldEditors.RichText.HyperlinkDialog.LinkText",
172
+ message: "Link text"
173
+ })), /*#__PURE__*/ _react.createElement(_f36components.TextInput, {
167
174
  testId: "link-text-input",
168
175
  name: "link-text",
169
176
  value: text || '',
@@ -174,7 +181,10 @@ class HyperlinkDialog extends (_React_Component = _react.Component) {
174
181
  })), isFeaturingEntitySelector(entitySelectorConfigs) && /*#__PURE__*/ _react.createElement(_f36components.FormControl, {
175
182
  id: "link-type",
176
183
  name: "link-type"
177
- }, /*#__PURE__*/ _react.createElement(_f36components.FormControl.Label, null, "Link type"), /*#__PURE__*/ _react.createElement(_f36components.Select, {
184
+ }, /*#__PURE__*/ _react.createElement(_f36components.FormControl.Label, null, _core.i18n._({
185
+ id: "FieldEditors.RichText.HyperlinkDialog.LinkType",
186
+ message: "Link type"
187
+ })), /*#__PURE__*/ _react.createElement(_f36components.Select, {
178
188
  value: type,
179
189
  onChange: (e)=>this.setState({
180
190
  type: e.target.value
@@ -182,14 +192,26 @@ class HyperlinkDialog extends (_React_Component = _react.Component) {
182
192
  testId: "link-type-select"
183
193
  }, allowedHyperlinkTypes.includes(LINK_TYPES.URI) || type === LINK_TYPES.URI ? /*#__PURE__*/ _react.createElement(_f36components.Select.Option, {
184
194
  value: LINK_TYPES.URI
185
- }, "URL") : null, allowedHyperlinkTypes.includes(LINK_TYPES.ENTRY) || type === LINK_TYPES.ENTRY ? /*#__PURE__*/ _react.createElement(_f36components.Select.Option, {
195
+ }, _core.i18n._({
196
+ id: "FieldEditors.RichText.HyperlinkDialog.URL",
197
+ message: "URL"
198
+ })) : null, allowedHyperlinkTypes.includes(LINK_TYPES.ENTRY) || type === LINK_TYPES.ENTRY ? /*#__PURE__*/ _react.createElement(_f36components.Select.Option, {
186
199
  value: LINK_TYPES.ENTRY
187
- }, "Entry") : null, allowedHyperlinkTypes.includes(LINK_TYPES.ASSET) || type === LINK_TYPES.ASSET ? /*#__PURE__*/ _react.createElement(_f36components.Select.Option, {
200
+ }, _core.i18n._({
201
+ id: "FieldEditors.RichText.HyperlinkDialog.Entry",
202
+ message: "Entry"
203
+ })) : null, allowedHyperlinkTypes.includes(LINK_TYPES.ASSET) || type === LINK_TYPES.ASSET ? /*#__PURE__*/ _react.createElement(_f36components.Select.Option, {
188
204
  value: LINK_TYPES.ASSET
189
- }, "Asset") : null)), type === LINK_TYPES.URI ? /*#__PURE__*/ _react.createElement(_f36components.FormControl, {
205
+ }, _core.i18n._({
206
+ id: "FieldEditors.RichText.HyperlinkDialog.Asset",
207
+ message: "Asset"
208
+ })) : null)), type === LINK_TYPES.URI ? /*#__PURE__*/ _react.createElement(_f36components.FormControl, {
190
209
  id: "link-uri",
191
210
  isRequired: true
192
- }, /*#__PURE__*/ _react.createElement(_f36components.FormControl.Label, null, "Link target"), /*#__PURE__*/ _react.createElement(_f36components.TextInput, {
211
+ }, /*#__PURE__*/ _react.createElement(_f36components.FormControl.Label, null, _core.i18n._({
212
+ id: "FieldEditors.RichText.HyperlinkDialog.LinkTarget",
213
+ message: "Link target"
214
+ })), /*#__PURE__*/ _react.createElement(_f36components.TextInput, {
193
215
  testId: "link-target-input",
194
216
  name: "link-uri",
195
217
  value: uri || '',
@@ -198,7 +220,10 @@ class HyperlinkDialog extends (_React_Component = _react.Component) {
198
220
  uri: e.target.value
199
221
  }),
200
222
  autoFocus: isUriInputAutoFocused
201
- }), /*#__PURE__*/ _react.createElement(_f36components.FormControl.HelpText, null, "A protocol may be required, e.g. https://")) : this.renderEntityField());
223
+ }), /*#__PURE__*/ _react.createElement(_f36components.FormControl.HelpText, null, _core.i18n._({
224
+ id: "FieldEditors.RichText.HyperlinkDialog.ProtocolHelpText",
225
+ message: "A protocol may be required, e.g. https://"
226
+ }))) : this.renderEntityField());
202
227
  }
203
228
  renderEntityField() {
204
229
  const { type, entityLinks } = this.state;
@@ -208,13 +233,19 @@ class HyperlinkDialog extends (_React_Component = _react.Component) {
208
233
  return /*#__PURE__*/ _react.createElement("div", null, /*#__PURE__*/ _react.createElement(_f36components.FormLabel, {
209
234
  required: true,
210
235
  htmlFor: ""
211
- }, "Link target"), !isEntitySelectorVisible && /*#__PURE__*/ _react.createElement(_f36components.TextLink, {
236
+ }, _core.i18n._({
237
+ id: "FieldEditors.RichText.HyperlinkDialog.LinkTarget",
238
+ message: "Link target"
239
+ })), !isEntitySelectorVisible && /*#__PURE__*/ _react.createElement(_f36components.TextLink, {
212
240
  as: "button",
213
241
  className: (0, _emotion.css)({
214
242
  marginLeft: _f36tokens.default.spacingS
215
243
  }),
216
244
  onClick: resetEntity
217
- }, "Remove selection"), entityLink && /*#__PURE__*/ _react.createElement("div", null, type === LINK_TYPES.ENTRY && /*#__PURE__*/ _react.createElement(_FetchingWrappedEntryCard.FetchingWrappedEntryCard, {
245
+ }, _core.i18n._({
246
+ id: "FieldEditors.RichText.HyperlinkDialog.RemoveSelection",
247
+ message: "Remove selection"
248
+ })), entityLink && /*#__PURE__*/ _react.createElement("div", null, type === LINK_TYPES.ENTRY && /*#__PURE__*/ _react.createElement(_FetchingWrappedEntryCard.FetchingWrappedEntryCard, {
218
249
  sdk: this.props.sdk,
219
250
  locale: this.props.entitySelectorConfigs.Entry.locale,
220
251
  entryId: entityLink.sys.id,
@@ -236,10 +267,16 @@ class HyperlinkDialog extends (_React_Component = _react.Component) {
236
267
  }, type === LINK_TYPES.ENTRY && /*#__PURE__*/ _react.createElement(_f36components.TextLink, {
237
268
  as: "button",
238
269
  onClick: this.selectEntry
239
- }, "Select entry"), type === LINK_TYPES.ASSET && /*#__PURE__*/ _react.createElement(_f36components.TextLink, {
270
+ }, _core.i18n._({
271
+ id: "FieldEditors.RichText.HyperlinkDialog.SelectEntry",
272
+ message: "Select entry"
273
+ })), type === LINK_TYPES.ASSET && /*#__PURE__*/ _react.createElement(_f36components.TextLink, {
240
274
  as: "button",
241
275
  onClick: this.selectAsset
242
- }, "Select asset"));
276
+ }, _core.i18n._({
277
+ id: "FieldEditors.RichText.HyperlinkDialog.SelectAsset",
278
+ message: "Select asset"
279
+ })));
243
280
  }
244
281
  constructor(props){
245
282
  super(props), _define_property(this, "handleSubmit", (event)=>{
@@ -309,8 +346,14 @@ _define_property(HyperlinkDialog, "propTypes", {
309
346
  });
310
347
  _define_property(HyperlinkDialog, "defaultProps", {
311
348
  labels: {
312
- title: 'Insert link',
313
- confirm: 'Insert link'
349
+ title: _core.i18n._({
350
+ id: "FieldEditors.RichText.HyperlinkDialog.DefaultTitle",
351
+ message: "Insert link"
352
+ }),
353
+ confirm: _core.i18n._({
354
+ id: "FieldEditors.RichText.HyperlinkDialog.DefaultConfirm",
355
+ message: "Insert link"
356
+ })
314
357
  },
315
358
  value: {},
316
359
  hideText: false,
@@ -325,8 +368,20 @@ const openHyperlinkDialog = (dialogs, { value, showTextInput, allowedHyperlinkTy
325
368
  const isNew = !(value.uri || value.target);
326
369
  const props = {
327
370
  labels: {
328
- title: isNew ? 'Insert hyperlink' : 'Edit hyperlink',
329
- confirm: isNew ? 'Insert' : 'Update'
371
+ title: isNew ? _core.i18n._({
372
+ id: "FieldEditors.RichText.HyperlinkDialog.InsertHyperlink",
373
+ message: "Insert hyperlink"
374
+ }) : _core.i18n._({
375
+ id: "FieldEditors.RichText.HyperlinkDialog.EditHyperlink",
376
+ message: "Edit hyperlink"
377
+ }),
378
+ confirm: isNew ? _core.i18n._({
379
+ id: "FieldEditors.RichText.HyperlinkDialog.Insert",
380
+ message: "Insert"
381
+ }) : _core.i18n._({
382
+ id: "FieldEditors.RichText.HyperlinkDialog.Update",
383
+ message: "Update"
384
+ })
330
385
  },
331
386
  value,
332
387
  hideText: !showTextInput,
@@ -15,6 +15,7 @@ import * as React from 'react';
15
15
  import { Button, Form, FormControl, FormLabel, ModalContent, ModalControls, Select, TextInput, TextLink } from '@contentful/f36-components';
16
16
  import tokens from '@contentful/f36-tokens';
17
17
  import { EntityProvider } from '@contentful/field-editor-reference';
18
+ import { i18n as $_i18n } from "@lingui/core";
18
19
  import { css } from 'emotion';
19
20
  import PropTypes from 'prop-types';
20
21
  import { FetchingWrappedAssetCard } from '../../plugins/shared/FetchingWrappedAssetCard';
@@ -80,7 +81,10 @@ export class HyperlinkDialog extends (_React_Component = React.Component) {
80
81
  variant: "secondary",
81
82
  testId: "cancel-cta",
82
83
  size: "small"
83
- }, "Cancel"), /*#__PURE__*/ React.createElement(Button, {
84
+ }, $_i18n._({
85
+ id: "FieldEditors.RichText.HyperlinkDialog.Cancel",
86
+ message: "Cancel"
87
+ })), /*#__PURE__*/ React.createElement(Button, {
84
88
  type: "submit",
85
89
  variant: "positive",
86
90
  onClick: this.handleSubmit,
@@ -96,7 +100,10 @@ export class HyperlinkDialog extends (_React_Component = React.Component) {
96
100
  return /*#__PURE__*/ React.createElement(Form, null, hideText ? null : /*#__PURE__*/ React.createElement(FormControl, {
97
101
  id: "link-text",
98
102
  isRequired: true
99
- }, /*#__PURE__*/ React.createElement(FormControl.Label, null, "Link text"), /*#__PURE__*/ React.createElement(TextInput, {
103
+ }, /*#__PURE__*/ React.createElement(FormControl.Label, null, $_i18n._({
104
+ id: "FieldEditors.RichText.HyperlinkDialog.LinkText",
105
+ message: "Link text"
106
+ })), /*#__PURE__*/ React.createElement(TextInput, {
100
107
  testId: "link-text-input",
101
108
  name: "link-text",
102
109
  value: text || '',
@@ -107,7 +114,10 @@ export class HyperlinkDialog extends (_React_Component = React.Component) {
107
114
  })), isFeaturingEntitySelector(entitySelectorConfigs) && /*#__PURE__*/ React.createElement(FormControl, {
108
115
  id: "link-type",
109
116
  name: "link-type"
110
- }, /*#__PURE__*/ React.createElement(FormControl.Label, null, "Link type"), /*#__PURE__*/ React.createElement(Select, {
117
+ }, /*#__PURE__*/ React.createElement(FormControl.Label, null, $_i18n._({
118
+ id: "FieldEditors.RichText.HyperlinkDialog.LinkType",
119
+ message: "Link type"
120
+ })), /*#__PURE__*/ React.createElement(Select, {
111
121
  value: type,
112
122
  onChange: (e)=>this.setState({
113
123
  type: e.target.value
@@ -115,14 +125,26 @@ export class HyperlinkDialog extends (_React_Component = React.Component) {
115
125
  testId: "link-type-select"
116
126
  }, allowedHyperlinkTypes.includes(LINK_TYPES.URI) || type === LINK_TYPES.URI ? /*#__PURE__*/ React.createElement(Select.Option, {
117
127
  value: LINK_TYPES.URI
118
- }, "URL") : null, allowedHyperlinkTypes.includes(LINK_TYPES.ENTRY) || type === LINK_TYPES.ENTRY ? /*#__PURE__*/ React.createElement(Select.Option, {
128
+ }, $_i18n._({
129
+ id: "FieldEditors.RichText.HyperlinkDialog.URL",
130
+ message: "URL"
131
+ })) : null, allowedHyperlinkTypes.includes(LINK_TYPES.ENTRY) || type === LINK_TYPES.ENTRY ? /*#__PURE__*/ React.createElement(Select.Option, {
119
132
  value: LINK_TYPES.ENTRY
120
- }, "Entry") : null, allowedHyperlinkTypes.includes(LINK_TYPES.ASSET) || type === LINK_TYPES.ASSET ? /*#__PURE__*/ React.createElement(Select.Option, {
133
+ }, $_i18n._({
134
+ id: "FieldEditors.RichText.HyperlinkDialog.Entry",
135
+ message: "Entry"
136
+ })) : null, allowedHyperlinkTypes.includes(LINK_TYPES.ASSET) || type === LINK_TYPES.ASSET ? /*#__PURE__*/ React.createElement(Select.Option, {
121
137
  value: LINK_TYPES.ASSET
122
- }, "Asset") : null)), type === LINK_TYPES.URI ? /*#__PURE__*/ React.createElement(FormControl, {
138
+ }, $_i18n._({
139
+ id: "FieldEditors.RichText.HyperlinkDialog.Asset",
140
+ message: "Asset"
141
+ })) : null)), type === LINK_TYPES.URI ? /*#__PURE__*/ React.createElement(FormControl, {
123
142
  id: "link-uri",
124
143
  isRequired: true
125
- }, /*#__PURE__*/ React.createElement(FormControl.Label, null, "Link target"), /*#__PURE__*/ React.createElement(TextInput, {
144
+ }, /*#__PURE__*/ React.createElement(FormControl.Label, null, $_i18n._({
145
+ id: "FieldEditors.RichText.HyperlinkDialog.LinkTarget",
146
+ message: "Link target"
147
+ })), /*#__PURE__*/ React.createElement(TextInput, {
126
148
  testId: "link-target-input",
127
149
  name: "link-uri",
128
150
  value: uri || '',
@@ -131,7 +153,10 @@ export class HyperlinkDialog extends (_React_Component = React.Component) {
131
153
  uri: e.target.value
132
154
  }),
133
155
  autoFocus: isUriInputAutoFocused
134
- }), /*#__PURE__*/ React.createElement(FormControl.HelpText, null, "A protocol may be required, e.g. https://")) : this.renderEntityField());
156
+ }), /*#__PURE__*/ React.createElement(FormControl.HelpText, null, $_i18n._({
157
+ id: "FieldEditors.RichText.HyperlinkDialog.ProtocolHelpText",
158
+ message: "A protocol may be required, e.g. https://"
159
+ }))) : this.renderEntityField());
135
160
  }
136
161
  renderEntityField() {
137
162
  const { type, entityLinks } = this.state;
@@ -141,13 +166,19 @@ export class HyperlinkDialog extends (_React_Component = React.Component) {
141
166
  return /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement(FormLabel, {
142
167
  required: true,
143
168
  htmlFor: ""
144
- }, "Link target"), !isEntitySelectorVisible && /*#__PURE__*/ React.createElement(TextLink, {
169
+ }, $_i18n._({
170
+ id: "FieldEditors.RichText.HyperlinkDialog.LinkTarget",
171
+ message: "Link target"
172
+ })), !isEntitySelectorVisible && /*#__PURE__*/ React.createElement(TextLink, {
145
173
  as: "button",
146
174
  className: css({
147
175
  marginLeft: tokens.spacingS
148
176
  }),
149
177
  onClick: resetEntity
150
- }, "Remove selection"), entityLink && /*#__PURE__*/ React.createElement("div", null, type === LINK_TYPES.ENTRY && /*#__PURE__*/ React.createElement(FetchingWrappedEntryCard, {
178
+ }, $_i18n._({
179
+ id: "FieldEditors.RichText.HyperlinkDialog.RemoveSelection",
180
+ message: "Remove selection"
181
+ })), entityLink && /*#__PURE__*/ React.createElement("div", null, type === LINK_TYPES.ENTRY && /*#__PURE__*/ React.createElement(FetchingWrappedEntryCard, {
151
182
  sdk: this.props.sdk,
152
183
  locale: this.props.entitySelectorConfigs.Entry.locale,
153
184
  entryId: entityLink.sys.id,
@@ -169,10 +200,16 @@ export class HyperlinkDialog extends (_React_Component = React.Component) {
169
200
  }, type === LINK_TYPES.ENTRY && /*#__PURE__*/ React.createElement(TextLink, {
170
201
  as: "button",
171
202
  onClick: this.selectEntry
172
- }, "Select entry"), type === LINK_TYPES.ASSET && /*#__PURE__*/ React.createElement(TextLink, {
203
+ }, $_i18n._({
204
+ id: "FieldEditors.RichText.HyperlinkDialog.SelectEntry",
205
+ message: "Select entry"
206
+ })), type === LINK_TYPES.ASSET && /*#__PURE__*/ React.createElement(TextLink, {
173
207
  as: "button",
174
208
  onClick: this.selectAsset
175
- }, "Select asset"));
209
+ }, $_i18n._({
210
+ id: "FieldEditors.RichText.HyperlinkDialog.SelectAsset",
211
+ message: "Select asset"
212
+ })));
176
213
  }
177
214
  constructor(props){
178
215
  super(props), _define_property(this, "handleSubmit", (event)=>{
@@ -242,8 +279,14 @@ _define_property(HyperlinkDialog, "propTypes", {
242
279
  });
243
280
  _define_property(HyperlinkDialog, "defaultProps", {
244
281
  labels: {
245
- title: 'Insert link',
246
- confirm: 'Insert link'
282
+ title: $_i18n._({
283
+ id: "FieldEditors.RichText.HyperlinkDialog.DefaultTitle",
284
+ message: "Insert link"
285
+ }),
286
+ confirm: $_i18n._({
287
+ id: "FieldEditors.RichText.HyperlinkDialog.DefaultConfirm",
288
+ message: "Insert link"
289
+ })
247
290
  },
248
291
  value: {},
249
292
  hideText: false,
@@ -258,8 +301,20 @@ export const openHyperlinkDialog = (dialogs, { value, showTextInput, allowedHype
258
301
  const isNew = !(value.uri || value.target);
259
302
  const props = {
260
303
  labels: {
261
- title: isNew ? 'Insert hyperlink' : 'Edit hyperlink',
262
- confirm: isNew ? 'Insert' : 'Update'
304
+ title: isNew ? $_i18n._({
305
+ id: "FieldEditors.RichText.HyperlinkDialog.InsertHyperlink",
306
+ message: "Insert hyperlink"
307
+ }) : $_i18n._({
308
+ id: "FieldEditors.RichText.HyperlinkDialog.EditHyperlink",
309
+ message: "Edit hyperlink"
310
+ }),
311
+ confirm: isNew ? $_i18n._({
312
+ id: "FieldEditors.RichText.HyperlinkDialog.Insert",
313
+ message: "Insert"
314
+ }) : $_i18n._({
315
+ id: "FieldEditors.RichText.HyperlinkDialog.Update",
316
+ message: "Update"
317
+ })
263
318
  },
264
319
  value,
265
320
  hideText: !showTextInput,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-rich-text",
3
- "version": "4.10.0",
3
+ "version": "4.10.1",
4
4
  "source": "./src/index.tsx",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -44,8 +44,8 @@
44
44
  "@contentful/f36-icons": "^4.29.0",
45
45
  "@contentful/f36-tokens": "^4.0.5",
46
46
  "@contentful/f36-utils": "^4.24.3",
47
- "@contentful/field-editor-reference": "^6.10.1",
48
- "@contentful/field-editor-shared": "^2.9.0",
47
+ "@contentful/field-editor-reference": "^6.10.2",
48
+ "@contentful/field-editor-shared": "^2.9.1",
49
49
  "@contentful/rich-text-plain-text-renderer": "^17.0.0",
50
50
  "@contentful/rich-text-types": "^17.0.0",
51
51
  "@popperjs/core": "^2.11.5",
@@ -88,5 +88,5 @@
88
88
  "publishConfig": {
89
89
  "registry": "https://npm.pkg.github.com/"
90
90
  },
91
- "gitHead": "299f71af5a480a95605b33898bead31cc239c918"
91
+ "gitHead": "4fa62eaa25b40c592cc3671df8626dd18013a206"
92
92
  }