@contentful/field-editor-rich-text 3.2.0 → 3.2.2
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 +64 -27
- 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 +65 -28
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/plugins/Text/createTextPlugin.d.ts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/package.json +6 -6
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.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)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- handle unavailable marks ([#1288](https://github.com/contentful/field-editors/issues/1288)) ([c672c51](https://github.com/contentful/field-editors/commit/c672c516332407ec0691bffc764912b5c6b18795))
|
|
11
|
+
|
|
12
|
+
## [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)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- explicitly setting sub super styles [TOL-30] ([#1281](https://github.com/contentful/field-editors/issues/1281)) ([6044115](https://github.com/contentful/field-editors/commit/6044115c89d68ac37d3a36d239bd45e5503cea7b))
|
|
17
|
+
|
|
6
18
|
# [3.2.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.1.12...@contentful/field-editor-rich-text@3.2.0) (2022-11-16)
|
|
7
19
|
|
|
8
20
|
### Features
|
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 & {
|
|
@@ -5313,13 +5313,21 @@ var createUnderlinePlugin = function createUnderlinePlugin() {
|
|
|
5313
5313
|
});
|
|
5314
5314
|
};
|
|
5315
5315
|
|
|
5316
|
+
var styles$f = {
|
|
5317
|
+
superscript: /*#__PURE__*/emotion.css({
|
|
5318
|
+
verticalAlign: 'super',
|
|
5319
|
+
fontSize: 'smaller'
|
|
5320
|
+
})
|
|
5321
|
+
};
|
|
5316
5322
|
var ToolbarSuperscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5317
5323
|
title: 'Superscript',
|
|
5318
5324
|
mark: Contentful.MARKS.SUPERSCRIPT,
|
|
5319
5325
|
icon: /*#__PURE__*/React.createElement(f36Icons.SuperscriptIcon, null)
|
|
5320
5326
|
});
|
|
5321
5327
|
function Superscript(props) {
|
|
5322
|
-
return /*#__PURE__*/React.createElement("sup", _extends({}, props.attributes
|
|
5328
|
+
return /*#__PURE__*/React.createElement("sup", _extends({}, props.attributes, {
|
|
5329
|
+
className: styles$f.superscript
|
|
5330
|
+
}), props.children);
|
|
5323
5331
|
}
|
|
5324
5332
|
var createSuperscriptPlugin = function createSuperscriptPlugin() {
|
|
5325
5333
|
return plateBasicMarks.createSuperscriptPlugin({
|
|
@@ -5336,6 +5344,12 @@ var createSuperscriptPlugin = function createSuperscriptPlugin() {
|
|
|
5336
5344
|
});
|
|
5337
5345
|
};
|
|
5338
5346
|
|
|
5347
|
+
var styles$g = {
|
|
5348
|
+
subscript: /*#__PURE__*/emotion.css({
|
|
5349
|
+
verticalAlign: 'sub',
|
|
5350
|
+
fontSize: 'smaller'
|
|
5351
|
+
})
|
|
5352
|
+
};
|
|
5339
5353
|
var ToolbarSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5340
5354
|
title: 'Subscript',
|
|
5341
5355
|
mark: Contentful.MARKS.SUBSCRIPT,
|
|
@@ -5344,7 +5358,9 @@ var ToolbarSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
|
5344
5358
|
})
|
|
5345
5359
|
});
|
|
5346
5360
|
function Subscript(props) {
|
|
5347
|
-
return /*#__PURE__*/React.createElement("sub", _extends({}, props.attributes
|
|
5361
|
+
return /*#__PURE__*/React.createElement("sub", _extends({}, props.attributes, {
|
|
5362
|
+
className: styles$g.subscript
|
|
5363
|
+
}), props.children);
|
|
5348
5364
|
}
|
|
5349
5365
|
var createSubscriptPlugin = function createSubscriptPlugin() {
|
|
5350
5366
|
return plateBasicMarks.createSubscriptPlugin({
|
|
@@ -5572,10 +5588,10 @@ var createNormalizerPlugin = function createNormalizerPlugin() {
|
|
|
5572
5588
|
};
|
|
5573
5589
|
|
|
5574
5590
|
var _templateObject$6, _styles$1;
|
|
5575
|
-
var styles$
|
|
5591
|
+
var styles$h = (_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);
|
|
5576
5592
|
function Paragraph(props) {
|
|
5577
5593
|
return /*#__PURE__*/React.createElement("div", _extends({}, props.attributes, {
|
|
5578
|
-
className: styles$
|
|
5594
|
+
className: styles$h[Contentful.BLOCKS.PARAGRAPH]
|
|
5579
5595
|
}), props.children);
|
|
5580
5596
|
}
|
|
5581
5597
|
|
|
@@ -6217,7 +6233,7 @@ var isTable = function isTable(node) {
|
|
|
6217
6233
|
return slate.Element.isElement(node) && node.type === Contentful.BLOCKS.TABLE;
|
|
6218
6234
|
};
|
|
6219
6235
|
|
|
6220
|
-
var styles$
|
|
6236
|
+
var styles$i = {
|
|
6221
6237
|
topRight: /*#__PURE__*/emotion.css({
|
|
6222
6238
|
position: 'absolute',
|
|
6223
6239
|
top: '6px',
|
|
@@ -6306,7 +6322,7 @@ var TableActions = function TableActions() {
|
|
|
6306
6322
|
size: "small",
|
|
6307
6323
|
variant: "transparent",
|
|
6308
6324
|
tabIndex: -1,
|
|
6309
|
-
className: styles$
|
|
6325
|
+
className: styles$i.topRight,
|
|
6310
6326
|
icon: /*#__PURE__*/React__default.createElement(f36Icons.ChevronDownIcon, null),
|
|
6311
6327
|
"aria-label": "Open table menu",
|
|
6312
6328
|
testId: "cf-table-actions-button"
|
|
@@ -6910,7 +6926,11 @@ function ToolbarTableButton(props) {
|
|
|
6910
6926
|
}, /*#__PURE__*/React.createElement(f36Icons.TableIcon, null));
|
|
6911
6927
|
}
|
|
6912
6928
|
|
|
6913
|
-
function createTextPlugin() {
|
|
6929
|
+
function createTextPlugin(restrictedMarks) {
|
|
6930
|
+
if (restrictedMarks === void 0) {
|
|
6931
|
+
restrictedMarks = [];
|
|
6932
|
+
}
|
|
6933
|
+
|
|
6914
6934
|
return {
|
|
6915
6935
|
key: 'TextPlugin',
|
|
6916
6936
|
handlers: {
|
|
@@ -6975,7 +6995,22 @@ function createTextPlugin() {
|
|
|
6975
6995
|
|
|
6976
6996
|
fixPasteAsPlainText(editor);
|
|
6977
6997
|
return editor;
|
|
6978
|
-
}
|
|
6998
|
+
},
|
|
6999
|
+
normalizer: [{
|
|
7000
|
+
match: slate.Text.isText,
|
|
7001
|
+
transform: function transform(editor, _ref) {
|
|
7002
|
+
var path = _ref[1];
|
|
7003
|
+
plateCore.unsetNodes(editor, restrictedMarks, {
|
|
7004
|
+
at: path
|
|
7005
|
+
});
|
|
7006
|
+
},
|
|
7007
|
+
validNode: function validNode(_editor, _ref2) {
|
|
7008
|
+
var node = _ref2[0];
|
|
7009
|
+
return !restrictedMarks.some(function (mark) {
|
|
7010
|
+
return mark in node;
|
|
7011
|
+
});
|
|
7012
|
+
}
|
|
7013
|
+
}]
|
|
6979
7014
|
};
|
|
6980
7015
|
}
|
|
6981
7016
|
|
|
@@ -7105,7 +7140,7 @@ var createVoidsPlugin = function createVoidsPlugin() {
|
|
|
7105
7140
|
};
|
|
7106
7141
|
};
|
|
7107
7142
|
|
|
7108
|
-
var getPlugins = function getPlugins(sdk, onAction) {
|
|
7143
|
+
var getPlugins = function getPlugins(sdk, onAction, restrictedMarks) {
|
|
7109
7144
|
return [// AST must come after the HTML deserializer
|
|
7110
7145
|
plateCore.createDeserializeHtmlPlugin(), plateCore.createDeserializeAstPlugin(), plateSerializerDocx.createDeserializeDocxPlugin(), // Tracking - This should come first so all plugins below will have access to `editor.tracking`
|
|
7111
7146
|
createTrackingPlugin(onAction), // Global / Global shortcuts
|
|
@@ -7113,7 +7148,7 @@ var getPlugins = function getPlugins(sdk, onAction) {
|
|
|
7113
7148
|
createParagraphPlugin(), createListPlugin(), createHrPlugin(), createHeadingPlugin(), createQuotePlugin(), createTablePlugin(), createEmbeddedEntryBlockPlugin(sdk), createEmbeddedAssetBlockPlugin(sdk), // Inline elements
|
|
7114
7149
|
createHyperlinkPlugin(sdk), createEmbeddedEntityInlinePlugin(sdk), // Marks
|
|
7115
7150
|
createMarksPlugin(), // Other
|
|
7116
|
-
createTrailingParagraphPlugin(), createTextPlugin(), createVoidsPlugin(), createSelectOnBackspacePlugin(), // Pasting content from other sources
|
|
7151
|
+
createTrailingParagraphPlugin(), createTextPlugin(restrictedMarks), createVoidsPlugin(), createSelectOnBackspacePlugin(), // Pasting content from other sources
|
|
7117
7152
|
createPasteHTMLPlugin(), // These plugins drive their configurations from the list of plugins
|
|
7118
7153
|
// above. They MUST come last.
|
|
7119
7154
|
createSoftBreakPlugin(), createExitBreakPlugin(), createResetNodePlugin(), createNormalizerPlugin()];
|
|
@@ -7236,7 +7271,7 @@ var normalizeEditorValue = function normalizeEditorValue(value, options) {
|
|
|
7236
7271
|
};
|
|
7237
7272
|
|
|
7238
7273
|
var STYLE_EDITOR_BORDER = "1px solid " + tokens.gray400;
|
|
7239
|
-
var styles$
|
|
7274
|
+
var styles$j = {
|
|
7240
7275
|
root: /*#__PURE__*/emotion.css({
|
|
7241
7276
|
position: 'relative'
|
|
7242
7277
|
}),
|
|
@@ -7353,7 +7388,7 @@ var EmbedEntityWidget = function EmbedEntityWidget(_ref) {
|
|
|
7353
7388
|
}, actions) : null;
|
|
7354
7389
|
};
|
|
7355
7390
|
|
|
7356
|
-
var styles$
|
|
7391
|
+
var styles$k = {
|
|
7357
7392
|
toolbar: /*#__PURE__*/emotion.css({
|
|
7358
7393
|
border: "1px solid " + tokens.gray400,
|
|
7359
7394
|
backgroundColor: tokens.gray100,
|
|
@@ -7398,14 +7433,14 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
7398
7433
|
var shouldDisableTables = isDisabled || !canInsertBlocks || isListSelected || isBlockquoteSelected;
|
|
7399
7434
|
return /*#__PURE__*/React__default.createElement(f36Components.Flex, {
|
|
7400
7435
|
testId: "toolbar",
|
|
7401
|
-
className: styles$
|
|
7436
|
+
className: styles$k.toolbar,
|
|
7402
7437
|
alignItems: "center"
|
|
7403
7438
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
7404
|
-
className: styles$
|
|
7439
|
+
className: styles$k.formattingOptionsWrapper
|
|
7405
7440
|
}, /*#__PURE__*/React__default.createElement(ToolbarHeadingButton, {
|
|
7406
7441
|
isDisabled: isDisabled || !canInsertBlocks
|
|
7407
7442
|
}), validationInfo.isAnyMarkEnabled && /*#__PURE__*/React__default.createElement("span", {
|
|
7408
|
-
className: styles$
|
|
7443
|
+
className: styles$k.divider
|
|
7409
7444
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.BOLD) && /*#__PURE__*/React__default.createElement(ToolbarBoldButton, {
|
|
7410
7445
|
isDisabled: isDisabled
|
|
7411
7446
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.ITALIC) && /*#__PURE__*/React__default.createElement(ToolbarItalicButton, {
|
|
@@ -7419,11 +7454,11 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
7419
7454
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.CODE) && /*#__PURE__*/React__default.createElement(ToolbarCodeButton, {
|
|
7420
7455
|
isDisabled: isDisabled
|
|
7421
7456
|
}), validationInfo.isAnyHyperlinkEnabled && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
|
7422
|
-
className: styles$
|
|
7457
|
+
className: styles$k.divider
|
|
7423
7458
|
}), /*#__PURE__*/React__default.createElement(ToolbarHyperlinkButton, {
|
|
7424
7459
|
isDisabled: isDisabled
|
|
7425
7460
|
})), validationInfo.isAnyBlockFormattingEnabled && /*#__PURE__*/React__default.createElement("span", {
|
|
7426
|
-
className: styles$
|
|
7461
|
+
className: styles$k.divider
|
|
7427
7462
|
}), /*#__PURE__*/React__default.createElement(ToolbarListButton, {
|
|
7428
7463
|
isDisabled: isDisabled || !canInsertBlocks
|
|
7429
7464
|
}), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.QUOTE) && /*#__PURE__*/React__default.createElement(ToolbarQuoteButton, {
|
|
@@ -7433,7 +7468,7 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
7433
7468
|
}), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.TABLE) && /*#__PURE__*/React__default.createElement(ToolbarTableButton, {
|
|
7434
7469
|
isDisabled: shouldDisableTables
|
|
7435
7470
|
})), /*#__PURE__*/React__default.createElement("div", {
|
|
7436
|
-
className: styles$
|
|
7471
|
+
className: styles$k.embedActionsWrapper
|
|
7437
7472
|
}, /*#__PURE__*/React__default.createElement(EmbedEntityWidget, {
|
|
7438
7473
|
isDisabled: isDisabled,
|
|
7439
7474
|
canInsertBlocks: canInsertBlocks
|
|
@@ -7458,7 +7493,7 @@ function getValidationInfo(field) {
|
|
|
7458
7493
|
}
|
|
7459
7494
|
|
|
7460
7495
|
var _templateObject$b;
|
|
7461
|
-
var styles$
|
|
7496
|
+
var styles$l = {
|
|
7462
7497
|
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 "])))
|
|
7463
7498
|
};
|
|
7464
7499
|
|
|
@@ -7466,7 +7501,7 @@ var StickyToolbarWrapper = function StickyToolbarWrapper(_ref) {
|
|
|
7466
7501
|
var isDisabled = _ref.isDisabled,
|
|
7467
7502
|
children = _ref.children;
|
|
7468
7503
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
7469
|
-
className: isDisabled ? '' : styles$
|
|
7504
|
+
className: isDisabled ? '' : styles$l.nativeSticky
|
|
7470
7505
|
}, children);
|
|
7471
7506
|
};
|
|
7472
7507
|
|
|
@@ -7533,14 +7568,14 @@ var useOnValueChanged = function useOnValueChanged(_ref) {
|
|
|
7533
7568
|
}, [editorId, onChange, skip, onSkip]);
|
|
7534
7569
|
};
|
|
7535
7570
|
|
|
7536
|
-
var _excluded = ["sdk", "isInitiallyDisabled", "onAction"];
|
|
7571
|
+
var _excluded = ["sdk", "isInitiallyDisabled", "onAction", "restrictedMarks"];
|
|
7537
7572
|
var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
7538
7573
|
var id = getContentfulEditorId(props.sdk);
|
|
7539
7574
|
var plugins = React__default.useMemo(function () {
|
|
7540
7575
|
var _props$onAction;
|
|
7541
7576
|
|
|
7542
|
-
return getPlugins(props.sdk, (_props$onAction = props.onAction) != null ? _props$onAction : noop);
|
|
7543
|
-
}, [props.sdk, props.onAction]);
|
|
7577
|
+
return getPlugins(props.sdk, (_props$onAction = props.onAction) != null ? _props$onAction : noop, props.restrictedMarks);
|
|
7578
|
+
}, [props.sdk, props.onAction, props.restrictedMarks]);
|
|
7544
7579
|
|
|
7545
7580
|
var _useState = React.useState(true),
|
|
7546
7581
|
isFirstRender = _useState[0],
|
|
@@ -7579,9 +7614,9 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
7579
7614
|
setPendingExternalUpdate(true);
|
|
7580
7615
|
setEditorContent(editor, documentToEditorValue(props.value));
|
|
7581
7616
|
}, [props.value, id]);
|
|
7582
|
-
var classNames = emotion.cx(styles$
|
|
7617
|
+
var classNames = emotion.cx(styles$j.editor, props.minHeight !== undefined ? emotion.css({
|
|
7583
7618
|
minHeight: props.minHeight
|
|
7584
|
-
}) : undefined, props.isDisabled ? styles$
|
|
7619
|
+
}) : undefined, props.isDisabled ? styles$j.disabled : styles$j.enabled, props.isToolbarHidden && styles$j.hiddenToolbar);
|
|
7585
7620
|
React.useEffect(function () {
|
|
7586
7621
|
if (!isFirstRender) {
|
|
7587
7622
|
return;
|
|
@@ -7597,7 +7632,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
7597
7632
|
}, /*#__PURE__*/React__default.createElement(ContentfulEditorIdProvider, {
|
|
7598
7633
|
value: id
|
|
7599
7634
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
7600
|
-
className: styles$
|
|
7635
|
+
className: styles$j.root,
|
|
7601
7636
|
"data-test-id": "rich-text-editor"
|
|
7602
7637
|
}, /*#__PURE__*/React__default.createElement(plateCore.Plate, {
|
|
7603
7638
|
id: id,
|
|
@@ -7619,6 +7654,7 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
7619
7654
|
var sdk = props.sdk,
|
|
7620
7655
|
isInitiallyDisabled = props.isInitiallyDisabled,
|
|
7621
7656
|
onAction = props.onAction,
|
|
7657
|
+
restrictedMarks = props.restrictedMarks,
|
|
7622
7658
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
7623
7659
|
|
|
7624
7660
|
var isEmptyValue = React.useCallback(function (value) {
|
|
@@ -7643,7 +7679,8 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
7643
7679
|
sdk: sdk,
|
|
7644
7680
|
onAction: onAction,
|
|
7645
7681
|
isDisabled: disabled,
|
|
7646
|
-
onChange: setValue
|
|
7682
|
+
onChange: setValue,
|
|
7683
|
+
restrictedMarks: restrictedMarks
|
|
7647
7684
|
}));
|
|
7648
7685
|
}));
|
|
7649
7686
|
};
|