@atlaskit/editor-core 188.12.0 → 188.12.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/CHANGELOG.md +9 -0
- package/dist/cjs/labs/next/presets/universal.js +12 -1
- package/dist/cjs/plugins/annotation/index.js +12 -1
- package/dist/cjs/plugins/annotation/pm-plugins/inline-comment.js +2 -1
- package/dist/cjs/plugins/annotation/pm-plugins/plugin-factory.js +5 -0
- package/dist/cjs/plugins/annotation/pm-plugins/reducer.js +2 -1
- package/dist/cjs/plugins/annotation/toolbar.js +2 -156
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +33 -31
- package/dist/cjs/plugins/layout/actions.js +20 -17
- package/dist/cjs/plugins/layout/index.js +6 -2
- package/dist/cjs/plugins/panel/index.js +1 -1
- package/dist/cjs/plugins/panel/toolbar.js +9 -7
- package/dist/cjs/plugins/paste/pm-plugins/analytics.js +0 -6
- package/dist/cjs/plugins/rank.js +1 -1
- package/dist/cjs/plugins/tasks-and-decisions/index.js +1 -1
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +104 -90
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +4 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/labs/next/presets/universal.js +12 -1
- package/dist/es2019/plugins/annotation/index.js +14 -1
- package/dist/es2019/plugins/annotation/pm-plugins/inline-comment.js +2 -1
- package/dist/es2019/plugins/annotation/pm-plugins/plugin-factory.js +6 -0
- package/dist/es2019/plugins/annotation/pm-plugins/reducer.js +2 -1
- package/dist/es2019/plugins/annotation/toolbar.js +1 -156
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
- package/dist/es2019/plugins/layout/actions.js +4 -3
- package/dist/es2019/plugins/layout/index.js +63 -57
- package/dist/es2019/plugins/panel/index.js +1 -1
- package/dist/es2019/plugins/panel/toolbar.js +9 -7
- package/dist/es2019/plugins/paste/pm-plugins/analytics.js +1 -4
- package/dist/es2019/plugins/rank.js +1 -1
- package/dist/es2019/plugins/tasks-and-decisions/index.js +1 -1
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +22 -14
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +4 -2
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/labs/next/presets/universal.js +12 -1
- package/dist/esm/plugins/annotation/index.js +12 -1
- package/dist/esm/plugins/annotation/pm-plugins/inline-comment.js +2 -1
- package/dist/esm/plugins/annotation/pm-plugins/plugin-factory.js +5 -0
- package/dist/esm/plugins/annotation/pm-plugins/reducer.js +2 -1
- package/dist/esm/plugins/annotation/toolbar.js +1 -156
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +33 -31
- package/dist/esm/plugins/layout/actions.js +15 -12
- package/dist/esm/plugins/layout/index.js +7 -3
- package/dist/esm/plugins/panel/index.js +1 -1
- package/dist/esm/plugins/panel/toolbar.js +9 -7
- package/dist/esm/plugins/paste/pm-plugins/analytics.js +1 -6
- package/dist/esm/plugins/rank.js +1 -1
- package/dist/esm/plugins/tasks-and-decisions/index.js +1 -1
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +104 -90
- package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +4 -2
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/annotation/pm-plugins/types.d.ts +1 -0
- package/dist/types/plugins/insert-block/types.d.ts +3 -1
- package/dist/types/plugins/layout/actions.d.ts +2 -1
- package/dist/types/plugins/layout/index.d.ts +4 -0
- package/dist/types/plugins/panel/index.d.ts +2 -2
- package/dist/types/plugins/panel/toolbar.d.ts +5 -3
- package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +0 -1
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +7 -4
- package/dist/types/plugins/tasks-and-decisions/types.d.ts +5 -1
- package/dist/types-ts4.5/plugins/annotation/pm-plugins/types.d.ts +1 -0
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +3 -1
- package/dist/types-ts4.5/plugins/layout/actions.d.ts +2 -1
- package/dist/types-ts4.5/plugins/layout/index.d.ts +4 -0
- package/dist/types-ts4.5/plugins/panel/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/panel/toolbar.d.ts +5 -3
- package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +0 -1
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +7 -4
- package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +3 -1
- package/package.json +6 -2
|
@@ -15,7 +15,8 @@ var _steps = require("@atlaskit/adf-schema/steps");
|
|
|
15
15
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
16
16
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
17
17
|
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
18
|
-
var _analytics = require("
|
|
18
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
19
|
+
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
19
20
|
var _commands2 = require("../commands");
|
|
20
21
|
var _commands3 = require("./commands");
|
|
21
22
|
var _helpers = require("./helpers");
|
|
@@ -96,16 +97,18 @@ var joinTaskDecisionFollowing = function joinTaskDecisionFollowing(state, dispat
|
|
|
96
97
|
}
|
|
97
98
|
return false;
|
|
98
99
|
};
|
|
99
|
-
var getUnindentCommand = exports.getUnindentCommand = function getUnindentCommand() {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
var getUnindentCommand = exports.getUnindentCommand = function getUnindentCommand(editorAnalyticsAPI) {
|
|
101
|
+
return function () {
|
|
102
|
+
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _analytics.INPUT_METHOD.KEYBOARD;
|
|
103
|
+
return (0, _utils2.filterCommand)(_helpers.isInsideTask, function (state, dispatch) {
|
|
104
|
+
var normalizedSelection = (0, _utils3.normalizeTaskItemsSelection)(state.selection);
|
|
105
|
+
var curIndentLevel = (0, _helpers.getCurrentIndentLevel)(normalizedSelection);
|
|
106
|
+
if (!curIndentLevel || curIndentLevel === 1) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, indentationAnalytics(curIndentLevel, _analytics.INDENT_DIRECTION.OUTDENT, inputMethod))((0, _commands.autoJoin)(_commands3.liftSelection, ['taskList']))(state, dispatch);
|
|
110
|
+
});
|
|
111
|
+
};
|
|
109
112
|
};
|
|
110
113
|
|
|
111
114
|
// if selection is decision item or first action item in table cell
|
|
@@ -122,53 +125,59 @@ var shouldLetTabThroughInTable = function shouldLetTabThroughInTable(state) {
|
|
|
122
125
|
}
|
|
123
126
|
return false;
|
|
124
127
|
};
|
|
125
|
-
var getIndentCommand = exports.getIndentCommand = function getIndentCommand() {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
var getIndentCommand = exports.getIndentCommand = function getIndentCommand(editorAnalyticsAPI) {
|
|
129
|
+
return function () {
|
|
130
|
+
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _analytics.INPUT_METHOD.KEYBOARD;
|
|
131
|
+
return (0, _utils2.filterCommand)(_helpers.isInsideTask, function (state, dispatch) {
|
|
132
|
+
var normalizedSelection = (0, _utils3.normalizeTaskItemsSelection)(state.selection);
|
|
133
|
+
var curIndentLevel = (0, _helpers.getCurrentIndentLevel)(normalizedSelection);
|
|
134
|
+
if (!curIndentLevel || curIndentLevel >= 6) {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, indentationAnalytics(curIndentLevel, _analytics.INDENT_DIRECTION.INDENT, inputMethod))((0, _commands.autoJoin)(_commands3.wrapSelectionInTaskList, ['taskList']))(state, dispatch);
|
|
138
|
+
});
|
|
139
|
+
};
|
|
135
140
|
};
|
|
136
|
-
var backspaceFrom = function backspaceFrom(
|
|
137
|
-
return function (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
var backspaceFrom = function backspaceFrom(editorAnalyticsAPI) {
|
|
142
|
+
return function ($from) {
|
|
143
|
+
return function (state, dispatch) {
|
|
144
|
+
// previous was empty, just delete backwards
|
|
145
|
+
var taskBefore = $from.doc.resolve($from.before());
|
|
146
|
+
if (taskBefore.nodeBefore && (0, _helpers.isActionOrDecisionItem)(taskBefore.nodeBefore) && taskBefore.nodeBefore.nodeSize === 2) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
143
149
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
// if nested, just unindent
|
|
151
|
+
var _state$schema$nodes3 = state.schema.nodes,
|
|
152
|
+
taskList = _state$schema$nodes3.taskList,
|
|
153
|
+
paragraph = _state$schema$nodes3.paragraph;
|
|
154
|
+
if ($from.node($from.depth - 2).type === taskList) {
|
|
155
|
+
return getUnindentCommand(editorAnalyticsAPI)()(state, dispatch);
|
|
156
|
+
}
|
|
151
157
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
158
|
+
// bottom level, should "unwrap" taskItem contents into paragraph
|
|
159
|
+
// we achieve this by slicing the content out, and replacing
|
|
160
|
+
if (actionDecisionFollowsOrNothing($from)) {
|
|
161
|
+
if (dispatch) {
|
|
162
|
+
var taskContent = state.doc.slice($from.start(), $from.end()).content;
|
|
157
163
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
164
|
+
// might be end of document after
|
|
165
|
+
var slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : paragraph.createChecked();
|
|
166
|
+
dispatch(splitListItemWith(state.tr, slice, $from, true));
|
|
167
|
+
}
|
|
168
|
+
return true;
|
|
161
169
|
}
|
|
162
|
-
return
|
|
163
|
-
}
|
|
164
|
-
return false;
|
|
170
|
+
return false;
|
|
171
|
+
};
|
|
165
172
|
};
|
|
166
173
|
};
|
|
167
|
-
var backspace =
|
|
168
|
-
return (0,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
var backspace = function backspace(editorAnalyticsAPI) {
|
|
175
|
+
return (0, _utils2.filterCommand)(_utils2.isEmptySelectionAtStart, (0, _commands.autoJoin)((0, _commands.chainCommands)(function (state, dispatch) {
|
|
176
|
+
return (0, _commands3.joinAtCut)(state.selection.$from)(state, dispatch);
|
|
177
|
+
}, (0, _utils2.filterCommand)(_helpers.isInsideTaskOrDecisionItem, function (state, dispatch) {
|
|
178
|
+
return backspaceFrom(editorAnalyticsAPI)(state.selection.$from)(state, dispatch);
|
|
179
|
+
})), ['taskList', 'decisionList']));
|
|
180
|
+
};
|
|
172
181
|
var unindentTaskOrUnwrapTaskDecisionFollowing = function unindentTaskOrUnwrapTaskDecisionFollowing(state, dispatch) {
|
|
173
182
|
var $from = state.selection.$from,
|
|
174
183
|
_state$schema$nodes4 = state.schema.nodes,
|
|
@@ -278,42 +287,44 @@ var splitListItem = function splitListItem(state, dispatch) {
|
|
|
278
287
|
}
|
|
279
288
|
return false;
|
|
280
289
|
};
|
|
281
|
-
var enter =
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
$
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
var
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
290
|
+
var enter = function enter(editorAnalyticsAPI) {
|
|
291
|
+
return (0, _utils2.filterCommand)(_helpers.isInsideTaskOrDecisionItem, (0, _commands.chainCommands)((0, _utils2.filterCommand)(_helpers.isEmptyTaskDecision, (0, _commands.chainCommands)(getUnindentCommand(editorAnalyticsAPI)(), splitListItem)), function (state, dispatch) {
|
|
292
|
+
var selection = state.selection,
|
|
293
|
+
schema = state.schema;
|
|
294
|
+
var taskItem = schema.nodes.taskItem;
|
|
295
|
+
var $from = selection.$from,
|
|
296
|
+
$to = selection.$to;
|
|
297
|
+
var node = $from.node($from.depth);
|
|
298
|
+
var nodeType = node && node.type;
|
|
299
|
+
var listType = nodeType === taskItem ? 'taskList' : 'decisionList';
|
|
300
|
+
var addItem = function addItem(_ref) {
|
|
301
|
+
var tr = _ref.tr,
|
|
302
|
+
itemLocalId = _ref.itemLocalId;
|
|
303
|
+
// ED-8932: When cursor is at the beginning of a task item, instead of split, we insert above.
|
|
304
|
+
if ($from.pos === $to.pos && $from.parentOffset === 0) {
|
|
305
|
+
var newTask = nodeType.createAndFill({
|
|
306
|
+
localId: itemLocalId
|
|
307
|
+
});
|
|
308
|
+
if (newTask) {
|
|
309
|
+
// Current position will point to text node, but we want to insert above the taskItem node
|
|
310
|
+
return tr.insert($from.pos - 1, newTask);
|
|
311
|
+
}
|
|
301
312
|
}
|
|
313
|
+
return tr.split($from.pos, 1, [{
|
|
314
|
+
type: nodeType,
|
|
315
|
+
attrs: {
|
|
316
|
+
localId: itemLocalId
|
|
317
|
+
}
|
|
318
|
+
}]);
|
|
319
|
+
};
|
|
320
|
+
var insertTr = (0, _commands2.insertTaskDecisionWithAnalytics)(state, listType, _analytics.INPUT_METHOD.KEYBOARD, addItem);
|
|
321
|
+
if (insertTr && dispatch) {
|
|
322
|
+
insertTr.scrollIntoView();
|
|
323
|
+
dispatch(insertTr);
|
|
302
324
|
}
|
|
303
|
-
return
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
localId: itemLocalId
|
|
307
|
-
}
|
|
308
|
-
}]);
|
|
309
|
-
};
|
|
310
|
-
var insertTr = (0, _commands2.insertTaskDecisionWithAnalytics)(state, listType, _analytics.INPUT_METHOD.KEYBOARD, addItem);
|
|
311
|
-
if (insertTr && dispatch) {
|
|
312
|
-
insertTr.scrollIntoView();
|
|
313
|
-
dispatch(insertTr);
|
|
314
|
-
}
|
|
315
|
-
return true;
|
|
316
|
-
}));
|
|
325
|
+
return true;
|
|
326
|
+
}));
|
|
327
|
+
};
|
|
317
328
|
var cmdOptEnter = (0, _utils2.filterCommand)(_helpers.isInsideTaskOrDecisionItem, function (state, dispatch) {
|
|
318
329
|
var selection = state.selection,
|
|
319
330
|
schema = state.schema;
|
|
@@ -334,17 +345,20 @@ var cmdOptEnter = (0, _utils2.filterCommand)(_helpers.isInsideTaskOrDecisionItem
|
|
|
334
345
|
}
|
|
335
346
|
return true;
|
|
336
347
|
});
|
|
337
|
-
function keymapPlugin(schema, allowNestedTasks, consumeTabs) {
|
|
348
|
+
function keymapPlugin(schema, api, allowNestedTasks, consumeTabs) {
|
|
349
|
+
var _api$analytics3, _api$analytics4;
|
|
338
350
|
var indentHandlers = {
|
|
339
351
|
'Shift-Tab': (0, _utils2.filterCommand)([_helpers.isInsideTaskOrDecisionItem, function (state) {
|
|
340
352
|
return !shouldLetTabThroughInTable(state);
|
|
341
353
|
}], function (state, dispatch) {
|
|
342
|
-
|
|
354
|
+
var _api$analytics;
|
|
355
|
+
return getUnindentCommand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.KEYBOARD)(state, dispatch) || !!consumeTabs;
|
|
343
356
|
}),
|
|
344
357
|
Tab: (0, _utils2.filterCommand)([_helpers.isInsideTaskOrDecisionItem, function (state) {
|
|
345
358
|
return !shouldLetTabThroughInTable(state);
|
|
346
359
|
}], function (state, dispatch) {
|
|
347
|
-
|
|
360
|
+
var _api$analytics2;
|
|
361
|
+
return getIndentCommand(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(_analytics.INPUT_METHOD.KEYBOARD)(state, dispatch) || !!consumeTabs;
|
|
348
362
|
})
|
|
349
363
|
};
|
|
350
364
|
var defaultHandlers = consumeTabs ? {
|
|
@@ -352,10 +366,10 @@ function keymapPlugin(schema, allowNestedTasks, consumeTabs) {
|
|
|
352
366
|
Tab: _helpers.isInsideTaskOrDecisionItem
|
|
353
367
|
} : {};
|
|
354
368
|
var keymaps = _objectSpread((0, _defineProperty2.default)({
|
|
355
|
-
Backspace: backspace,
|
|
369
|
+
Backspace: backspace(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
|
|
356
370
|
Delete: deleteForwards,
|
|
357
371
|
'Ctrl-d': deleteForwards,
|
|
358
|
-
Enter: enter
|
|
372
|
+
Enter: enter(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)
|
|
359
373
|
}, _keymaps.toggleTaskItemCheckbox.common, cmdOptEnter), allowNestedTasks ? indentHandlers : defaultHandlers);
|
|
360
374
|
return (0, _keymap.keymap)(keymaps);
|
|
361
375
|
}
|
|
@@ -30,7 +30,8 @@ var onItemActivated = exports.onItemActivated = function onItemActivated(pluginI
|
|
|
30
30
|
pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.indentList(_analytics.INPUT_METHOD.TOOLBAR));
|
|
31
31
|
}
|
|
32
32
|
if (node === 'taskList') {
|
|
33
|
-
|
|
33
|
+
var _pluginInjectionApi$a;
|
|
34
|
+
(0, _keymaps.getIndentCommand)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(_analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
34
35
|
}
|
|
35
36
|
break;
|
|
36
37
|
}
|
|
@@ -45,7 +46,8 @@ var onItemActivated = exports.onItemActivated = function onItemActivated(pluginI
|
|
|
45
46
|
pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.outdentList(_analytics.INPUT_METHOD.TOOLBAR));
|
|
46
47
|
}
|
|
47
48
|
if (_node === 'taskList') {
|
|
48
|
-
|
|
49
|
+
var _pluginInjectionApi$a2;
|
|
50
|
+
(0, _keymaps.getUnindentCommand)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(_analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
49
51
|
}
|
|
50
52
|
break;
|
|
51
53
|
}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = exports.name = "@atlaskit/editor-core";
|
|
8
|
-
var version = exports.version = "188.12.
|
|
8
|
+
var version = exports.version = "188.12.1";
|
|
9
9
|
var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
|
|
10
10
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
11
11
|
};
|
|
@@ -20,6 +20,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
|
20
20
|
import { saveOnEnterPlugin } from '@atlaskit/editor-plugin-save-on-enter';
|
|
21
21
|
import { scrollIntoViewPlugin } from '@atlaskit/editor-plugin-scroll-into-view';
|
|
22
22
|
import { mentionsPlugin } from '@atlaskit/editor-plugin-mentions';
|
|
23
|
+
import { selectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
|
|
23
24
|
import { isFullPage as fullPageCheck } from '../../../utils/is-full-page';
|
|
24
25
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
25
26
|
import { createDefaultPreset } from './default';
|
|
@@ -398,6 +399,16 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
|
|
|
398
399
|
return builder;
|
|
399
400
|
}).add([codeBidiWarningPlugin, {
|
|
400
401
|
appearance
|
|
401
|
-
}])
|
|
402
|
+
}])
|
|
403
|
+
/**
|
|
404
|
+
* Do not use this plugin - it is for AI purposes only.
|
|
405
|
+
*/.maybeAdd(selectionToolbarPlugin, (plugin, builder) => {
|
|
406
|
+
if (getBooleanFF('platform.editor.enable-selection-toolbar_ucdwd')) {
|
|
407
|
+
return builder.add([plugin, {
|
|
408
|
+
preferenceToolbarAboveSelection: false
|
|
409
|
+
}]);
|
|
410
|
+
}
|
|
411
|
+
return builder;
|
|
412
|
+
});
|
|
402
413
|
return finalPreset;
|
|
403
414
|
}
|
|
@@ -7,6 +7,7 @@ import { getPluginState } from './utils';
|
|
|
7
7
|
import { buildToolbar } from './toolbar';
|
|
8
8
|
import { InlineCommentView } from './ui/InlineCommentView';
|
|
9
9
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
10
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
const annotationPlugin = ({
|
|
11
12
|
config: annotationProviders,
|
|
12
13
|
api
|
|
@@ -53,7 +54,19 @@ const annotationPlugin = ({
|
|
|
53
54
|
}],
|
|
54
55
|
pluginsOptions: {
|
|
55
56
|
floatingToolbar(state, intl) {
|
|
56
|
-
if (!annotationProviders) {
|
|
57
|
+
if (getBooleanFF('platform.editor.enable-selection-toolbar_ucdwd') || !annotationProviders) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const pluginState = getPluginState(state);
|
|
61
|
+
if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
|
|
62
|
+
const {
|
|
63
|
+
isToolbarAbove
|
|
64
|
+
} = annotationProviders.inlineComment;
|
|
65
|
+
return buildToolbar(state, intl, isToolbarAbove);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
selectionToolbar(state, intl) {
|
|
69
|
+
if (!getBooleanFF('platform.editor.enable-selection-toolbar_ucdwd') || !annotationProviders) {
|
|
57
70
|
return;
|
|
58
71
|
}
|
|
59
72
|
const pluginState = getPluginState(state);
|
|
@@ -11,6 +11,12 @@ const handleDocChanged = (tr, prevPluginState) => {
|
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
const handleSelectionChanged = (tr, pluginState) => {
|
|
14
|
+
if (pluginState.skipSelectionHandling) {
|
|
15
|
+
return {
|
|
16
|
+
...pluginState,
|
|
17
|
+
skipSelectionHandling: false
|
|
18
|
+
};
|
|
19
|
+
}
|
|
14
20
|
const selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc);
|
|
15
21
|
const changed = selectedAnnotations.length !== pluginState.selectedAnnotations.length || selectedAnnotations.some(annotationInfo => {
|
|
16
22
|
return !pluginState.selectedAnnotations.some(aInfo => aInfo.type === annotationInfo.id);
|
|
@@ -54,7 +54,8 @@ export default ((pluginState, action) => {
|
|
|
54
54
|
case ACTIONS.SET_SELECTED_ANNOTATION:
|
|
55
55
|
return {
|
|
56
56
|
...pluginState,
|
|
57
|
-
selectedAnnotations: [...action.data.selectedAnnotations]
|
|
57
|
+
selectedAnnotations: [...action.data.selectedAnnotations],
|
|
58
|
+
skipSelectionHandling: true
|
|
58
59
|
};
|
|
59
60
|
default:
|
|
60
61
|
return pluginState;
|
|
@@ -1,166 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import CommentIcon from '@atlaskit/icon/glyph/comment';
|
|
3
|
-
// AFP-2532 TODO: Fix automatic suppressions below
|
|
4
|
-
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
5
3
|
import { addInlineComment, ToolTipContent } from '../../keymaps';
|
|
6
4
|
import { setInlineCommentDraftState } from './commands';
|
|
7
5
|
import { AnnotationTestIds, AnnotationSelectionType } from './types';
|
|
8
6
|
import { isSelectionValid } from './utils';
|
|
9
7
|
import { annotationMessages } from '@atlaskit/editor-common/messages';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Returns the coordintes at the bottom the selection.
|
|
13
|
-
*/
|
|
14
|
-
const getCoordsBelowSelection = (bottomCoords, toolbarRect) => {
|
|
15
|
-
return {
|
|
16
|
-
top: (bottomCoords.top || 0) + toolbarRect.height / 1.15,
|
|
17
|
-
left: bottomCoords.right - toolbarRect.width / 2
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/*
|
|
22
|
-
Calculates the position of the floating toolbar relative to the selection.
|
|
23
|
-
|
|
24
|
-
This is a re-implementation which closely matches the behaviour on Confluence renderer.
|
|
25
|
-
The main difference is the popup is always above the selection.
|
|
26
|
-
|
|
27
|
-
Things to consider:
|
|
28
|
-
- popup is always above the selection
|
|
29
|
-
- coordinates of head X and getBoundingClientRect() are absolute in client viewport (not including scroll offsets)
|
|
30
|
-
- popup may appear in '.fabric-editor-popup-scroll-parent' (or body)
|
|
31
|
-
- we use the toolbarRect to center align toolbar
|
|
32
|
-
- use wrapperBounds to clamp values
|
|
33
|
-
- editorView.dom bounds differ to wrapperBounds, convert at the end
|
|
34
|
-
*/
|
|
35
|
-
const calculateToolbarPositionAboveSelection = toolbarTitle => (editorView, nextPos) => {
|
|
36
|
-
const toolbar = document.querySelector(`div[aria-label="${toolbarTitle}"]`);
|
|
37
|
-
if (!toolbar) {
|
|
38
|
-
return nextPos;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// scroll wrapper for full page, fall back to document body
|
|
42
|
-
// TODO: look into using getScrollGutterOptions()
|
|
43
|
-
const scrollWrapper = editorView.dom.closest('.fabric-editor-popup-scroll-parent') || document.body;
|
|
44
|
-
const wrapperBounds = scrollWrapper.getBoundingClientRect();
|
|
45
|
-
const selection = window && window.getSelection();
|
|
46
|
-
const range = selection && !selection.isCollapsed && selection.getRangeAt(0);
|
|
47
|
-
if (!range) {
|
|
48
|
-
return nextPos;
|
|
49
|
-
}
|
|
50
|
-
const toolbarRect = toolbar.getBoundingClientRect();
|
|
51
|
-
const {
|
|
52
|
-
head,
|
|
53
|
-
anchor
|
|
54
|
-
} = editorView.state.selection;
|
|
55
|
-
const topCoords = editorView.coordsAtPos(Math.min(head, anchor));
|
|
56
|
-
const bottomCoords = editorView.coordsAtPos(Math.max(head, anchor) - Math.min(range.endOffset, 1));
|
|
57
|
-
let top = (topCoords.top || 0) - toolbarRect.height * 1.5;
|
|
58
|
-
let left = 0;
|
|
59
|
-
|
|
60
|
-
// If not on the same line
|
|
61
|
-
if (topCoords.top !== bottomCoords.top) {
|
|
62
|
-
// selecting downwards
|
|
63
|
-
if (head > anchor) {
|
|
64
|
-
left = Math.max(topCoords.right, bottomCoords.right);
|
|
65
|
-
} else {
|
|
66
|
-
left = Math.min(topCoords.left, bottomCoords.left);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/*
|
|
70
|
-
short selection above a long paragraph
|
|
71
|
-
eg. short {<}heading
|
|
72
|
-
The purpose of this text is to show the selection range{>}.
|
|
73
|
-
The horizontal positioning should center around "heading",
|
|
74
|
-
not where it ends at "range".
|
|
75
|
-
Note: if it was "head<b>ing</b>" then it would only center
|
|
76
|
-
around "head". Undesireable but matches the current renderer.
|
|
77
|
-
*/
|
|
78
|
-
const cliffPosition = range.getClientRects()[0];
|
|
79
|
-
if (cliffPosition.right < left) {
|
|
80
|
-
left = cliffPosition.left + cliffPosition.width / 2;
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
// Otherwise center on the single line selection
|
|
84
|
-
left = topCoords.left + (bottomCoords.right - topCoords.left) / 2;
|
|
85
|
-
}
|
|
86
|
-
left -= toolbarRect.width / 2;
|
|
87
|
-
|
|
88
|
-
// Place toolbar below selection if not sufficient space above
|
|
89
|
-
if (top < wrapperBounds.top) {
|
|
90
|
-
({
|
|
91
|
-
top,
|
|
92
|
-
left
|
|
93
|
-
} = getCoordsBelowSelection(bottomCoords, toolbarRect));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// remap positions from browser document to wrapperBounds
|
|
97
|
-
return {
|
|
98
|
-
top: top - wrapperBounds.top + scrollWrapper.scrollTop,
|
|
99
|
-
left: Math.max(0, left - wrapperBounds.left)
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
/*
|
|
104
|
-
Calculates the position of the floating toolbar relative to the selection.
|
|
105
|
-
|
|
106
|
-
This is a re-implementation which closely matches the behaviour on Confluence renderer.
|
|
107
|
-
The main difference is the popup is always above the selection.
|
|
108
|
-
|
|
109
|
-
Things to consider:
|
|
110
|
-
- stick as close to the head X release coordinates as possible
|
|
111
|
-
- coordinates of head X and getBoundingClientRect() are absolute in client viewport (not including scroll offsets)
|
|
112
|
-
- popup may appear in '.fabric-editor-popup-scroll-parent' (or body)
|
|
113
|
-
- we use the toolbarRect to center align toolbar
|
|
114
|
-
- use wrapperBounds to clamp values
|
|
115
|
-
- editorView.dom bounds differ to wrapperBounds, convert at the end
|
|
116
|
-
*/
|
|
117
|
-
const calculateToolbarPositionTrackHead = toolbarTitle => (editorView, nextPos) => {
|
|
118
|
-
const toolbar = document.querySelector(`div[aria-label="${toolbarTitle}"]`);
|
|
119
|
-
if (!toolbar) {
|
|
120
|
-
return nextPos;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// scroll wrapper for full page, fall back to document body
|
|
124
|
-
// TODO: look into using getScrollGutterOptions()
|
|
125
|
-
const scrollWrapper = editorView.dom.closest('.fabric-editor-popup-scroll-parent') || document.body;
|
|
126
|
-
const wrapperBounds = scrollWrapper.getBoundingClientRect();
|
|
127
|
-
const selection = window && window.getSelection();
|
|
128
|
-
const range = selection && !selection.isCollapsed && selection.getRangeAt(0);
|
|
129
|
-
if (!range) {
|
|
130
|
-
return nextPos;
|
|
131
|
-
}
|
|
132
|
-
const toolbarRect = toolbar.getBoundingClientRect();
|
|
133
|
-
const {
|
|
134
|
-
head,
|
|
135
|
-
anchor
|
|
136
|
-
} = editorView.state.selection;
|
|
137
|
-
let topCoords = editorView.coordsAtPos(Math.min(head, anchor));
|
|
138
|
-
let bottomCoords = editorView.coordsAtPos(Math.max(head, anchor) - Math.min(range.endOffset, 1));
|
|
139
|
-
let top;
|
|
140
|
-
// If not the same line, display toolbar below.
|
|
141
|
-
if (head > anchor && topCoords.top !== bottomCoords.top) {
|
|
142
|
-
// We are taking the previous pos to the maxium, so avoid end of line positions
|
|
143
|
-
// returning the next line's rect.
|
|
144
|
-
top = (bottomCoords.top || 0) + toolbarRect.height / 1.15;
|
|
145
|
-
} else {
|
|
146
|
-
top = (topCoords.top || 0) - toolbarRect.height * 1.5;
|
|
147
|
-
}
|
|
148
|
-
let left = (head > anchor ? bottomCoords.right : topCoords.left) - toolbarRect.width / 2;
|
|
149
|
-
|
|
150
|
-
// Place toolbar below selection if not sufficient space above
|
|
151
|
-
if (top < wrapperBounds.top) {
|
|
152
|
-
({
|
|
153
|
-
top,
|
|
154
|
-
left
|
|
155
|
-
} = getCoordsBelowSelection(bottomCoords, toolbarRect));
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// remap positions from browser document to wrapperBounds
|
|
159
|
-
return {
|
|
160
|
-
top: top - wrapperBounds.top + scrollWrapper.scrollTop,
|
|
161
|
-
left: Math.max(0, left - wrapperBounds.left)
|
|
162
|
-
};
|
|
163
|
-
};
|
|
8
|
+
import { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
|
|
164
9
|
export const buildToolbar = (state, intl, isToolbarAbove = false) => {
|
|
165
10
|
const {
|
|
166
11
|
schema
|
|
@@ -10,7 +10,6 @@ import ToolbarButton from '../../../../ui/ToolbarButton';
|
|
|
10
10
|
import { separatorStyles, buttonGroupStyle, wrapperStyle } from '@atlaskit/editor-common/styles';
|
|
11
11
|
import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
|
|
12
12
|
import { showPlaceholderFloatingToolbar } from '../../../placeholder-text/actions';
|
|
13
|
-
import { insertLayoutColumnsWithAnalytics } from '../../../layout/actions';
|
|
14
13
|
import { insertTaskDecisionCommand } from '../../../tasks-and-decisions/commands';
|
|
15
14
|
import { insertExpand } from '../../../expand/commands';
|
|
16
15
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
@@ -206,10 +205,12 @@ export class ToolbarInsertBlock extends React.PureComponent {
|
|
|
206
205
|
return true;
|
|
207
206
|
});
|
|
208
207
|
_defineProperty(this, "insertLayoutColumns", inputMethod => {
|
|
208
|
+
var _pluginInjectionApi$l;
|
|
209
209
|
const {
|
|
210
|
-
editorView
|
|
210
|
+
editorView,
|
|
211
|
+
pluginInjectionApi
|
|
211
212
|
} = this.props;
|
|
212
|
-
|
|
213
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$l = pluginInjectionApi.layout) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.actions.insertLayoutColumns(inputMethod)(editorView.state, editorView.dispatch);
|
|
213
214
|
return true;
|
|
214
215
|
});
|
|
215
216
|
_defineProperty(this, "createStatus", inputMethod => {
|
|
@@ -3,8 +3,9 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
import { TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { flatmap, mapChildren } from '../../utils/slice';
|
|
5
5
|
import { getStepRange, isEmptyDocument } from '@atlaskit/editor-common/utils';
|
|
6
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '
|
|
7
|
-
import { addAnalytics
|
|
6
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
7
|
+
import { addAnalytics } from '../analytics/utils';
|
|
8
|
+
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
8
9
|
import { LAYOUT_TYPE } from '../analytics/types/node-events';
|
|
9
10
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
10
11
|
export const ONE_COL_LAYOUTS = ['single'];
|
|
@@ -75,7 +76,7 @@ export const insertLayoutColumns = (state, dispatch) => {
|
|
|
75
76
|
}
|
|
76
77
|
return true;
|
|
77
78
|
};
|
|
78
|
-
export const insertLayoutColumnsWithAnalytics = inputMethod => withAnalytics({
|
|
79
|
+
export const insertLayoutColumnsWithAnalytics = editorAnalyticsAPI => inputMethod => withAnalytics(editorAnalyticsAPI, {
|
|
79
80
|
action: ACTION.INSERTED,
|
|
80
81
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
81
82
|
actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
|