@contentful/field-editor-rich-text 3.2.1 → 3.3.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.
- package/CHANGELOG.md +12 -0
- package/dist/RichTextEditor.d.ts +1 -0
- package/dist/field-editor-rich-text.cjs.development.js +128 -42
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +130 -44
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/plugins/Marks/Code.d.ts +6 -0
- package/dist/plugins/Marks/Subscript.d.ts +6 -0
- package/dist/plugins/Marks/Superscript.d.ts +6 -0
- package/dist/plugins/Marks/components/MarkToolbarButton.d.ts +1 -1
- package/dist/plugins/Text/createTextPlugin.d.ts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.3.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.2.2...@contentful/field-editor-rich-text@3.3.0) (2022-12-09)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- dropdown toolbar rich text [TOL-764] ([#1287](https://github.com/contentful/field-editors/issues/1287)) ([bfcc3d1](https://github.com/contentful/field-editors/commit/bfcc3d1f2a0da46877c0f35f53e13a3c79abca3b))
|
|
11
|
+
|
|
12
|
+
## [3.2.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.2.1...@contentful/field-editor-rich-text@3.2.2) (2022-12-08)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- handle unavailable marks ([#1288](https://github.com/contentful/field-editors/issues/1288)) ([c672c51](https://github.com/contentful/field-editors/commit/c672c516332407ec0691bffc764912b5c6b18795))
|
|
17
|
+
|
|
6
18
|
## [3.2.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.2.0...@contentful/field-editor-rich-text@3.2.1) (2022-11-18)
|
|
7
19
|
|
|
8
20
|
### Bug Fixes
|
package/dist/RichTextEditor.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ declare type ConnectedProps = {
|
|
|
10
10
|
onChange?: (doc: Contentful.Document) => unknown;
|
|
11
11
|
isToolbarHidden?: boolean;
|
|
12
12
|
actionsDisabled?: boolean;
|
|
13
|
+
restrictedMarks?: string[];
|
|
13
14
|
};
|
|
14
15
|
export declare const ConnectedRichTextEditor: (props: ConnectedProps) => JSX.Element;
|
|
15
16
|
declare type Props = ConnectedProps & {
|
|
@@ -5120,6 +5120,12 @@ var buildMarkEventHandler = function buildMarkEventHandler(type) {
|
|
|
5120
5120
|
};
|
|
5121
5121
|
};
|
|
5122
5122
|
|
|
5123
|
+
var styles$c = {
|
|
5124
|
+
isActive: /*#__PURE__*/emotion.css({
|
|
5125
|
+
backgroundColor: tokens.blue100,
|
|
5126
|
+
color: tokens.blue600
|
|
5127
|
+
})
|
|
5128
|
+
};
|
|
5123
5129
|
var createMarkToolbarButton = function createMarkToolbarButton(_ref) {
|
|
5124
5130
|
var mark = _ref.mark,
|
|
5125
5131
|
title = _ref.title,
|
|
@@ -5138,6 +5144,18 @@ var createMarkToolbarButton = function createMarkToolbarButton(_ref) {
|
|
|
5138
5144
|
focus(editor);
|
|
5139
5145
|
}, [editor]);
|
|
5140
5146
|
if (!editor) return null;
|
|
5147
|
+
|
|
5148
|
+
if (!icon) {
|
|
5149
|
+
var _cx;
|
|
5150
|
+
|
|
5151
|
+
return /*#__PURE__*/React.createElement(f36Components.Menu.Item, {
|
|
5152
|
+
onClick: handleClick,
|
|
5153
|
+
disabled: isDisabled,
|
|
5154
|
+
className: emotion.cx((_cx = {}, _cx[styles$c.isActive] = plateCore.isMarkActive(editor, mark), _cx)),
|
|
5155
|
+
testId: mark + "-toolbar-button"
|
|
5156
|
+
}, title);
|
|
5157
|
+
}
|
|
5158
|
+
|
|
5141
5159
|
return /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
5142
5160
|
title: title,
|
|
5143
5161
|
testId: mark + "-toolbar-button",
|
|
@@ -5156,14 +5174,14 @@ var ToolbarBoldButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
5156
5174
|
mark: Contentful.MARKS.BOLD,
|
|
5157
5175
|
icon: /*#__PURE__*/React.createElement(f36Icons.FormatBoldIcon, null)
|
|
5158
5176
|
});
|
|
5159
|
-
var styles$
|
|
5177
|
+
var styles$d = {
|
|
5160
5178
|
bold: /*#__PURE__*/emotion.css({
|
|
5161
5179
|
fontWeight: 600
|
|
5162
5180
|
})
|
|
5163
5181
|
};
|
|
5164
5182
|
function Bold(props) {
|
|
5165
5183
|
return /*#__PURE__*/React.createElement("strong", _extends({}, props.attributes, {
|
|
5166
|
-
className: styles$
|
|
5184
|
+
className: styles$d.bold
|
|
5167
5185
|
}), props.children);
|
|
5168
5186
|
}
|
|
5169
5187
|
|
|
@@ -5203,7 +5221,11 @@ var ToolbarCodeButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
5203
5221
|
mark: Contentful.MARKS.CODE,
|
|
5204
5222
|
icon: /*#__PURE__*/React.createElement(f36Icons.CodeIcon, null)
|
|
5205
5223
|
});
|
|
5206
|
-
var
|
|
5224
|
+
var ToolbarDropdownCodeButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5225
|
+
title: 'Code',
|
|
5226
|
+
mark: Contentful.MARKS.CODE
|
|
5227
|
+
});
|
|
5228
|
+
var styles$e = {
|
|
5207
5229
|
code: /*#__PURE__*/emotion.css({
|
|
5208
5230
|
fontFamily: 'monospace',
|
|
5209
5231
|
fontSize: '.9em'
|
|
@@ -5211,7 +5233,7 @@ var styles$d = {
|
|
|
5211
5233
|
};
|
|
5212
5234
|
function Code(props) {
|
|
5213
5235
|
return /*#__PURE__*/React.createElement("code", _extends({}, props.attributes, {
|
|
5214
|
-
className: styles$
|
|
5236
|
+
className: styles$e.code
|
|
5215
5237
|
}), props.children);
|
|
5216
5238
|
}
|
|
5217
5239
|
var createCodePlugin = function createCodePlugin() {
|
|
@@ -5241,14 +5263,14 @@ var ToolbarItalicButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
5241
5263
|
mark: Contentful.MARKS.ITALIC,
|
|
5242
5264
|
icon: /*#__PURE__*/React.createElement(f36Icons.FormatItalicIcon, null)
|
|
5243
5265
|
});
|
|
5244
|
-
var styles$
|
|
5266
|
+
var styles$f = {
|
|
5245
5267
|
italic: /*#__PURE__*/emotion.css({
|
|
5246
5268
|
fontStyle: 'italic'
|
|
5247
5269
|
})
|
|
5248
5270
|
};
|
|
5249
5271
|
function Italic(props) {
|
|
5250
5272
|
return /*#__PURE__*/React.createElement("em", _extends({}, props.attributes, {
|
|
5251
|
-
className: styles$
|
|
5273
|
+
className: styles$f.italic
|
|
5252
5274
|
}), props.children);
|
|
5253
5275
|
}
|
|
5254
5276
|
var createItalicPlugin = function createItalicPlugin() {
|
|
@@ -5313,7 +5335,7 @@ var createUnderlinePlugin = function createUnderlinePlugin() {
|
|
|
5313
5335
|
});
|
|
5314
5336
|
};
|
|
5315
5337
|
|
|
5316
|
-
var styles$
|
|
5338
|
+
var styles$g = {
|
|
5317
5339
|
superscript: /*#__PURE__*/emotion.css({
|
|
5318
5340
|
verticalAlign: 'super',
|
|
5319
5341
|
fontSize: 'smaller'
|
|
@@ -5324,9 +5346,13 @@ var ToolbarSuperscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
5324
5346
|
mark: Contentful.MARKS.SUPERSCRIPT,
|
|
5325
5347
|
icon: /*#__PURE__*/React.createElement(f36Icons.SuperscriptIcon, null)
|
|
5326
5348
|
});
|
|
5349
|
+
var ToolbarDropdownSuperscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5350
|
+
title: 'Superscript',
|
|
5351
|
+
mark: Contentful.MARKS.SUPERSCRIPT
|
|
5352
|
+
});
|
|
5327
5353
|
function Superscript(props) {
|
|
5328
5354
|
return /*#__PURE__*/React.createElement("sup", _extends({}, props.attributes, {
|
|
5329
|
-
className: styles$
|
|
5355
|
+
className: styles$g.superscript
|
|
5330
5356
|
}), props.children);
|
|
5331
5357
|
}
|
|
5332
5358
|
var createSuperscriptPlugin = function createSuperscriptPlugin() {
|
|
@@ -5344,7 +5370,7 @@ var createSuperscriptPlugin = function createSuperscriptPlugin() {
|
|
|
5344
5370
|
});
|
|
5345
5371
|
};
|
|
5346
5372
|
|
|
5347
|
-
var styles$
|
|
5373
|
+
var styles$h = {
|
|
5348
5374
|
subscript: /*#__PURE__*/emotion.css({
|
|
5349
5375
|
verticalAlign: 'sub',
|
|
5350
5376
|
fontSize: 'smaller'
|
|
@@ -5357,9 +5383,13 @@ var ToolbarSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
5357
5383
|
viewBox: "0 0 23 18"
|
|
5358
5384
|
})
|
|
5359
5385
|
});
|
|
5386
|
+
var ToolbarDropdownSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5387
|
+
title: 'Subscript',
|
|
5388
|
+
mark: Contentful.MARKS.SUBSCRIPT
|
|
5389
|
+
});
|
|
5360
5390
|
function Subscript(props) {
|
|
5361
5391
|
return /*#__PURE__*/React.createElement("sub", _extends({}, props.attributes, {
|
|
5362
|
-
className: styles$
|
|
5392
|
+
className: styles$h.subscript
|
|
5363
5393
|
}), props.children);
|
|
5364
5394
|
}
|
|
5365
5395
|
var createSubscriptPlugin = function createSubscriptPlugin() {
|
|
@@ -5588,10 +5618,10 @@ var createNormalizerPlugin = function createNormalizerPlugin() {
|
|
|
5588
5618
|
};
|
|
5589
5619
|
|
|
5590
5620
|
var _templateObject$6, _styles$1;
|
|
5591
|
-
var styles$
|
|
5621
|
+
var styles$i = (_styles$1 = {}, _styles$1[Contentful.BLOCKS.PARAGRAPH] = /*#__PURE__*/emotion.css(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: ", ";\n margin-bottom: 1.5em;\n "])), tokens.lineHeightDefault), _styles$1);
|
|
5592
5622
|
function Paragraph(props) {
|
|
5593
5623
|
return /*#__PURE__*/React.createElement("div", _extends({}, props.attributes, {
|
|
5594
|
-
className: styles$
|
|
5624
|
+
className: styles$i[Contentful.BLOCKS.PARAGRAPH]
|
|
5595
5625
|
}), props.children);
|
|
5596
5626
|
}
|
|
5597
5627
|
|
|
@@ -6233,7 +6263,7 @@ var isTable = function isTable(node) {
|
|
|
6233
6263
|
return slate.Element.isElement(node) && node.type === Contentful.BLOCKS.TABLE;
|
|
6234
6264
|
};
|
|
6235
6265
|
|
|
6236
|
-
var styles$
|
|
6266
|
+
var styles$j = {
|
|
6237
6267
|
topRight: /*#__PURE__*/emotion.css({
|
|
6238
6268
|
position: 'absolute',
|
|
6239
6269
|
top: '6px',
|
|
@@ -6322,7 +6352,7 @@ var TableActions = function TableActions() {
|
|
|
6322
6352
|
size: "small",
|
|
6323
6353
|
variant: "transparent",
|
|
6324
6354
|
tabIndex: -1,
|
|
6325
|
-
className: styles$
|
|
6355
|
+
className: styles$j.topRight,
|
|
6326
6356
|
icon: /*#__PURE__*/React__default.createElement(f36Icons.ChevronDownIcon, null),
|
|
6327
6357
|
"aria-label": "Open table menu",
|
|
6328
6358
|
testId: "cf-table-actions-button"
|
|
@@ -6926,7 +6956,11 @@ function ToolbarTableButton(props) {
|
|
|
6926
6956
|
}, /*#__PURE__*/React.createElement(f36Icons.TableIcon, null));
|
|
6927
6957
|
}
|
|
6928
6958
|
|
|
6929
|
-
function createTextPlugin() {
|
|
6959
|
+
function createTextPlugin(restrictedMarks) {
|
|
6960
|
+
if (restrictedMarks === void 0) {
|
|
6961
|
+
restrictedMarks = [];
|
|
6962
|
+
}
|
|
6963
|
+
|
|
6930
6964
|
return {
|
|
6931
6965
|
key: 'TextPlugin',
|
|
6932
6966
|
handlers: {
|
|
@@ -6991,7 +7025,22 @@ function createTextPlugin() {
|
|
|
6991
7025
|
|
|
6992
7026
|
fixPasteAsPlainText(editor);
|
|
6993
7027
|
return editor;
|
|
6994
|
-
}
|
|
7028
|
+
},
|
|
7029
|
+
normalizer: [{
|
|
7030
|
+
match: slate.Text.isText,
|
|
7031
|
+
transform: function transform(editor, _ref) {
|
|
7032
|
+
var path = _ref[1];
|
|
7033
|
+
plateCore.unsetNodes(editor, restrictedMarks, {
|
|
7034
|
+
at: path
|
|
7035
|
+
});
|
|
7036
|
+
},
|
|
7037
|
+
validNode: function validNode(_editor, _ref2) {
|
|
7038
|
+
var node = _ref2[0];
|
|
7039
|
+
return !restrictedMarks.some(function (mark) {
|
|
7040
|
+
return mark in node;
|
|
7041
|
+
});
|
|
7042
|
+
}
|
|
7043
|
+
}]
|
|
6995
7044
|
};
|
|
6996
7045
|
}
|
|
6997
7046
|
|
|
@@ -7121,7 +7170,7 @@ var createVoidsPlugin = function createVoidsPlugin() {
|
|
|
7121
7170
|
};
|
|
7122
7171
|
};
|
|
7123
7172
|
|
|
7124
|
-
var getPlugins = function getPlugins(sdk, onAction) {
|
|
7173
|
+
var getPlugins = function getPlugins(sdk, onAction, restrictedMarks) {
|
|
7125
7174
|
return [// AST must come after the HTML deserializer
|
|
7126
7175
|
plateCore.createDeserializeHtmlPlugin(), plateCore.createDeserializeAstPlugin(), plateSerializerDocx.createDeserializeDocxPlugin(), // Tracking - This should come first so all plugins below will have access to `editor.tracking`
|
|
7127
7176
|
createTrackingPlugin(onAction), // Global / Global shortcuts
|
|
@@ -7129,7 +7178,7 @@ var getPlugins = function getPlugins(sdk, onAction) {
|
|
|
7129
7178
|
createParagraphPlugin(), createListPlugin(), createHrPlugin(), createHeadingPlugin(), createQuotePlugin(), createTablePlugin(), createEmbeddedEntryBlockPlugin(sdk), createEmbeddedAssetBlockPlugin(sdk), // Inline elements
|
|
7130
7179
|
createHyperlinkPlugin(sdk), createEmbeddedEntityInlinePlugin(sdk), // Marks
|
|
7131
7180
|
createMarksPlugin(), // Other
|
|
7132
|
-
createTrailingParagraphPlugin(), createTextPlugin(), createVoidsPlugin(), createSelectOnBackspacePlugin(), // Pasting content from other sources
|
|
7181
|
+
createTrailingParagraphPlugin(), createTextPlugin(restrictedMarks), createVoidsPlugin(), createSelectOnBackspacePlugin(), // Pasting content from other sources
|
|
7133
7182
|
createPasteHTMLPlugin(), // These plugins drive their configurations from the list of plugins
|
|
7134
7183
|
// above. They MUST come last.
|
|
7135
7184
|
createSoftBreakPlugin(), createExitBreakPlugin(), createResetNodePlugin(), createNormalizerPlugin()];
|
|
@@ -7252,7 +7301,7 @@ var normalizeEditorValue = function normalizeEditorValue(value, options) {
|
|
|
7252
7301
|
};
|
|
7253
7302
|
|
|
7254
7303
|
var STYLE_EDITOR_BORDER = "1px solid " + tokens.gray400;
|
|
7255
|
-
var styles$
|
|
7304
|
+
var styles$k = {
|
|
7256
7305
|
root: /*#__PURE__*/emotion.css({
|
|
7257
7306
|
position: 'relative'
|
|
7258
7307
|
}),
|
|
@@ -7369,13 +7418,19 @@ var EmbedEntityWidget = function EmbedEntityWidget(_ref) {
|
|
|
7369
7418
|
}, actions) : null;
|
|
7370
7419
|
};
|
|
7371
7420
|
|
|
7372
|
-
var styles$
|
|
7421
|
+
var styles$l = {
|
|
7373
7422
|
toolbar: /*#__PURE__*/emotion.css({
|
|
7374
7423
|
border: "1px solid " + tokens.gray400,
|
|
7375
7424
|
backgroundColor: tokens.gray100,
|
|
7376
7425
|
padding: tokens.spacingXs,
|
|
7377
7426
|
borderRadius: tokens.borderRadiusMedium + " " + tokens.borderRadiusMedium + " 0 0"
|
|
7378
7427
|
}),
|
|
7428
|
+
toolbarBtn: /*#__PURE__*/emotion.css({
|
|
7429
|
+
height: '30px',
|
|
7430
|
+
width: '30px',
|
|
7431
|
+
marginLeft: tokens.spacing2Xs,
|
|
7432
|
+
marginRight: tokens.spacing2Xs
|
|
7433
|
+
}),
|
|
7379
7434
|
divider: /*#__PURE__*/emotion.css({
|
|
7380
7435
|
display: 'inline-block',
|
|
7381
7436
|
height: '21px',
|
|
@@ -7401,8 +7456,30 @@ var styles$k = {
|
|
|
7401
7456
|
})
|
|
7402
7457
|
};
|
|
7403
7458
|
|
|
7404
|
-
var
|
|
7405
|
-
var
|
|
7459
|
+
var Dropdown = function Dropdown(_ref) {
|
|
7460
|
+
var sdk = _ref.sdk,
|
|
7461
|
+
isDisabled = _ref.isDisabled;
|
|
7462
|
+
var editor = useContentfulEditor();
|
|
7463
|
+
var isActive = plateCore.isMarkActive(editor, Contentful.MARKS.SUPERSCRIPT) || plateCore.isMarkActive(editor, Contentful.MARKS.SUBSCRIPT) || plateCore.isMarkActive(editor, Contentful.MARKS.CODE);
|
|
7464
|
+
return /*#__PURE__*/React__default.createElement(f36Components.Menu, null, /*#__PURE__*/React__default.createElement(f36Components.Menu.Trigger, null, /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(f36Components.IconButton, {
|
|
7465
|
+
size: "small",
|
|
7466
|
+
className: styles$l.toolbarBtn,
|
|
7467
|
+
variant: isActive ? 'secondary' : 'transparent',
|
|
7468
|
+
icon: /*#__PURE__*/React__default.createElement(f36Icons.MoreHorizontalIcon, null),
|
|
7469
|
+
"aria-label": "toggle menu",
|
|
7470
|
+
isDisabled: isDisabled,
|
|
7471
|
+
testId: "dropdown-toolbar-button"
|
|
7472
|
+
}))), /*#__PURE__*/React__default.createElement(f36Components.Menu.List, null, isMarkEnabled(sdk.field, Contentful.MARKS.SUPERSCRIPT) && /*#__PURE__*/React__default.createElement(ToolbarDropdownSuperscriptButton, {
|
|
7473
|
+
isDisabled: isDisabled
|
|
7474
|
+
}), isMarkEnabled(sdk.field, Contentful.MARKS.SUBSCRIPT) && /*#__PURE__*/React__default.createElement(ToolbarDropdownSubscriptButton, {
|
|
7475
|
+
isDisabled: isDisabled
|
|
7476
|
+
}), isMarkEnabled(sdk.field, Contentful.MARKS.CODE) && /*#__PURE__*/React__default.createElement(ToolbarDropdownCodeButton, {
|
|
7477
|
+
isDisabled: isDisabled
|
|
7478
|
+
})));
|
|
7479
|
+
};
|
|
7480
|
+
|
|
7481
|
+
var Toolbar = function Toolbar(_ref2) {
|
|
7482
|
+
var isDisabled = _ref2.isDisabled;
|
|
7406
7483
|
var sdk = useSdkContext();
|
|
7407
7484
|
var editor = useContentfulEditor();
|
|
7408
7485
|
var canInsertBlocks = !isNodeTypeSelected(editor, Contentful.BLOCKS.TABLE);
|
|
@@ -7411,35 +7488,42 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
7411
7488
|
}, [sdk.field]);
|
|
7412
7489
|
var isListSelected = isNodeTypeSelected(editor, Contentful.BLOCKS.UL_LIST) || isNodeTypeSelected(editor, Contentful.BLOCKS.OL_LIST);
|
|
7413
7490
|
var isBlockquoteSelected = isNodeTypeSelected(editor, Contentful.BLOCKS.QUOTE);
|
|
7414
|
-
var shouldDisableTables = isDisabled || !canInsertBlocks || isListSelected || isBlockquoteSelected;
|
|
7491
|
+
var shouldDisableTables = isDisabled || !canInsertBlocks || isListSelected || isBlockquoteSelected; // We only show the dropdown when: whenever at least bold , italic and underline are available; If nothing that would go inside the dropdown is available, we hide it
|
|
7492
|
+
|
|
7493
|
+
var boldItalicUnderlineAvailable = isMarkEnabled(sdk.field, Contentful.MARKS.BOLD) || isMarkEnabled(sdk.field, Contentful.MARKS.ITALIC) || isMarkEnabled(sdk.field, Contentful.MARKS.UNDERLINE);
|
|
7494
|
+
var dropdownItemsAvailable = isMarkEnabled(sdk.field, Contentful.MARKS.SUPERSCRIPT) || isMarkEnabled(sdk.field, Contentful.MARKS.SUBSCRIPT) || isMarkEnabled(sdk.field, Contentful.MARKS.CODE);
|
|
7495
|
+
var shouldShowDropdown = boldItalicUnderlineAvailable && dropdownItemsAvailable;
|
|
7415
7496
|
return /*#__PURE__*/React__default.createElement(f36Components.Flex, {
|
|
7416
7497
|
testId: "toolbar",
|
|
7417
|
-
className: styles$
|
|
7498
|
+
className: styles$l.toolbar,
|
|
7418
7499
|
alignItems: "center"
|
|
7419
7500
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
7420
|
-
className: styles$
|
|
7501
|
+
className: styles$l.formattingOptionsWrapper
|
|
7421
7502
|
}, /*#__PURE__*/React__default.createElement(ToolbarHeadingButton, {
|
|
7422
7503
|
isDisabled: isDisabled || !canInsertBlocks
|
|
7423
7504
|
}), validationInfo.isAnyMarkEnabled && /*#__PURE__*/React__default.createElement("span", {
|
|
7424
|
-
className: styles$
|
|
7505
|
+
className: styles$l.divider
|
|
7425
7506
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.BOLD) && /*#__PURE__*/React__default.createElement(ToolbarBoldButton, {
|
|
7426
7507
|
isDisabled: isDisabled
|
|
7427
7508
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.ITALIC) && /*#__PURE__*/React__default.createElement(ToolbarItalicButton, {
|
|
7428
7509
|
isDisabled: isDisabled
|
|
7429
|
-
}), isMarkEnabled(sdk.field, Contentful.MARKS.
|
|
7510
|
+
}), isMarkEnabled(sdk.field, Contentful.MARKS.UNDERLINE) && /*#__PURE__*/React__default.createElement(ToolbarUnderlineButton, {
|
|
7430
7511
|
isDisabled: isDisabled
|
|
7431
|
-
}), isMarkEnabled(sdk.field, Contentful.MARKS.
|
|
7512
|
+
}), !boldItalicUnderlineAvailable && isMarkEnabled(sdk.field, Contentful.MARKS.SUPERSCRIPT) && /*#__PURE__*/React__default.createElement(ToolbarSuperscriptButton, {
|
|
7432
7513
|
isDisabled: isDisabled
|
|
7433
|
-
}), isMarkEnabled(sdk.field, Contentful.MARKS.
|
|
7514
|
+
}), !boldItalicUnderlineAvailable && isMarkEnabled(sdk.field, Contentful.MARKS.SUBSCRIPT) && /*#__PURE__*/React__default.createElement(ToolbarSubscriptButton, {
|
|
7434
7515
|
isDisabled: isDisabled
|
|
7435
|
-
}), isMarkEnabled(sdk.field, Contentful.MARKS.CODE) && /*#__PURE__*/React__default.createElement(ToolbarCodeButton, {
|
|
7516
|
+
}), !boldItalicUnderlineAvailable && isMarkEnabled(sdk.field, Contentful.MARKS.CODE) && /*#__PURE__*/React__default.createElement(ToolbarCodeButton, {
|
|
7517
|
+
isDisabled: isDisabled
|
|
7518
|
+
}), shouldShowDropdown && /*#__PURE__*/React__default.createElement(Dropdown, {
|
|
7519
|
+
sdk: sdk,
|
|
7436
7520
|
isDisabled: isDisabled
|
|
7437
7521
|
}), validationInfo.isAnyHyperlinkEnabled && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
|
7438
|
-
className: styles$
|
|
7522
|
+
className: styles$l.divider
|
|
7439
7523
|
}), /*#__PURE__*/React__default.createElement(ToolbarHyperlinkButton, {
|
|
7440
7524
|
isDisabled: isDisabled
|
|
7441
7525
|
})), validationInfo.isAnyBlockFormattingEnabled && /*#__PURE__*/React__default.createElement("span", {
|
|
7442
|
-
className: styles$
|
|
7526
|
+
className: styles$l.divider
|
|
7443
7527
|
}), /*#__PURE__*/React__default.createElement(ToolbarListButton, {
|
|
7444
7528
|
isDisabled: isDisabled || !canInsertBlocks
|
|
7445
7529
|
}), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.QUOTE) && /*#__PURE__*/React__default.createElement(ToolbarQuoteButton, {
|
|
@@ -7449,7 +7533,7 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
7449
7533
|
}), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.TABLE) && /*#__PURE__*/React__default.createElement(ToolbarTableButton, {
|
|
7450
7534
|
isDisabled: shouldDisableTables
|
|
7451
7535
|
})), /*#__PURE__*/React__default.createElement("div", {
|
|
7452
|
-
className: styles$
|
|
7536
|
+
className: styles$l.embedActionsWrapper
|
|
7453
7537
|
}, /*#__PURE__*/React__default.createElement(EmbedEntityWidget, {
|
|
7454
7538
|
isDisabled: isDisabled,
|
|
7455
7539
|
canInsertBlocks: canInsertBlocks
|
|
@@ -7474,7 +7558,7 @@ function getValidationInfo(field) {
|
|
|
7474
7558
|
}
|
|
7475
7559
|
|
|
7476
7560
|
var _templateObject$b;
|
|
7477
|
-
var styles$
|
|
7561
|
+
var styles$m = {
|
|
7478
7562
|
nativeSticky: /*#__PURE__*/emotion.css(_templateObject$b || (_templateObject$b = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: -webkit-sticky;\n position: sticky;\n top: -1px;\n z-index: 2;\n "])))
|
|
7479
7563
|
};
|
|
7480
7564
|
|
|
@@ -7482,7 +7566,7 @@ var StickyToolbarWrapper = function StickyToolbarWrapper(_ref) {
|
|
|
7482
7566
|
var isDisabled = _ref.isDisabled,
|
|
7483
7567
|
children = _ref.children;
|
|
7484
7568
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
7485
|
-
className: isDisabled ? '' : styles$
|
|
7569
|
+
className: isDisabled ? '' : styles$m.nativeSticky
|
|
7486
7570
|
}, children);
|
|
7487
7571
|
};
|
|
7488
7572
|
|
|
@@ -7549,14 +7633,14 @@ var useOnValueChanged = function useOnValueChanged(_ref) {
|
|
|
7549
7633
|
}, [editorId, onChange, skip, onSkip]);
|
|
7550
7634
|
};
|
|
7551
7635
|
|
|
7552
|
-
var _excluded = ["sdk", "isInitiallyDisabled", "onAction"];
|
|
7636
|
+
var _excluded = ["sdk", "isInitiallyDisabled", "onAction", "restrictedMarks"];
|
|
7553
7637
|
var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
7554
7638
|
var id = getContentfulEditorId(props.sdk);
|
|
7555
7639
|
var plugins = React__default.useMemo(function () {
|
|
7556
7640
|
var _props$onAction;
|
|
7557
7641
|
|
|
7558
|
-
return getPlugins(props.sdk, (_props$onAction = props.onAction) != null ? _props$onAction : noop);
|
|
7559
|
-
}, [props.sdk, props.onAction]);
|
|
7642
|
+
return getPlugins(props.sdk, (_props$onAction = props.onAction) != null ? _props$onAction : noop, props.restrictedMarks);
|
|
7643
|
+
}, [props.sdk, props.onAction, props.restrictedMarks]);
|
|
7560
7644
|
|
|
7561
7645
|
var _useState = React.useState(true),
|
|
7562
7646
|
isFirstRender = _useState[0],
|
|
@@ -7595,9 +7679,9 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
7595
7679
|
setPendingExternalUpdate(true);
|
|
7596
7680
|
setEditorContent(editor, documentToEditorValue(props.value));
|
|
7597
7681
|
}, [props.value, id]);
|
|
7598
|
-
var classNames = emotion.cx(styles$
|
|
7682
|
+
var classNames = emotion.cx(styles$k.editor, props.minHeight !== undefined ? emotion.css({
|
|
7599
7683
|
minHeight: props.minHeight
|
|
7600
|
-
}) : undefined, props.isDisabled ? styles$
|
|
7684
|
+
}) : undefined, props.isDisabled ? styles$k.disabled : styles$k.enabled, props.isToolbarHidden && styles$k.hiddenToolbar);
|
|
7601
7685
|
React.useEffect(function () {
|
|
7602
7686
|
if (!isFirstRender) {
|
|
7603
7687
|
return;
|
|
@@ -7613,7 +7697,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
7613
7697
|
}, /*#__PURE__*/React__default.createElement(ContentfulEditorIdProvider, {
|
|
7614
7698
|
value: id
|
|
7615
7699
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
7616
|
-
className: styles$
|
|
7700
|
+
className: styles$k.root,
|
|
7617
7701
|
"data-test-id": "rich-text-editor"
|
|
7618
7702
|
}, /*#__PURE__*/React__default.createElement(plateCore.Plate, {
|
|
7619
7703
|
id: id,
|
|
@@ -7635,6 +7719,7 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
7635
7719
|
var sdk = props.sdk,
|
|
7636
7720
|
isInitiallyDisabled = props.isInitiallyDisabled,
|
|
7637
7721
|
onAction = props.onAction,
|
|
7722
|
+
restrictedMarks = props.restrictedMarks,
|
|
7638
7723
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
7639
7724
|
|
|
7640
7725
|
var isEmptyValue = React.useCallback(function (value) {
|
|
@@ -7659,7 +7744,8 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
7659
7744
|
sdk: sdk,
|
|
7660
7745
|
onAction: onAction,
|
|
7661
7746
|
isDisabled: disabled,
|
|
7662
|
-
onChange: setValue
|
|
7747
|
+
onChange: setValue,
|
|
7748
|
+
restrictedMarks: restrictedMarks
|
|
7663
7749
|
}));
|
|
7664
7750
|
}));
|
|
7665
7751
|
};
|