@contentful/field-editor-rich-text 0.24.1-next → 0.25.0-next
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/dist/field-editor-rich-text.cjs.development.js +39 -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 +41 -10
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/plugins/List/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -27,6 +27,7 @@ var fieldEditorShared = require('@contentful/field-editor-shared');
|
|
|
27
27
|
var moment = _interopDefault(require('moment'));
|
|
28
28
|
var mimetype = _interopDefault(require('@contentful/mimetype'));
|
|
29
29
|
var plateTable = require('@udecode/plate-table');
|
|
30
|
+
var richTextPlainTextRenderer = require('@contentful/rich-text-plain-text-renderer');
|
|
30
31
|
var plateHtmlSerializer = require('@udecode/plate-html-serializer');
|
|
31
32
|
var plateParagraph = require('@udecode/plate-paragraph');
|
|
32
33
|
var plateBreak = require('@udecode/plate-break');
|
|
@@ -1135,6 +1136,11 @@ var withListOptions = (_withListOptions = {}, _withListOptions[plateList.ELEMENT
|
|
|
1135
1136
|
type: Contentful.BLOCKS.OL_LIST,
|
|
1136
1137
|
component: OL
|
|
1137
1138
|
}, _withListOptions);
|
|
1139
|
+
var createListPlugin = function createListPlugin() {
|
|
1140
|
+
return plateList.createListPlugin({
|
|
1141
|
+
validLiChildrenTypes: Contentful.LIST_ITEM_BLOCKS
|
|
1142
|
+
});
|
|
1143
|
+
};
|
|
1138
1144
|
|
|
1139
1145
|
var _withBoldOptions;
|
|
1140
1146
|
function ToolbarBoldButton(props) {
|
|
@@ -3634,6 +3640,15 @@ var TableActions = function TableActions() {
|
|
|
3634
3640
|
|
|
3635
3641
|
var _templateObject$4, _templateObject2$3, _templateObject3$3, _templateObject4$1, _styles$1, _withTableOptions;
|
|
3636
3642
|
var styles$g = (_styles$1 = {}, _styles$1[Contentful.BLOCKS.TABLE] = /*#__PURE__*/emotion.css(_templateObject$4 || (_templateObject$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-bottom: 1.5em;\n border-collapse: collapse;\n border-radius: 5px;\n border-style: hidden;\n box-shadow: 0 0 0 1px ", ";\n width: 100%;\n table-layout: fixed;\n overflow: hidden;\n "])), tokens.gray400), _styles$1[Contentful.BLOCKS.TABLE_ROW] = /*#__PURE__*/emotion.css(_templateObject2$3 || (_templateObject2$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border: 1px solid ", ";\n &:hover td {\n background-color: transparent !important;\n }\n "])), tokens.gray400), _styles$1[Contentful.BLOCKS.TABLE_HEADER_CELL] = /*#__PURE__*/emotion.css(_templateObject3$3 || (_templateObject3$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n background-color: ", ";\n border: 1px solid ", ";\n padding: 10px 12px;\n font-weight: ", ";\n text-align: left;\n min-width: 48px;\n position: relative;\n div:last-child {\n margin-bottom: 0;\n }\n "])), tokens.gray200, tokens.gray400, tokens.fontWeightMedium), _styles$1[Contentful.BLOCKS.TABLE_CELL] = /*#__PURE__*/emotion.css(_templateObject4$1 || (_templateObject4$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n border: 1px solid ", ";\n padding: 10px 12px;\n min-width: 48px;\n position: relative;\n div:last-child {\n margin-bottom: 0;\n }\n "])), tokens.gray400), _styles$1);
|
|
3643
|
+
|
|
3644
|
+
var slateNodeToText = function slateNodeToText(node) {
|
|
3645
|
+
var contentfulNode = contentfulSlatejsAdapter.toContentfulDocument({
|
|
3646
|
+
document: [node],
|
|
3647
|
+
schema: schema
|
|
3648
|
+
});
|
|
3649
|
+
return richTextPlainTextRenderer.documentToPlainTextString(contentfulNode);
|
|
3650
|
+
};
|
|
3651
|
+
|
|
3637
3652
|
var Table = function Table(props) {
|
|
3638
3653
|
return /*#__PURE__*/React.createElement("table", Object.assign({}, props.attributes, {
|
|
3639
3654
|
className: styles$g[Contentful.BLOCKS.TABLE]
|
|
@@ -3695,6 +3710,14 @@ function addTableTrackingEvents(editor, _ref) {
|
|
|
3695
3710
|
};
|
|
3696
3711
|
}
|
|
3697
3712
|
|
|
3713
|
+
var paragraph = function paragraph() {
|
|
3714
|
+
return {
|
|
3715
|
+
type: Contentful.BLOCKS.PARAGRAPH,
|
|
3716
|
+
data: {},
|
|
3717
|
+
children: []
|
|
3718
|
+
};
|
|
3719
|
+
};
|
|
3720
|
+
|
|
3698
3721
|
function addTableNormalization(editor) {
|
|
3699
3722
|
var normalizeNode = editor.normalizeNode;
|
|
3700
3723
|
|
|
@@ -3713,12 +3736,20 @@ function addTableNormalization(editor) {
|
|
|
3713
3736
|
childPath = _step$value[1];
|
|
3714
3737
|
|
|
3715
3738
|
if (slate.Text.isText(child)) {
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
}
|
|
3721
|
-
|
|
3739
|
+
slate.Transforms.wrapNodes(editor, paragraph(), {
|
|
3740
|
+
at: childPath
|
|
3741
|
+
});
|
|
3742
|
+
} else if (!Contentful.CONTAINERS[node.type].includes(child.type)) {
|
|
3743
|
+
var paragraphWithTextFromNode = _extends({}, paragraph(), {
|
|
3744
|
+
children: [{
|
|
3745
|
+
text: slateNodeToText(child)
|
|
3746
|
+
}]
|
|
3747
|
+
});
|
|
3748
|
+
|
|
3749
|
+
slate.Transforms.removeNodes(editor, {
|
|
3750
|
+
at: childPath
|
|
3751
|
+
});
|
|
3752
|
+
slate.Transforms.insertNodes(editor, paragraphWithTextFromNode, {
|
|
3722
3753
|
at: childPath
|
|
3723
3754
|
});
|
|
3724
3755
|
}
|
|
@@ -4759,7 +4790,7 @@ var removeComments = function removeComments(_ref) {
|
|
|
4759
4790
|
|
|
4760
4791
|
var TAG_NAME_TABLE = 'TABLE';
|
|
4761
4792
|
var TAG_NAME_TABLE_CAPTION = 'CAPTION';
|
|
4762
|
-
var DISALLOWED_TABLE_CHILD_ELEMENTS = [
|
|
4793
|
+
var DISALLOWED_TABLE_CHILD_ELEMENTS = [TAG_NAME_TABLE_CAPTION];
|
|
4763
4794
|
|
|
4764
4795
|
var isHTMLElement = function isHTMLElement(node) {
|
|
4765
4796
|
return node.nodeType === Node.ELEMENT_NODE;
|
|
@@ -5049,7 +5080,7 @@ var getPlugins = function getPlugins(sdk, tracking) {
|
|
|
5049
5080
|
plateCore.createReactPlugin(), plateCore.createHistoryPlugin(), // Behavior
|
|
5050
5081
|
createPastePlugin(), // Global shortcuts
|
|
5051
5082
|
createNewLinePlugin(), createInsertBeforeFirstVoidBlockPlugin(), // Block Elements
|
|
5052
|
-
createParagraphPlugin(),
|
|
5083
|
+
createParagraphPlugin(), createListPlugin(), createHrPlugin(), createHeadingPlugin(), createQuotePlugin(), createTablePlugin(tracking), createEmbeddedEntryBlockPlugin(sdk), createEmbeddedAssetBlockPlugin(sdk), // Inline elements
|
|
5053
5084
|
createHyperlinkPlugin(sdk), createEmbeddedEntityInlinePlugin(sdk), // Marks
|
|
5054
5085
|
createBoldPlugin(), createCodePlugin(), createItalicPlugin(), createUnderlinePlugin(), // Other
|
|
5055
5086
|
createTrailingParagraphPlugin()];
|