@modusoperandi/licit 0.1.9 → 0.13.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/.github/workflows/build.yml +1 -7
- package/.github/workflows/lint.yml +1 -1
- package/README.md +1 -1
- package/babel.config.json +54 -0
- package/dist/BlockquoteNodeSpec.js +2 -2
- package/dist/CZIProseMirror.js +4 -4
- package/dist/CodeBlockCommand.js +2 -2
- package/dist/CodeBlockCommand.js.flow +1 -1
- package/dist/CursorPlaceholderPlugin.js +2 -2
- package/dist/DocLayoutCommand.js +2 -4
- package/dist/DocLayoutCommand.js.flow +1 -1
- package/dist/DocNodeSpec.js +1 -1
- package/dist/EditorCommands.js +23 -35
- package/dist/EditorCommands.js.flow +7 -7
- package/dist/EditorKeyMap.js +3 -3
- package/dist/FontTypeMarkSpec.js +1 -1
- package/dist/HeadingNodeSpec.js +2 -2
- package/dist/ImageSourceCommand.js +2 -4
- package/dist/ImageSourceCommand.js.flow +1 -1
- package/dist/ImageUploadPlaceholderPlugin.js +1 -1
- package/dist/LinkSetURLCommand.js +4 -8
- package/dist/LinkSetURLCommand.js.flow +3 -3
- package/dist/LinkTooltipPlugin.js +9 -15
- package/dist/LinkTooltipPlugin.js.flow +5 -5
- package/dist/ListToggleCommand.js +5 -11
- package/dist/ListToggleCommand.js.flow +3 -3
- package/dist/MarkNames.js +1 -1
- package/dist/MarksClearCommand.js +3 -3
- package/dist/MarksClearCommand.js.flow +1 -1
- package/dist/MathEditCommand.js +2 -2
- package/dist/MathEditCommand.js.flow +1 -1
- package/dist/ParagraphNodeSpec.js +3 -4
- package/dist/ParagraphNodeSpec.js.flow +2 -6
- package/dist/ParagraphSpacingCommand.js +3 -3
- package/dist/SelectionPlaceholderPlugin.js +2 -2
- package/dist/SpacerMarkSpec.js +1 -1
- package/dist/TableBackgroundColorCommand.js +3 -7
- package/dist/TableBackgroundColorCommand.js.flow +3 -3
- package/dist/TableBorderColorCommand.js +3 -7
- package/dist/TableBorderColorCommand.js.flow +3 -3
- package/dist/TableCellColorCommand.js +3 -7
- package/dist/TableCellColorCommand.js.flow +3 -3
- package/dist/TableCellMenuPlugin.js +4 -6
- package/dist/TableCellMenuPlugin.js.flow +3 -3
- package/dist/TableInsertCommand.js +3 -5
- package/dist/TableInsertCommand.js.flow +2 -2
- package/dist/TableResizePlugin.js +2 -2
- package/dist/TextInsertTabSpaceCommand.js +2 -4
- package/dist/TextInsertTabSpaceCommand.js.flow +1 -1
- package/dist/Types.js +1 -1
- package/dist/bom.xml +4970 -4167
- package/dist/client/CollabConnector.js +17 -2
- package/dist/client/CollabConnector.js.flow +17 -2
- package/dist/client/EditorConnection.js +15 -4
- package/dist/client/EditorConnection.js.flow +14 -3
- package/dist/client/Licit.js +73 -58
- package/dist/client/Licit.js.flow +101 -85
- package/dist/client/Licit.test.js +18 -17
- package/dist/client/Licit.test.js.flow +13 -11
- package/dist/client/SimpleConnector.js +4 -2
- package/dist/client/SimpleConnector.js.flow +3 -1
- package/dist/client/http.js +3 -3
- package/dist/convertToCSSPTValue.js +1 -1
- package/dist/createEmptyEditorState.js +1 -1
- package/dist/index.js +16 -16
- package/dist/joinListNode.js +2 -2
- package/dist/joinListNode.js.flow +1 -1
- package/dist/keymaps.js +2 -2
- package/dist/patchStyleElements.js +3 -3
- package/dist/patchStyleElements.js.flow +1 -1
- package/dist/splitListItem.js +2 -2
- package/dist/styles.css +2 -2
- package/dist/styles0.css +3 -3
- package/dist/toggleBlockquote.js +6 -14
- package/dist/toggleBlockquote.js.flow +4 -4
- package/dist/toggleCodeBlock.js +4 -10
- package/dist/toggleCodeBlock.js.flow +3 -3
- package/dist/ui/AlertInfo.js +2 -2
- package/dist/ui/CommandButton.js +2 -4
- package/dist/ui/CommandButton.js.flow +1 -1
- package/dist/ui/CommandMenuButton.js +5 -7
- package/dist/ui/CommandMenuButton.js.flow +2 -2
- package/dist/ui/CustomMenuItem.js +3 -5
- package/dist/ui/CustomMenuItem.js.flow +1 -1
- package/dist/ui/CustomNodeView.js +3 -3
- package/dist/ui/CustomRadioButton.js +8 -6
- package/dist/ui/CustomRadioButton.js.flow +3 -3
- package/dist/ui/DocLayoutEditor.js +5 -7
- package/dist/ui/DocLayoutEditor.js.flow +2 -2
- package/dist/ui/Editor.js +1 -2
- package/dist/ui/Editor.js.flow +1 -2
- package/dist/ui/EditorFrameset.js +1 -1
- package/dist/ui/EditorToolbar.js +4 -4
- package/dist/ui/EditorToolbar.js.flow +1 -1
- package/dist/ui/EditorToolbarConfig.js +1 -1
- package/dist/ui/FontSizeCommandMenuButton.js +3 -3
- package/dist/ui/FontSizeCommandMenuButton.js.flow +1 -1
- package/dist/ui/FontTypeCommandMenuButton.js +3 -3
- package/dist/ui/FontTypeCommandMenuButton.js.flow +1 -1
- package/dist/ui/ImageAlignEditor.js +5 -5
- package/dist/ui/ImageAlignEditor.js.flow +1 -1
- package/dist/ui/ImageInlineEditor.js +5 -5
- package/dist/ui/ImageInlineEditor.js.flow +1 -1
- package/dist/ui/ImageNodeView.js +5 -7
- package/dist/ui/ImageNodeView.js.flow +2 -2
- package/dist/ui/ImageResizeBox.js +4 -4
- package/dist/ui/ImageResizeBox.js.flow +1 -1
- package/dist/ui/ImageURLEditor.js +6 -8
- package/dist/ui/ImageURLEditor.js.flow +2 -2
- package/dist/ui/ImageUploadEditor.js +3 -5
- package/dist/ui/ImageUploadEditor.js.flow +2 -2
- package/dist/ui/LinkTooltip.js +4 -4
- package/dist/ui/LinkTooltip.js.flow +1 -1
- package/dist/ui/LinkURLEditor.js +4 -6
- package/dist/ui/LinkURLEditor.js.flow +2 -2
- package/dist/ui/ListTypeButton.js +5 -7
- package/dist/ui/ListTypeButton.js.flow +2 -2
- package/dist/ui/MathEditor.js +4 -6
- package/dist/ui/MathEditor.js.flow +2 -2
- package/dist/ui/MathInlineEditor.js +7 -9
- package/dist/ui/MathInlineEditor.js.flow +2 -2
- package/dist/ui/MathNodeView.js +5 -7
- package/dist/ui/MathNodeView.js.flow +2 -2
- package/dist/ui/ResizeObserver.js +1 -1
- package/dist/ui/TableGridSizeEditor.js +7 -9
- package/dist/ui/TableGridSizeEditor.js.flow +2 -2
- package/dist/ui/czi-link-tooltip.css +1 -1
- package/dist/ui/czi-vars.css +1 -45
- package/dist/ui/findActiveFontType.js +1 -1
- package/dist/ui/htmlElementToRect.js +1 -1
- package/dist/ui/isElementFullyVisible.js +2 -2
- package/dist/ui/isElementFullyVisible.js.flow +1 -1
- package/dist/ui/mathquill-editor/MathQuillEditorSymbols.js +1 -1
- package/dist/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +2 -2
- package/dist/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js.flow +1 -1
- package/dist/ui/resolveImage.js +3 -3
- package/dist/ui/toCSSColor.js +1 -1
- package/dist/ui/toCSSLineSpacing.js +1 -36
- package/dist/ui/toCSSLineSpacing.js.flow +0 -27
- package/flow-typed/@modusoperandilicit-ui-commands.js +5 -0
- package/jest.config.js +207 -0
- package/lint.sh +0 -0
- package/node_modules/prosemirror-utils/LICENSE +13 -0
- package/{dist/ui/PopUpTypes.js.flow → node_modules/prosemirror-utils/README.md} +0 -0
- package/node_modules/prosemirror-utils/dist/helpers.js +119 -0
- package/node_modules/prosemirror-utils/dist/index.js +17 -0
- package/node_modules/prosemirror-utils/dist/index.js.map +1 -0
- package/node_modules/prosemirror-utils/dist/node.js +106 -0
- package/node_modules/prosemirror-utils/dist/selection.js +168 -0
- package/node_modules/prosemirror-utils/dist/transforms.js +257 -0
- package/node_modules/prosemirror-utils/package.json +81 -0
- package/node_modules/prosemirror-utils/typings.d.ts +79 -0
- package/package.json +14 -8
- package/scripts/build_bin.py +0 -0
- package/scripts/ci_check_dist.sh +0 -0
- package/src/CodeBlockCommand.js +1 -1
- package/src/DocLayoutCommand.js +1 -1
- package/src/EditorCommands.js +7 -7
- package/src/ImageSourceCommand.js +1 -1
- package/src/LinkSetURLCommand.js +3 -3
- package/src/LinkTooltipPlugin.js +5 -5
- package/src/ListToggleCommand.js +3 -3
- package/src/MarksClearCommand.js +1 -1
- package/src/MathEditCommand.js +1 -1
- package/src/ParagraphNodeSpec.js +2 -6
- package/src/TableBackgroundColorCommand.js +3 -3
- package/src/TableBorderColorCommand.js +3 -3
- package/src/TableCellColorCommand.js +3 -3
- package/src/TableCellMenuPlugin.js +3 -3
- package/src/TableInsertCommand.js +2 -2
- package/src/TextInsertTabSpaceCommand.js +1 -1
- package/src/client/CollabConnector.js +17 -2
- package/src/client/EditorConnection.js +14 -3
- package/src/client/Licit.js +101 -85
- package/src/client/Licit.test.js +13 -11
- package/src/client/SimpleConnector.js +3 -1
- package/src/joinListNode.js +1 -1
- package/src/patchStyleElements.js +1 -1
- package/src/styles.css +2 -2
- package/src/styles0.css +3 -3
- package/src/toggleBlockquote.js +4 -4
- package/src/toggleCodeBlock.js +3 -3
- package/src/ui/CommandButton.js +1 -1
- package/src/ui/CommandMenuButton.js +2 -2
- package/src/ui/CustomMenuItem.js +1 -1
- package/src/ui/CustomRadioButton.js +3 -3
- package/src/ui/DocLayoutEditor.js +2 -2
- package/src/ui/Editor.js +1 -2
- package/src/ui/EditorToolbar.js +1 -1
- package/src/ui/FontSizeCommandMenuButton.js +1 -1
- package/src/ui/FontTypeCommandMenuButton.js +1 -1
- package/src/ui/ImageAlignEditor.js +1 -1
- package/src/ui/ImageInlineEditor.js +1 -1
- package/src/ui/ImageNodeView.js +2 -2
- package/src/ui/ImageResizeBox.js +1 -1
- package/src/ui/ImageURLEditor.js +2 -2
- package/src/ui/ImageUploadEditor.js +2 -2
- package/src/ui/LinkTooltip.js +1 -1
- package/src/ui/LinkURLEditor.js +2 -2
- package/src/ui/ListTypeButton.js +2 -2
- package/src/ui/MathEditor.js +2 -2
- package/src/ui/MathInlineEditor.js +2 -2
- package/src/ui/MathNodeView.js +2 -2
- package/src/ui/TableGridSizeEditor.js +2 -2
- package/src/ui/czi-link-tooltip.css +1 -1
- package/src/ui/czi-vars.css +1 -45
- package/src/ui/isElementFullyVisible.js +1 -1
- package/src/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +1 -1
- package/src/ui/toCSSLineSpacing.js +0 -27
- package/build_customstyle_server.py +0 -7
- package/dist/FontSizeCommand.js +0 -80
- package/dist/FontSizeCommand.js.flow +0 -57
- package/dist/FontTypeCommand.js +0 -137
- package/dist/FontTypeCommand.js.flow +0 -100
- package/dist/HeadingCommand.js +0 -65
- package/dist/HeadingCommand.js.flow +0 -51
- package/dist/IndentCommand.js +0 -57
- package/dist/IndentCommand.js.flow +0 -41
- package/dist/MarkToggleCommand.js +0 -90
- package/dist/MarkToggleCommand.js.flow +0 -66
- package/dist/TextAlignCommand.js +0 -151
- package/dist/TextAlignCommand.js.flow +0 -122
- package/dist/TextColorCommand.js +0 -114
- package/dist/TextColorCommand.js.flow +0 -87
- package/dist/TextHighlightCommand.js +0 -118
- package/dist/TextHighlightCommand.js.flow +0 -91
- package/dist/TextLineSpacingCommand.js +0 -177
- package/dist/TextLineSpacingCommand.js.flow +0 -157
- package/dist/applyMark.js +0 -84
- package/dist/applyMark.js.flow +0 -61
- package/dist/clearMarks.js +0 -160
- package/dist/clearMarks.js.flow +0 -128
- package/dist/compareNumber.js +0 -18
- package/dist/compareNumber.js.flow +0 -11
- package/dist/consolidateListNodes.js +0 -291
- package/dist/consolidateListNodes.js.flow +0 -281
- package/dist/coverage/lcov-report/block-navigation.js +0 -77
- package/dist/coverage/lcov-report/block-navigation.js.flow +0 -79
- package/dist/coverage/lcov-report/prettify.js +0 -994
- package/dist/coverage/lcov-report/prettify.js.flow +0 -2
- package/dist/coverage/lcov-report/sorter.js +0 -187
- package/dist/coverage/lcov-report/sorter.js.flow +0 -170
- package/dist/findNodesWithSameMark.js +0 -89
- package/dist/findNodesWithSameMark.js.flow +0 -89
- package/dist/isBulletListNode.js +0 -14
- package/dist/isBulletListNode.js.flow +0 -9
- package/dist/isInsideListItem.js +0 -19
- package/dist/isInsideListItem.js.flow +0 -13
- package/dist/isListNode.js +0 -22
- package/dist/isListNode.js.flow +0 -13
- package/dist/isNodeSelectionForNodeType.js +0 -19
- package/dist/isNodeSelectionForNodeType.js.flow +0 -15
- package/dist/isOrderedListNode.js +0 -14
- package/dist/isOrderedListNode.js.flow +0 -9
- package/dist/isTextStyleMarkCommandEnabled.js +0 -59
- package/dist/isTextStyleMarkCommandEnabled.js.flow +0 -49
- package/dist/noop.js +0 -11
- package/dist/noop.js.flow +0 -5
- package/dist/toggleHeading.js +0 -135
- package/dist/toggleHeading.js.flow +0 -113
- package/dist/toggleList.js +0 -431
- package/dist/toggleList.js.flow +0 -450
- package/dist/transformAndPreserveTextSelection.js +0 -173
- package/dist/transformAndPreserveTextSelection.js.flow +0 -151
- package/dist/ui/ColorEditor.js +0 -118
- package/dist/ui/ColorEditor.js.flow +0 -101
- package/dist/ui/CustomButton.js +0 -62
- package/dist/ui/CustomButton.js.flow +0 -33
- package/dist/ui/PointerSurface.js +0 -173
- package/dist/ui/PointerSurface.js.flow +0 -141
- package/dist/ui/PopUp.js +0 -129
- package/dist/ui/PopUp.js.flow +0 -77
- package/dist/ui/PopUpManager.js +0 -266
- package/dist/ui/PopUpManager.js.flow +0 -213
- package/dist/ui/PopUpPosition.js +0 -156
- package/dist/ui/PopUpPosition.js.flow +0 -104
- package/dist/ui/PopUpTypes.js +0 -1
- package/dist/ui/TooltipSurface.js +0 -99
- package/dist/ui/TooltipSurface.js.flow +0 -76
- package/dist/ui/clamp.js +0 -18
- package/dist/ui/clamp.js.flow +0 -11
- package/dist/ui/createPopUp.js +0 -199
- package/dist/ui/createPopUp.js.flow +0 -205
- package/dist/ui/czi-animations.css +0 -15
- package/dist/ui/czi-color-editor.css +0 -56
- package/dist/ui/czi-custom-button.css +0 -93
- package/dist/ui/czi-pop-up.css +0 -32
- package/dist/ui/czi-tooltip-surface.css +0 -45
- package/dist/ui/preventEventDefault.js +0 -10
- package/dist/ui/preventEventDefault.js.flow +0 -5
- package/dist/ui/rects.js +0 -58
- package/dist/ui/rects.js.flow +0 -47
- package/dist/updateIndentLevel.js +0 -232
- package/dist/updateIndentLevel.js.flow +0 -211
- package/flow-typed/@molicit-citation.js +0 -5
- package/licit/server/customstyles/start.js +0 -184
- package/run_customstyle_server.py +0 -20
- package/src/FontSizeCommand.js +0 -57
- package/src/FontTypeCommand.js +0 -100
- package/src/HeadingCommand.js +0 -51
- package/src/IndentCommand.js +0 -41
- package/src/MarkToggleCommand.js +0 -66
- package/src/TextAlignCommand.js +0 -122
- package/src/TextColorCommand.js +0 -87
- package/src/TextHighlightCommand.js +0 -91
- package/src/TextLineSpacingCommand.js +0 -157
- package/src/applyMark.js +0 -61
- package/src/clearMarks.js +0 -128
- package/src/compareNumber.js +0 -11
- package/src/consolidateListNodes.js +0 -281
- package/src/findNodesWithSameMark.js +0 -89
- package/src/isBulletListNode.js +0 -9
- package/src/isInsideListItem.js +0 -13
- package/src/isListNode.js +0 -13
- package/src/isNodeSelectionForNodeType.js +0 -15
- package/src/isOrderedListNode.js +0 -9
- package/src/isTextStyleMarkCommandEnabled.js +0 -49
- package/src/noop.js +0 -5
- package/src/toggleHeading.js +0 -113
- package/src/toggleList.js +0 -450
- package/src/transformAndPreserveTextSelection.js +0 -151
- package/src/ui/ColorEditor.js +0 -101
- package/src/ui/CustomButton.js +0 -33
- package/src/ui/PointerSurface.js +0 -141
- package/src/ui/PopUp.js +0 -77
- package/src/ui/PopUpManager.js +0 -213
- package/src/ui/PopUpPosition.js +0 -104
- package/src/ui/PopUpTypes.js +0 -0
- package/src/ui/TooltipSurface.js +0 -76
- package/src/ui/clamp.js +0 -11
- package/src/ui/createPopUp.js +0 -205
- package/src/ui/czi-animations.css +0 -15
- package/src/ui/czi-color-editor.css +0 -56
- package/src/ui/czi-custom-button.css +0 -93
- package/src/ui/czi-pop-up.css +0 -32
- package/src/ui/czi-tooltip-surface.css +0 -45
- package/src/ui/preventEventDefault.js +0 -5
- package/src/ui/rects.js +0 -47
- package/src/updateIndentLevel.js +0 -211
- package/utils/build_customstyle_server.js +0 -72
package/dist/ui/resolveImage.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = resolveImage;
|
|
7
6
|
exports.bpfrpt_proptype_ImageResult = void 0;
|
|
7
|
+
exports.default = resolveImage;
|
|
8
8
|
|
|
9
9
|
var _url = _interopRequireDefault(require("url"));
|
|
10
10
|
|
|
@@ -14,9 +14,9 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
|
|
17
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
17
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
18
|
|
|
19
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
19
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
20
|
|
|
21
21
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
22
|
|
package/dist/ui/toCSSColor.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.default = void 0;
|
|
6
7
|
exports.isTransparent = isTransparent;
|
|
7
8
|
exports.toCSSColor = toCSSColor;
|
|
8
|
-
exports.default = void 0;
|
|
9
9
|
|
|
10
10
|
var _color = _interopRequireDefault(require("color"));
|
|
11
11
|
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.LINE_SPACING_200 = exports.LINE_SPACING_150 = exports.LINE_SPACING_115 = exports.LINE_SPACING_100 = void 0;
|
|
6
7
|
exports.default = toCSSLineSpacing;
|
|
7
|
-
exports.getLineSpacingValue = getLineSpacingValue;
|
|
8
|
-
exports.DOUBLE_LINE_SPACING = exports.SINGLE_LINE_SPACING = exports.LINE_SPACING_200 = exports.LINE_SPACING_150 = exports.LINE_SPACING_115 = exports.LINE_SPACING_100 = void 0;
|
|
9
8
|
// Line spacing names and their values.
|
|
10
9
|
const LINE_SPACING_100 = '125%';
|
|
11
10
|
exports.LINE_SPACING_100 = LINE_SPACING_100;
|
|
@@ -15,10 +14,6 @@ const LINE_SPACING_150 = '165%';
|
|
|
15
14
|
exports.LINE_SPACING_150 = LINE_SPACING_150;
|
|
16
15
|
const LINE_SPACING_200 = '232%';
|
|
17
16
|
exports.LINE_SPACING_200 = LINE_SPACING_200;
|
|
18
|
-
const SINGLE_LINE_SPACING = LINE_SPACING_100;
|
|
19
|
-
exports.SINGLE_LINE_SPACING = SINGLE_LINE_SPACING;
|
|
20
|
-
const DOUBLE_LINE_SPACING = LINE_SPACING_200;
|
|
21
|
-
exports.DOUBLE_LINE_SPACING = DOUBLE_LINE_SPACING;
|
|
22
17
|
const NUMBER_VALUE_PATTERN = /^\d+(.\d+)?$/; // Normalize the css line-height vlaue to percentage-based value if applicable.
|
|
23
18
|
// Also, it calibrates the incorrect line spacing value exported from Google
|
|
24
19
|
// Doc.
|
|
@@ -62,34 +57,4 @@ function toCSSLineSpacing(source) {
|
|
|
62
57
|
|
|
63
58
|
|
|
64
59
|
return strValue;
|
|
65
|
-
} // [FS] IRAD-1104 2020-11-13
|
|
66
|
-
// Issue fix : Linespacing Double and Single not applied in the sample text paragraph
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
function getLineSpacingValue(lineSpacing) {
|
|
70
|
-
let _lineSpaceValue = '';
|
|
71
|
-
|
|
72
|
-
switch (lineSpacing) {
|
|
73
|
-
case 'Single':
|
|
74
|
-
_lineSpaceValue = SINGLE_LINE_SPACING;
|
|
75
|
-
break;
|
|
76
|
-
|
|
77
|
-
case '1.15':
|
|
78
|
-
_lineSpaceValue = LINE_SPACING_115;
|
|
79
|
-
break;
|
|
80
|
-
|
|
81
|
-
case '1.5':
|
|
82
|
-
_lineSpaceValue = LINE_SPACING_150;
|
|
83
|
-
break;
|
|
84
|
-
|
|
85
|
-
case 'Double':
|
|
86
|
-
_lineSpaceValue = DOUBLE_LINE_SPACING;
|
|
87
|
-
break;
|
|
88
|
-
|
|
89
|
-
default:
|
|
90
|
-
_lineSpaceValue = SINGLE_LINE_SPACING;
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return _lineSpaceValue;
|
|
95
60
|
}
|
|
@@ -6,9 +6,6 @@ export const LINE_SPACING_115 = '138%';
|
|
|
6
6
|
export const LINE_SPACING_150 = '165%';
|
|
7
7
|
export const LINE_SPACING_200 = '232%';
|
|
8
8
|
|
|
9
|
-
export const SINGLE_LINE_SPACING = LINE_SPACING_100;
|
|
10
|
-
export const DOUBLE_LINE_SPACING = LINE_SPACING_200;
|
|
11
|
-
|
|
12
9
|
const NUMBER_VALUE_PATTERN = /^\d+(.\d+)?$/;
|
|
13
10
|
|
|
14
11
|
// Normalize the css line-height vlaue to percentage-based value if applicable.
|
|
@@ -56,27 +53,3 @@ export default function toCSSLineSpacing(source: any): string {
|
|
|
56
53
|
// e.g. line-height: 15px;
|
|
57
54
|
return strValue;
|
|
58
55
|
}
|
|
59
|
-
|
|
60
|
-
// [FS] IRAD-1104 2020-11-13
|
|
61
|
-
// Issue fix : Linespacing Double and Single not applied in the sample text paragraph
|
|
62
|
-
export function getLineSpacingValue(lineSpacing: string): string {
|
|
63
|
-
let _lineSpaceValue = '';
|
|
64
|
-
switch (lineSpacing) {
|
|
65
|
-
case 'Single':
|
|
66
|
-
_lineSpaceValue = SINGLE_LINE_SPACING;
|
|
67
|
-
break;
|
|
68
|
-
case '1.15':
|
|
69
|
-
_lineSpaceValue = LINE_SPACING_115;
|
|
70
|
-
break;
|
|
71
|
-
case '1.5':
|
|
72
|
-
_lineSpaceValue = LINE_SPACING_150;
|
|
73
|
-
break;
|
|
74
|
-
case 'Double':
|
|
75
|
-
_lineSpaceValue = DOUBLE_LINE_SPACING;
|
|
76
|
-
break;
|
|
77
|
-
default:
|
|
78
|
-
_lineSpaceValue = SINGLE_LINE_SPACING;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
return _lineSpaceValue;
|
|
82
|
-
}
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* For a detailed explanation regarding each configuration property and type check, visit:
|
|
3
|
+
* https://jestjs.io/docs/configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
// All imported modules in your tests should be mocked automatically
|
|
8
|
+
// automock: false,
|
|
9
|
+
|
|
10
|
+
// Stop running tests after `n` failures
|
|
11
|
+
// bail: 0,
|
|
12
|
+
|
|
13
|
+
// The directory where Jest should store its cached dependency information
|
|
14
|
+
// cacheDirectory: "/tmp/jest_rs",
|
|
15
|
+
|
|
16
|
+
// Automatically clear mock calls and instances between every test
|
|
17
|
+
clearMocks: true,
|
|
18
|
+
|
|
19
|
+
// Indicates whether the coverage information should be collected while executing the test
|
|
20
|
+
collectCoverage: true,
|
|
21
|
+
|
|
22
|
+
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
|
23
|
+
collectCoverageFrom: [
|
|
24
|
+
'**/*.{js}'
|
|
25
|
+
],
|
|
26
|
+
|
|
27
|
+
// The directory where Jest should output its coverage files
|
|
28
|
+
coverageDirectory: '../coverage',
|
|
29
|
+
|
|
30
|
+
// An array of regexp pattern strings used to skip coverage collection
|
|
31
|
+
// coveragePathIgnorePatterns: [
|
|
32
|
+
// "/node_modules/"
|
|
33
|
+
// ],
|
|
34
|
+
|
|
35
|
+
// Indicates which provider should be used to instrument code for coverage
|
|
36
|
+
// coverageProvider: "babel",
|
|
37
|
+
|
|
38
|
+
// A list of reporter names that Jest uses when writing coverage reports
|
|
39
|
+
coverageReporters: [
|
|
40
|
+
// "json",
|
|
41
|
+
// "text",
|
|
42
|
+
'lcov',
|
|
43
|
+
// "clover"
|
|
44
|
+
],
|
|
45
|
+
|
|
46
|
+
// An object that configures minimum threshold enforcement for coverage results
|
|
47
|
+
// coverageThreshold: undefined,
|
|
48
|
+
|
|
49
|
+
// A path to a custom dependency extractor
|
|
50
|
+
// dependencyExtractor: undefined,
|
|
51
|
+
|
|
52
|
+
// Make calling deprecated APIs throw helpful error messages
|
|
53
|
+
// errorOnDeprecated: false,
|
|
54
|
+
|
|
55
|
+
// Force coverage collection from ignored files using an array of glob patterns
|
|
56
|
+
// forceCoverageMatch: [],
|
|
57
|
+
|
|
58
|
+
// A path to a module which exports an async function that is triggered once before all test suites
|
|
59
|
+
// globalSetup: undefined,
|
|
60
|
+
|
|
61
|
+
// A path to a module which exports an async function that is triggered once after all test suites
|
|
62
|
+
// globalTeardown: undefined,
|
|
63
|
+
|
|
64
|
+
// A set of global variables that need to be available in all test environments
|
|
65
|
+
// globals: {},
|
|
66
|
+
|
|
67
|
+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
|
68
|
+
// maxWorkers: "50%",
|
|
69
|
+
|
|
70
|
+
// An array of directory names to be searched recursively up from the requiring module's location
|
|
71
|
+
// moduleDirectories: [
|
|
72
|
+
// "node_modules"
|
|
73
|
+
// ],
|
|
74
|
+
|
|
75
|
+
// An array of file extensions your modules use
|
|
76
|
+
moduleFileExtensions: [
|
|
77
|
+
'js',
|
|
78
|
+
// "jsx",
|
|
79
|
+
// "ts",
|
|
80
|
+
// "tsx",
|
|
81
|
+
// "json",
|
|
82
|
+
// "node"
|
|
83
|
+
],
|
|
84
|
+
|
|
85
|
+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
|
86
|
+
moduleNameMapper: {
|
|
87
|
+
'\\.(css|less|scss|sass)$': 'identity-obj-proxy'
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
|
91
|
+
// modulePathIgnorePatterns: [],
|
|
92
|
+
|
|
93
|
+
// Activates notifications for test results
|
|
94
|
+
// notify: false,
|
|
95
|
+
|
|
96
|
+
// An enum that specifies notification mode. Requires { notify: true }
|
|
97
|
+
// notifyMode: "failure-change",
|
|
98
|
+
|
|
99
|
+
// A preset that is used as a base for Jest's configuration
|
|
100
|
+
//preset: 'ts-jest/presets/default',
|
|
101
|
+
|
|
102
|
+
// Run tests from one or more projects
|
|
103
|
+
// projects: undefined,
|
|
104
|
+
|
|
105
|
+
// Use this configuration option to add custom reporters to Jest
|
|
106
|
+
// reporters: undefined,
|
|
107
|
+
|
|
108
|
+
// Automatically reset mock state between every test
|
|
109
|
+
// resetMocks: false,
|
|
110
|
+
|
|
111
|
+
// Reset the module registry before running each individual test
|
|
112
|
+
// resetModules: false,
|
|
113
|
+
|
|
114
|
+
// A path to a custom resolver
|
|
115
|
+
// resolver: undefined,
|
|
116
|
+
|
|
117
|
+
// Automatically restore mock state between every test
|
|
118
|
+
// restoreMocks: false,
|
|
119
|
+
|
|
120
|
+
// The root directory that Jest should scan for tests and modules within
|
|
121
|
+
rootDir: 'src',
|
|
122
|
+
|
|
123
|
+
// A list of paths to directories that Jest should use to search for files in
|
|
124
|
+
// roots: [
|
|
125
|
+
// "<rootDir>"
|
|
126
|
+
// ],
|
|
127
|
+
|
|
128
|
+
// Allows you to use a custom runner instead of Jest's default test runner
|
|
129
|
+
// runner: "jest-runner",
|
|
130
|
+
|
|
131
|
+
// The paths to modules that run some code to configure or set up the testing environment before each test
|
|
132
|
+
setupFiles: [
|
|
133
|
+
'../jest.setup.js'
|
|
134
|
+
],
|
|
135
|
+
|
|
136
|
+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
|
137
|
+
setupFilesAfterEnv: [
|
|
138
|
+
'jest-prosemirror/environment'
|
|
139
|
+
],
|
|
140
|
+
|
|
141
|
+
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
|
142
|
+
// slowTestThreshold: 5,
|
|
143
|
+
|
|
144
|
+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
|
145
|
+
// snapshotSerializers: [],
|
|
146
|
+
|
|
147
|
+
// The test environment that will be used for testing
|
|
148
|
+
testEnvironment: 'jsdom',
|
|
149
|
+
|
|
150
|
+
// Options that will be passed to the testEnvironment
|
|
151
|
+
// testEnvironmentOptions: {},
|
|
152
|
+
|
|
153
|
+
// Adds a location field to test results
|
|
154
|
+
// testLocationInResults: false,
|
|
155
|
+
|
|
156
|
+
// The glob patterns Jest uses to detect test files
|
|
157
|
+
testMatch: [
|
|
158
|
+
// "**/__tests__/**/*.[jt]s?(x)",
|
|
159
|
+
'**/?(*.)+(spec|test).[j]s?(x)'
|
|
160
|
+
],
|
|
161
|
+
|
|
162
|
+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
|
163
|
+
// testPathIgnorePatterns: [
|
|
164
|
+
// "/node_modules/"
|
|
165
|
+
// ],
|
|
166
|
+
|
|
167
|
+
// The regexp pattern or array of patterns that Jest uses to detect test files
|
|
168
|
+
//testRegex: ["((\\.|/*.)(test))\\.ts?$"],
|
|
169
|
+
|
|
170
|
+
// This option allows the use of a custom results processor
|
|
171
|
+
// testResultsProcessor: "jest-sonar-reporter",
|
|
172
|
+
|
|
173
|
+
// This option allows use of a custom test runner
|
|
174
|
+
// testRunner: "jest-circus/runner",
|
|
175
|
+
|
|
176
|
+
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
|
|
177
|
+
// testURL: "http://localhost",
|
|
178
|
+
|
|
179
|
+
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
|
|
180
|
+
// timers: "real",
|
|
181
|
+
|
|
182
|
+
// A map from regular expressions to paths to transformers
|
|
183
|
+
/*transform: {
|
|
184
|
+
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest"
|
|
185
|
+
},*/
|
|
186
|
+
|
|
187
|
+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
|
188
|
+
transformIgnorePatterns: [
|
|
189
|
+
'node_modules/(?!(prosemirror-utils|@modusoperandi)/).+\\.js$'
|
|
190
|
+
// "\\.pnp\\.[^\\/]+$"
|
|
191
|
+
],
|
|
192
|
+
|
|
193
|
+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
|
194
|
+
// unmockedModulePathPatterns: undefined,
|
|
195
|
+
|
|
196
|
+
// Indicates whether each individual test should be reported during the run
|
|
197
|
+
verbose: true,
|
|
198
|
+
|
|
199
|
+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
|
200
|
+
// watchPathIgnorePatterns: [],
|
|
201
|
+
|
|
202
|
+
// Whether to use watchman for file crawling
|
|
203
|
+
// watchman: true,
|
|
204
|
+
|
|
205
|
+
// Default timeout of a test in milliseconds.
|
|
206
|
+
testTimeout: 30000,
|
|
207
|
+
};
|
package/lint.sh
CHANGED
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2018 Atlassian Pty Ltd
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
File without changes
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { NodeSelection } from 'prosemirror-state';
|
|
2
|
+
import { Fragment, Node as PMNode } from 'prosemirror-model';
|
|
3
|
+
import { setTextSelection } from './transforms';
|
|
4
|
+
import { findParentNodeClosestToPos } from './selection';
|
|
5
|
+
|
|
6
|
+
// :: (selection: Selection) → boolean
|
|
7
|
+
// Checks if current selection is a `NodeSelection`.
|
|
8
|
+
//
|
|
9
|
+
// ```javascript
|
|
10
|
+
// if (isNodeSelection(tr.selection)) {
|
|
11
|
+
// // ...
|
|
12
|
+
// }
|
|
13
|
+
// ```
|
|
14
|
+
export const isNodeSelection = selection => {
|
|
15
|
+
return selection instanceof NodeSelection;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// (nodeType: union<NodeType, [NodeType]>) → boolean
|
|
19
|
+
// Checks if the type a given `node` equals to a given `nodeType`.
|
|
20
|
+
export const equalNodeType = (nodeType, node) => {
|
|
21
|
+
return (
|
|
22
|
+
(Array.isArray(nodeType) && nodeType.indexOf(node.type) > -1) ||
|
|
23
|
+
node.type === nodeType
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// (tr: Transaction) → Transaction
|
|
28
|
+
// Creates a new transaction object from a given transaction
|
|
29
|
+
export const cloneTr = tr => {
|
|
30
|
+
return Object.assign(Object.create(tr), tr).setTime(Date.now());
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// (position: number, content: union<ProseMirrorNode, Fragment>) → (tr: Transaction) → Transaction
|
|
34
|
+
// Returns a `replace` transaction that replaces a node at a given position with the given `content`.
|
|
35
|
+
// It will return the original transaction if replacing is not possible.
|
|
36
|
+
// `position` should point at the position immediately before the node.
|
|
37
|
+
export const replaceNodeAtPos = (position, content) => tr => {
|
|
38
|
+
const node = tr.doc.nodeAt(position);
|
|
39
|
+
const $pos = tr.doc.resolve(position);
|
|
40
|
+
if (canReplace($pos, content)) {
|
|
41
|
+
tr = tr.replaceWith(position, position + node.nodeSize, content);
|
|
42
|
+
const start = tr.selection.$from.pos - 1;
|
|
43
|
+
// put cursor inside of the inserted node
|
|
44
|
+
tr = setTextSelection(Math.max(start, 0), -1)(tr);
|
|
45
|
+
// move cursor to the start of the node
|
|
46
|
+
tr = setTextSelection(tr.selection.$from.start())(tr);
|
|
47
|
+
return cloneTr(tr);
|
|
48
|
+
}
|
|
49
|
+
return tr;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// ($pos: ResolvedPos, doc: ProseMirrorNode, content: union<ProseMirrorNode, Fragment>, ) → boolean
|
|
53
|
+
// Checks if replacing a node at a given `$pos` inside of the `doc` node with the given `content` is possible.
|
|
54
|
+
export const canReplace = ($pos, content) => {
|
|
55
|
+
const node = $pos.node($pos.depth);
|
|
56
|
+
return (
|
|
57
|
+
node &&
|
|
58
|
+
node.type.validContent(
|
|
59
|
+
content instanceof Fragment ? content : Fragment.from(content)
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// (position: number) → (tr: Transaction) → Transaction
|
|
65
|
+
// Returns a `delete` transaction that removes a node at a given position with the given `node`.
|
|
66
|
+
// `position` should point at the position immediately before the node.
|
|
67
|
+
export const removeNodeAtPos = position => tr => {
|
|
68
|
+
const node = tr.doc.nodeAt(position);
|
|
69
|
+
return cloneTr(tr.delete(position, position + node.nodeSize));
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// :: ($pos: ResolvedPos, content: union<ProseMirrorNode, Fragment>) → boolean
|
|
73
|
+
// Checks if a given `content` can be inserted at the given `$pos`
|
|
74
|
+
//
|
|
75
|
+
// ```javascript
|
|
76
|
+
// const { selection: { $from } } = state;
|
|
77
|
+
// const node = state.schema.nodes.atom.createChecked();
|
|
78
|
+
// if (canInsert($from, node)) {
|
|
79
|
+
// // ...
|
|
80
|
+
// }
|
|
81
|
+
// ```
|
|
82
|
+
export const canInsert = ($pos, content) => {
|
|
83
|
+
const index = $pos.index();
|
|
84
|
+
|
|
85
|
+
if (content instanceof Fragment) {
|
|
86
|
+
return $pos.parent.canReplace(index, index, content);
|
|
87
|
+
} else if (content instanceof PMNode) {
|
|
88
|
+
return $pos.parent.canReplaceWith(index, index, content.type);
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// (node: ProseMirrorNode) → boolean
|
|
94
|
+
// Checks if a given `node` is an empty paragraph
|
|
95
|
+
export const isEmptyParagraph = node => {
|
|
96
|
+
return !node || (node.type.name === 'paragraph' && node.nodeSize === 2);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const checkInvalidMovements = (
|
|
100
|
+
originIndex,
|
|
101
|
+
targetIndex,
|
|
102
|
+
targets,
|
|
103
|
+
type
|
|
104
|
+
) => {
|
|
105
|
+
const direction = originIndex > targetIndex ? -1 : 1;
|
|
106
|
+
const errorMessage = `Target position is invalid, you can't move the ${type} ${originIndex} to ${targetIndex}, the target can't be split. You could use tryToFit option.`;
|
|
107
|
+
|
|
108
|
+
if (direction === 1) {
|
|
109
|
+
if (targets.slice(0, targets.length - 1).indexOf(targetIndex) !== -1) {
|
|
110
|
+
throw new Error(errorMessage);
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
if (targets.slice(1).indexOf(targetIndex) !== -1) {
|
|
114
|
+
throw new Error(errorMessage);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return true;
|
|
119
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var selection_js = require('./selection.js');
|
|
6
|
+
var node_js = require('./node.js');
|
|
7
|
+
var transforms_js = require('./transforms.js');
|
|
8
|
+
var helpers_js = require('./helpers.js');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Object.keys(selection_js).forEach(function (key) { exports[key] = selection_js[key]; });
|
|
13
|
+
Object.keys(node_js).forEach(function (key) { exports[key] = node_js[key]; });
|
|
14
|
+
Object.keys(transforms_js).forEach(function (key) { exports[key] = transforms_js[key]; });
|
|
15
|
+
exports.isNodeSelection = helpers_js.isNodeSelection;
|
|
16
|
+
exports.canInsert = helpers_js.canInsert;
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// :: (node: ProseMirrorNode, descend: ?boolean) → [{ node: ProseMirrorNode, pos: number }]
|
|
2
|
+
// Flattens descendants of a given `node`. It doesn't descend into a node when descend argument is `false` (defaults to `true`).
|
|
3
|
+
//
|
|
4
|
+
// ```javascript
|
|
5
|
+
// const children = flatten(node);
|
|
6
|
+
// ```
|
|
7
|
+
export const flatten = (node, descend = true) => {
|
|
8
|
+
if (!node) {
|
|
9
|
+
throw new Error('Invalid "node" parameter');
|
|
10
|
+
}
|
|
11
|
+
const result = [];
|
|
12
|
+
node.descendants((child, pos) => {
|
|
13
|
+
result.push({ node: child, pos });
|
|
14
|
+
if (!descend) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// :: (node: ProseMirrorNode, predicate: (node: ProseMirrorNode) → boolean, descend: ?boolean) → [{ node: ProseMirrorNode, pos: number }]
|
|
22
|
+
// Iterates over descendants of a given `node`, returning child nodes predicate returns truthy for. It doesn't descend into a node when descend argument is `false` (defaults to `true`).
|
|
23
|
+
//
|
|
24
|
+
// ```javascript
|
|
25
|
+
// const textNodes = findChildren(node, child => child.isText, false);
|
|
26
|
+
// ```
|
|
27
|
+
export const findChildren = (node, predicate, descend) => {
|
|
28
|
+
if (!node) {
|
|
29
|
+
throw new Error('Invalid "node" parameter');
|
|
30
|
+
} else if (!predicate) {
|
|
31
|
+
throw new Error('Invalid "predicate" parameter');
|
|
32
|
+
}
|
|
33
|
+
return flatten(node, descend).filter(child => predicate(child.node));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// :: (node: ProseMirrorNode, descend: ?boolean) → [{ node: ProseMirrorNode, pos: number }]
|
|
37
|
+
// Returns text nodes of a given `node`. It doesn't descend into a node when descend argument is `false` (defaults to `true`).
|
|
38
|
+
//
|
|
39
|
+
// ```javascript
|
|
40
|
+
// const textNodes = findTextNodes(node);
|
|
41
|
+
// ```
|
|
42
|
+
export const findTextNodes = (node, descend) => {
|
|
43
|
+
return findChildren(node, child => child.isText, descend);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// :: (node: ProseMirrorNode, descend: ?boolean) → [{ node: ProseMirrorNode, pos: number }]
|
|
47
|
+
// Returns inline nodes of a given `node`. It doesn't descend into a node when descend argument is `false` (defaults to `true`).
|
|
48
|
+
//
|
|
49
|
+
// ```javascript
|
|
50
|
+
// const inlineNodes = findInlineNodes(node);
|
|
51
|
+
// ```
|
|
52
|
+
export const findInlineNodes = (node, descend) => {
|
|
53
|
+
return findChildren(node, child => child.isInline, descend);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// :: (node: ProseMirrorNode, descend: ?boolean) → [{ node: ProseMirrorNode, pos: number }]
|
|
57
|
+
// Returns block descendants of a given `node`. It doesn't descend into a node when descend argument is `false` (defaults to `true`).
|
|
58
|
+
//
|
|
59
|
+
// ```javascript
|
|
60
|
+
// const blockNodes = findBlockNodes(node);
|
|
61
|
+
// ```
|
|
62
|
+
export const findBlockNodes = (node, descend) => {
|
|
63
|
+
return findChildren(node, child => child.isBlock, descend);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// :: (node: ProseMirrorNode, predicate: (attrs: ?Object) → boolean, descend: ?boolean) → [{ node: ProseMirrorNode, pos: number }]
|
|
67
|
+
// Iterates over descendants of a given `node`, returning child nodes predicate returns truthy for. It doesn't descend into a node when descend argument is `false` (defaults to `true`).
|
|
68
|
+
//
|
|
69
|
+
// ```javascript
|
|
70
|
+
// const mergedCells = findChildrenByAttr(table, attrs => attrs.colspan === 2);
|
|
71
|
+
// ```
|
|
72
|
+
export const findChildrenByAttr = (node, predicate, descend) => {
|
|
73
|
+
return findChildren(node, child => !!predicate(child.attrs), descend);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// :: (node: ProseMirrorNode, nodeType: NodeType, descend: ?boolean) → [{ node: ProseMirrorNode, pos: number }]
|
|
77
|
+
// Iterates over descendants of a given `node`, returning child nodes of a given nodeType. It doesn't descend into a node when descend argument is `false` (defaults to `true`).
|
|
78
|
+
//
|
|
79
|
+
// ```javascript
|
|
80
|
+
// const cells = findChildrenByType(table, schema.nodes.tableCell);
|
|
81
|
+
// ```
|
|
82
|
+
export const findChildrenByType = (node, nodeType, descend) => {
|
|
83
|
+
return findChildren(node, child => child.type === nodeType, descend);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// :: (node: ProseMirrorNode, markType: markType, descend: ?boolean) → [{ node: ProseMirrorNode, pos: number }]
|
|
87
|
+
// Iterates over descendants of a given `node`, returning child nodes that have a mark of a given markType. It doesn't descend into a `node` when descend argument is `false` (defaults to `true`).
|
|
88
|
+
//
|
|
89
|
+
// ```javascript
|
|
90
|
+
// const nodes = findChildrenByMark(state.doc, schema.marks.strong);
|
|
91
|
+
// ```
|
|
92
|
+
export const findChildrenByMark = (node, markType, descend) => {
|
|
93
|
+
return findChildren(node, child => markType.isInSet(child.marks), descend);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// :: (node: ProseMirrorNode, nodeType: NodeType) → boolean
|
|
97
|
+
// Returns `true` if a given node contains nodes of a given `nodeType`
|
|
98
|
+
//
|
|
99
|
+
// ```javascript
|
|
100
|
+
// if (contains(panel, schema.nodes.listItem)) {
|
|
101
|
+
// // ...
|
|
102
|
+
// }
|
|
103
|
+
// ```
|
|
104
|
+
export const contains = (node, nodeType) => {
|
|
105
|
+
return !!findChildrenByType(node, nodeType).length;
|
|
106
|
+
};
|