@atlaskit/editor-core 187.17.5 → 187.18.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 +18 -0
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/plugins/annotation/toolbar.js +31 -8
- package/dist/cjs/plugins/base/pm-plugins/inline-cursor-target.js +7 -41
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +0 -3
- package/dist/cjs/plugins/selection/pm-plugins/gap-cursor-main.js +27 -13
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/plugins/annotation/toolbar.js +34 -9
- package/dist/es2019/plugins/base/pm-plugins/inline-cursor-target.js +9 -41
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +0 -3
- package/dist/es2019/plugins/selection/pm-plugins/gap-cursor-main.js +27 -13
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/plugins/annotation/toolbar.js +30 -7
- package/dist/esm/plugins/base/pm-plugins/inline-cursor-target.js +7 -41
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +0 -3
- package/dist/esm/plugins/selection/pm-plugins/gap-cursor-main.js +27 -13
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/extensibility.d.ts +0 -2
- package/dist/types/index.d.ts +0 -5
- package/dist/types/labs/next/presets/default.d.ts +28 -30
- package/dist/types/plugins/analytics/index.d.ts +0 -2
- package/dist/types/plugins/annotation/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/annotation/types.d.ts +9 -3
- package/dist/types/plugins/annotation/utils.d.ts +2 -5
- package/dist/types/plugins/base/pm-plugins/context-identifier.d.ts +1 -1
- package/dist/types/plugins/block-type/commands/block-type.d.ts +0 -2
- package/dist/types/plugins/block-type/pm-plugins/main.d.ts +6 -1
- package/dist/types/plugins/code-bidi-warning/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.d.ts +5 -1
- package/dist/types/plugins/code-block/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/code-block/utils.d.ts +1 -1
- package/dist/types/plugins/collab-edit/utils.d.ts +1 -5
- package/dist/types/plugins/copy-button/pm-plugins/main.d.ts +10 -1
- package/dist/types/plugins/copy-button/toolbar.d.ts +0 -2
- package/dist/types/plugins/copy-button/utils.d.ts +1 -1
- package/dist/types/plugins/custom-autoformat/index.d.ts +2 -1
- package/dist/types/plugins/date/pm-plugins/main.d.ts +0 -2
- package/dist/types/plugins/expand/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/expand/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/extension/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/extension/utils.d.ts +1 -1
- package/dist/types/plugins/find-replace/plugin.d.ts +0 -2
- package/dist/types/plugins/find-replace/utils/index.d.ts +1 -4
- package/dist/types/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +3 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/list/pm-plugins/input-rules/wrapping-join-rule.d.ts +1 -2
- package/dist/types/plugins/media/commands/helpers.d.ts +1 -1
- package/dist/types/plugins/media/pm-plugins/alt-text/index.d.ts +1 -3
- package/dist/types/plugins/media/pm-plugins/linking/index.d.ts +0 -2
- package/dist/types/plugins/media/toolbar/utils.d.ts +1 -3
- package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +0 -1
- package/dist/types/plugins/media/ui/ResizableMediaSingle/index.d.ts +0 -1
- package/dist/types/plugins/mobile-dimensions/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/panel/utils.d.ts +1 -1
- package/dist/types/plugins/paste/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/paste/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/paste/util/index.d.ts +1 -1
- package/dist/types/plugins/selection/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/selection/pm-plugins/gap-cursor-main.d.ts +1 -1
- package/dist/types/plugins/selection/pm-plugins/selection-main.d.ts +1 -1
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +1 -2
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/utils/action.d.ts +1 -60
- package/dist/types/utils/list-commands.d.ts +0 -1
- package/dist/types-ts4.5/extensibility.d.ts +0 -2
- package/dist/types-ts4.5/index.d.ts +0 -5
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +28 -30
- package/dist/types-ts4.5/plugins/analytics/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/annotation/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/annotation/types.d.ts +9 -3
- package/dist/types-ts4.5/plugins/annotation/utils.d.ts +2 -5
- package/dist/types-ts4.5/plugins/base/pm-plugins/context-identifier.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +0 -2
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/main.d.ts +6 -1
- package/dist/types-ts4.5/plugins/code-bidi-warning/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.d.ts +8 -1
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/plugins/code-block/utils.d.ts +1 -1
- package/dist/types-ts4.5/plugins/collab-edit/utils.d.ts +1 -5
- package/dist/types-ts4.5/plugins/copy-button/pm-plugins/main.d.ts +10 -1
- package/dist/types-ts4.5/plugins/copy-button/toolbar.d.ts +0 -2
- package/dist/types-ts4.5/plugins/copy-button/utils.d.ts +1 -1
- package/dist/types-ts4.5/plugins/custom-autoformat/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/date/pm-plugins/main.d.ts +0 -2
- package/dist/types-ts4.5/plugins/expand/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/expand/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/extension/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/extension/utils.d.ts +1 -1
- package/dist/types-ts4.5/plugins/find-replace/plugin.d.ts +0 -2
- package/dist/types-ts4.5/plugins/find-replace/utils/index.d.ts +1 -4
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/list/pm-plugins/input-rules/wrapping-join-rule.d.ts +1 -2
- package/dist/types-ts4.5/plugins/media/commands/helpers.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/index.d.ts +1 -3
- package/dist/types-ts4.5/plugins/media/pm-plugins/linking/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/media/toolbar/utils.d.ts +1 -3
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +0 -1
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/mobile-dimensions/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/panel/utils.d.ts +1 -1
- package/dist/types-ts4.5/plugins/paste/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/paste/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/paste/util/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/selection/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/selection/pm-plugins/gap-cursor-main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/selection/pm-plugins/selection-main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +1 -2
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/utils/action.d.ts +1 -60
- package/dist/types-ts4.5/utils/list-commands.d.ts +0 -1
- package/package.json +5 -4
- package/report.api.md +1 -24
- package/tmp/api-report-tmp.d.ts +1 -21
- package/dist/cjs/plugins/text-formatting/actions.js +0 -188
- package/dist/cjs/plugins/text-formatting/commands/clear-formatting.js +0 -111
- package/dist/cjs/plugins/text-formatting/commands/text-formatting.js +0 -143
- package/dist/cjs/plugins/text-formatting/commands/transform-to-code.js +0 -68
- package/dist/cjs/plugins/text-formatting/index.js +0 -136
- package/dist/cjs/plugins/text-formatting/pm-plugins/clear-formatting-keymap.js +0 -21
- package/dist/cjs/plugins/text-formatting/pm-plugins/clear-formatting.js +0 -36
- package/dist/cjs/plugins/text-formatting/pm-plugins/cursor.js +0 -55
- package/dist/cjs/plugins/text-formatting/pm-plugins/input-rule.js +0 -276
- package/dist/cjs/plugins/text-formatting/pm-plugins/keymap.js +0 -52
- package/dist/cjs/plugins/text-formatting/pm-plugins/main.js +0 -113
- package/dist/cjs/plugins/text-formatting/pm-plugins/plugin-key.js +0 -9
- package/dist/cjs/plugins/text-formatting/pm-plugins/smart-input-rule.js +0 -176
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/constants.js +0 -19
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +0 -86
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +0 -53
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +0 -225
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/menu-state.js +0 -23
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/hooks/responsive-toolbar-buttons.js +0 -60
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/index.js +0 -201
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/more-button.js +0 -40
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/single-toolbar-buttons.js +0 -46
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/types.js +0 -17
- package/dist/cjs/plugins/text-formatting/utils/cell-selection.js +0 -12
- package/dist/cjs/plugins/text-formatting/utils.js +0 -86
- package/dist/es2019/plugins/text-formatting/actions.js +0 -161
- package/dist/es2019/plugins/text-formatting/commands/clear-formatting.js +0 -105
- package/dist/es2019/plugins/text-formatting/commands/text-formatting.js +0 -144
- package/dist/es2019/plugins/text-formatting/commands/transform-to-code.js +0 -71
- package/dist/es2019/plugins/text-formatting/index.js +0 -127
- package/dist/es2019/plugins/text-formatting/pm-plugins/clear-formatting-keymap.js +0 -10
- package/dist/es2019/plugins/text-formatting/pm-plugins/clear-formatting.js +0 -26
- package/dist/es2019/plugins/text-formatting/pm-plugins/cursor.js +0 -52
- package/dist/es2019/plugins/text-formatting/pm-plugins/input-rule.js +0 -244
- package/dist/es2019/plugins/text-formatting/pm-plugins/keymap.js +0 -43
- package/dist/es2019/plugins/text-formatting/pm-plugins/main.js +0 -109
- package/dist/es2019/plugins/text-formatting/pm-plugins/plugin-key.js +0 -2
- package/dist/es2019/plugins/text-formatting/pm-plugins/smart-input-rule.js +0 -155
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/constants.js +0 -20
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +0 -66
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +0 -42
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +0 -210
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/menu-state.js +0 -11
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/hooks/responsive-toolbar-buttons.js +0 -48
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/index.js +0 -168
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/more-button.js +0 -32
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/single-toolbar-buttons.js +0 -36
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/types.js +0 -10
- package/dist/es2019/plugins/text-formatting/utils/cell-selection.js +0 -5
- package/dist/es2019/plugins/text-formatting/utils.js +0 -74
- package/dist/esm/plugins/text-formatting/actions.js +0 -168
- package/dist/esm/plugins/text-formatting/commands/clear-formatting.js +0 -101
- package/dist/esm/plugins/text-formatting/commands/text-formatting.js +0 -134
- package/dist/esm/plugins/text-formatting/commands/transform-to-code.js +0 -61
- package/dist/esm/plugins/text-formatting/index.js +0 -128
- package/dist/esm/plugins/text-formatting/pm-plugins/clear-formatting-keymap.js +0 -10
- package/dist/esm/plugins/text-formatting/pm-plugins/clear-formatting.js +0 -28
- package/dist/esm/plugins/text-formatting/pm-plugins/cursor.js +0 -48
- package/dist/esm/plugins/text-formatting/pm-plugins/input-rule.js +0 -259
- package/dist/esm/plugins/text-formatting/pm-plugins/keymap.js +0 -43
- package/dist/esm/plugins/text-formatting/pm-plugins/main.js +0 -98
- package/dist/esm/plugins/text-formatting/pm-plugins/plugin-key.js +0 -2
- package/dist/esm/plugins/text-formatting/pm-plugins/smart-input-rule.js +0 -169
- package/dist/esm/plugins/text-formatting/ui/Toolbar/constants.js +0 -8
- package/dist/esm/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +0 -75
- package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.js +0 -45
- package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.js +0 -213
- package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/menu-state.js +0 -15
- package/dist/esm/plugins/text-formatting/ui/Toolbar/hooks/responsive-toolbar-buttons.js +0 -50
- package/dist/esm/plugins/text-formatting/ui/Toolbar/index.js +0 -191
- package/dist/esm/plugins/text-formatting/ui/Toolbar/more-button.js +0 -31
- package/dist/esm/plugins/text-formatting/ui/Toolbar/single-toolbar-buttons.js +0 -35
- package/dist/esm/plugins/text-formatting/ui/Toolbar/types.js +0 -10
- package/dist/esm/plugins/text-formatting/utils/cell-selection.js +0 -5
- package/dist/esm/plugins/text-formatting/utils.js +0 -75
- package/dist/types/plugins/text-formatting/actions.d.ts +0 -22
- package/dist/types/plugins/text-formatting/commands/clear-formatting.d.ts +0 -6
- package/dist/types/plugins/text-formatting/commands/text-formatting.d.ts +0 -5
- package/dist/types/plugins/text-formatting/commands/transform-to-code.d.ts +0 -2
- package/dist/types/plugins/text-formatting/index.d.ts +0 -17
- package/dist/types/plugins/text-formatting/pm-plugins/clear-formatting-keymap.d.ts +0 -4
- package/dist/types/plugins/text-formatting/pm-plugins/clear-formatting.d.ts +0 -8
- package/dist/types/plugins/text-formatting/pm-plugins/cursor.d.ts +0 -3
- package/dist/types/plugins/text-formatting/pm-plugins/input-rule.d.ts +0 -24
- package/dist/types/plugins/text-formatting/pm-plugins/keymap.d.ts +0 -4
- package/dist/types/plugins/text-formatting/pm-plugins/main.d.ts +0 -7
- package/dist/types/plugins/text-formatting/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types/plugins/text-formatting/pm-plugins/smart-input-rule.d.ts +0 -3
- package/dist/types/plugins/text-formatting/ui/Toolbar/constants.d.ts +0 -6
- package/dist/types/plugins/text-formatting/ui/Toolbar/dropdown-menu.d.ts +0 -15
- package/dist/types/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.d.ts +0 -7
- package/dist/types/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.d.ts +0 -14
- package/dist/types/plugins/text-formatting/ui/Toolbar/hooks/menu-state.d.ts +0 -1
- package/dist/types/plugins/text-formatting/ui/Toolbar/hooks/responsive-toolbar-buttons.d.ts +0 -20
- package/dist/types/plugins/text-formatting/ui/Toolbar/index.d.ts +0 -26
- package/dist/types/plugins/text-formatting/ui/Toolbar/more-button.d.ts +0 -13
- package/dist/types/plugins/text-formatting/ui/Toolbar/single-toolbar-buttons.d.ts +0 -9
- package/dist/types/plugins/text-formatting/ui/Toolbar/types.d.ts +0 -32
- package/dist/types/plugins/text-formatting/utils/cell-selection.d.ts +0 -3
- package/dist/types/plugins/text-formatting/utils.d.ts +0 -11
- package/dist/types-ts4.5/plugins/text-formatting/actions.d.ts +0 -22
- package/dist/types-ts4.5/plugins/text-formatting/commands/clear-formatting.d.ts +0 -6
- package/dist/types-ts4.5/plugins/text-formatting/commands/text-formatting.d.ts +0 -5
- package/dist/types-ts4.5/plugins/text-formatting/commands/transform-to-code.d.ts +0 -2
- package/dist/types-ts4.5/plugins/text-formatting/index.d.ts +0 -19
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/clear-formatting-keymap.d.ts +0 -4
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/clear-formatting.d.ts +0 -8
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/cursor.d.ts +0 -3
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/input-rule.d.ts +0 -24
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/keymap.d.ts +0 -4
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/main.d.ts +0 -7
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/smart-input-rule.d.ts +0 -3
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/constants.d.ts +0 -6
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/dropdown-menu.d.ts +0 -15
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/hooks/clear-formatting-icon.d.ts +0 -7
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/hooks/formatting-icons.d.ts +0 -14
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/hooks/menu-state.d.ts +0 -5
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/hooks/responsive-toolbar-buttons.d.ts +0 -20
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/index.d.ts +0 -26
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/more-button.d.ts +0 -13
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/single-toolbar-buttons.d.ts +0 -9
- package/dist/types-ts4.5/plugins/text-formatting/ui/Toolbar/types.d.ts +0 -32
- package/dist/types-ts4.5/plugins/text-formatting/utils/cell-selection.d.ts +0 -3
- package/dist/types-ts4.5/plugins/text-formatting/utils.d.ts +0 -11
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.markActive = exports.isArrayContainsContent = exports.hasCode = exports.compareItemsArrays = exports.checkFormattingIsPresent = void 0;
|
|
7
|
-
var _mark = require("@atlaskit/editor-common/mark");
|
|
8
|
-
var _clearFormatting = require("./commands/clear-formatting");
|
|
9
|
-
var hasCode = function hasCode(state, pos) {
|
|
10
|
-
var code = state.schema.marks.code;
|
|
11
|
-
var node = pos >= 0 && state.doc.nodeAt(pos);
|
|
12
|
-
if (node) {
|
|
13
|
-
return !!node.marks.filter(function (mark) {
|
|
14
|
-
return mark.type === code;
|
|
15
|
-
}).length;
|
|
16
|
-
}
|
|
17
|
-
return false;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Determine if a mark (with specific attribute values) exists anywhere in the selection.
|
|
22
|
-
*/
|
|
23
|
-
exports.hasCode = hasCode;
|
|
24
|
-
var markActive = function markActive(state, mark) {
|
|
25
|
-
var _state$selection = state.selection,
|
|
26
|
-
from = _state$selection.from,
|
|
27
|
-
to = _state$selection.to,
|
|
28
|
-
empty = _state$selection.empty;
|
|
29
|
-
// When the selection is empty, only the active marks apply.
|
|
30
|
-
if (empty) {
|
|
31
|
-
return !!mark.isInSet(state.tr.storedMarks || state.selection.$from.marks());
|
|
32
|
-
}
|
|
33
|
-
// For a non-collapsed selection, the marks on the nodes matter.
|
|
34
|
-
var found = false;
|
|
35
|
-
state.doc.nodesBetween(from, to, function (node) {
|
|
36
|
-
found = found || mark.isInSet(node.marks);
|
|
37
|
-
});
|
|
38
|
-
return found;
|
|
39
|
-
};
|
|
40
|
-
exports.markActive = markActive;
|
|
41
|
-
var blockStylingIsPresent = function blockStylingIsPresent(state) {
|
|
42
|
-
var _state$selection2 = state.selection,
|
|
43
|
-
from = _state$selection2.from,
|
|
44
|
-
to = _state$selection2.to;
|
|
45
|
-
var isBlockStyling = false;
|
|
46
|
-
state.doc.nodesBetween(from, to, function (node) {
|
|
47
|
-
if (_clearFormatting.FORMATTING_NODE_TYPES.indexOf(node.type.name) !== -1) {
|
|
48
|
-
isBlockStyling = true;
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
return true;
|
|
52
|
-
});
|
|
53
|
-
return isBlockStyling;
|
|
54
|
-
};
|
|
55
|
-
var marksArePresent = function marksArePresent(state) {
|
|
56
|
-
var activeMarkTypes = _clearFormatting.FORMATTING_MARK_TYPES.filter(function (mark) {
|
|
57
|
-
if (!!state.schema.marks[mark]) {
|
|
58
|
-
var _state$selection3 = state.selection,
|
|
59
|
-
$from = _state$selection3.$from,
|
|
60
|
-
empty = _state$selection3.empty;
|
|
61
|
-
var marks = state.schema.marks;
|
|
62
|
-
if (empty) {
|
|
63
|
-
return !!marks[mark].isInSet(state.storedMarks || $from.marks());
|
|
64
|
-
}
|
|
65
|
-
return (0, _mark.anyMarkActive)(state, marks[mark]);
|
|
66
|
-
}
|
|
67
|
-
return false;
|
|
68
|
-
});
|
|
69
|
-
return activeMarkTypes.length > 0;
|
|
70
|
-
};
|
|
71
|
-
var checkFormattingIsPresent = function checkFormattingIsPresent(state) {
|
|
72
|
-
return marksArePresent(state) || blockStylingIsPresent(state);
|
|
73
|
-
};
|
|
74
|
-
exports.checkFormattingIsPresent = checkFormattingIsPresent;
|
|
75
|
-
var compareItemsArrays = function compareItemsArrays(items, prevItems) {
|
|
76
|
-
return items && items.filter(function (item) {
|
|
77
|
-
return !prevItems.includes(item);
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
exports.compareItemsArrays = compareItemsArrays;
|
|
81
|
-
var isArrayContainsContent = function isArrayContainsContent(items, content) {
|
|
82
|
-
return items.filter(function (item) {
|
|
83
|
-
return item.content === content;
|
|
84
|
-
}).length > 0;
|
|
85
|
-
};
|
|
86
|
-
exports.isArrayContainsContent = isArrayContainsContent;
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
3
|
-
import { toggleMark } from '@atlaskit/editor-common/mark';
|
|
4
|
-
export const toggleEm = () => {
|
|
5
|
-
return (state, dispatch) => {
|
|
6
|
-
const {
|
|
7
|
-
em
|
|
8
|
-
} = state.schema.marks;
|
|
9
|
-
if (em) {
|
|
10
|
-
return toggleMark(em)(state, dispatch);
|
|
11
|
-
}
|
|
12
|
-
return false;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export const toggleEmWithAnalytics = editorAnalyticsAPI => ({
|
|
16
|
-
inputMethod
|
|
17
|
-
}) => withAnalytics(editorAnalyticsAPI, {
|
|
18
|
-
action: ACTION.FORMATTED,
|
|
19
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
20
|
-
eventType: EVENT_TYPE.TRACK,
|
|
21
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_ITALIC,
|
|
22
|
-
attributes: {
|
|
23
|
-
inputMethod
|
|
24
|
-
}
|
|
25
|
-
})(toggleEm());
|
|
26
|
-
export const toggleStrike = () => {
|
|
27
|
-
return (state, dispatch) => {
|
|
28
|
-
const {
|
|
29
|
-
strike
|
|
30
|
-
} = state.schema.marks;
|
|
31
|
-
if (strike) {
|
|
32
|
-
return toggleMark(strike)(state, dispatch);
|
|
33
|
-
}
|
|
34
|
-
return false;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
export const toggleStrikeWithAnalytics = editorAnalyticsAPI => ({
|
|
38
|
-
inputMethod
|
|
39
|
-
}) => withAnalytics(editorAnalyticsAPI, {
|
|
40
|
-
action: ACTION.FORMATTED,
|
|
41
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
42
|
-
eventType: EVENT_TYPE.TRACK,
|
|
43
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_STRIKE,
|
|
44
|
-
attributes: {
|
|
45
|
-
inputMethod
|
|
46
|
-
}
|
|
47
|
-
})(toggleStrike());
|
|
48
|
-
export const toggleStrong = () => {
|
|
49
|
-
return (state, dispatch) => {
|
|
50
|
-
const {
|
|
51
|
-
strong
|
|
52
|
-
} = state.schema.marks;
|
|
53
|
-
if (strong) {
|
|
54
|
-
return toggleMark(strong)(state, dispatch);
|
|
55
|
-
}
|
|
56
|
-
return false;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
export const toggleStrongWithAnalytics = editorAnalyticsAPI => ({
|
|
60
|
-
inputMethod
|
|
61
|
-
}) => withAnalytics(editorAnalyticsAPI, {
|
|
62
|
-
action: ACTION.FORMATTED,
|
|
63
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
64
|
-
eventType: EVENT_TYPE.TRACK,
|
|
65
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_STRONG,
|
|
66
|
-
attributes: {
|
|
67
|
-
inputMethod
|
|
68
|
-
}
|
|
69
|
-
})(toggleStrong());
|
|
70
|
-
export const toggleUnderline = () => {
|
|
71
|
-
return (state, dispatch) => {
|
|
72
|
-
const {
|
|
73
|
-
underline
|
|
74
|
-
} = state.schema.marks;
|
|
75
|
-
if (underline) {
|
|
76
|
-
return toggleMark(underline)(state, dispatch);
|
|
77
|
-
}
|
|
78
|
-
return false;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
export const toggleUnderlineWithAnalytics = editorAnalyticsAPI => ({
|
|
82
|
-
inputMethod
|
|
83
|
-
}) => withAnalytics(editorAnalyticsAPI, {
|
|
84
|
-
action: ACTION.FORMATTED,
|
|
85
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
86
|
-
eventType: EVENT_TYPE.TRACK,
|
|
87
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_UNDERLINE,
|
|
88
|
-
attributes: {
|
|
89
|
-
inputMethod
|
|
90
|
-
}
|
|
91
|
-
})(toggleUnderline());
|
|
92
|
-
export const toggleSuperscript = () => {
|
|
93
|
-
return (state, dispatch) => {
|
|
94
|
-
const {
|
|
95
|
-
subsup
|
|
96
|
-
} = state.schema.marks;
|
|
97
|
-
if (subsup) {
|
|
98
|
-
return toggleMark(subsup, {
|
|
99
|
-
type: 'sup'
|
|
100
|
-
})(state, dispatch);
|
|
101
|
-
}
|
|
102
|
-
return false;
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
export const toggleSuperscriptWithAnalytics = editorAnalyticsAPI => ({
|
|
106
|
-
inputMethod
|
|
107
|
-
}) => withAnalytics(editorAnalyticsAPI, {
|
|
108
|
-
action: ACTION.FORMATTED,
|
|
109
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
110
|
-
eventType: EVENT_TYPE.TRACK,
|
|
111
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_SUPER,
|
|
112
|
-
attributes: {
|
|
113
|
-
inputMethod
|
|
114
|
-
}
|
|
115
|
-
})(toggleSuperscript());
|
|
116
|
-
export const toggleSubscript = () => {
|
|
117
|
-
return (state, dispatch) => {
|
|
118
|
-
const {
|
|
119
|
-
subsup
|
|
120
|
-
} = state.schema.marks;
|
|
121
|
-
if (subsup) {
|
|
122
|
-
return toggleMark(subsup, {
|
|
123
|
-
type: 'sub'
|
|
124
|
-
})(state, dispatch);
|
|
125
|
-
}
|
|
126
|
-
return false;
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
export const toggleSubscriptWithAnalytics = editorAnalyticsAPI => ({
|
|
130
|
-
inputMethod
|
|
131
|
-
}) => withAnalytics(editorAnalyticsAPI, {
|
|
132
|
-
action: ACTION.FORMATTED,
|
|
133
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
134
|
-
eventType: EVENT_TYPE.TRACK,
|
|
135
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_SUB,
|
|
136
|
-
attributes: {
|
|
137
|
-
inputMethod
|
|
138
|
-
}
|
|
139
|
-
})(toggleSubscript());
|
|
140
|
-
export const toggleCode = () => {
|
|
141
|
-
return (state, dispatch) => {
|
|
142
|
-
const {
|
|
143
|
-
code
|
|
144
|
-
} = state.schema.marks;
|
|
145
|
-
if (code) {
|
|
146
|
-
return toggleMark(code)(state, dispatch);
|
|
147
|
-
}
|
|
148
|
-
return false;
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
export const toggleCodeWithAnalytics = editorAnalyticsAPI => ({
|
|
152
|
-
inputMethod
|
|
153
|
-
}) => withAnalytics(editorAnalyticsAPI, {
|
|
154
|
-
action: ACTION.FORMATTED,
|
|
155
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
156
|
-
eventType: EVENT_TYPE.TRACK,
|
|
157
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_CODE,
|
|
158
|
-
attributes: {
|
|
159
|
-
inputMethod
|
|
160
|
-
}
|
|
161
|
-
})(toggleCode());
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
2
|
-
import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { cellSelectionNodesBetween } from '../utils/cell-selection';
|
|
5
|
-
export const FORMATTING_NODE_TYPES = ['heading', 'blockquote'];
|
|
6
|
-
export const FORMATTING_MARK_TYPES = ['em', 'code', 'strike', 'strong', 'underline', 'textColor', 'subsup'];
|
|
7
|
-
const formatTypes = {
|
|
8
|
-
em: ACTION_SUBJECT_ID.FORMAT_ITALIC,
|
|
9
|
-
code: ACTION_SUBJECT_ID.FORMAT_CODE,
|
|
10
|
-
strike: ACTION_SUBJECT_ID.FORMAT_STRIKE,
|
|
11
|
-
strong: ACTION_SUBJECT_ID.FORMAT_STRONG,
|
|
12
|
-
underline: ACTION_SUBJECT_ID.FORMAT_UNDERLINE,
|
|
13
|
-
textColor: ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
14
|
-
subsup: 'subsup'
|
|
15
|
-
};
|
|
16
|
-
export function clearFormattingWithAnalytics(inputMethod, editorAnalyticsAPI) {
|
|
17
|
-
return clearFormatting(inputMethod, editorAnalyticsAPI);
|
|
18
|
-
}
|
|
19
|
-
function clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName, formattingCleared) {
|
|
20
|
-
return function (node, pos) {
|
|
21
|
-
if (node.type === formattedNodeType) {
|
|
22
|
-
if (formattedNodeType.isTextblock) {
|
|
23
|
-
tr.setNodeMarkup(pos, state.schema.nodes.paragraph);
|
|
24
|
-
formattingCleared.push(nodeName);
|
|
25
|
-
return false;
|
|
26
|
-
} else {
|
|
27
|
-
// In case of panel or blockquote
|
|
28
|
-
let fromPos = tr.doc.resolve(pos + 1);
|
|
29
|
-
let toPos = tr.doc.resolve(pos + node.nodeSize - 1);
|
|
30
|
-
const nodeRange = fromPos.blockRange(toPos);
|
|
31
|
-
if (nodeRange) {
|
|
32
|
-
const targetLiftDepth = liftTarget(nodeRange);
|
|
33
|
-
if (targetLiftDepth || targetLiftDepth === 0) {
|
|
34
|
-
formattingCleared.push(nodeName);
|
|
35
|
-
tr.lift(nodeRange, targetLiftDepth);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return true;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
export function clearFormatting(inputMethod, editorAnalyticsAPI) {
|
|
44
|
-
return function (state, dispatch) {
|
|
45
|
-
const {
|
|
46
|
-
tr
|
|
47
|
-
} = state;
|
|
48
|
-
const formattingCleared = [];
|
|
49
|
-
FORMATTING_MARK_TYPES.forEach(mark => {
|
|
50
|
-
const {
|
|
51
|
-
from,
|
|
52
|
-
to
|
|
53
|
-
} = tr.selection;
|
|
54
|
-
const markType = state.schema.marks[mark];
|
|
55
|
-
if (!markType) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (tr.selection instanceof CellSelection) {
|
|
59
|
-
cellSelectionNodesBetween(tr.selection, tr.doc, (node, pos) => {
|
|
60
|
-
const isTableCell = node.type === state.schema.nodes.tableCell || node.type === state.schema.nodes.tableHeader;
|
|
61
|
-
if (!isTableCell) {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
if (tr.doc.rangeHasMark(pos, pos + node.nodeSize, markType)) {
|
|
65
|
-
formattingCleared.push(formatTypes[mark]);
|
|
66
|
-
tr.removeMark(pos, pos + node.nodeSize, markType);
|
|
67
|
-
}
|
|
68
|
-
return false;
|
|
69
|
-
});
|
|
70
|
-
} else if (tr.doc.rangeHasMark(from, to, markType)) {
|
|
71
|
-
formattingCleared.push(formatTypes[mark]);
|
|
72
|
-
tr.removeMark(from, to, markType);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
FORMATTING_NODE_TYPES.forEach(nodeName => {
|
|
76
|
-
const formattedNodeType = state.schema.nodes[nodeName];
|
|
77
|
-
const {
|
|
78
|
-
$from,
|
|
79
|
-
$to
|
|
80
|
-
} = tr.selection;
|
|
81
|
-
if (tr.selection instanceof CellSelection) {
|
|
82
|
-
cellSelectionNodesBetween(tr.selection, tr.doc, clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName, formattingCleared));
|
|
83
|
-
} else {
|
|
84
|
-
tr.doc.nodesBetween($from.pos, $to.pos, clearNodeFormattingOnSelection(state, tr, formattedNodeType, nodeName, formattingCleared));
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
tr.setStoredMarks([]);
|
|
88
|
-
if (formattingCleared.length && inputMethod) {
|
|
89
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
90
|
-
action: ACTION.FORMATTED,
|
|
91
|
-
eventType: EVENT_TYPE.TRACK,
|
|
92
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
93
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_CLEAR,
|
|
94
|
-
attributes: {
|
|
95
|
-
inputMethod,
|
|
96
|
-
formattingCleared
|
|
97
|
-
}
|
|
98
|
-
})(tr);
|
|
99
|
-
}
|
|
100
|
-
if (dispatch) {
|
|
101
|
-
dispatch(tr);
|
|
102
|
-
}
|
|
103
|
-
return true;
|
|
104
|
-
};
|
|
105
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { applyMarkOnRange } from '@atlaskit/editor-common/mark';
|
|
3
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { hasCode, markActive } from '../utils';
|
|
5
|
-
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
6
|
-
export const moveRight = () => {
|
|
7
|
-
return (state, dispatch) => {
|
|
8
|
-
const {
|
|
9
|
-
code
|
|
10
|
-
} = state.schema.marks;
|
|
11
|
-
const {
|
|
12
|
-
empty,
|
|
13
|
-
$cursor
|
|
14
|
-
} = state.selection;
|
|
15
|
-
if (!empty || !$cursor) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
const {
|
|
19
|
-
storedMarks
|
|
20
|
-
} = state.tr;
|
|
21
|
-
if (code) {
|
|
22
|
-
const insideCode = markActive(state, code.create());
|
|
23
|
-
const currentPosHasCode = state.doc.rangeHasMark($cursor.pos, $cursor.pos, code);
|
|
24
|
-
const nextPosHasCode = state.doc.rangeHasMark($cursor.pos, $cursor.pos + 1, code);
|
|
25
|
-
const exitingCode = !currentPosHasCode && !nextPosHasCode && (!storedMarks || !!storedMarks.length);
|
|
26
|
-
const enteringCode = !currentPosHasCode && nextPosHasCode && (!storedMarks || !storedMarks.length);
|
|
27
|
-
|
|
28
|
-
// entering code mark (from the left edge): don't move the cursor, just add the mark
|
|
29
|
-
if (!insideCode && enteringCode) {
|
|
30
|
-
if (dispatch) {
|
|
31
|
-
dispatch(state.tr.addStoredMark(code.create()));
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// exiting code mark: don't move the cursor, just remove the mark
|
|
37
|
-
if (insideCode && exitingCode) {
|
|
38
|
-
if (dispatch) {
|
|
39
|
-
dispatch(state.tr.removeStoredMark(code));
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return false;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
export const moveLeft = () => {
|
|
48
|
-
return (state, dispatch) => {
|
|
49
|
-
const {
|
|
50
|
-
code
|
|
51
|
-
} = state.schema.marks;
|
|
52
|
-
const {
|
|
53
|
-
empty,
|
|
54
|
-
$cursor
|
|
55
|
-
} = state.selection;
|
|
56
|
-
if (!empty || !$cursor) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
const {
|
|
60
|
-
storedMarks
|
|
61
|
-
} = state.tr;
|
|
62
|
-
if (code) {
|
|
63
|
-
const insideCode = code && markActive(state, code.create());
|
|
64
|
-
const currentPosHasCode = hasCode(state, $cursor.pos);
|
|
65
|
-
const nextPosHasCode = hasCode(state, $cursor.pos - 1);
|
|
66
|
-
const nextNextPosHasCode = hasCode(state, $cursor.pos - 2);
|
|
67
|
-
const exitingCode = currentPosHasCode && !nextPosHasCode && Array.isArray(storedMarks);
|
|
68
|
-
const atLeftEdge = nextPosHasCode && !nextNextPosHasCode && (storedMarks === null || Array.isArray(storedMarks) && !!storedMarks.length);
|
|
69
|
-
const atRightEdge = (exitingCode && Array.isArray(storedMarks) && !storedMarks.length || !exitingCode && storedMarks === null) && !nextPosHasCode && nextNextPosHasCode;
|
|
70
|
-
const enteringCode = !currentPosHasCode && nextPosHasCode && Array.isArray(storedMarks) && !storedMarks.length;
|
|
71
|
-
|
|
72
|
-
// at the right edge: remove code mark and move the cursor to the left
|
|
73
|
-
if (!insideCode && atRightEdge) {
|
|
74
|
-
const tr = state.tr.setSelection(Selection.near(state.doc.resolve($cursor.pos - 1)));
|
|
75
|
-
if (dispatch) {
|
|
76
|
-
dispatch(tr.removeStoredMark(code));
|
|
77
|
-
}
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// entering code mark (from right edge): don't move the cursor, just add the mark
|
|
82
|
-
if (!insideCode && enteringCode) {
|
|
83
|
-
if (dispatch) {
|
|
84
|
-
dispatch(state.tr.addStoredMark(code.create()));
|
|
85
|
-
}
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// at the left edge: add code mark and move the cursor to the left
|
|
90
|
-
if (insideCode && atLeftEdge) {
|
|
91
|
-
const tr = state.tr.setSelection(Selection.near(state.doc.resolve($cursor.pos - 1)));
|
|
92
|
-
if (dispatch) {
|
|
93
|
-
dispatch(tr.addStoredMark(code.create()));
|
|
94
|
-
}
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// exiting code mark (or at the beginning of the line): don't move the cursor, just remove the mark
|
|
99
|
-
const isFirstChild = $cursor.index($cursor.depth - 1) === 0;
|
|
100
|
-
if (insideCode && (exitingCode || !$cursor.nodeBefore && isFirstChild)) {
|
|
101
|
-
if (dispatch) {
|
|
102
|
-
dispatch(state.tr.removeStoredMark(code));
|
|
103
|
-
}
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return false;
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
const createInlineCodeFromTextInput = (from, to, text) => {
|
|
111
|
-
return (state, dispatch) => {
|
|
112
|
-
if (state.selection.empty) {
|
|
113
|
-
const {
|
|
114
|
-
nodeBefore: before
|
|
115
|
-
} = state.doc.resolve(from);
|
|
116
|
-
const {
|
|
117
|
-
nodeAfter: after
|
|
118
|
-
} = state.doc.resolve(to);
|
|
119
|
-
const hasTickBefore = before && before.text && before.text.endsWith('`');
|
|
120
|
-
const hasTickAfter = after && after.text && after.text.startsWith('`');
|
|
121
|
-
if (hasTickBefore && hasTickAfter) {
|
|
122
|
-
let tr = state.tr.replaceRangeWith(from - 1, to + 1, state.schema.text(text));
|
|
123
|
-
if (dispatch) {
|
|
124
|
-
const codeMark = state.schema.marks.code.create();
|
|
125
|
-
tr = applyMarkOnRange(tr.mapping.map(from - 1), tr.mapping.map(to + 1), false, codeMark, tr).setStoredMarks([codeMark]);
|
|
126
|
-
dispatch(tr);
|
|
127
|
-
}
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return false;
|
|
132
|
-
};
|
|
133
|
-
};
|
|
134
|
-
export const createInlineCodeFromTextInputWithAnalytics = editorAnalyticsAPI => (from, to, text) => {
|
|
135
|
-
return withAnalytics(editorAnalyticsAPI, {
|
|
136
|
-
action: ACTION.FORMATTED,
|
|
137
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
138
|
-
eventType: EVENT_TYPE.TRACK,
|
|
139
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_CODE,
|
|
140
|
-
attributes: {
|
|
141
|
-
inputMethod: INPUT_METHOD.FORMATTING
|
|
142
|
-
}
|
|
143
|
-
})(createInlineCodeFromTextInput(from, to, text));
|
|
144
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { filterChildrenBetween } from '@atlaskit/editor-common/mark';
|
|
2
|
-
const SMART_TO_ASCII = {
|
|
3
|
-
'…': '...',
|
|
4
|
-
'→': '->',
|
|
5
|
-
'←': '<-',
|
|
6
|
-
'–': '--',
|
|
7
|
-
'“': '"',
|
|
8
|
-
'”': '"',
|
|
9
|
-
'‘': "'",
|
|
10
|
-
'’': "'"
|
|
11
|
-
};
|
|
12
|
-
const FIND_SMART_CHAR = new RegExp(`[${Object.keys(SMART_TO_ASCII).join('')}]`, 'g');
|
|
13
|
-
const replaceMentionOrEmojiForTextContent = (position, nodeSize, textContent, tr) => {
|
|
14
|
-
const currentPos = tr.mapping.map(position);
|
|
15
|
-
const {
|
|
16
|
-
schema
|
|
17
|
-
} = tr.doc.type;
|
|
18
|
-
tr.replaceWith(currentPos, currentPos + nodeSize, schema.text(textContent));
|
|
19
|
-
};
|
|
20
|
-
const replaceSmartCharsToAscii = (position, textContent, tr) => {
|
|
21
|
-
const {
|
|
22
|
-
schema
|
|
23
|
-
} = tr.doc.type;
|
|
24
|
-
let match;
|
|
25
|
-
while (match = FIND_SMART_CHAR.exec(textContent)) {
|
|
26
|
-
const {
|
|
27
|
-
0: smartChar,
|
|
28
|
-
index: offset
|
|
29
|
-
} = match;
|
|
30
|
-
const replacePos = tr.mapping.map(position + offset);
|
|
31
|
-
const replacementText = schema.text(SMART_TO_ASCII[smartChar]);
|
|
32
|
-
tr.replaceWith(replacePos, replacePos + smartChar.length, replacementText);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const isNodeTextBlock = schema => {
|
|
36
|
-
const {
|
|
37
|
-
mention,
|
|
38
|
-
text,
|
|
39
|
-
emoji
|
|
40
|
-
} = schema.nodes;
|
|
41
|
-
return (node, _, parent) => {
|
|
42
|
-
if (node.type === mention || node.type === emoji || node.type === text) {
|
|
43
|
-
return parent === null || parent === void 0 ? void 0 : parent.isTextblock;
|
|
44
|
-
}
|
|
45
|
-
return;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
export const transformSmartCharsMentionsAndEmojis = (from, to, tr) => {
|
|
49
|
-
const {
|
|
50
|
-
schema
|
|
51
|
-
} = tr.doc.type;
|
|
52
|
-
const {
|
|
53
|
-
mention,
|
|
54
|
-
text,
|
|
55
|
-
emoji
|
|
56
|
-
} = schema.nodes;
|
|
57
|
-
// Traverse through all the nodes within the range and replace them with their plaintext counterpart
|
|
58
|
-
const children = filterChildrenBetween(tr.doc, from, to, isNodeTextBlock(schema));
|
|
59
|
-
children.forEach(({
|
|
60
|
-
node,
|
|
61
|
-
pos
|
|
62
|
-
}) => {
|
|
63
|
-
if (node.type === mention || node.type === emoji) {
|
|
64
|
-
replaceMentionOrEmojiForTextContent(pos, node.nodeSize, node.attrs.text, tr);
|
|
65
|
-
} else if (node.type === text && node.text) {
|
|
66
|
-
const replacePosition = pos > from ? pos : from;
|
|
67
|
-
const textToReplace = pos > from ? node.text : node.text.substr(from - pos);
|
|
68
|
-
replaceSmartCharsToAscii(replacePosition, textToReplace, tr);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
};
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { code, em, strike, strong, subsup, underline } from '@atlaskit/adf-schema';
|
|
3
|
-
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
4
|
-
import { plugin as textFormattingPlugin, pluginKey as textFormattingPluginKey } from './pm-plugins/main';
|
|
5
|
-
import { plugin as clearFormattingPlugin, pluginKey as clearFormattingPluginKey } from './pm-plugins/clear-formatting';
|
|
6
|
-
import clearFormattingKeymapPlugin from './pm-plugins/clear-formatting-keymap';
|
|
7
|
-
import textFormattingCursorPlugin from './pm-plugins/cursor';
|
|
8
|
-
import textFormattingInputRulePlugin from './pm-plugins/input-rule';
|
|
9
|
-
import keymapPlugin from './pm-plugins/keymap';
|
|
10
|
-
import textFormattingSmartInputRulePlugin from './pm-plugins/smart-input-rule';
|
|
11
|
-
import Toolbar from './ui/Toolbar';
|
|
12
|
-
import { toggleSuperscriptWithAnalytics, toggleSubscriptWithAnalytics, toggleStrikeWithAnalytics, toggleCodeWithAnalytics, toggleUnderlineWithAnalytics, toggleEmWithAnalytics, toggleStrongWithAnalytics } from './actions';
|
|
13
|
-
const textFormatting = (options = {}, api) => {
|
|
14
|
-
var _api$dependencies$ana7, _api$dependencies$ana8, _api$dependencies$ana9, _api$dependencies$ana10, _api$dependencies$ana11, _api$dependencies$ana12, _api$dependencies$ana13;
|
|
15
|
-
return {
|
|
16
|
-
name: 'textFormatting',
|
|
17
|
-
marks() {
|
|
18
|
-
return [{
|
|
19
|
-
name: 'em',
|
|
20
|
-
mark: em
|
|
21
|
-
}, {
|
|
22
|
-
name: 'strong',
|
|
23
|
-
mark: strong
|
|
24
|
-
}, {
|
|
25
|
-
name: 'strike',
|
|
26
|
-
mark: strike
|
|
27
|
-
}].concat(options.disableCode ? [] : {
|
|
28
|
-
name: 'code',
|
|
29
|
-
mark: code
|
|
30
|
-
}).concat(options.disableSuperscriptAndSubscript ? [] : {
|
|
31
|
-
name: 'subsup',
|
|
32
|
-
mark: subsup
|
|
33
|
-
}).concat(options.disableUnderline ? [] : {
|
|
34
|
-
name: 'underline',
|
|
35
|
-
mark: underline
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
pmPlugins() {
|
|
39
|
-
return [{
|
|
40
|
-
name: 'textFormatting',
|
|
41
|
-
plugin: ({
|
|
42
|
-
dispatch
|
|
43
|
-
}) => {
|
|
44
|
-
var _api$dependencies$ana;
|
|
45
|
-
return textFormattingPlugin(dispatch, api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions);
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
name: 'textFormattingCursor',
|
|
49
|
-
plugin: () => textFormattingCursorPlugin
|
|
50
|
-
}, {
|
|
51
|
-
name: 'textFormattingInputRule',
|
|
52
|
-
// Don't remove the unused featureFlags, this gets used to test if we're properly passing them to the PM plugin
|
|
53
|
-
plugin: ({
|
|
54
|
-
schema,
|
|
55
|
-
featureFlags
|
|
56
|
-
}) => {
|
|
57
|
-
var _api$dependencies$ana2;
|
|
58
|
-
return textFormattingInputRulePlugin(schema, featureFlags, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions);
|
|
59
|
-
}
|
|
60
|
-
}, {
|
|
61
|
-
name: 'textFormattingSmartRule',
|
|
62
|
-
plugin: () => {
|
|
63
|
-
var _api$dependencies$ana3;
|
|
64
|
-
return !options.disableSmartTextCompletion ? textFormattingSmartInputRulePlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions) : undefined;
|
|
65
|
-
}
|
|
66
|
-
}, {
|
|
67
|
-
name: 'textFormattingClear',
|
|
68
|
-
plugin: ({
|
|
69
|
-
dispatch
|
|
70
|
-
}) => clearFormattingPlugin(dispatch)
|
|
71
|
-
}, {
|
|
72
|
-
name: 'textFormattingClearKeymap',
|
|
73
|
-
plugin: () => {
|
|
74
|
-
var _api$dependencies$ana4;
|
|
75
|
-
return clearFormattingKeymapPlugin(api === null || api === void 0 ? void 0 : (_api$dependencies$ana4 = api.dependencies.analytics) === null || _api$dependencies$ana4 === void 0 ? void 0 : _api$dependencies$ana4.actions);
|
|
76
|
-
}
|
|
77
|
-
}, {
|
|
78
|
-
name: 'textFormattingKeymap',
|
|
79
|
-
plugin: ({
|
|
80
|
-
schema
|
|
81
|
-
}) => {
|
|
82
|
-
var _api$dependencies$ana5;
|
|
83
|
-
return keymapPlugin(schema, api === null || api === void 0 ? void 0 : (_api$dependencies$ana5 = api.dependencies.analytics) === null || _api$dependencies$ana5 === void 0 ? void 0 : _api$dependencies$ana5.actions);
|
|
84
|
-
}
|
|
85
|
-
}];
|
|
86
|
-
},
|
|
87
|
-
primaryToolbarComponent({
|
|
88
|
-
editorView,
|
|
89
|
-
popupsMountPoint,
|
|
90
|
-
popupsScrollableElement,
|
|
91
|
-
isToolbarReducedSpacing,
|
|
92
|
-
toolbarSize,
|
|
93
|
-
disabled
|
|
94
|
-
}) {
|
|
95
|
-
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
96
|
-
plugins: {
|
|
97
|
-
textFormattingState: textFormattingPluginKey,
|
|
98
|
-
clearFormattingPluginState: clearFormattingPluginKey
|
|
99
|
-
},
|
|
100
|
-
render: () => {
|
|
101
|
-
var _api$dependencies$ana6;
|
|
102
|
-
return /*#__PURE__*/React.createElement(Toolbar, {
|
|
103
|
-
editorState: editorView.state,
|
|
104
|
-
popupsMountPoint: popupsMountPoint,
|
|
105
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
106
|
-
toolbarSize: toolbarSize,
|
|
107
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
108
|
-
editorView: editorView,
|
|
109
|
-
isToolbarDisabled: disabled,
|
|
110
|
-
shouldUseResponsiveToolbar: Boolean(options.responsiveToolbarMenu),
|
|
111
|
-
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$dependencies$ana6 = api.dependencies.analytics) === null || _api$dependencies$ana6 === void 0 ? void 0 : _api$dependencies$ana6.actions
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
},
|
|
116
|
-
actions: {
|
|
117
|
-
toggleSuperscript: toggleSuperscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana7 = api.dependencies.analytics) === null || _api$dependencies$ana7 === void 0 ? void 0 : _api$dependencies$ana7.actions),
|
|
118
|
-
toggleSubscript: toggleSubscriptWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana8 = api.dependencies.analytics) === null || _api$dependencies$ana8 === void 0 ? void 0 : _api$dependencies$ana8.actions),
|
|
119
|
-
toggleStrike: toggleStrikeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana9 = api.dependencies.analytics) === null || _api$dependencies$ana9 === void 0 ? void 0 : _api$dependencies$ana9.actions),
|
|
120
|
-
toggleCode: toggleCodeWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana10 = api.dependencies.analytics) === null || _api$dependencies$ana10 === void 0 ? void 0 : _api$dependencies$ana10.actions),
|
|
121
|
-
toggleUnderline: toggleUnderlineWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana11 = api.dependencies.analytics) === null || _api$dependencies$ana11 === void 0 ? void 0 : _api$dependencies$ana11.actions),
|
|
122
|
-
toggleEm: toggleEmWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana12 = api.dependencies.analytics) === null || _api$dependencies$ana12 === void 0 ? void 0 : _api$dependencies$ana12.actions),
|
|
123
|
-
toggleStrong: toggleStrongWithAnalytics(api === null || api === void 0 ? void 0 : (_api$dependencies$ana13 = api.dependencies.analytics) === null || _api$dependencies$ana13 === void 0 ? void 0 : _api$dependencies$ana13.actions)
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
export default textFormatting;
|