@contentful/field-editor-rich-text 3.1.11 → 3.2.0
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 +10 -0
- package/dist/field-editor-rich-text.cjs.development.js +78 -22
- 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 +80 -24
- 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 +4 -4
|
@@ -20,10 +20,10 @@ import find from 'lodash-es/find';
|
|
|
20
20
|
import flow from 'lodash-es/flow';
|
|
21
21
|
import get from 'lodash-es/get';
|
|
22
22
|
import tokens from '@contentful/f36-tokens';
|
|
23
|
-
import { AssetIcon, EmbeddedEntryBlockIcon, ClockIcon, EmbeddedEntryInlineIcon, ChevronDownIcon, HorizontalRuleIcon, LinkIcon, ListBulletedIcon, ListNumberedIcon, FormatBoldIcon, CodeIcon, FormatItalicIcon, FormatUnderlinedIcon, QuoteIcon, TableIcon, PlusIcon } from '@contentful/f36-icons';
|
|
23
|
+
import { AssetIcon, EmbeddedEntryBlockIcon, ClockIcon, EmbeddedEntryInlineIcon, ChevronDownIcon, HorizontalRuleIcon, LinkIcon, ListBulletedIcon, ListNumberedIcon, FormatBoldIcon, CodeIcon, FormatItalicIcon, FormatUnderlinedIcon, SuperscriptIcon, SubscriptIcon, QuoteIcon, TableIcon, PlusIcon } from '@contentful/f36-icons';
|
|
24
24
|
import { getListTypes, ELEMENT_LIC, getListItemEntry, isListNested, moveListItemUp, ELEMENT_LI, unwrapList as unwrapList$1, removeFirstListItem, removeListItem, deleteForwardList, deleteFragmentList, normalizeList, createListPlugin as createListPlugin$1, ELEMENT_UL, ELEMENT_OL } from '@udecode/plate-list';
|
|
25
25
|
import castArray from 'lodash-es/castArray';
|
|
26
|
-
import { createBoldPlugin as createBoldPlugin$1, createCodePlugin as createCodePlugin$1, createItalicPlugin as createItalicPlugin$1, createUnderlinePlugin as createUnderlinePlugin$1 } from '@udecode/plate-basic-marks';
|
|
26
|
+
import { createBoldPlugin as createBoldPlugin$1, createCodePlugin as createCodePlugin$1, createItalicPlugin as createItalicPlugin$1, createUnderlinePlugin as createUnderlinePlugin$1, createSuperscriptPlugin as createSuperscriptPlugin$1, createSubscriptPlugin as createSubscriptPlugin$1 } from '@udecode/plate-basic-marks';
|
|
27
27
|
import isPlainObject from 'is-plain-obj';
|
|
28
28
|
import { createParagraphPlugin as createParagraphPlugin$1 } from '@udecode/plate-paragraph';
|
|
29
29
|
import { createSelectOnBackspacePlugin as createSelectOnBackspacePlugin$1 } from '@udecode/plate-select';
|
|
@@ -5089,6 +5089,30 @@ function ToolbarListButton(props) {
|
|
|
5089
5089
|
}, /*#__PURE__*/createElement(ListNumberedIcon, null)));
|
|
5090
5090
|
}
|
|
5091
5091
|
|
|
5092
|
+
var toggleMarkAndDeactivateConflictingMarks = function toggleMarkAndDeactivateConflictingMarks(editor, mark) {
|
|
5093
|
+
var subs = [MARKS.SUPERSCRIPT, MARKS.SUBSCRIPT];
|
|
5094
|
+
var clear = subs.includes(mark) ? subs : [];
|
|
5095
|
+
toggleMark(editor, {
|
|
5096
|
+
key: mark,
|
|
5097
|
+
clear: clear
|
|
5098
|
+
});
|
|
5099
|
+
};
|
|
5100
|
+
var buildMarkEventHandler = function buildMarkEventHandler(type) {
|
|
5101
|
+
return function (editor, _ref) {
|
|
5102
|
+
var hotkey = _ref.options.hotkey;
|
|
5103
|
+
return function (event) {
|
|
5104
|
+
if (editor.selection && hotkey && isHotkey(hotkey, event)) {
|
|
5105
|
+
event.preventDefault();
|
|
5106
|
+
var isActive = isMarkActive(editor, type);
|
|
5107
|
+
editor.tracking.onShortcutAction(isActive ? 'unmark' : 'mark', {
|
|
5108
|
+
markType: type
|
|
5109
|
+
});
|
|
5110
|
+
toggleMarkAndDeactivateConflictingMarks(editor, type);
|
|
5111
|
+
}
|
|
5112
|
+
};
|
|
5113
|
+
};
|
|
5114
|
+
};
|
|
5115
|
+
|
|
5092
5116
|
var createMarkToolbarButton = function createMarkToolbarButton(_ref) {
|
|
5093
5117
|
var mark = _ref.mark,
|
|
5094
5118
|
title = _ref.title,
|
|
@@ -5103,9 +5127,7 @@ var createMarkToolbarButton = function createMarkToolbarButton(_ref) {
|
|
|
5103
5127
|
editor.tracking.onToolbarAction(isActive ? 'unmark' : 'mark', {
|
|
5104
5128
|
markType: mark
|
|
5105
5129
|
});
|
|
5106
|
-
|
|
5107
|
-
key: mark
|
|
5108
|
-
});
|
|
5130
|
+
toggleMarkAndDeactivateConflictingMarks(editor, mark);
|
|
5109
5131
|
focus(editor);
|
|
5110
5132
|
}, [editor]);
|
|
5111
5133
|
if (!editor) return null;
|
|
@@ -5122,24 +5144,6 @@ var createMarkToolbarButton = function createMarkToolbarButton(_ref) {
|
|
|
5122
5144
|
return Mark;
|
|
5123
5145
|
};
|
|
5124
5146
|
|
|
5125
|
-
var buildMarkEventHandler = function buildMarkEventHandler(type) {
|
|
5126
|
-
return function (editor, _ref) {
|
|
5127
|
-
var hotkey = _ref.options.hotkey;
|
|
5128
|
-
return function (event) {
|
|
5129
|
-
if (editor.selection && hotkey && isHotkey(hotkey, event)) {
|
|
5130
|
-
event.preventDefault();
|
|
5131
|
-
var isActive = isMarkActive(editor, type);
|
|
5132
|
-
editor.tracking.onShortcutAction(isActive ? 'unmark' : 'mark', {
|
|
5133
|
-
markType: type
|
|
5134
|
-
});
|
|
5135
|
-
toggleMark(editor, {
|
|
5136
|
-
key: type
|
|
5137
|
-
});
|
|
5138
|
-
}
|
|
5139
|
-
};
|
|
5140
|
-
};
|
|
5141
|
-
};
|
|
5142
|
-
|
|
5143
5147
|
var ToolbarBoldButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5144
5148
|
title: 'Bold',
|
|
5145
5149
|
mark: MARKS.BOLD,
|
|
@@ -5302,10 +5306,58 @@ var createUnderlinePlugin = function createUnderlinePlugin() {
|
|
|
5302
5306
|
});
|
|
5303
5307
|
};
|
|
5304
5308
|
|
|
5309
|
+
var ToolbarSuperscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5310
|
+
title: 'Superscript',
|
|
5311
|
+
mark: MARKS.SUPERSCRIPT,
|
|
5312
|
+
icon: /*#__PURE__*/createElement(SuperscriptIcon, null)
|
|
5313
|
+
});
|
|
5314
|
+
function Superscript(props) {
|
|
5315
|
+
return /*#__PURE__*/createElement("sup", _extends({}, props.attributes), props.children);
|
|
5316
|
+
}
|
|
5317
|
+
var createSuperscriptPlugin = function createSuperscriptPlugin() {
|
|
5318
|
+
return createSuperscriptPlugin$1({
|
|
5319
|
+
type: MARKS.SUPERSCRIPT,
|
|
5320
|
+
component: Superscript,
|
|
5321
|
+
handlers: {
|
|
5322
|
+
onKeyDown: buildMarkEventHandler(MARKS.SUPERSCRIPT)
|
|
5323
|
+
},
|
|
5324
|
+
deserializeHtml: {
|
|
5325
|
+
rules: [{
|
|
5326
|
+
validNodeName: ['SUP']
|
|
5327
|
+
}]
|
|
5328
|
+
}
|
|
5329
|
+
});
|
|
5330
|
+
};
|
|
5331
|
+
|
|
5332
|
+
var ToolbarSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
|
|
5333
|
+
title: 'Subscript',
|
|
5334
|
+
mark: MARKS.SUBSCRIPT,
|
|
5335
|
+
icon: /*#__PURE__*/createElement(SubscriptIcon, {
|
|
5336
|
+
viewBox: "0 0 23 18"
|
|
5337
|
+
})
|
|
5338
|
+
});
|
|
5339
|
+
function Subscript(props) {
|
|
5340
|
+
return /*#__PURE__*/createElement("sub", _extends({}, props.attributes), props.children);
|
|
5341
|
+
}
|
|
5342
|
+
var createSubscriptPlugin = function createSubscriptPlugin() {
|
|
5343
|
+
return createSubscriptPlugin$1({
|
|
5344
|
+
type: MARKS.SUBSCRIPT,
|
|
5345
|
+
component: Subscript,
|
|
5346
|
+
handlers: {
|
|
5347
|
+
onKeyDown: buildMarkEventHandler(MARKS.SUBSCRIPT)
|
|
5348
|
+
},
|
|
5349
|
+
deserializeHtml: {
|
|
5350
|
+
rules: [{
|
|
5351
|
+
validNodeName: ['SUB']
|
|
5352
|
+
}]
|
|
5353
|
+
}
|
|
5354
|
+
});
|
|
5355
|
+
};
|
|
5356
|
+
|
|
5305
5357
|
var createMarksPlugin = function createMarksPlugin() {
|
|
5306
5358
|
return {
|
|
5307
5359
|
key: 'Marks',
|
|
5308
|
-
plugins: [createBoldPlugin(), createCodePlugin(), createItalicPlugin(), createUnderlinePlugin()]
|
|
5360
|
+
plugins: [createBoldPlugin(), createCodePlugin(), createItalicPlugin(), createUnderlinePlugin(), createSuperscriptPlugin(), createSubscriptPlugin()]
|
|
5309
5361
|
};
|
|
5310
5362
|
};
|
|
5311
5363
|
|
|
@@ -7351,6 +7403,10 @@ var Toolbar = function Toolbar(_ref) {
|
|
|
7351
7403
|
isDisabled: isDisabled
|
|
7352
7404
|
}), isMarkEnabled(sdk.field, MARKS.ITALIC) && /*#__PURE__*/React__default.createElement(ToolbarItalicButton, {
|
|
7353
7405
|
isDisabled: isDisabled
|
|
7406
|
+
}), isMarkEnabled(sdk.field, MARKS.SUPERSCRIPT) && /*#__PURE__*/React__default.createElement(ToolbarSuperscriptButton, {
|
|
7407
|
+
isDisabled: isDisabled
|
|
7408
|
+
}), isMarkEnabled(sdk.field, MARKS.SUBSCRIPT) && /*#__PURE__*/React__default.createElement(ToolbarSubscriptButton, {
|
|
7409
|
+
isDisabled: isDisabled
|
|
7354
7410
|
}), isMarkEnabled(sdk.field, MARKS.UNDERLINE) && /*#__PURE__*/React__default.createElement(ToolbarUnderlineButton, {
|
|
7355
7411
|
isDisabled: isDisabled
|
|
7356
7412
|
}), isMarkEnabled(sdk.field, MARKS.CODE) && /*#__PURE__*/React__default.createElement(ToolbarCodeButton, {
|