@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
|
@@ -2,7 +2,7 @@ import React__default, { createContext, useContext, useMemo, useState, useEffect
|
|
|
2
2
|
import { MissingEntityCard, WrappedAssetCard, useEntity, useEntityLoader, WrappedEntryCard, ScheduledIconWithTooltip, EntityProvider, getScheduleTooltipContent } from '@contentful/field-editor-reference';
|
|
3
3
|
import { entityHelpers, ModalDialogLauncher, FieldConnector } from '@contentful/field-editor-shared';
|
|
4
4
|
import { BLOCKS, INLINES, TEXT_CONTAINERS, HEADINGS, LIST_ITEM_BLOCKS, MARKS, CONTAINERS, TOP_LEVEL_BLOCKS, VOID_BLOCKS, EMPTY_DOCUMENT } from '@contentful/rich-text-types';
|
|
5
|
-
import { usePlateEditorRef, usePlateEditorState, toggleNodeType, getText, getAbove, removeMark, setMarks, isMarkActive, getNodes, setNodes, isAncestorEmpty, match, getLastChildPath, wrapNodes, getPluginType, unwrapNodes, isCollapsed, isRangeAcrossBlocks, ELEMENT_DEFAULT, findNode, getParent, getBlockAbove, isSelectionAtBlockStart, isSelectionAtBlockEnd, isFirstChild, insertNodes, moveChildren, isBlockAboveEmpty, mockPlugin, deleteFragment, toggleMark, someHtmlElement, KEY_DESERIALIZE_HTML, hasSingleChild, isLastChild, someNode, getChildren as getChildren$1, queryNode, createDeserializeHtmlPlugin, createDeserializeAstPlugin, createPlateEditor, getPlateSelectors, getPlateActions, Plate } from '@udecode/plate-core';
|
|
5
|
+
import { usePlateEditorRef, usePlateEditorState, toggleNodeType, getText, getAbove, removeMark, setMarks, isMarkActive, getNodes, setNodes, isAncestorEmpty, match, getLastChildPath, wrapNodes, getPluginType, unwrapNodes, isCollapsed, isRangeAcrossBlocks, ELEMENT_DEFAULT, findNode, getParent, getBlockAbove, isSelectionAtBlockStart, isSelectionAtBlockEnd, isFirstChild, insertNodes, moveChildren, isBlockAboveEmpty, mockPlugin, deleteFragment, toggleMark, someHtmlElement, KEY_DESERIALIZE_HTML, hasSingleChild, isLastChild, someNode, getChildren as getChildren$1, unsetNodes, queryNode, createDeserializeHtmlPlugin, createDeserializeAstPlugin, createPlateEditor, getPlateSelectors, getPlateActions, Plate } from '@udecode/plate-core';
|
|
6
6
|
import { css, cx } from 'emotion';
|
|
7
7
|
import areEqual from 'fast-deep-equal';
|
|
8
8
|
import noop from 'lodash-es/noop';
|
|
@@ -6919,7 +6919,11 @@ function ToolbarTableButton(props) {
|
|
|
6919
6919
|
}, /*#__PURE__*/createElement(TableIcon, null));
|
|
6920
6920
|
}
|
|
6921
6921
|
|
|
6922
|
-
function createTextPlugin() {
|
|
6922
|
+
function createTextPlugin(restrictedMarks) {
|
|
6923
|
+
if (restrictedMarks === void 0) {
|
|
6924
|
+
restrictedMarks = [];
|
|
6925
|
+
}
|
|
6926
|
+
|
|
6923
6927
|
return {
|
|
6924
6928
|
key: 'TextPlugin',
|
|
6925
6929
|
handlers: {
|
|
@@ -6984,7 +6988,22 @@ function createTextPlugin() {
|
|
|
6984
6988
|
|
|
6985
6989
|
fixPasteAsPlainText(editor);
|
|
6986
6990
|
return editor;
|
|
6987
|
-
}
|
|
6991
|
+
},
|
|
6992
|
+
normalizer: [{
|
|
6993
|
+
match: Text.isText,
|
|
6994
|
+
transform: function transform(editor, _ref) {
|
|
6995
|
+
var path = _ref[1];
|
|
6996
|
+
unsetNodes(editor, restrictedMarks, {
|
|
6997
|
+
at: path
|
|
6998
|
+
});
|
|
6999
|
+
},
|
|
7000
|
+
validNode: function validNode(_editor, _ref2) {
|
|
7001
|
+
var node = _ref2[0];
|
|
7002
|
+
return !restrictedMarks.some(function (mark) {
|
|
7003
|
+
return mark in node;
|
|
7004
|
+
});
|
|
7005
|
+
}
|
|
7006
|
+
}]
|
|
6988
7007
|
};
|
|
6989
7008
|
}
|
|
6990
7009
|
|
|
@@ -7114,7 +7133,7 @@ var createVoidsPlugin = function createVoidsPlugin() {
|
|
|
7114
7133
|
};
|
|
7115
7134
|
};
|
|
7116
7135
|
|
|
7117
|
-
var getPlugins = function getPlugins(sdk, onAction) {
|
|
7136
|
+
var getPlugins = function getPlugins(sdk, onAction, restrictedMarks) {
|
|
7118
7137
|
return [// AST must come after the HTML deserializer
|
|
7119
7138
|
createDeserializeHtmlPlugin(), createDeserializeAstPlugin(), createDeserializeDocxPlugin(), // Tracking - This should come first so all plugins below will have access to `editor.tracking`
|
|
7120
7139
|
createTrackingPlugin(onAction), // Global / Global shortcuts
|
|
@@ -7122,7 +7141,7 @@ var getPlugins = function getPlugins(sdk, onAction) {
|
|
|
7122
7141
|
createParagraphPlugin(), createListPlugin(), createHrPlugin(), createHeadingPlugin(), createQuotePlugin(), createTablePlugin(), createEmbeddedEntryBlockPlugin(sdk), createEmbeddedAssetBlockPlugin(sdk), // Inline elements
|
|
7123
7142
|
createHyperlinkPlugin(sdk), createEmbeddedEntityInlinePlugin(sdk), // Marks
|
|
7124
7143
|
createMarksPlugin(), // Other
|
|
7125
|
-
createTrailingParagraphPlugin(), createTextPlugin(), createVoidsPlugin(), createSelectOnBackspacePlugin(), // Pasting content from other sources
|
|
7144
|
+
createTrailingParagraphPlugin(), createTextPlugin(restrictedMarks), createVoidsPlugin(), createSelectOnBackspacePlugin(), // Pasting content from other sources
|
|
7126
7145
|
createPasteHTMLPlugin(), // These plugins drive their configurations from the list of plugins
|
|
7127
7146
|
// above. They MUST come last.
|
|
7128
7147
|
createSoftBreakPlugin(), createExitBreakPlugin(), createResetNodePlugin(), createNormalizerPlugin()];
|
|
@@ -7542,14 +7561,14 @@ var useOnValueChanged = function useOnValueChanged(_ref) {
|
|
|
7542
7561
|
}, [editorId, onChange, skip, onSkip]);
|
|
7543
7562
|
};
|
|
7544
7563
|
|
|
7545
|
-
var _excluded = ["sdk", "isInitiallyDisabled", "onAction"];
|
|
7564
|
+
var _excluded = ["sdk", "isInitiallyDisabled", "onAction", "restrictedMarks"];
|
|
7546
7565
|
var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
7547
7566
|
var id = getContentfulEditorId(props.sdk);
|
|
7548
7567
|
var plugins = React__default.useMemo(function () {
|
|
7549
7568
|
var _props$onAction;
|
|
7550
7569
|
|
|
7551
|
-
return getPlugins(props.sdk, (_props$onAction = props.onAction) != null ? _props$onAction : noop);
|
|
7552
|
-
}, [props.sdk, props.onAction]);
|
|
7570
|
+
return getPlugins(props.sdk, (_props$onAction = props.onAction) != null ? _props$onAction : noop, props.restrictedMarks);
|
|
7571
|
+
}, [props.sdk, props.onAction, props.restrictedMarks]);
|
|
7553
7572
|
|
|
7554
7573
|
var _useState = useState(true),
|
|
7555
7574
|
isFirstRender = _useState[0],
|
|
@@ -7628,6 +7647,7 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
7628
7647
|
var sdk = props.sdk,
|
|
7629
7648
|
isInitiallyDisabled = props.isInitiallyDisabled,
|
|
7630
7649
|
onAction = props.onAction,
|
|
7650
|
+
restrictedMarks = props.restrictedMarks,
|
|
7631
7651
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
7632
7652
|
|
|
7633
7653
|
var isEmptyValue = useCallback(function (value) {
|
|
@@ -7652,7 +7672,8 @@ var RichTextEditor = function RichTextEditor(props) {
|
|
|
7652
7672
|
sdk: sdk,
|
|
7653
7673
|
onAction: onAction,
|
|
7654
7674
|
isDisabled: disabled,
|
|
7655
|
-
onChange: setValue
|
|
7675
|
+
onChange: setValue,
|
|
7676
|
+
restrictedMarks: restrictedMarks
|
|
7656
7677
|
}));
|
|
7657
7678
|
}));
|
|
7658
7679
|
};
|