@atlaskit/editor-core 187.9.2 → 187.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -0
- package/CHANGELOG.md +17 -0
- package/dist/cjs/commands/index.js +8 -134
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/plugins/base/index.js +2 -2
- package/dist/cjs/plugins/block-type/commands/block-type.js +34 -36
- package/dist/cjs/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/cjs/plugins/block-type/index.js +16 -13
- package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +19 -18
- package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +12 -14
- package/dist/cjs/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +7 -7
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +3 -4
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +13 -5
- package/dist/cjs/plugins/block-type/utils.js +73 -2
- package/dist/cjs/plugins/caption/pm-plugins/keymap.js +2 -2
- package/dist/cjs/plugins/floating-toolbar/index.js +154 -132
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/force-focus/index.js +11 -10
- package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +14 -7
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +6 -1
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +4 -1
- package/dist/cjs/plugins/media/toolbar/alt-text.js +6 -6
- package/dist/cjs/plugins/media/toolbar/linking.js +4 -1
- package/dist/cjs/plugins/media/ui/MediaLinkingToolbar.js +2 -2
- package/dist/cjs/plugins/media/utils/media-common.js +5 -5
- package/dist/cjs/plugins/undo-redo/pm-plugins/keymaps.js +2 -2
- package/dist/cjs/ui/ColorPickerButton/index.js +3 -3
- package/dist/cjs/ui/styles.js +4 -11
- package/dist/cjs/utils/index.js +4 -80
- package/dist/cjs/utils/input-rules.js +6 -66
- package/dist/cjs/utils/mark.js +2 -38
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/commands/index.js +1 -128
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/plugins/base/index.js +1 -1
- package/dist/es2019/plugins/block-type/commands/block-type.js +11 -13
- package/dist/es2019/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/es2019/plugins/block-type/index.js +21 -12
- package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +18 -18
- package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +8 -9
- package/dist/es2019/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -2
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +2 -3
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +21 -2
- package/dist/es2019/plugins/block-type/utils.js +70 -1
- package/dist/es2019/plugins/caption/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/floating-toolbar/index.js +152 -128
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/force-focus/index.js +12 -8
- package/dist/es2019/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +5 -4
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +12 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +3 -1
- package/dist/es2019/plugins/media/toolbar/alt-text.js +10 -6
- package/dist/es2019/plugins/media/toolbar/linking.js +8 -1
- package/dist/es2019/plugins/media/ui/MediaLinkingToolbar.js +5 -3
- package/dist/es2019/plugins/media/utils/media-common.js +1 -1
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -1
- package/dist/es2019/plugins/undo-redo/pm-plugins/keymaps.js +1 -1
- package/dist/es2019/ui/ColorPickerButton/index.js +2 -2
- package/dist/es2019/ui/styles.js +0 -16
- package/dist/es2019/utils/index.js +0 -80
- package/dist/es2019/utils/input-rules.js +4 -61
- package/dist/es2019/utils/mark.js +0 -33
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/commands/index.js +7 -125
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/plugins/base/index.js +1 -1
- package/dist/esm/plugins/block-type/commands/block-type.js +11 -13
- package/dist/esm/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/esm/plugins/block-type/index.js +15 -12
- package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +18 -18
- package/dist/esm/plugins/block-type/pm-plugins/keymap.js +8 -9
- package/dist/esm/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -2
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +2 -3
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +8 -4
- package/dist/esm/plugins/block-type/utils.js +69 -1
- package/dist/esm/plugins/caption/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/floating-toolbar/index.js +153 -131
- package/dist/esm/plugins/floating-toolbar/pm-plugins/force-focus/index.js +9 -7
- package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +14 -7
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +6 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.js +4 -1
- package/dist/esm/plugins/media/toolbar/alt-text.js +6 -6
- package/dist/esm/plugins/media/toolbar/linking.js +4 -1
- package/dist/esm/plugins/media/ui/MediaLinkingToolbar.js +2 -2
- package/dist/esm/plugins/media/utils/media-common.js +1 -1
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -1
- package/dist/esm/plugins/undo-redo/pm-plugins/keymaps.js +1 -1
- package/dist/esm/ui/ColorPickerButton/index.js +3 -3
- package/dist/esm/ui/styles.js +3 -6
- package/dist/esm/utils/index.js +3 -77
- package/dist/esm/utils/input-rules.js +4 -61
- package/dist/esm/utils/mark.js +0 -35
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/commands/index.d.ts +0 -6
- package/dist/types/labs/next/presets/default.d.ts +40 -8
- package/dist/types/plugins/block-type/commands/block-type.d.ts +5 -6
- package/dist/types/plugins/block-type/commands/delete-and-move-cursor.d.ts +1 -1
- package/dist/types/plugins/block-type/commands/delete-block-content.d.ts +1 -1
- package/dist/types/plugins/block-type/index.d.ts +1 -1
- package/dist/types/plugins/block-type/pm-plugins/input-rule.d.ts +3 -2
- package/dist/types/plugins/block-type/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/plugins/block-type/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/block-type/styles.d.ts +1 -1
- package/dist/types/plugins/block-type/types.d.ts +2 -3
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -2
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/index.d.ts +2 -2
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +5 -1
- package/dist/types/plugins/block-type/utils.d.ts +15 -1
- package/dist/types/plugins/date/index.d.ts +2 -2
- package/dist/types/plugins/floating-toolbar/index.d.ts +1 -7
- package/dist/types/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +2 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.d.ts +2 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/types.d.ts +0 -3
- package/dist/types/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/media/index.d.ts +2 -2
- package/dist/types/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.d.ts +1 -0
- package/dist/types/plugins/media/ui/MediaLinkingToolbar.d.ts +3 -3
- package/dist/types/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
- package/dist/types/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ColorPickerButton/index.d.ts +2 -2
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/ui/styles.d.ts +0 -3
- package/dist/types/utils/index.d.ts +0 -6
- package/dist/types/utils/input-rules.d.ts +4 -16
- package/dist/types/utils/mark.d.ts +0 -1
- package/dist/types-ts4.5/commands/index.d.ts +0 -6
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +44 -8
- package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +5 -6
- package/dist/types-ts4.5/plugins/block-type/commands/delete-and-move-cursor.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/commands/delete-block-content.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/input-rule.d.ts +3 -2
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/plugins/block-type/styles.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/types.d.ts +2 -3
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -2
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +5 -1
- package/dist/types-ts4.5/plugins/block-type/utils.d.ts +15 -1
- package/dist/types-ts4.5/plugins/date/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +1 -7
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +1 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.d.ts +1 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +1 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.d.ts +2 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/types.d.ts +0 -3
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +1 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/media/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/ui/AltTextEdit.d.ts +1 -0
- package/dist/types-ts4.5/plugins/media/ui/MediaLinkingToolbar.d.ts +3 -3
- package/dist/types-ts4.5/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
- package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ColorPickerButton/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/styles.d.ts +0 -3
- package/dist/types-ts4.5/utils/index.d.ts +0 -6
- package/dist/types-ts4.5/utils/input-rules.d.ts +4 -16
- package/dist/types-ts4.5/utils/mark.d.ts +0 -1
- package/package.json +6 -5
- package/report.api.md +9 -37
- package/tmp/api-report-tmp.d.ts +8 -34
- package/dist/cjs/plugins/editor-disabled/index.js +0 -75
- package/dist/cjs/types/allowed-block-types.js +0 -5
- package/dist/cjs/utils/keymap.js +0 -38
- package/dist/es2019/plugins/editor-disabled/index.js +0 -62
- package/dist/es2019/types/allowed-block-types.js +0 -1
- package/dist/es2019/utils/keymap.js +0 -33
- package/dist/esm/plugins/editor-disabled/index.js +0 -66
- package/dist/esm/types/allowed-block-types.js +0 -1
- package/dist/esm/utils/keymap.js +0 -33
- package/dist/types/plugins/editor-disabled/index.d.ts +0 -13
- package/dist/types/types/allowed-block-types.d.ts +0 -1
- package/dist/types/utils/keymap.d.ts +0 -11
- package/dist/types-ts4.5/plugins/editor-disabled/index.d.ts +0 -13
- package/dist/types-ts4.5/types/allowed-block-types.d.ts +0 -1
- package/dist/types-ts4.5/utils/keymap.d.ts +0 -11
- /package/dist/cjs/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/es2019/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/esm/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/types/{keymaps → plugins/block-type}/consts.d.ts +0 -0
- /package/dist/types-ts4.5/{keymaps → plugins/block-type}/consts.d.ts +0 -0
package/dist/cjs/ui/styles.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.expandIconWrapperStyle = exports.clickSelectWrapperStyle =
|
|
7
|
+
exports.expandIconWrapperStyle = exports.clickSelectWrapperStyle = void 0;
|
|
8
8
|
Object.defineProperty(exports, "scrollbarStyles", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function get() {
|
|
@@ -17,19 +17,12 @@ Object.defineProperty(exports, "shortcutStyle", {
|
|
|
17
17
|
return _shortcut.shortcutStyle;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
exports.wrapperSmallStyle = void 0;
|
|
21
20
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
22
21
|
var _react = require("@emotion/react");
|
|
23
22
|
var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
24
23
|
var _scrollbar = require("@atlaskit/editor-shared-styles/scrollbar");
|
|
25
|
-
var _templateObject, _templateObject2
|
|
26
|
-
var
|
|
27
|
-
exports.wrapperSmallStyle = wrapperSmallStyle;
|
|
28
|
-
var expandIconWrapperStyle = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n margin-left: -8px;\n"])));
|
|
24
|
+
var _templateObject, _templateObject2;
|
|
25
|
+
var expandIconWrapperStyle = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n margin-left: -8px;\n"])));
|
|
29
26
|
exports.expandIconWrapperStyle = expandIconWrapperStyle;
|
|
30
|
-
var
|
|
31
|
-
exports.buttonContentStyle = buttonContentStyle;
|
|
32
|
-
var buttonContentReducedSpacingStyle = (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n padding: ", ";\n"])), "var(--ds-space-100, 8px)");
|
|
33
|
-
exports.buttonContentReducedSpacingStyle = buttonContentReducedSpacingStyle;
|
|
34
|
-
var clickSelectWrapperStyle = (0, _react.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n user-select: all;\n"])));
|
|
27
|
+
var clickSelectWrapperStyle = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n user-select: all;\n"])));
|
|
35
28
|
exports.clickSelectWrapperStyle = clickSelectWrapperStyle;
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -10,9 +10,6 @@ Object.defineProperty(exports, "SetAttrsStep", {
|
|
|
10
10
|
return _steps.SetAttrsStep;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
exports.areBlockTypesDisabled = areBlockTypesDisabled;
|
|
14
|
-
exports.canMoveDown = canMoveDown;
|
|
15
|
-
exports.canMoveUp = canMoveUp;
|
|
16
13
|
exports.checkNodeDown = checkNodeDown;
|
|
17
14
|
exports.compose = compose;
|
|
18
15
|
exports.dedupe = dedupe;
|
|
@@ -138,18 +135,16 @@ exports.sum = sum;
|
|
|
138
135
|
exports.toJSON = toJSON;
|
|
139
136
|
exports.whichTransitionEvent = whichTransitionEvent;
|
|
140
137
|
var _commands = require("@atlaskit/editor-prosemirror/commands");
|
|
141
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
142
138
|
var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
|
|
143
139
|
var _cursor = require("../plugins/fake-text-cursor/cursor");
|
|
144
140
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
145
141
|
var _document = require("./document");
|
|
146
|
-
var _position = require("./prosemirror/position");
|
|
147
|
-
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
148
142
|
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
149
143
|
var _mark = require("./mark");
|
|
150
144
|
var _nodes = require("./nodes");
|
|
151
145
|
var _selection = require("./selection");
|
|
152
146
|
var _measureEnum = _interopRequireDefault(require("./performance/measure-enum"));
|
|
147
|
+
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
153
148
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
154
149
|
function isMarkTypeCompatibleWithMark(markType, mark) {
|
|
155
150
|
return !mark.type.excludes(markType) && !markType.excludes(mark.type);
|
|
@@ -157,37 +152,6 @@ function isMarkTypeCompatibleWithMark(markType, mark) {
|
|
|
157
152
|
function isMarkTypeAllowedInNode(markType, state) {
|
|
158
153
|
return (0, _commands.toggleMark)(markType)(state);
|
|
159
154
|
}
|
|
160
|
-
function canMoveUp(state) {
|
|
161
|
-
var selection = state.selection;
|
|
162
|
-
/**
|
|
163
|
-
* If there's a media element on the selection it will use a gap cursor to move
|
|
164
|
-
*/
|
|
165
|
-
if (selection instanceof _state.NodeSelection && (0, _utils2.isMediaNode)(selection.node)) {
|
|
166
|
-
return true;
|
|
167
|
-
}
|
|
168
|
-
if (selection instanceof _state.TextSelection) {
|
|
169
|
-
if (!selection.empty) {
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return !(0, _position.atTheBeginningOfDoc)(state);
|
|
174
|
-
}
|
|
175
|
-
function canMoveDown(state) {
|
|
176
|
-
var selection = state.selection;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* If there's a media element on the selection it will use a gap cursor to move
|
|
180
|
-
*/
|
|
181
|
-
if (selection instanceof _state.NodeSelection && (0, _utils2.isMediaNode)(selection.node)) {
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
if (selection instanceof _state.TextSelection) {
|
|
185
|
-
if (!selection.empty) {
|
|
186
|
-
return true;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return !(0, _position.atTheEndOfDoc)(state);
|
|
190
|
-
}
|
|
191
155
|
function isSelectionInsideLastNodeInDocument(selection) {
|
|
192
156
|
var docNode = selection.$anchor.node(0);
|
|
193
157
|
var rootNode = selection.$anchor.node(1);
|
|
@@ -312,46 +276,6 @@ function whichTransitionEvent() {
|
|
|
312
276
|
}
|
|
313
277
|
return;
|
|
314
278
|
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Function will create a list of wrapper blocks present in a selection.
|
|
318
|
-
*/
|
|
319
|
-
function getSelectedWrapperNodes(state) {
|
|
320
|
-
var nodes = [];
|
|
321
|
-
if (state.selection) {
|
|
322
|
-
var _state$selection = state.selection,
|
|
323
|
-
$from = _state$selection.$from,
|
|
324
|
-
$to = _state$selection.$to;
|
|
325
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
326
|
-
blockquote = _state$schema$nodes.blockquote,
|
|
327
|
-
panel = _state$schema$nodes.panel,
|
|
328
|
-
orderedList = _state$schema$nodes.orderedList,
|
|
329
|
-
bulletList = _state$schema$nodes.bulletList,
|
|
330
|
-
listItem = _state$schema$nodes.listItem,
|
|
331
|
-
codeBlock = _state$schema$nodes.codeBlock,
|
|
332
|
-
decisionItem = _state$schema$nodes.decisionItem,
|
|
333
|
-
decisionList = _state$schema$nodes.decisionList,
|
|
334
|
-
taskItem = _state$schema$nodes.taskItem,
|
|
335
|
-
taskList = _state$schema$nodes.taskList;
|
|
336
|
-
state.doc.nodesBetween($from.pos, $to.pos, function (node) {
|
|
337
|
-
if (node.isBlock && [blockquote, panel, orderedList, bulletList, listItem, codeBlock, decisionItem, decisionList, taskItem, taskList].indexOf(node.type) >= 0) {
|
|
338
|
-
nodes.push(node.type);
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
return nodes;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Function will check if changing block types: Paragraph, Heading is enabled.
|
|
347
|
-
*/
|
|
348
|
-
function areBlockTypesDisabled(state) {
|
|
349
|
-
var nodesTypes = getSelectedWrapperNodes(state);
|
|
350
|
-
var panel = state.schema.nodes.panel;
|
|
351
|
-
return nodesTypes.filter(function (type) {
|
|
352
|
-
return type !== panel;
|
|
353
|
-
}).length > 0;
|
|
354
|
-
}
|
|
355
279
|
var isTemporary = function isTemporary(id) {
|
|
356
280
|
return id.indexOf('temporary:') === 0;
|
|
357
281
|
};
|
|
@@ -410,9 +334,9 @@ var isEmptyNode = function isEmptyNode(schema) {
|
|
|
410
334
|
};
|
|
411
335
|
exports.isEmptyNode = isEmptyNode;
|
|
412
336
|
var insideTableCell = function insideTableCell(state) {
|
|
413
|
-
var _state$schema$
|
|
414
|
-
tableCell = _state$schema$
|
|
415
|
-
tableHeader = _state$schema$
|
|
337
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
338
|
+
tableCell = _state$schema$nodes.tableCell,
|
|
339
|
+
tableHeader = _state$schema$nodes.tableHeader;
|
|
416
340
|
return (0, _utils.hasParentNodeOfType)([tableCell, tableHeader])(state.selection);
|
|
417
341
|
};
|
|
418
342
|
exports.insideTableCell = insideTableCell;
|
|
@@ -4,14 +4,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.ruleWithAnalytics =
|
|
7
|
+
exports.ruleWithAnalytics = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
10
|
-
var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
|
|
11
9
|
var _analytics = require("../plugins/analytics");
|
|
12
|
-
var _analytics2 = require("@atlaskit/editor-common/analytics");
|
|
13
10
|
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; }
|
|
14
11
|
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) { (0, _defineProperty2.default)(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; }
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
* @deprecated Use import {inputRuleWithAnalytics} from "@atlaskit/editor-common/utils"; instead
|
|
15
|
+
*/
|
|
15
16
|
var ruleWithAnalytics = function ruleWithAnalytics(getPayload) {
|
|
16
17
|
return function (originalRule) {
|
|
17
18
|
var onHandlerApply = function onHandlerApply(state, tr, matchResult) {
|
|
@@ -26,65 +27,4 @@ var ruleWithAnalytics = function ruleWithAnalytics(getPayload) {
|
|
|
26
27
|
});
|
|
27
28
|
};
|
|
28
29
|
};
|
|
29
|
-
exports.ruleWithAnalytics = ruleWithAnalytics;
|
|
30
|
-
var createWrappingTextBlockRule = function createWrappingTextBlockRule(_ref) {
|
|
31
|
-
var match = _ref.match,
|
|
32
|
-
nodeType = _ref.nodeType,
|
|
33
|
-
getAttrs = _ref.getAttrs;
|
|
34
|
-
var handler = function handler(state, match, start, end) {
|
|
35
|
-
var fixedStart = Math.max(start, 1);
|
|
36
|
-
var $start = state.doc.resolve(fixedStart);
|
|
37
|
-
var attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
|
|
38
|
-
var nodeBefore = $start.node(-1);
|
|
39
|
-
if (nodeBefore && !nodeBefore.canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
return state.tr.delete(fixedStart, end).setBlockType(fixedStart, fixedStart, nodeType, attrs);
|
|
43
|
-
};
|
|
44
|
-
return (0, _prosemirrorInputRules.createRule)(match, handler);
|
|
45
|
-
};
|
|
46
|
-
exports.createWrappingTextBlockRule = createWrappingTextBlockRule;
|
|
47
|
-
var createWrappingJoinRule = function createWrappingJoinRule(_ref2) {
|
|
48
|
-
var match = _ref2.match,
|
|
49
|
-
nodeType = _ref2.nodeType,
|
|
50
|
-
getAttrs = _ref2.getAttrs,
|
|
51
|
-
joinPredicate = _ref2.joinPredicate;
|
|
52
|
-
var handler = function handler(state, match, start, end) {
|
|
53
|
-
var attrs = (getAttrs instanceof Function ? getAttrs(match) : getAttrs) || {};
|
|
54
|
-
var tr = state.tr;
|
|
55
|
-
var fixedStart = Math.max(start, 1);
|
|
56
|
-
tr.delete(fixedStart, end);
|
|
57
|
-
var $start = tr.doc.resolve(fixedStart);
|
|
58
|
-
var range = $start.blockRange();
|
|
59
|
-
var wrapping = range && (0, _transform.findWrapping)(range, nodeType, attrs);
|
|
60
|
-
if (!wrapping || !range) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
var parentNodePosMapped = tr.mapping.map(range.start);
|
|
64
|
-
var parentNode = tr.doc.nodeAt(parentNodePosMapped);
|
|
65
|
-
var lastWrap = wrapping[wrapping.length - 1];
|
|
66
|
-
if (parentNode && lastWrap) {
|
|
67
|
-
var allowedMarks = lastWrap.type.allowedMarks(parentNode.marks) || [];
|
|
68
|
-
tr.setNodeMarkup(parentNodePosMapped, parentNode.type, parentNode.attrs, allowedMarks);
|
|
69
|
-
}
|
|
70
|
-
tr.wrap(range, wrapping);
|
|
71
|
-
var before = tr.doc.resolve(fixedStart - 1).nodeBefore;
|
|
72
|
-
if (before && before.type === nodeType && (0, _transform.canJoin)(tr.doc, fixedStart - 1) && (!joinPredicate || joinPredicate(match, before, _analytics2.JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.JOINED_TO_LIST_ABOVE))) {
|
|
73
|
-
tr.join(fixedStart - 1);
|
|
74
|
-
}
|
|
75
|
-
return tr;
|
|
76
|
-
};
|
|
77
|
-
return (0, _prosemirrorInputRules.createRule)(match, handler);
|
|
78
|
-
};
|
|
79
|
-
exports.createWrappingJoinRule = createWrappingJoinRule;
|
|
80
|
-
var createJoinNodesRule = function createJoinNodesRule(match, nodeType) {
|
|
81
|
-
return createWrappingJoinRule({
|
|
82
|
-
nodeType: nodeType,
|
|
83
|
-
match: match,
|
|
84
|
-
getAttrs: {},
|
|
85
|
-
joinPredicate: function joinPredicate(_, node) {
|
|
86
|
-
return node.type === nodeType;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
exports.createJoinNodesRule = createJoinNodesRule;
|
|
30
|
+
exports.ruleWithAnalytics = ruleWithAnalytics;
|
package/dist/cjs/utils/mark.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.sanitiseSelectionMarksForWrapping = exports.sanitiseMarksInSelection = exports.
|
|
7
|
+
exports.sanitiseSelectionMarksForWrapping = exports.sanitiseMarksInSelection = exports.isMarkExcluded = exports.isMarkAllowedInRange = void 0;
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var isMarkAllowedInRange = function isMarkAllowedInRange(doc, ranges, type) {
|
|
10
10
|
var _loop = function _loop() {
|
|
@@ -40,47 +40,11 @@ var isMarkExcluded = function isMarkExcluded(type, marks) {
|
|
|
40
40
|
}
|
|
41
41
|
return false;
|
|
42
42
|
};
|
|
43
|
-
exports.isMarkExcluded = isMarkExcluded;
|
|
44
|
-
var not = function not(fn) {
|
|
45
|
-
return function (arg) {
|
|
46
|
-
return !fn(arg);
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
var removeBlockMarks = function removeBlockMarks(state, marks) {
|
|
50
|
-
var selection = state.selection,
|
|
51
|
-
schema = state.schema;
|
|
52
|
-
var tr = state.tr;
|
|
53
|
-
|
|
54
|
-
// Marks might not exist in Schema
|
|
55
|
-
var marksToRemove = marks.filter(Boolean);
|
|
56
|
-
if (marksToRemove.length === 0) {
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** Saves an extra dispatch */
|
|
61
|
-
var blockMarksExists = false;
|
|
62
|
-
var hasMark = function hasMark(mark) {
|
|
63
|
-
return marksToRemove.indexOf(mark.type) > -1;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* When you need to toggle the selection
|
|
67
|
-
* when another type which does not allow alignment is applied
|
|
68
|
-
*/
|
|
69
|
-
state.doc.nodesBetween(selection.from, selection.to, function (node, pos) {
|
|
70
|
-
if (node.type === schema.nodes.paragraph && node.marks.some(hasMark)) {
|
|
71
|
-
blockMarksExists = true;
|
|
72
|
-
var resolvedPos = state.doc.resolve(pos);
|
|
73
|
-
var withoutBlockMarks = node.marks.filter(not(hasMark));
|
|
74
|
-
tr = tr.setNodeMarkup(resolvedPos.pos, undefined, node.attrs, withoutBlockMarks);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return blockMarksExists ? tr : undefined;
|
|
78
|
-
};
|
|
79
43
|
|
|
80
44
|
/**
|
|
81
45
|
* Removes marks from nodes in the current selection that are not supported
|
|
82
46
|
*/
|
|
83
|
-
exports.
|
|
47
|
+
exports.isMarkExcluded = isMarkExcluded;
|
|
84
48
|
var sanitiseSelectionMarksForWrapping = function sanitiseSelectionMarksForWrapping(state, newParentType) {
|
|
85
49
|
var tr = state.tr;
|
|
86
50
|
sanitiseMarksInSelection(tr, newParentType);
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/editor-core";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "187.
|
|
9
|
+
var version = "187.10.1";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,132 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
1
|
+
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
2
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, withAnalytics } from '../plugins/analytics';
|
|
5
|
-
import { canMoveDown, canMoveUp } from '../utils';
|
|
6
|
-
export function preventDefault() {
|
|
7
|
-
return function () {
|
|
8
|
-
return true;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export function insertNewLine() {
|
|
12
|
-
return function (state, dispatch) {
|
|
13
|
-
const {
|
|
14
|
-
$from
|
|
15
|
-
} = state.selection;
|
|
16
|
-
const parent = $from.parent;
|
|
17
|
-
const {
|
|
18
|
-
hardBreak
|
|
19
|
-
} = state.schema.nodes;
|
|
20
|
-
if (hardBreak) {
|
|
21
|
-
const hardBreakNode = hardBreak.createChecked();
|
|
22
|
-
if (parent && parent.type.validContent(Fragment.from(hardBreakNode))) {
|
|
23
|
-
if (dispatch) {
|
|
24
|
-
dispatch(state.tr.replaceSelectionWith(hardBreakNode, false));
|
|
25
|
-
}
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (state.selection instanceof TextSelection) {
|
|
30
|
-
if (dispatch) {
|
|
31
|
-
dispatch(state.tr.insertText('\n'));
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export const insertNewLineWithAnalytics = withAnalytics({
|
|
39
|
-
action: ACTION.INSERTED,
|
|
40
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
41
|
-
actionSubjectId: ACTION_SUBJECT_ID.LINE_BREAK,
|
|
42
|
-
eventType: EVENT_TYPE.TRACK
|
|
43
|
-
})(insertNewLine());
|
|
44
|
-
export const createNewParagraphAbove = (state, dispatch) => {
|
|
45
|
-
const append = false;
|
|
46
|
-
if (!canMoveUp(state) && canCreateParagraphNear(state)) {
|
|
47
|
-
createParagraphNear(append)(state, dispatch);
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
return false;
|
|
51
|
-
};
|
|
52
|
-
export const createNewParagraphBelow = (state, dispatch) => {
|
|
53
|
-
const append = true;
|
|
54
|
-
if (!canMoveDown(state) && canCreateParagraphNear(state)) {
|
|
55
|
-
createParagraphNear(append)(state, dispatch);
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
59
|
-
};
|
|
60
|
-
function canCreateParagraphNear(state) {
|
|
61
|
-
const {
|
|
62
|
-
selection: {
|
|
63
|
-
$from
|
|
64
|
-
}
|
|
65
|
-
} = state;
|
|
66
|
-
const node = $from.node($from.depth);
|
|
67
|
-
const insideCodeBlock = !!node && node.type === state.schema.nodes.codeBlock;
|
|
68
|
-
const isNodeSelection = state.selection instanceof NodeSelection;
|
|
69
|
-
return $from.depth > 1 || isNodeSelection || insideCodeBlock;
|
|
70
|
-
}
|
|
71
|
-
export function createParagraphNear(append = true) {
|
|
72
|
-
return function (state, dispatch) {
|
|
73
|
-
const paragraph = state.schema.nodes.paragraph;
|
|
74
|
-
if (!paragraph) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
let insertPos;
|
|
78
|
-
if (state.selection instanceof TextSelection) {
|
|
79
|
-
if (topLevelNodeIsEmptyTextBlock(state)) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
insertPos = getInsertPosFromTextBlock(state, append);
|
|
83
|
-
} else {
|
|
84
|
-
insertPos = getInsertPosFromNonTextBlock(state, append);
|
|
85
|
-
}
|
|
86
|
-
const tr = state.tr.insert(insertPos, paragraph.createAndFill());
|
|
87
|
-
tr.setSelection(TextSelection.create(tr.doc, insertPos + 1));
|
|
88
|
-
if (dispatch) {
|
|
89
|
-
dispatch(tr);
|
|
90
|
-
}
|
|
91
|
-
return true;
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function getInsertPosFromTextBlock(state, append) {
|
|
95
|
-
const {
|
|
96
|
-
$from,
|
|
97
|
-
$to
|
|
98
|
-
} = state.selection;
|
|
99
|
-
let pos;
|
|
100
|
-
if (!append) {
|
|
101
|
-
pos = $from.start(0);
|
|
102
|
-
} else {
|
|
103
|
-
pos = $to.end(0);
|
|
104
|
-
}
|
|
105
|
-
return pos;
|
|
106
|
-
}
|
|
107
|
-
function getInsertPosFromNonTextBlock(state, append) {
|
|
108
|
-
const {
|
|
109
|
-
$from,
|
|
110
|
-
$to
|
|
111
|
-
} = state.selection;
|
|
112
|
-
const nodeAtSelection = state.selection instanceof NodeSelection && state.doc.nodeAt(state.selection.$anchor.pos);
|
|
113
|
-
const isMediaSelection = nodeAtSelection && nodeAtSelection.type.name === 'mediaGroup';
|
|
114
|
-
let pos;
|
|
115
|
-
if (!append) {
|
|
116
|
-
// The start position is different with text block because it starts from 0
|
|
117
|
-
pos = $from.start($from.depth);
|
|
118
|
-
// The depth is different with text block because it starts from 0
|
|
119
|
-
pos = $from.depth > 0 && !isMediaSelection ? pos - 1 : pos;
|
|
120
|
-
} else {
|
|
121
|
-
pos = $to.end($to.depth);
|
|
122
|
-
pos = $to.depth > 0 && !isMediaSelection ? pos + 1 : pos;
|
|
123
|
-
}
|
|
124
|
-
return pos;
|
|
125
|
-
}
|
|
126
|
-
function topLevelNodeIsEmptyTextBlock(state) {
|
|
127
|
-
const topLevelNode = state.selection.$from.node(1);
|
|
128
|
-
return topLevelNode.isTextblock && topLevelNode.type !== state.schema.nodes.codeBlock && topLevelNode.nodeSize === 2;
|
|
129
|
-
}
|
|
130
3
|
export function addParagraphAtEnd(tr) {
|
|
131
4
|
const {
|
|
132
5
|
doc: {
|
|
@@ -8,7 +8,7 @@ import textFormattingPlugin from '../../../plugins/text-formatting';
|
|
|
8
8
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
9
9
|
import unsupportedContentPlugin from '../../../plugins/unsupported-content';
|
|
10
10
|
import basePlugin from '../../../plugins/base';
|
|
11
|
-
import editorDisabledPlugin from '
|
|
11
|
+
import { editorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
12
12
|
import typeAheadPlugin from '../../../plugins/type-ahead';
|
|
13
13
|
import submitEditorPlugin from '../../../plugins/submit-editor';
|
|
14
14
|
import fakeTextCursorPlugin from '../../../plugins/fake-text-cursor';
|
|
@@ -11,7 +11,7 @@ import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
|
|
|
11
11
|
import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
|
|
12
12
|
import betterTypeHistoryPlugin from './pm-plugins/better-type-history';
|
|
13
13
|
import scrollGutter from './pm-plugins/scroll-gutter';
|
|
14
|
-
import { keymap } from '
|
|
14
|
+
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
15
15
|
import frozenEditor from './pm-plugins/frozen-editor';
|
|
16
16
|
import compositionPlugin from './pm-plugins/composition';
|
|
17
17
|
// Chrome >= 88
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { findWrapping } from '@atlaskit/editor-prosemirror/transform';
|
|
2
2
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { PanelType } from '@atlaskit/adf-schema';
|
|
4
|
+
import { CellSelection } from '@atlaskit/editor-tables';
|
|
5
5
|
import { shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
6
|
-
import { withAnalytics as withAnalyticsDeprecated } from '../../analytics';
|
|
7
6
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
8
7
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
9
|
-
import { filterChildrenBetween } from '@atlaskit/editor-common/
|
|
10
|
-
import {
|
|
11
|
-
import { CellSelection } from '@atlaskit/editor-tables';
|
|
8
|
+
import { filterChildrenBetween, removeBlockMarks } from '@atlaskit/editor-common/utils';
|
|
9
|
+
import { CODE_BLOCK, BLOCK_QUOTE, PANEL, HEADINGS_BY_NAME, NORMAL_TEXT } from '../types';
|
|
12
10
|
import { transformToCodeBlockAction } from './transform-to-code-block';
|
|
13
11
|
export function setBlockType(name) {
|
|
14
12
|
return (state, dispatch) => {
|
|
@@ -25,17 +23,17 @@ export function setBlockType(name) {
|
|
|
25
23
|
return false;
|
|
26
24
|
};
|
|
27
25
|
}
|
|
28
|
-
export function setBlockTypeWithAnalytics(name, inputMethod) {
|
|
26
|
+
export function setBlockTypeWithAnalytics(name, inputMethod, editorAnalyticsApi) {
|
|
29
27
|
return (state, dispatch) => {
|
|
30
28
|
const {
|
|
31
29
|
nodes
|
|
32
30
|
} = state.schema;
|
|
33
31
|
if (name === NORMAL_TEXT.name && nodes.paragraph) {
|
|
34
|
-
return setNormalTextWithAnalytics(inputMethod)(state, dispatch);
|
|
32
|
+
return setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi)(state, dispatch);
|
|
35
33
|
}
|
|
36
34
|
const headingBlockType = HEADINGS_BY_NAME[name];
|
|
37
35
|
if (headingBlockType && nodes.heading && headingBlockType.level) {
|
|
38
|
-
return setHeadingWithAnalytics(headingBlockType.level, inputMethod)(state, dispatch);
|
|
36
|
+
return setHeadingWithAnalytics(headingBlockType.level, inputMethod, editorAnalyticsApi)(state, dispatch);
|
|
39
37
|
}
|
|
40
38
|
return false;
|
|
41
39
|
};
|
|
@@ -86,8 +84,8 @@ function withCurrentHeadingLevel(fn) {
|
|
|
86
84
|
return fn(level)(state, dispatch, view);
|
|
87
85
|
};
|
|
88
86
|
}
|
|
89
|
-
export function setNormalTextWithAnalytics(inputMethod) {
|
|
90
|
-
return withCurrentHeadingLevel(previousHeadingLevel =>
|
|
87
|
+
export function setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi) {
|
|
88
|
+
return withCurrentHeadingLevel(previousHeadingLevel => withAnalytics(editorAnalyticsApi, {
|
|
91
89
|
action: ACTION.FORMATTED,
|
|
92
90
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
93
91
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -121,8 +119,8 @@ export function setHeading(level) {
|
|
|
121
119
|
return true;
|
|
122
120
|
};
|
|
123
121
|
}
|
|
124
|
-
export const setHeadingWithAnalytics = (newHeadingLevel, inputMethod) => {
|
|
125
|
-
return withCurrentHeadingLevel(previousHeadingLevel =>
|
|
122
|
+
export const setHeadingWithAnalytics = (newHeadingLevel, inputMethod, editorAnalyticsApi) => {
|
|
123
|
+
return withCurrentHeadingLevel(previousHeadingLevel => withAnalytics(editorAnalyticsApi, {
|
|
126
124
|
action: ACTION.FORMATTED,
|
|
127
125
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
128
126
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { mapSlice } from '../../../utils/slice';
|
|
3
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
3
|
+
import { timestampToString, mapSlice } from '@atlaskit/editor-common/utils';
|
|
5
4
|
export function transformToCodeBlockAction(state, start, attrs) {
|
|
6
5
|
const startOfCodeBlockText = state.selection.$from;
|
|
7
6
|
const endPosition = state.selection.empty ? startOfCodeBlockText.end() : state.selection.$to.pos;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { blockquote, hardBreak, heading } from '@atlaskit/adf-schema';
|
|
3
|
+
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
4
|
+
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
5
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
|
|
7
|
+
import * as keymaps from '@atlaskit/editor-common/keymaps';
|
|
3
8
|
import { createPlugin, pluginKey } from './pm-plugins/main';
|
|
4
9
|
import keymapPlugin from './pm-plugins/keymap';
|
|
5
10
|
import inputRulePlugin from './pm-plugins/input-rule';
|
|
6
11
|
import ToolbarBlockType from './ui/ToolbarBlockType';
|
|
7
|
-
import WithPluginState from '../../ui/WithPluginState';
|
|
8
12
|
import { setBlockTypeWithAnalytics } from './commands';
|
|
9
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
10
|
-
import * as keymaps from '../../keymaps';
|
|
11
|
-
import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
|
|
12
13
|
import { messages } from './messages';
|
|
13
|
-
import { ToolbarSize } from '../../ui/Toolbar/types';
|
|
14
14
|
const headingPluginOptions = ({
|
|
15
15
|
formatMessage
|
|
16
16
|
}, isAllowed, editorAnalyticsApi) => {
|
|
@@ -105,13 +105,19 @@ const blockTypePlugin = (options, api) => ({
|
|
|
105
105
|
name: 'blockType',
|
|
106
106
|
plugin: ({
|
|
107
107
|
dispatch
|
|
108
|
-
}) =>
|
|
108
|
+
}) => {
|
|
109
|
+
var _api$dependencies$ana;
|
|
110
|
+
return createPlugin(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, dispatch, options && options.lastNodeMustBeParagraph);
|
|
111
|
+
}
|
|
109
112
|
}, {
|
|
110
113
|
name: 'blockTypeInputRule',
|
|
111
114
|
plugin: ({
|
|
112
115
|
schema,
|
|
113
116
|
featureFlags
|
|
114
|
-
}) =>
|
|
117
|
+
}) => {
|
|
118
|
+
var _api$dependencies$ana2;
|
|
119
|
+
return inputRulePlugin(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, schema, featureFlags);
|
|
120
|
+
}
|
|
115
121
|
},
|
|
116
122
|
// Needs to be lower priority than editor-tables.tableEditing
|
|
117
123
|
// plugin as it is currently swallowing right/down arrow events inside tables
|
|
@@ -121,8 +127,8 @@ const blockTypePlugin = (options, api) => ({
|
|
|
121
127
|
schema,
|
|
122
128
|
featureFlags
|
|
123
129
|
}) => {
|
|
124
|
-
var _api$dependencies$
|
|
125
|
-
return keymapPlugin(
|
|
130
|
+
var _api$dependencies$ana3;
|
|
131
|
+
return keymapPlugin(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, schema, featureFlags);
|
|
126
132
|
}
|
|
127
133
|
}];
|
|
128
134
|
},
|
|
@@ -137,7 +143,10 @@ const blockTypePlugin = (options, api) => ({
|
|
|
137
143
|
eventDispatcher
|
|
138
144
|
}) {
|
|
139
145
|
const isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
|
|
140
|
-
const boundSetBlockType = name =>
|
|
146
|
+
const boundSetBlockType = name => {
|
|
147
|
+
var _api$dependencies$ana4;
|
|
148
|
+
return setBlockTypeWithAnalytics(name, INPUT_METHOD.TOOLBAR, 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)(editorView.state, editorView.dispatch);
|
|
149
|
+
};
|
|
141
150
|
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
142
151
|
editorView: editorView,
|
|
143
152
|
eventDispatcher: eventDispatcher,
|
|
@@ -162,9 +171,9 @@ const blockTypePlugin = (options, api) => ({
|
|
|
162
171
|
},
|
|
163
172
|
pluginsOptions: {
|
|
164
173
|
quickInsert: intl => {
|
|
165
|
-
var _api$dependencies$
|
|
174
|
+
var _api$dependencies$ana5, _api$dependencies$ana6;
|
|
166
175
|
const exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
|
|
167
|
-
return [...blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
176
|
+
return [...blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, 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), ...headingPluginOptions(intl, exclude.indexOf('heading') === -1, 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)];
|
|
168
177
|
}
|
|
169
178
|
}
|
|
170
179
|
});
|