@contentful/field-editor-rich-text 3.2.1 → 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 +6 -0
- package/dist/RichTextEditor.d.ts +1 -0
- package/dist/field-editor-rich-text.cjs.development.js +29 -8
- 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 +30 -9
- 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 +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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
|
+
|
|
6
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)
|
|
7
13
|
|
|
8
14
|
### 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 & {
|
|
@@ -6926,7 +6926,11 @@ function ToolbarTableButton(props) {
|
|
|
6926
6926
|
}, /*#__PURE__*/React.createElement(f36Icons.TableIcon, null));
|
|
6927
6927
|
}
|
|
6928
6928
|
|
|
6929
|
-
function createTextPlugin() {
|
|
6929
|
+
function createTextPlugin(restrictedMarks) {
|
|
6930
|
+
if (restrictedMarks === void 0) {
|
|
6931
|
+
restrictedMarks = [];
|
|
6932
|
+
}
|
|
6933
|
+
|
|
6930
6934
|
return {
|
|
6931
6935
|
key: 'TextPlugin',
|
|
6932
6936
|
handlers: {
|
|
@@ -6991,7 +6995,22 @@ function createTextPlugin() {
|
|
|
6991
6995
|
|
|
6992
6996
|
fixPasteAsPlainText(editor);
|
|
6993
6997
|
return editor;
|
|
6994
|
-
}
|
|
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
|
+
}]
|
|
6995
7014
|
};
|
|
6996
7015
|
}
|
|
6997
7016
|
|
|
@@ -7121,7 +7140,7 @@ var createVoidsPlugin = function createVoidsPlugin() {
|
|
|
7121
7140
|
};
|
|
7122
7141
|
};
|
|
7123
7142
|
|
|
7124
|
-
var getPlugins = function getPlugins(sdk, onAction) {
|
|
7143
|
+
var getPlugins = function getPlugins(sdk, onAction, restrictedMarks) {
|
|
7125
7144
|
return [// AST must come after the HTML deserializer
|
|
7126
7145
|
plateCore.createDeserializeHtmlPlugin(), plateCore.createDeserializeAstPlugin(), plateSerializerDocx.createDeserializeDocxPlugin(), // Tracking - This should come first so all plugins below will have access to `editor.tracking`
|
|
7127
7146
|
createTrackingPlugin(onAction), // Global / Global shortcuts
|
|
@@ -7129,7 +7148,7 @@ var getPlugins = function getPlugins(sdk, onAction) {
|
|
|
7129
7148
|
createParagraphPlugin(), createListPlugin(), createHrPlugin(), createHeadingPlugin(), createQuotePlugin(), createTablePlugin(), createEmbeddedEntryBlockPlugin(sdk), createEmbeddedAssetBlockPlugin(sdk), // Inline elements
|
|
7130
7149
|
createHyperlinkPlugin(sdk), createEmbeddedEntityInlinePlugin(sdk), // Marks
|
|
7131
7150
|
createMarksPlugin(), // Other
|
|
7132
|
-
createTrailingParagraphPlugin(), createTextPlugin(), createVoidsPlugin(), createSelectOnBackspacePlugin(), // Pasting content from other sources
|
|
7151
|
+
createTrailingParagraphPlugin(), createTextPlugin(restrictedMarks), createVoidsPlugin(), createSelectOnBackspacePlugin(), // Pasting content from other sources
|
|
7133
7152
|
createPasteHTMLPlugin(), // These plugins drive their configurations from the list of plugins
|
|
7134
7153
|
// above. They MUST come last.
|
|
7135
7154
|
createSoftBreakPlugin(), createExitBreakPlugin(), createResetNodePlugin(), createNormalizerPlugin()];
|
|
@@ -7549,14 +7568,14 @@ var useOnValueChanged = function useOnValueChanged(_ref) {
|
|
|
7549
7568
|
}, [editorId, onChange, skip, onSkip]);
|
|
7550
7569
|
};
|
|
7551
7570
|
|
|
7552
|
-
var _excluded = ["sdk", "isInitiallyDisabled", "onAction"];
|
|
7571
|
+
var _excluded = ["sdk", "isInitiallyDisabled", "onAction", "restrictedMarks"];
|
|
7553
7572
|
var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
7554
7573
|
var id = getContentfulEditorId(props.sdk);
|
|
7555
7574
|
var plugins = React__default.useMemo(function () {
|
|
7556
7575
|
var _props$onAction;
|
|
7557
7576
|
|
|
7558
|
-
return getPlugins(props.sdk, (_props$onAction = props.onAction) != null ? _props$onAction : noop);
|
|
7559
|
-
}, [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]);
|
|
7560
7579
|
|
|
7561
7580
|
var _useState = React.useState(true),
|
|
7562
7581
|
isFirstRender = _useState[0],
|
|
@@ -7635,6 +7654,7 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
7635
7654
|
var sdk = props.sdk,
|
|
7636
7655
|
isInitiallyDisabled = props.isInitiallyDisabled,
|
|
7637
7656
|
onAction = props.onAction,
|
|
7657
|
+
restrictedMarks = props.restrictedMarks,
|
|
7638
7658
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
7639
7659
|
|
|
7640
7660
|
var isEmptyValue = React.useCallback(function (value) {
|
|
@@ -7659,7 +7679,8 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
7659
7679
|
sdk: sdk,
|
|
7660
7680
|
onAction: onAction,
|
|
7661
7681
|
isDisabled: disabled,
|
|
7662
|
-
onChange: setValue
|
|
7682
|
+
onChange: setValue,
|
|
7683
|
+
restrictedMarks: restrictedMarks
|
|
7663
7684
|
}));
|
|
7664
7685
|
}));
|
|
7665
7686
|
};
|