@contentful/field-editor-rich-text 3.1.12 → 3.2.1
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/field-editor-rich-text.cjs.development.js +111 -39
- 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 +113 -41
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/plugins/Marks/Subscript.d.ts +11 -0
- package/dist/plugins/Marks/Superscript.d.ts +11 -0
- package/dist/plugins/Marks/helpers.d.ts +2 -0
- package/dist/types.d.ts +2 -0
- package/package.json +3 -3
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.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
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- 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))
|
|
11
|
+
|
|
12
|
+
# [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)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- superscipt and subscript support to rich text editor [TOL-30] ([#1280](https://github.com/contentful/field-editors/issues/1280)) ([3c50f07](https://github.com/contentful/field-editors/commit/3c50f0770f95e7c11c12411e3c33c9d3593b19a7))
|
|
17
|
+
|
|
6
18
|
## [3.1.12](https://github.com/contentful/field-editors/compare/@contentful/field-editor-rich-text@3.1.11...@contentful/field-editor-rich-text@3.1.12) (2022-11-07)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @contentful/field-editor-rich-text
|
|
@@ -5096,6 +5096,30 @@ function ToolbarListButton(props) {
|
|
|
5096
5096
|
}, /*#__PURE__*/React.createElement(f36Icons.ListNumberedIcon, null)));
|
|
5097
5097
|
}
|
|
5098
5098
|
|
|
5099
|
+
var toggleMarkAndDeactivateConflictingMarks = function toggleMarkAndDeactivateConflictingMarks(editor, mark) {
|
|
5100
|
+
var subs = [Contentful.MARKS.SUPERSCRIPT, Contentful.MARKS.SUBSCRIPT];
|
|
5101
|
+
var clear = subs.includes(mark) ? subs : [];
|
|
5102
|
+
plateCore.toggleMark(editor, {
|
|
5103
|
+
key: mark,
|
|
5104
|
+
clear: clear
|
|
5105
|
+
});
|
|
5106
|
+
};
|
|
5107
|
+
var buildMarkEventHandler = function buildMarkEventHandler(type) {
|
|
5108
|
+
return function (editor, _ref) {
|
|
5109
|
+
var hotkey = _ref.options.hotkey;
|
|
5110
|
+
return function (event) {
|
|
5111
|
+
if (editor.selection && hotkey && isHotkey(hotkey, event)) {
|
|
5112
|
+
event.preventDefault();
|
|
5113
|
+
var isActive = plateCore.isMarkActive(editor, type);
|
|
5114
|
+
editor.tracking.onShortcutAction(isActive ? 'unmark' : 'mark', {
|
|
5115
|
+
markType: type
|
|
5116
|
+
});
|
|
5117
|
+
toggleMarkAndDeactivateConflictingMarks(editor, type);
|
|
5118
|
+
}
|
|
5119
|
+
};
|
|
5120
|
+
};
|
|
5121
|
+
};
|
|
5122
|
+
|
|
5099
5123
|
var createMarkToolbarButton = function createMarkToolbarButton(_ref) {
|
|
5100
5124
|
var mark = _ref.mark,
|
|
5101
5125
|
title = _ref.title,
|
|
@@ -5110,9 +5134,7 @@ var createMarkToolbarButton = function createMarkToolbarButton(_ref) {
|
|
|
5110
5134
|
editor.tracking.onToolbarAction(isActive ? 'unmark' : 'mark', {
|
|
5111
5135
|
markType: mark
|
|
5112
5136
|
});
|
|
5113
|
-
|
|
5114
|
-
key: mark
|
|
5115
|
-
});
|
|
5137
|
+
toggleMarkAndDeactivateConflictingMarks(editor, mark);
|
|
5116
5138
|
focus(editor);
|
|
5117
5139
|
}, [editor]);
|
|
5118
5140
|
if (!editor) return null;
|
|
@@ -5129,24 +5151,6 @@ var createMarkToolbarButton = function createMarkToolbarButton(_ref) {
|
|
|
5129
5151
|
return Mark;
|
|
5130
5152
|
};
|
|
5131
5153
|
|
|
5132
|
-
var buildMarkEventHandler = function buildMarkEventHandler(type) {
|
|
5133
|
-
return function (editor, _ref) {
|
|
5134
|
-
var hotkey = _ref.options.hotkey;
|
|
5135
|
-
return function (event) {
|
|
5136
|
-
if (editor.selection && hotkey && isHotkey(hotkey, event)) {
|
|
5137
|
-
event.preventDefault();
|
|
5138
|
-
var isActive = plateCore.isMarkActive(editor, type);
|
|
5139
|
-
editor.tracking.onShortcutAction(isActive ? 'unmark' : 'mark', {
|
|
5140
|
-
markType: type
|
|
5141
|
-
});
|
|
5142
|
-
plateCore.toggleMark(editor, {
|
|
5143
|
-
key: type
|
|
5144
|
-
});
|
|
5145
|
-
}
|
|
5146
|
-
};
|
|
5147
|
-
};
|
|
5148
|
-
};
|
|
5149
|
-
|
|
5150
5154
|
var ToolbarBoldButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5151
5155
|
title: 'Bold',
|
|
5152
5156
|
mark: Contentful.MARKS.BOLD,
|
|
@@ -5309,10 +5313,74 @@ var createUnderlinePlugin = function createUnderlinePlugin() {
|
|
|
5309
5313
|
});
|
|
5310
5314
|
};
|
|
5311
5315
|
|
|
5316
|
+
var styles$f = {
|
|
5317
|
+
superscript: /*#__PURE__*/emotion.css({
|
|
5318
|
+
verticalAlign: 'super',
|
|
5319
|
+
fontSize: 'smaller'
|
|
5320
|
+
})
|
|
5321
|
+
};
|
|
5322
|
+
var ToolbarSuperscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5323
|
+
title: 'Superscript',
|
|
5324
|
+
mark: Contentful.MARKS.SUPERSCRIPT,
|
|
5325
|
+
icon: /*#__PURE__*/React.createElement(f36Icons.SuperscriptIcon, null)
|
|
5326
|
+
});
|
|
5327
|
+
function Superscript(props) {
|
|
5328
|
+
return /*#__PURE__*/React.createElement("sup", _extends({}, props.attributes, {
|
|
5329
|
+
className: styles$f.superscript
|
|
5330
|
+
}), props.children);
|
|
5331
|
+
}
|
|
5332
|
+
var createSuperscriptPlugin = function createSuperscriptPlugin() {
|
|
5333
|
+
return plateBasicMarks.createSuperscriptPlugin({
|
|
5334
|
+
type: Contentful.MARKS.SUPERSCRIPT,
|
|
5335
|
+
component: Superscript,
|
|
5336
|
+
handlers: {
|
|
5337
|
+
onKeyDown: buildMarkEventHandler(Contentful.MARKS.SUPERSCRIPT)
|
|
5338
|
+
},
|
|
5339
|
+
deserializeHtml: {
|
|
5340
|
+
rules: [{
|
|
5341
|
+
validNodeName: ['SUP']
|
|
5342
|
+
}]
|
|
5343
|
+
}
|
|
5344
|
+
});
|
|
5345
|
+
};
|
|
5346
|
+
|
|
5347
|
+
var styles$g = {
|
|
5348
|
+
subscript: /*#__PURE__*/emotion.css({
|
|
5349
|
+
verticalAlign: 'sub',
|
|
5350
|
+
fontSize: 'smaller'
|
|
5351
|
+
})
|
|
5352
|
+
};
|
|
5353
|
+
var ToolbarSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5354
|
+
title: 'Subscript',
|
|
5355
|
+
mark: Contentful.MARKS.SUBSCRIPT,
|
|
5356
|
+
icon: /*#__PURE__*/React.createElement(f36Icons.SubscriptIcon, {
|
|
5357
|
+
viewBox: "0 0 23 18"
|
|
5358
|
+
})
|
|
5359
|
+
});
|
|
5360
|
+
function Subscript(props) {
|
|
5361
|
+
return /*#__PURE__*/React.createElement("sub", _extends({}, props.attributes, {
|
|
5362
|
+
className: styles$g.subscript
|
|
5363
|
+
}), props.children);
|
|
5364
|
+
}
|
|
5365
|
+
var createSubscriptPlugin = function createSubscriptPlugin() {
|
|
5366
|
+
return plateBasicMarks.createSubscriptPlugin({
|
|
5367
|
+
type: Contentful.MARKS.SUBSCRIPT,
|
|
5368
|
+
component: Subscript,
|
|
5369
|
+
handlers: {
|
|
5370
|
+
onKeyDown: buildMarkEventHandler(Contentful.MARKS.SUBSCRIPT)
|
|
5371
|
+
},
|
|
5372
|
+
deserializeHtml: {
|
|
5373
|
+
rules: [{
|
|
5374
|
+
validNodeName: ['SUB']
|
|
5375
|
+
}]
|
|
5376
|
+
}
|
|
5377
|
+
});
|
|
5378
|
+
};
|
|
5379
|
+
|
|
5312
5380
|
var createMarksPlugin = function createMarksPlugin() {
|
|
5313
5381
|
return {
|
|
5314
5382
|
key: 'Marks',
|
|
5315
|
-
plugins: [createBoldPlugin(), createCodePlugin(), createItalicPlugin(), createUnderlinePlugin()]
|
|
5383
|
+
plugins: [createBoldPlugin(), createCodePlugin(), createItalicPlugin(), createUnderlinePlugin(), createSuperscriptPlugin(), createSubscriptPlugin()]
|
|
5316
5384
|
};
|
|
5317
5385
|
};
|
|
5318
5386
|
|
|
@@ -5520,10 +5588,10 @@ var createNormalizerPlugin = function createNormalizerPlugin() {
|
|
|
5520
5588
|
};
|
|
5521
5589
|
|
|
5522
5590
|
var _templateObject$6, _styles$1;
|
|
5523
|
-
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);
|
|
5524
5592
|
function Paragraph(props) {
|
|
5525
5593
|
return /*#__PURE__*/React.createElement("div", _extends({}, props.attributes, {
|
|
5526
|
-
className: styles$
|
|
5594
|
+
className: styles$h[Contentful.BLOCKS.PARAGRAPH]
|
|
5527
5595
|
}), props.children);
|
|
5528
5596
|
}
|
|
5529
5597
|
|
|
@@ -6165,7 +6233,7 @@ var isTable = function isTable(node) {
|
|
|
6165
6233
|
return slate.Element.isElement(node) && node.type === Contentful.BLOCKS.TABLE;
|
|
6166
6234
|
};
|
|
6167
6235
|
|
|
6168
|
-
var styles$
|
|
6236
|
+
var styles$i = {
|
|
6169
6237
|
topRight: /*#__PURE__*/emotion.css({
|
|
6170
6238
|
position: 'absolute',
|
|
6171
6239
|
top: '6px',
|
|
@@ -6254,7 +6322,7 @@ var TableActions = function TableActions() {
|
|
|
6254
6322
|
size: "small",
|
|
6255
6323
|
variant: "transparent",
|
|
6256
6324
|
tabIndex: -1,
|
|
6257
|
-
className: styles$
|
|
6325
|
+
className: styles$i.topRight,
|
|
6258
6326
|
icon: /*#__PURE__*/React__default.createElement(f36Icons.ChevronDownIcon, null),
|
|
6259
6327
|
"aria-label": "Open table menu",
|
|
6260
6328
|
testId: "cf-table-actions-button"
|
|
@@ -7184,7 +7252,7 @@ var normalizeEditorValue = function normalizeEditorValue(value, options) {
|
|
|
7184
7252
|
};
|
|
7185
7253
|
|
|
7186
7254
|
var STYLE_EDITOR_BORDER = "1px solid " + tokens.gray400;
|
|
7187
|
-
var styles$
|
|
7255
|
+
var styles$j = {
|
|
7188
7256
|
root: /*#__PURE__*/emotion.css({
|
|
7189
7257
|
position: 'relative'
|
|
7190
7258
|
}),
|
|
@@ -7301,7 +7369,7 @@ var EmbedEntityWidget = function EmbedEntityWidget(_ref) {
|
|
|
7301
7369
|
}, actions) : null;
|
|
7302
7370
|
};
|
|
7303
7371
|
|
|
7304
|
-
var styles$
|
|
7372
|
+
var styles$k = {
|
|
7305
7373
|
toolbar: /*#__PURE__*/emotion.css({
|
|
7306
7374
|
border: "1px solid " + tokens.gray400,
|
|
7307
7375
|
backgroundColor: tokens.gray100,
|
|
@@ -7346,28 +7414,32 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
7346
7414
|
var shouldDisableTables = isDisabled || !canInsertBlocks || isListSelected || isBlockquoteSelected;
|
|
7347
7415
|
return /*#__PURE__*/React__default.createElement(f36Components.Flex, {
|
|
7348
7416
|
testId: "toolbar",
|
|
7349
|
-
className: styles$
|
|
7417
|
+
className: styles$k.toolbar,
|
|
7350
7418
|
alignItems: "center"
|
|
7351
7419
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
7352
|
-
className: styles$
|
|
7420
|
+
className: styles$k.formattingOptionsWrapper
|
|
7353
7421
|
}, /*#__PURE__*/React__default.createElement(ToolbarHeadingButton, {
|
|
7354
7422
|
isDisabled: isDisabled || !canInsertBlocks
|
|
7355
7423
|
}), validationInfo.isAnyMarkEnabled && /*#__PURE__*/React__default.createElement("span", {
|
|
7356
|
-
className: styles$
|
|
7424
|
+
className: styles$k.divider
|
|
7357
7425
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.BOLD) && /*#__PURE__*/React__default.createElement(ToolbarBoldButton, {
|
|
7358
7426
|
isDisabled: isDisabled
|
|
7359
7427
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.ITALIC) && /*#__PURE__*/React__default.createElement(ToolbarItalicButton, {
|
|
7360
7428
|
isDisabled: isDisabled
|
|
7429
|
+
}), isMarkEnabled(sdk.field, Contentful.MARKS.SUPERSCRIPT) && /*#__PURE__*/React__default.createElement(ToolbarSuperscriptButton, {
|
|
7430
|
+
isDisabled: isDisabled
|
|
7431
|
+
}), isMarkEnabled(sdk.field, Contentful.MARKS.SUBSCRIPT) && /*#__PURE__*/React__default.createElement(ToolbarSubscriptButton, {
|
|
7432
|
+
isDisabled: isDisabled
|
|
7361
7433
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.UNDERLINE) && /*#__PURE__*/React__default.createElement(ToolbarUnderlineButton, {
|
|
7362
7434
|
isDisabled: isDisabled
|
|
7363
7435
|
}), isMarkEnabled(sdk.field, Contentful.MARKS.CODE) && /*#__PURE__*/React__default.createElement(ToolbarCodeButton, {
|
|
7364
7436
|
isDisabled: isDisabled
|
|
7365
7437
|
}), validationInfo.isAnyHyperlinkEnabled && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
|
7366
|
-
className: styles$
|
|
7438
|
+
className: styles$k.divider
|
|
7367
7439
|
}), /*#__PURE__*/React__default.createElement(ToolbarHyperlinkButton, {
|
|
7368
7440
|
isDisabled: isDisabled
|
|
7369
7441
|
})), validationInfo.isAnyBlockFormattingEnabled && /*#__PURE__*/React__default.createElement("span", {
|
|
7370
|
-
className: styles$
|
|
7442
|
+
className: styles$k.divider
|
|
7371
7443
|
}), /*#__PURE__*/React__default.createElement(ToolbarListButton, {
|
|
7372
7444
|
isDisabled: isDisabled || !canInsertBlocks
|
|
7373
7445
|
}), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.QUOTE) && /*#__PURE__*/React__default.createElement(ToolbarQuoteButton, {
|
|
@@ -7377,7 +7449,7 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
7377
7449
|
}), isNodeTypeEnabled(sdk.field, Contentful.BLOCKS.TABLE) && /*#__PURE__*/React__default.createElement(ToolbarTableButton, {
|
|
7378
7450
|
isDisabled: shouldDisableTables
|
|
7379
7451
|
})), /*#__PURE__*/React__default.createElement("div", {
|
|
7380
|
-
className: styles$
|
|
7452
|
+
className: styles$k.embedActionsWrapper
|
|
7381
7453
|
}, /*#__PURE__*/React__default.createElement(EmbedEntityWidget, {
|
|
7382
7454
|
isDisabled: isDisabled,
|
|
7383
7455
|
canInsertBlocks: canInsertBlocks
|
|
@@ -7402,7 +7474,7 @@ function getValidationInfo(field) {
|
|
|
7402
7474
|
}
|
|
7403
7475
|
|
|
7404
7476
|
var _templateObject$b;
|
|
7405
|
-
var styles$
|
|
7477
|
+
var styles$l = {
|
|
7406
7478
|
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 "])))
|
|
7407
7479
|
};
|
|
7408
7480
|
|
|
@@ -7410,7 +7482,7 @@ var StickyToolbarWrapper = function StickyToolbarWrapper(_ref) {
|
|
|
7410
7482
|
var isDisabled = _ref.isDisabled,
|
|
7411
7483
|
children = _ref.children;
|
|
7412
7484
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
7413
|
-
className: isDisabled ? '' : styles$
|
|
7485
|
+
className: isDisabled ? '' : styles$l.nativeSticky
|
|
7414
7486
|
}, children);
|
|
7415
7487
|
};
|
|
7416
7488
|
|
|
@@ -7523,9 +7595,9 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
7523
7595
|
setPendingExternalUpdate(true);
|
|
7524
7596
|
setEditorContent(editor, documentToEditorValue(props.value));
|
|
7525
7597
|
}, [props.value, id]);
|
|
7526
|
-
var classNames = emotion.cx(styles$
|
|
7598
|
+
var classNames = emotion.cx(styles$j.editor, props.minHeight !== undefined ? emotion.css({
|
|
7527
7599
|
minHeight: props.minHeight
|
|
7528
|
-
}) : undefined, props.isDisabled ? styles$
|
|
7600
|
+
}) : undefined, props.isDisabled ? styles$j.disabled : styles$j.enabled, props.isToolbarHidden && styles$j.hiddenToolbar);
|
|
7529
7601
|
React.useEffect(function () {
|
|
7530
7602
|
if (!isFirstRender) {
|
|
7531
7603
|
return;
|
|
@@ -7541,7 +7613,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
|
|
|
7541
7613
|
}, /*#__PURE__*/React__default.createElement(ContentfulEditorIdProvider, {
|
|
7542
7614
|
value: id
|
|
7543
7615
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
7544
|
-
className: styles$
|
|
7616
|
+
className: styles$j.root,
|
|
7545
7617
|
"data-test-id": "rich-text-editor"
|
|
7546
7618
|
}, /*#__PURE__*/React__default.createElement(plateCore.Plate, {
|
|
7547
7619
|
id: id,
|