@atlaskit/editor-core 187.8.7 → 187.8.11
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 +14 -0
- package/dist/cjs/index.js +0 -6
- package/dist/cjs/plugins/base/pm-plugins/newline-preserve-marks.js +1 -1
- package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +4 -4
- package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +5 -5
- package/dist/cjs/plugins/layout/pm-plugins/main.js +1 -1
- package/dist/cjs/plugins/list/actions/conversions.js +5 -5
- package/dist/cjs/plugins/list/actions/indent-list-items-selected.js +11 -11
- package/dist/cjs/plugins/list/actions/join-list-items-forward.js +6 -6
- package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +6 -7
- package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +3 -4
- package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +3 -4
- package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +2 -2
- package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +2 -2
- package/dist/cjs/plugins/list/actions/merge-lists.js +3 -3
- package/dist/cjs/plugins/list/actions/outdent-list-items-selected.js +11 -11
- package/dist/cjs/plugins/list/actions/wrap-and-join-lists.js +2 -2
- package/dist/cjs/plugins/list/commands/indent-list.js +6 -7
- package/dist/cjs/plugins/list/commands/index.js +8 -10
- package/dist/cjs/plugins/list/commands/join-list-item-forward.js +5 -5
- package/dist/cjs/plugins/list/commands/listBackspace.js +13 -14
- package/dist/cjs/plugins/list/commands/outdent-list.js +4 -3
- package/dist/cjs/plugins/list/pm-plugins/main.js +5 -6
- package/dist/cjs/plugins/list/utils/analytics.js +1 -35
- package/dist/cjs/plugins/list/utils/indentation.js +2 -20
- package/dist/cjs/plugins/list/utils/node.js +2 -106
- package/dist/cjs/plugins/list/utils/selection.js +3 -54
- package/dist/cjs/plugins/tasks-and-decisions/commands.js +2 -2
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +17 -18
- package/dist/cjs/plugins/text-formatting/index.js +23 -21
- package/dist/cjs/plugins/text-formatting/pm-plugins/input-rule.js +48 -54
- package/dist/cjs/plugins/text-formatting/pm-plugins/smart-input-rule.js +28 -33
- package/dist/cjs/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +2 -1
- package/dist/cjs/utils/commands.js +3 -109
- package/dist/cjs/utils/document.js +1 -26
- package/dist/cjs/utils/index.js +0 -6
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/plugins/base/pm-plugins/newline-preserve-marks.js +1 -1
- package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +1 -1
- package/dist/es2019/plugins/layout/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/list/actions/conversions.js +2 -2
- package/dist/es2019/plugins/list/actions/indent-list-items-selected.js +2 -2
- package/dist/es2019/plugins/list/actions/join-list-items-forward.js +1 -1
- package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +1 -2
- package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +2 -2
- package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +2 -2
- package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +1 -1
- package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +1 -1
- package/dist/es2019/plugins/list/actions/merge-lists.js +1 -1
- package/dist/es2019/plugins/list/actions/outdent-list-items-selected.js +3 -3
- package/dist/es2019/plugins/list/actions/wrap-and-join-lists.js +1 -1
- package/dist/es2019/plugins/list/commands/indent-list.js +3 -4
- package/dist/es2019/plugins/list/commands/index.js +4 -5
- package/dist/es2019/plugins/list/commands/join-list-item-forward.js +1 -1
- package/dist/es2019/plugins/list/commands/listBackspace.js +1 -2
- package/dist/es2019/plugins/list/commands/outdent-list.js +3 -2
- package/dist/es2019/plugins/list/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/list/utils/analytics.js +0 -36
- package/dist/es2019/plugins/list/utils/indentation.js +0 -18
- package/dist/es2019/plugins/list/utils/node.js +3 -89
- package/dist/es2019/plugins/list/utils/selection.js +1 -52
- package/dist/es2019/plugins/tasks-and-decisions/commands.js +1 -1
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
- package/dist/es2019/plugins/text-formatting/index.js +15 -10
- package/dist/es2019/plugins/text-formatting/pm-plugins/input-rule.js +20 -18
- package/dist/es2019/plugins/text-formatting/pm-plugins/smart-input-rule.js +11 -12
- package/dist/es2019/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +2 -1
- package/dist/es2019/utils/commands.js +2 -102
- package/dist/es2019/utils/document.js +1 -26
- package/dist/es2019/utils/index.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/plugins/base/pm-plugins/newline-preserve-marks.js +1 -1
- package/dist/esm/plugins/block-type/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +1 -1
- package/dist/esm/plugins/layout/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/list/actions/conversions.js +2 -2
- package/dist/esm/plugins/list/actions/indent-list-items-selected.js +2 -2
- package/dist/esm/plugins/list/actions/join-list-items-forward.js +1 -1
- package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +1 -2
- package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +2 -2
- package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +2 -2
- package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +1 -1
- package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +1 -1
- package/dist/esm/plugins/list/actions/merge-lists.js +1 -1
- package/dist/esm/plugins/list/actions/outdent-list-items-selected.js +3 -3
- package/dist/esm/plugins/list/actions/wrap-and-join-lists.js +1 -1
- package/dist/esm/plugins/list/commands/indent-list.js +3 -4
- package/dist/esm/plugins/list/commands/index.js +4 -5
- package/dist/esm/plugins/list/commands/join-list-item-forward.js +1 -1
- package/dist/esm/plugins/list/commands/listBackspace.js +1 -2
- package/dist/esm/plugins/list/commands/outdent-list.js +3 -2
- package/dist/esm/plugins/list/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/list/utils/analytics.js +0 -32
- package/dist/esm/plugins/list/utils/indentation.js +0 -17
- package/dist/esm/plugins/list/utils/node.js +3 -81
- package/dist/esm/plugins/list/utils/selection.js +3 -51
- package/dist/esm/plugins/tasks-and-decisions/commands.js +1 -1
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
- package/dist/esm/plugins/text-formatting/index.js +23 -21
- package/dist/esm/plugins/text-formatting/pm-plugins/input-rule.js +48 -54
- package/dist/esm/plugins/text-formatting/pm-plugins/smart-input-rule.js +26 -31
- package/dist/esm/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +2 -1
- package/dist/esm/utils/commands.js +2 -100
- package/dist/esm/utils/document.js +1 -26
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/plugins/list/actions/join-list-items-forward.d.ts +1 -1
- package/dist/types/plugins/list/commands/indent-list.d.ts +2 -1
- package/dist/types/plugins/list/commands/index.d.ts +2 -1
- package/dist/types/plugins/list/commands/join-list-item-forward.d.ts +1 -1
- package/dist/types/plugins/list/commands/listBackspace.d.ts +1 -1
- package/dist/types/plugins/list/commands/outdent-list.d.ts +2 -1
- package/dist/types/plugins/list/utils/analytics.d.ts +2 -4
- package/dist/types/plugins/list/utils/indentation.d.ts +0 -5
- package/dist/types/plugins/list/utils/node.d.ts +2 -17
- package/dist/types/plugins/list/utils/selection.d.ts +1 -12
- package/dist/types/plugins/text-formatting/pm-plugins/input-rule.d.ts +2 -1
- package/dist/types/plugins/text-formatting/pm-plugins/smart-input-rule.d.ts +2 -2
- package/dist/types/utils/commands.d.ts +3 -32
- package/dist/types/utils/document.d.ts +0 -4
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/list/actions/join-list-items-forward.d.ts +1 -1
- package/dist/types-ts4.5/plugins/list/commands/indent-list.d.ts +2 -1
- package/dist/types-ts4.5/plugins/list/commands/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/list/commands/join-list-item-forward.d.ts +1 -1
- package/dist/types-ts4.5/plugins/list/commands/listBackspace.d.ts +1 -1
- package/dist/types-ts4.5/plugins/list/commands/outdent-list.d.ts +2 -1
- package/dist/types-ts4.5/plugins/list/utils/analytics.d.ts +2 -4
- package/dist/types-ts4.5/plugins/list/utils/indentation.d.ts +0 -5
- package/dist/types-ts4.5/plugins/list/utils/node.d.ts +2 -17
- package/dist/types-ts4.5/plugins/list/utils/selection.d.ts +1 -12
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/input-rule.d.ts +2 -1
- package/dist/types-ts4.5/plugins/text-formatting/pm-plugins/smart-input-rule.d.ts +2 -2
- package/dist/types-ts4.5/utils/commands.d.ts +3 -38
- package/dist/types-ts4.5/utils/document.d.ts +0 -4
- package/dist/types-ts4.5/utils/index.d.ts +1 -1
- package/package.json +2 -2
- package/report.api.md +0 -3
- package/tmp/api-report-tmp.d.ts +0 -3
- package/dist/cjs/plugins/list/utils/replace-content.js +0 -24
- package/dist/cjs/utils/prosemirror/autojoin.js +0 -68
- package/dist/es2019/plugins/list/utils/replace-content.js +0 -18
- package/dist/es2019/utils/prosemirror/autojoin.js +0 -57
- package/dist/esm/plugins/list/utils/replace-content.js +0 -17
- package/dist/esm/utils/prosemirror/autojoin.js +0 -63
- package/dist/types/plugins/list/utils/replace-content.d.ts +0 -8
- package/dist/types/utils/prosemirror/autojoin.d.ts +0 -13
- package/dist/types-ts4.5/plugins/list/utils/replace-content.d.ts +0 -8
- package/dist/types-ts4.5/utils/prosemirror/autojoin.d.ts +0 -13
|
@@ -13,11 +13,10 @@ var _model = require("@atlaskit/editor-prosemirror/model");
|
|
|
13
13
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
14
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
15
15
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
16
|
-
var _commands2 = require("../../../utils/commands");
|
|
17
16
|
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
18
17
|
var _analytics = require("../../analytics");
|
|
19
|
-
var
|
|
20
|
-
var
|
|
18
|
+
var _commands2 = require("../commands");
|
|
19
|
+
var _commands3 = require("./commands");
|
|
21
20
|
var _helpers = require("./helpers");
|
|
22
21
|
var _utils3 = require("../utils");
|
|
23
22
|
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; }
|
|
@@ -46,7 +45,7 @@ var actionDecisionFollowsOrNothing = function actionDecisionFollowsOrNothing($po
|
|
|
46
45
|
};
|
|
47
46
|
var joinTaskDecisionFollowing = function joinTaskDecisionFollowing(state, dispatch) {
|
|
48
47
|
// only run if selection is at end of text, and inside a task or decision item
|
|
49
|
-
if (!(0,
|
|
48
|
+
if (!(0, _utils2.isEmptySelectionAtEnd)(state) || !(0, _helpers.isInsideTaskOrDecisionItem)(state) || !dispatch) {
|
|
50
49
|
return false;
|
|
51
50
|
}
|
|
52
51
|
// look for the node after this current one
|
|
@@ -67,7 +66,7 @@ var joinTaskDecisionFollowing = function joinTaskDecisionFollowing(state, dispat
|
|
|
67
66
|
if (!parentList) {
|
|
68
67
|
if ($next.parent.type === paragraph) {
|
|
69
68
|
// try to join paragraph and taskList when backspacing
|
|
70
|
-
return (0,
|
|
69
|
+
return (0, _commands3.joinAtCut)($next.doc.resolve($next.pos))(state, dispatch);
|
|
71
70
|
}
|
|
72
71
|
// If the item we are joining is a list
|
|
73
72
|
if ($next.parent.type === bulletList || $next.parent.type === orderedList) {
|
|
@@ -97,13 +96,13 @@ var joinTaskDecisionFollowing = function joinTaskDecisionFollowing(state, dispat
|
|
|
97
96
|
};
|
|
98
97
|
var getUnindentCommand = function getUnindentCommand() {
|
|
99
98
|
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _analytics.INPUT_METHOD.KEYBOARD;
|
|
100
|
-
return (0, _utils2.
|
|
99
|
+
return (0, _utils2.filterCommand)(_helpers.isInsideTask, function (state, dispatch) {
|
|
101
100
|
var normalizedSelection = (0, _utils3.normalizeTaskItemsSelection)(state.selection);
|
|
102
101
|
var curIndentLevel = (0, _helpers.getCurrentIndentLevel)(normalizedSelection);
|
|
103
102
|
if (!curIndentLevel || curIndentLevel === 1) {
|
|
104
103
|
return false;
|
|
105
104
|
}
|
|
106
|
-
return (0, _analytics.withAnalytics)(indentationAnalytics(curIndentLevel, _analytics.INDENT_DIRECTION.OUTDENT, inputMethod))((0, _commands.autoJoin)(
|
|
105
|
+
return (0, _analytics.withAnalytics)(indentationAnalytics(curIndentLevel, _analytics.INDENT_DIRECTION.OUTDENT, inputMethod))((0, _commands.autoJoin)(_commands3.liftSelection, ['taskList']))(state, dispatch);
|
|
107
106
|
});
|
|
108
107
|
};
|
|
109
108
|
|
|
@@ -124,13 +123,13 @@ var shouldLetTabThroughInTable = function shouldLetTabThroughInTable(state) {
|
|
|
124
123
|
};
|
|
125
124
|
var getIndentCommand = function getIndentCommand() {
|
|
126
125
|
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _analytics.INPUT_METHOD.KEYBOARD;
|
|
127
|
-
return (0, _utils2.
|
|
126
|
+
return (0, _utils2.filterCommand)(_helpers.isInsideTask, function (state, dispatch) {
|
|
128
127
|
var normalizedSelection = (0, _utils3.normalizeTaskItemsSelection)(state.selection);
|
|
129
128
|
var curIndentLevel = (0, _helpers.getCurrentIndentLevel)(normalizedSelection);
|
|
130
129
|
if (!curIndentLevel || curIndentLevel >= 6) {
|
|
131
130
|
return true;
|
|
132
131
|
}
|
|
133
|
-
return (0, _analytics.withAnalytics)(indentationAnalytics(curIndentLevel, _analytics.INDENT_DIRECTION.INDENT, inputMethod))((0, _commands.autoJoin)(
|
|
132
|
+
return (0, _analytics.withAnalytics)(indentationAnalytics(curIndentLevel, _analytics.INDENT_DIRECTION.INDENT, inputMethod))((0, _commands.autoJoin)(_commands3.wrapSelectionInTaskList, ['taskList']))(state, dispatch);
|
|
134
133
|
});
|
|
135
134
|
};
|
|
136
135
|
exports.getIndentCommand = getIndentCommand;
|
|
@@ -165,9 +164,9 @@ var backspaceFrom = function backspaceFrom($from) {
|
|
|
165
164
|
return false;
|
|
166
165
|
};
|
|
167
166
|
};
|
|
168
|
-
var backspace = (0, _utils2.
|
|
169
|
-
return (0,
|
|
170
|
-
}, (0, _utils2.
|
|
167
|
+
var backspace = (0, _utils2.filterCommand)(_utils2.isEmptySelectionAtStart, (0, _commands.autoJoin)((0, _commands.chainCommands)(function (state, dispatch) {
|
|
168
|
+
return (0, _commands3.joinAtCut)(state.selection.$from)(state, dispatch);
|
|
169
|
+
}, (0, _utils2.filterCommand)(_helpers.isInsideTaskOrDecisionItem, function (state, dispatch) {
|
|
171
170
|
return backspaceFrom(state.selection.$from)(state, dispatch);
|
|
172
171
|
})), ['taskList', 'decisionList']));
|
|
173
172
|
var unindentTaskOrUnwrapTaskDecisionFollowing = function unindentTaskOrUnwrapTaskDecisionFollowing(state, dispatch) {
|
|
@@ -179,7 +178,7 @@ var unindentTaskOrUnwrapTaskDecisionFollowing = function unindentTaskOrUnwrapTas
|
|
|
179
178
|
tr = state.tr;
|
|
180
179
|
|
|
181
180
|
// only run if cursor is at the end of the node
|
|
182
|
-
if (!(0,
|
|
181
|
+
if (!(0, _utils2.isEmptySelectionAtEnd)(state) || !dispatch) {
|
|
183
182
|
return false;
|
|
184
183
|
}
|
|
185
184
|
|
|
@@ -213,7 +212,7 @@ var unindentTaskOrUnwrapTaskDecisionFollowing = function unindentTaskOrUnwrapTas
|
|
|
213
212
|
}
|
|
214
213
|
return false;
|
|
215
214
|
};
|
|
216
|
-
var deleteForwards = (0, _commands.autoJoin)((0, _commands.chainCommands)((0,
|
|
215
|
+
var deleteForwards = (0, _commands.autoJoin)((0, _commands.chainCommands)((0, _utils2.deleteEmptyParagraphAndMoveBlockUp)(_helpers.isActionOrDecisionList), joinTaskDecisionFollowing, unindentTaskOrUnwrapTaskDecisionFollowing), ['taskList', 'decisionList']);
|
|
217
216
|
var splitListItemWith = function splitListItemWith(tr, content, $from, setSelection) {
|
|
218
217
|
var origDoc = tr.doc;
|
|
219
218
|
|
|
@@ -279,7 +278,7 @@ var splitListItem = function splitListItem(state, dispatch) {
|
|
|
279
278
|
}
|
|
280
279
|
return false;
|
|
281
280
|
};
|
|
282
|
-
var enter = (0, _utils2.
|
|
281
|
+
var enter = (0, _utils2.filterCommand)(_helpers.isInsideTaskOrDecisionItem, (0, _commands.chainCommands)((0, _utils2.filterCommand)(_helpers.isEmptyTaskDecision, (0, _commands.chainCommands)(getUnindentCommand(), splitListItem)), function (state, dispatch) {
|
|
283
282
|
var selection = state.selection,
|
|
284
283
|
schema = state.schema;
|
|
285
284
|
var taskItem = schema.nodes.taskItem;
|
|
@@ -308,7 +307,7 @@ var enter = (0, _utils2.filterCommands)(_helpers.isInsideTaskOrDecisionItem, (0,
|
|
|
308
307
|
}
|
|
309
308
|
}]);
|
|
310
309
|
};
|
|
311
|
-
var insertTr = (0,
|
|
310
|
+
var insertTr = (0, _commands2.insertTaskDecisionWithAnalytics)(state, listType, _analytics.INPUT_METHOD.KEYBOARD, addItem);
|
|
312
311
|
if (insertTr && dispatch) {
|
|
313
312
|
insertTr.scrollIntoView();
|
|
314
313
|
dispatch(insertTr);
|
|
@@ -317,12 +316,12 @@ var enter = (0, _utils2.filterCommands)(_helpers.isInsideTaskOrDecisionItem, (0,
|
|
|
317
316
|
}));
|
|
318
317
|
function keymapPlugin(schema, allowNestedTasks, consumeTabs) {
|
|
319
318
|
var indentHandlers = {
|
|
320
|
-
'Shift-Tab': (0, _utils2.
|
|
319
|
+
'Shift-Tab': (0, _utils2.filterCommand)([_helpers.isInsideTaskOrDecisionItem, function (state) {
|
|
321
320
|
return !shouldLetTabThroughInTable(state);
|
|
322
321
|
}], function (state, dispatch) {
|
|
323
322
|
return getUnindentCommand(_analytics.INPUT_METHOD.KEYBOARD)(state, dispatch) || !!consumeTabs;
|
|
324
323
|
}),
|
|
325
|
-
Tab: (0, _utils2.
|
|
324
|
+
Tab: (0, _utils2.filterCommand)([_helpers.isInsideTaskOrDecisionItem, function (state) {
|
|
326
325
|
return !shouldLetTabThroughInTable(state);
|
|
327
326
|
}], function (state, dispatch) {
|
|
328
327
|
return getIndentCommand(_analytics.INPUT_METHOD.KEYBOARD)(state, dispatch) || !!consumeTabs;
|
|
@@ -57,52 +57,54 @@ var textFormatting = function textFormatting() {
|
|
|
57
57
|
}
|
|
58
58
|
}, {
|
|
59
59
|
name: 'textFormattingInputRule',
|
|
60
|
+
// Don't remove the unused featureFlags, this gets used to test if we're properly passing them to the PM plugin
|
|
60
61
|
plugin: function plugin(_ref2) {
|
|
62
|
+
var _api$dependencies$ana2;
|
|
61
63
|
var schema = _ref2.schema,
|
|
62
64
|
featureFlags = _ref2.featureFlags;
|
|
63
|
-
return (0, _inputRule.default)(schema, featureFlags);
|
|
65
|
+
return (0, _inputRule.default)(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);
|
|
64
66
|
}
|
|
65
67
|
}, {
|
|
66
68
|
name: 'textFormattingSmartRule',
|
|
67
|
-
plugin: function plugin(
|
|
68
|
-
var
|
|
69
|
-
return !options.disableSmartTextCompletion ? (0, _smartInputRule.default)(
|
|
69
|
+
plugin: function plugin() {
|
|
70
|
+
var _api$dependencies$ana3;
|
|
71
|
+
return !options.disableSmartTextCompletion ? (0, _smartInputRule.default)(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;
|
|
70
72
|
}
|
|
71
73
|
}, {
|
|
72
74
|
name: 'textFormattingClear',
|
|
73
|
-
plugin: function plugin(
|
|
74
|
-
var dispatch =
|
|
75
|
+
plugin: function plugin(_ref3) {
|
|
76
|
+
var dispatch = _ref3.dispatch;
|
|
75
77
|
return (0, _clearFormatting.plugin)(dispatch);
|
|
76
78
|
}
|
|
77
79
|
}, {
|
|
78
80
|
name: 'textFormattingClearKeymap',
|
|
79
81
|
plugin: function plugin() {
|
|
80
|
-
var _api$dependencies$
|
|
81
|
-
return (0, _clearFormattingKeymap.default)(api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
82
|
+
var _api$dependencies$ana4;
|
|
83
|
+
return (0, _clearFormattingKeymap.default)(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);
|
|
82
84
|
}
|
|
83
85
|
}, {
|
|
84
86
|
name: 'textFormattingKeymap',
|
|
85
|
-
plugin: function plugin(
|
|
86
|
-
var _api$dependencies$
|
|
87
|
-
var schema =
|
|
88
|
-
return (0, _keymap.default)(schema, api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
87
|
+
plugin: function plugin(_ref4) {
|
|
88
|
+
var _api$dependencies$ana5;
|
|
89
|
+
var schema = _ref4.schema;
|
|
90
|
+
return (0, _keymap.default)(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);
|
|
89
91
|
}
|
|
90
92
|
}];
|
|
91
93
|
},
|
|
92
|
-
primaryToolbarComponent: function primaryToolbarComponent(
|
|
93
|
-
var editorView =
|
|
94
|
-
popupsMountPoint =
|
|
95
|
-
popupsScrollableElement =
|
|
96
|
-
isToolbarReducedSpacing =
|
|
97
|
-
toolbarSize =
|
|
98
|
-
disabled =
|
|
94
|
+
primaryToolbarComponent: function primaryToolbarComponent(_ref5) {
|
|
95
|
+
var editorView = _ref5.editorView,
|
|
96
|
+
popupsMountPoint = _ref5.popupsMountPoint,
|
|
97
|
+
popupsScrollableElement = _ref5.popupsScrollableElement,
|
|
98
|
+
isToolbarReducedSpacing = _ref5.isToolbarReducedSpacing,
|
|
99
|
+
toolbarSize = _ref5.toolbarSize,
|
|
100
|
+
disabled = _ref5.disabled;
|
|
99
101
|
return /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
|
|
100
102
|
plugins: {
|
|
101
103
|
textFormattingState: _main.pluginKey,
|
|
102
104
|
clearFormattingPluginState: _clearFormatting.pluginKey
|
|
103
105
|
},
|
|
104
106
|
render: function render() {
|
|
105
|
-
var _api$dependencies$
|
|
107
|
+
var _api$dependencies$ana6;
|
|
106
108
|
return /*#__PURE__*/_react.default.createElement(_Toolbar.default, {
|
|
107
109
|
editorState: editorView.state,
|
|
108
110
|
popupsMountPoint: popupsMountPoint,
|
|
@@ -112,7 +114,7 @@ var textFormatting = function textFormatting() {
|
|
|
112
114
|
editorView: editorView,
|
|
113
115
|
isToolbarDisabled: disabled,
|
|
114
116
|
shouldUseResponsiveToolbar: Boolean(options.responsiveToolbarMenu),
|
|
115
|
-
editorAnalyticsAPI: api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
117
|
+
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
|
|
116
118
|
});
|
|
117
119
|
}
|
|
118
120
|
});
|
|
@@ -16,10 +16,10 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
16
16
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
17
|
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
|
|
18
18
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
-
var _inputRules = require("../../../utils/input-rules");
|
|
20
19
|
var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
|
|
21
20
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
22
21
|
var _mark = require("@atlaskit/editor-common/mark");
|
|
22
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
23
23
|
var _ValidCombinations;
|
|
24
24
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
25
25
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
@@ -175,18 +175,16 @@ var codeRegex = buildRegex(ValidAutoformatChars.CODE);
|
|
|
175
175
|
* @returns {InputRuleWrapper[]}
|
|
176
176
|
*/
|
|
177
177
|
exports.codeRegex = codeRegex;
|
|
178
|
-
function getStrongInputRules(schema) {
|
|
179
|
-
var ruleWithStrongAnalytics = (0,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
};
|
|
189
|
-
});
|
|
178
|
+
function getStrongInputRules(schema, editorAnalyticsAPI) {
|
|
179
|
+
var ruleWithStrongAnalytics = (0, _utils.inputRuleWithAnalytics)({
|
|
180
|
+
action: _analytics.ACTION.FORMATTED,
|
|
181
|
+
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
182
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_STRONG,
|
|
183
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
184
|
+
attributes: {
|
|
185
|
+
inputMethod: _analytics.INPUT_METHOD.FORMATTING
|
|
186
|
+
}
|
|
187
|
+
}, editorAnalyticsAPI);
|
|
190
188
|
// **string** or __strong__ should bold the text
|
|
191
189
|
var doubleUnderscoreRule = (0, _prosemirrorInputRules.createRule)(strongRegex1, addMark(schema.marks.strong, schema, ValidAutoformatChars.STRONG));
|
|
192
190
|
var doubleAsterixRule = (0, _prosemirrorInputRules.createRule)(strongRegex2, addMark(schema.marks.strong, schema, ValidAutoformatChars.STRONG_MARKDOWN));
|
|
@@ -199,18 +197,16 @@ function getStrongInputRules(schema) {
|
|
|
199
197
|
* @param {Schema} schema
|
|
200
198
|
* @returns {InputRuleWrapper[]}
|
|
201
199
|
*/
|
|
202
|
-
function getItalicInputRules(schema) {
|
|
203
|
-
var ruleWithItalicAnalytics = (0,
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
};
|
|
213
|
-
});
|
|
200
|
+
function getItalicInputRules(schema, editorAnalyticsAPI) {
|
|
201
|
+
var ruleWithItalicAnalytics = (0, _utils.inputRuleWithAnalytics)({
|
|
202
|
+
action: _analytics.ACTION.FORMATTED,
|
|
203
|
+
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
204
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_ITALIC,
|
|
205
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
206
|
+
attributes: {
|
|
207
|
+
inputMethod: _analytics.INPUT_METHOD.FORMATTING
|
|
208
|
+
}
|
|
209
|
+
}, editorAnalyticsAPI);
|
|
214
210
|
var underscoreRule = (0, _prosemirrorInputRules.createRule)(italicRegex1, addMark(schema.marks.em, schema, ValidAutoformatChars.ITALIC));
|
|
215
211
|
var asterixRule = (0, _prosemirrorInputRules.createRule)(italicRegex2, addMark(schema.marks.em, schema, ValidAutoformatChars.ITALIC_MARKDOWN));
|
|
216
212
|
return [ruleWithItalicAnalytics(underscoreRule), ruleWithItalicAnalytics(asterixRule)];
|
|
@@ -222,18 +218,16 @@ function getItalicInputRules(schema) {
|
|
|
222
218
|
* @param {Schema} schema
|
|
223
219
|
* @returns {InputRuleWrapper[]}
|
|
224
220
|
*/
|
|
225
|
-
function getStrikeInputRules(schema) {
|
|
226
|
-
var ruleWithStrikeAnalytics = (0,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
};
|
|
236
|
-
});
|
|
221
|
+
function getStrikeInputRules(schema, editorAnalyticsAPI) {
|
|
222
|
+
var ruleWithStrikeAnalytics = (0, _utils.inputRuleWithAnalytics)({
|
|
223
|
+
action: _analytics.ACTION.FORMATTED,
|
|
224
|
+
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
225
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_STRIKE,
|
|
226
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
227
|
+
attributes: {
|
|
228
|
+
inputMethod: _analytics.INPUT_METHOD.FORMATTING
|
|
229
|
+
}
|
|
230
|
+
}, editorAnalyticsAPI);
|
|
237
231
|
var doubleTildeRule = (0, _prosemirrorInputRules.createRule)(strikeRegex, addMark(schema.marks.strike, schema, ValidAutoformatChars.STRIKE));
|
|
238
232
|
return [ruleWithStrikeAnalytics(doubleTildeRule)];
|
|
239
233
|
}
|
|
@@ -244,34 +238,34 @@ function getStrikeInputRules(schema) {
|
|
|
244
238
|
* @param {Schema} schema
|
|
245
239
|
* @returns {InputRuleWrapper[]}
|
|
246
240
|
*/
|
|
247
|
-
function getCodeInputRules(schema) {
|
|
248
|
-
var ruleWithCodeAnalytics = (0,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
};
|
|
258
|
-
});
|
|
241
|
+
function getCodeInputRules(schema, editorAnalyticsAPI) {
|
|
242
|
+
var ruleWithCodeAnalytics = (0, _utils.inputRuleWithAnalytics)({
|
|
243
|
+
action: _analytics.ACTION.FORMATTED,
|
|
244
|
+
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
245
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_CODE,
|
|
246
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
247
|
+
attributes: {
|
|
248
|
+
inputMethod: _analytics.INPUT_METHOD.FORMATTING
|
|
249
|
+
}
|
|
250
|
+
}, editorAnalyticsAPI);
|
|
259
251
|
var backTickRule = (0, _prosemirrorInputRules.createRule)(codeRegex, addMark(schema.marks.code, schema, ValidAutoformatChars.CODE));
|
|
260
252
|
return [ruleWithCodeAnalytics(backTickRule)];
|
|
261
253
|
}
|
|
262
|
-
function inputRulePlugin(schema,
|
|
254
|
+
function inputRulePlugin(schema,
|
|
255
|
+
// Don't remove the unused featureFlags, this gets used to test if we're properly passing them to the PM plugin
|
|
256
|
+
_featureFlags, editorAnalyticsAPI) {
|
|
263
257
|
var rules = [];
|
|
264
258
|
if (schema.marks.strong) {
|
|
265
|
-
rules.push.apply(rules, (0, _toConsumableArray2.default)(getStrongInputRules(schema)));
|
|
259
|
+
rules.push.apply(rules, (0, _toConsumableArray2.default)(getStrongInputRules(schema, editorAnalyticsAPI)));
|
|
266
260
|
}
|
|
267
261
|
if (schema.marks.em) {
|
|
268
|
-
rules.push.apply(rules, (0, _toConsumableArray2.default)(getItalicInputRules(schema)));
|
|
262
|
+
rules.push.apply(rules, (0, _toConsumableArray2.default)(getItalicInputRules(schema, editorAnalyticsAPI)));
|
|
269
263
|
}
|
|
270
264
|
if (schema.marks.strike) {
|
|
271
|
-
rules.push.apply(rules, (0, _toConsumableArray2.default)(getStrikeInputRules(schema)));
|
|
265
|
+
rules.push.apply(rules, (0, _toConsumableArray2.default)(getStrikeInputRules(schema, editorAnalyticsAPI)));
|
|
272
266
|
}
|
|
273
267
|
if (schema.marks.code) {
|
|
274
|
-
rules.push.apply(rules, (0, _toConsumableArray2.default)(getCodeInputRules(schema)));
|
|
268
|
+
rules.push.apply(rules, (0, _toConsumableArray2.default)(getCodeInputRules(schema, editorAnalyticsAPI)));
|
|
275
269
|
}
|
|
276
270
|
if (rules.length !== 0) {
|
|
277
271
|
return (0, _prosemirrorInputRules.createPlugin)('text-formatting', rules);
|
|
@@ -8,10 +8,10 @@ exports.default = void 0;
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
var
|
|
12
|
-
var _inputRules = require("../../../utils/input-rules");
|
|
11
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
12
|
var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
|
|
14
13
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
14
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
15
|
/**
|
|
16
16
|
* Creates an InputRuleHandler that will match on a regular expression of the
|
|
17
17
|
* form `(prefix, content, suffix?)`, and replace it with some given text,
|
|
@@ -33,7 +33,7 @@ function replaceTextUsingCaptureGroup(text) {
|
|
|
33
33
|
// But, this is JS #trustnoone
|
|
34
34
|
Math.max(startPos, 0), end);
|
|
35
35
|
tr.replaceWith(safePos, end, state.schema.text(replacement, $to.marks()));
|
|
36
|
-
tr.setSelection(
|
|
36
|
+
tr.setSelection(_state.Selection.near(tr.doc.resolve(tr.selection.to)));
|
|
37
37
|
return tr;
|
|
38
38
|
};
|
|
39
39
|
}
|
|
@@ -86,9 +86,9 @@ function createSingleQuotesRules() {
|
|
|
86
86
|
/**
|
|
87
87
|
* Get replacement rules related to product
|
|
88
88
|
*/
|
|
89
|
-
function getProductRules() {
|
|
89
|
+
function getProductRules(editorAnalyticsAPI) {
|
|
90
90
|
var productRuleWithAnalytics = function productRuleWithAnalytics(product) {
|
|
91
|
-
return (0,
|
|
91
|
+
return (0, _utils.inputRuleWithAnalytics)(function (_, match) {
|
|
92
92
|
return {
|
|
93
93
|
action: _analytics.ACTION.SUBSTITUTED,
|
|
94
94
|
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
@@ -99,7 +99,7 @@ function getProductRules() {
|
|
|
99
99
|
originalSpelling: match[2]
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
|
-
});
|
|
102
|
+
}, editorAnalyticsAPI);
|
|
103
103
|
};
|
|
104
104
|
return createReplacementRules({
|
|
105
105
|
Atlassian: /(\s+|^)(atlassian)(\s)$/,
|
|
@@ -113,24 +113,22 @@ function getProductRules() {
|
|
|
113
113
|
/**
|
|
114
114
|
* Get replacement rules related to symbol
|
|
115
115
|
*/
|
|
116
|
-
function getSymbolRules() {
|
|
116
|
+
function getSymbolRules(editorAnalyticsAPI) {
|
|
117
117
|
var symbolToString = {
|
|
118
118
|
'→': _analytics.SYMBOL.ARROW_RIGHT,
|
|
119
119
|
'←': _analytics.SYMBOL.ARROW_LEFT,
|
|
120
120
|
'↔︎': _analytics.SYMBOL.ARROW_DOUBLE
|
|
121
121
|
};
|
|
122
122
|
var symbolRuleWithAnalytics = function symbolRuleWithAnalytics(symbol) {
|
|
123
|
-
return (0,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
};
|
|
133
|
-
});
|
|
123
|
+
return (0, _utils.inputRuleWithAnalytics)({
|
|
124
|
+
action: _analytics.ACTION.SUBSTITUTED,
|
|
125
|
+
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
126
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYMBOL,
|
|
127
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
128
|
+
attributes: {
|
|
129
|
+
symbol: symbolToString[symbol]
|
|
130
|
+
}
|
|
131
|
+
}, editorAnalyticsAPI);
|
|
134
132
|
};
|
|
135
133
|
return createReplacementRules({
|
|
136
134
|
'→': /(\s+|^)(--?>)(\s)$/,
|
|
@@ -142,25 +140,22 @@ function getSymbolRules() {
|
|
|
142
140
|
/**
|
|
143
141
|
* Get replacement rules related to punctuation
|
|
144
142
|
*/
|
|
145
|
-
function getPunctuationRules() {
|
|
143
|
+
function getPunctuationRules(editorAnalyticsAPI) {
|
|
146
144
|
var punctuationToString = (0, _defineProperty2.default)({
|
|
147
145
|
'–': _analytics.PUNC.DASH,
|
|
148
146
|
'…': _analytics.PUNC.ELLIPSIS,
|
|
149
|
-
'“': _analytics.PUNC.QUOTE_DOUBLE,
|
|
150
147
|
'”': _analytics.PUNC.QUOTE_DOUBLE
|
|
151
148
|
}, _analytics.PUNC.QUOTE_SINGLE, _analytics.PUNC.QUOTE_SINGLE);
|
|
152
149
|
var punctuationRuleWithAnalytics = function punctuationRuleWithAnalytics(punctuation) {
|
|
153
|
-
return (0,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
};
|
|
163
|
-
});
|
|
150
|
+
return (0, _utils.inputRuleWithAnalytics)({
|
|
151
|
+
action: _analytics.ACTION.SUBSTITUTED,
|
|
152
|
+
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
153
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.PUNC,
|
|
154
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
155
|
+
attributes: {
|
|
156
|
+
punctuation: punctuationToString[punctuation]
|
|
157
|
+
}
|
|
158
|
+
}, editorAnalyticsAPI);
|
|
164
159
|
};
|
|
165
160
|
var dashEllipsisRules = createReplacementRules({
|
|
166
161
|
'–': /(\s+|^)(--)(\s)$/,
|
|
@@ -175,7 +170,7 @@ function getPunctuationRules() {
|
|
|
175
170
|
return punctuationRuleWithAnalytics(_analytics.PUNC.QUOTE_SINGLE)(rule);
|
|
176
171
|
})));
|
|
177
172
|
}
|
|
178
|
-
var _default = function _default(
|
|
179
|
-
return (0, _prosemirrorInputRules.createPlugin)('text-formatting:smart-input', [].concat((0, _toConsumableArray2.default)(getProductRules()), (0, _toConsumableArray2.default)(getSymbolRules()), (0, _toConsumableArray2.default)(getPunctuationRules())));
|
|
173
|
+
var _default = function _default(editorAnalyticsAPI) {
|
|
174
|
+
return (0, _prosemirrorInputRules.createPlugin)('text-formatting:smart-input', [].concat((0, _toConsumableArray2.default)(getProductRules(editorAnalyticsAPI)), (0, _toConsumableArray2.default)(getSymbolRules(editorAnalyticsAPI)), (0, _toConsumableArray2.default)(getPunctuationRules(editorAnalyticsAPI))));
|
|
180
175
|
};
|
|
181
176
|
exports.default = _default;
|
|
@@ -11,6 +11,7 @@ var _utils2 = require("@atlaskit/editor-common/utils");
|
|
|
11
11
|
var _selection = require("../../list/utils/selection");
|
|
12
12
|
var _helpers = require("../../tasks-and-decisions/pm-plugins/helpers");
|
|
13
13
|
var _commands = require("../../indentation/commands");
|
|
14
|
+
var _lists = require("@atlaskit/editor-common/lists");
|
|
14
15
|
var pluginKey = new _state.PluginKey('indentationButtonsPlugin');
|
|
15
16
|
exports.pluginKey = pluginKey;
|
|
16
17
|
function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndentation) {
|
|
@@ -27,7 +28,7 @@ function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndenta
|
|
|
27
28
|
// Check for lists before paragraphs and headings in case
|
|
28
29
|
// the selection is in a list nested in a layout column.
|
|
29
30
|
if ((0, _selection.isInsideListItem)(editorState)) {
|
|
30
|
-
var _getListItemAttribute = (0,
|
|
31
|
+
var _getListItemAttribute = (0, _lists.getListItemAttributes)(selection.$head),
|
|
31
32
|
indentLevel = _getListItemAttribute.indentLevel,
|
|
32
33
|
itemIndex = _getListItemAttribute.itemIndex;
|
|
33
34
|
return {
|
|
@@ -1,30 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports.deleteEmptyParagraphAndMoveBlockUp = void 0;
|
|
8
6
|
exports.findCutBefore = findCutBefore;
|
|
9
|
-
exports.withScrollIntoView = exports.
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
7
|
+
exports.withScrollIntoView = exports.selectNode = exports.isNthParentOfType = exports.isFirstChildOfParent = void 0;
|
|
11
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
9
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
13
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
14
|
-
var isEmptySelectionAtStart = function isEmptySelectionAtStart(state) {
|
|
15
|
-
var _state$selection = state.selection,
|
|
16
|
-
empty = _state$selection.empty,
|
|
17
|
-
$from = _state$selection.$from;
|
|
18
|
-
return empty && ($from.parentOffset === 0 || state.selection instanceof _selection.GapCursorSelection);
|
|
19
|
-
};
|
|
20
|
-
exports.isEmptySelectionAtStart = isEmptySelectionAtStart;
|
|
21
|
-
var isEmptySelectionAtEnd = function isEmptySelectionAtEnd(state) {
|
|
22
|
-
var _state$selection2 = state.selection,
|
|
23
|
-
empty = _state$selection2.empty,
|
|
24
|
-
$from = _state$selection2.$from;
|
|
25
|
-
return empty && ($from.end() === $from.pos || state.selection instanceof _selection.GapCursorSelection);
|
|
26
|
-
};
|
|
27
|
-
exports.isEmptySelectionAtEnd = isEmptySelectionAtEnd;
|
|
28
10
|
var isFirstChildOfParent = function isFirstChildOfParent(state) {
|
|
29
11
|
var $from = state.selection.$from;
|
|
30
12
|
return $from.depth > 1 ? state.selection instanceof _selection.GapCursorSelection && $from.parentOffset === 0 || $from.index($from.depth - 1) === 0 : true;
|
|
@@ -81,46 +63,6 @@ var withScrollIntoView = function withScrollIntoView(command) {
|
|
|
81
63
|
}, view);
|
|
82
64
|
};
|
|
83
65
|
};
|
|
84
|
-
exports.withScrollIntoView = withScrollIntoView;
|
|
85
|
-
/**
|
|
86
|
-
* Walk forwards from a position until we encounter the (inside) start of
|
|
87
|
-
* the next node, or reach the end of the document.
|
|
88
|
-
*
|
|
89
|
-
* @param $startPos Position to start walking from.
|
|
90
|
-
*/
|
|
91
|
-
var walkNextNode = function walkNextNode($startPos) {
|
|
92
|
-
var $pos = $startPos;
|
|
93
|
-
|
|
94
|
-
// invariant 1: don't walk past the end of the document
|
|
95
|
-
// invariant 2: we are at the beginning or
|
|
96
|
-
// we haven't walked to the start of *any* node
|
|
97
|
-
// parentOffset includes textOffset.
|
|
98
|
-
while ($pos.pos < $pos.doc.nodeSize - 2 && ($pos.pos === $startPos.pos || $pos.parentOffset > 0)) {
|
|
99
|
-
$pos = $pos.doc.resolve($pos.pos + 1);
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
$pos: $pos,
|
|
103
|
-
foundNode: $pos.pos < $pos.doc.nodeSize - 2
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Walk backwards from a position until we encounter the (inside) end of
|
|
109
|
-
* the previous node, or reach the start of the document.
|
|
110
|
-
*
|
|
111
|
-
* @param $startPos Position to start walking from.
|
|
112
|
-
*/
|
|
113
|
-
exports.walkNextNode = walkNextNode;
|
|
114
|
-
var walkPrevNode = function walkPrevNode($startPos) {
|
|
115
|
-
var $pos = $startPos;
|
|
116
|
-
while ($pos.pos > 0 && ($pos.pos === $startPos.pos || $pos.parentOffset < $pos.parent.nodeSize - 2)) {
|
|
117
|
-
$pos = $pos.doc.resolve($pos.pos - 1);
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
$pos: $pos,
|
|
121
|
-
foundNode: $pos.pos > 0
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
66
|
|
|
125
67
|
/**
|
|
126
68
|
* Insert content, delete a range and create a new selection
|
|
@@ -131,23 +73,7 @@ var walkPrevNode = function walkPrevNode($startPos) {
|
|
|
131
73
|
* @param insertions content to insert at the specified position
|
|
132
74
|
* @param deletions the ranges to delete
|
|
133
75
|
*/
|
|
134
|
-
exports.
|
|
135
|
-
var insertContentDeleteRange = function insertContentDeleteRange(tr, getSelectionResolvedPos, insertions, deletions) {
|
|
136
|
-
insertions.forEach(function (contentInsert) {
|
|
137
|
-
var _contentInsert = (0, _slicedToArray2.default)(contentInsert, 2),
|
|
138
|
-
content = _contentInsert[0],
|
|
139
|
-
pos = _contentInsert[1];
|
|
140
|
-
tr.insert(tr.mapping.map(pos), content);
|
|
141
|
-
});
|
|
142
|
-
deletions.forEach(function (deleteRange) {
|
|
143
|
-
var _deleteRange = (0, _slicedToArray2.default)(deleteRange, 2),
|
|
144
|
-
firstPos = _deleteRange[0],
|
|
145
|
-
lastPos = _deleteRange[1];
|
|
146
|
-
tr.delete(tr.mapping.map(firstPos), tr.mapping.map(lastPos));
|
|
147
|
-
});
|
|
148
|
-
tr.setSelection(new _state.TextSelection(getSelectionResolvedPos(tr)));
|
|
149
|
-
};
|
|
150
|
-
exports.insertContentDeleteRange = insertContentDeleteRange;
|
|
76
|
+
exports.withScrollIntoView = withScrollIntoView;
|
|
151
77
|
var selectNode = function selectNode(pos) {
|
|
152
78
|
return function (state, dispatch) {
|
|
153
79
|
if (dispatch) {
|
|
@@ -156,36 +82,4 @@ var selectNode = function selectNode(pos) {
|
|
|
156
82
|
return true;
|
|
157
83
|
};
|
|
158
84
|
};
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* If the selection is empty, is inside a paragraph node and `canNextNodeMoveUp` is true then delete current paragraph
|
|
162
|
-
* and move the node below it up. The selection will be retained, to be placed in the moved node.
|
|
163
|
-
*
|
|
164
|
-
* @param canNextNodeMoveUp check if node directly after the selection is able to be brought up to selection
|
|
165
|
-
* @returns PM Command
|
|
166
|
-
*/
|
|
167
|
-
exports.selectNode = selectNode;
|
|
168
|
-
var deleteEmptyParagraphAndMoveBlockUp = function deleteEmptyParagraphAndMoveBlockUp(canNextNodeMoveUp) {
|
|
169
|
-
return function (state, dispatch, view) {
|
|
170
|
-
var _state$selection3 = state.selection,
|
|
171
|
-
_state$selection3$$fr = _state$selection3.$from,
|
|
172
|
-
pos = _state$selection3$$fr.pos,
|
|
173
|
-
parent = _state$selection3$$fr.parent,
|
|
174
|
-
$head = _state$selection3.$head,
|
|
175
|
-
empty = _state$selection3.empty,
|
|
176
|
-
tr = state.tr,
|
|
177
|
-
doc = state.doc;
|
|
178
|
-
var _walkNextNode = walkNextNode($head),
|
|
179
|
-
$pos = _walkNextNode.$pos;
|
|
180
|
-
var nextPMNode = doc.nodeAt($pos.pos - 1);
|
|
181
|
-
if (empty && nextPMNode && canNextNodeMoveUp(nextPMNode) && (0, _utils.isEmptyParagraph)(parent) && view !== null && view !== void 0 && view.endOfTextblock('right')) {
|
|
182
|
-
tr.deleteRange(pos - 1, pos + 1);
|
|
183
|
-
if (dispatch) {
|
|
184
|
-
dispatch(tr);
|
|
185
|
-
}
|
|
186
|
-
return true;
|
|
187
|
-
}
|
|
188
|
-
return false;
|
|
189
|
-
};
|
|
190
|
-
};
|
|
191
|
-
exports.deleteEmptyParagraphAndMoveBlockUp = deleteEmptyParagraphAndMoveBlockUp;
|
|
85
|
+
exports.selectNode = selectNode;
|