@atlaskit/editor-core 187.27.1 → 187.28.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 +19 -0
- package/dist/cjs/create-editor/ReactEditorViewInternal.js +3 -3
- package/dist/cjs/create-editor/create-plugins-list.js +2 -2
- package/dist/cjs/index.js +0 -7
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/plugins/base/index.js +7 -126
- package/dist/cjs/plugins/base/plugin.js +140 -0
- package/dist/cjs/plugins/base/pm-plugins/scroll-gutter.js +3 -9
- package/dist/cjs/plugins/index.js +2 -2
- package/dist/cjs/plugins/insert-block/types.js +5 -0
- package/dist/cjs/plugins/list/index.js +17 -0
- package/dist/cjs/plugins/list/utils/find.js +4 -3
- package/dist/cjs/plugins/paste/handlers.js +27 -3
- package/dist/cjs/plugins/paste/pm-plugins/analytics.js +2 -2
- package/dist/cjs/plugins/paste/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/toolbar-lists-indentation/index.js +58 -36
- package/dist/cjs/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +6 -6
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/index.js +3 -3
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +8 -9
- package/dist/cjs/test-utils.js +2 -2
- package/dist/cjs/ui/ContentStyles/index.js +19 -18
- package/dist/cjs/ui/ToolbarFeedback/index.js +22 -16
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/create-editor/ReactEditorViewInternal.js +3 -3
- package/dist/es2019/create-editor/create-plugins-list.js +1 -1
- package/dist/es2019/index.js +0 -1
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/plugins/base/index.js +2 -104
- package/dist/es2019/plugins/base/plugin.js +109 -0
- package/dist/es2019/plugins/base/pm-plugins/scroll-gutter.js +1 -4
- package/dist/es2019/plugins/index.js +1 -1
- package/dist/es2019/plugins/insert-block/types.js +1 -0
- package/dist/es2019/plugins/list/index.js +19 -0
- package/dist/es2019/plugins/list/utils/find.js +2 -2
- package/dist/es2019/plugins/paste/handlers.js +27 -3
- package/dist/es2019/plugins/paste/pm-plugins/analytics.js +2 -2
- package/dist/es2019/plugins/paste/pm-plugins/main.js +2 -2
- package/dist/es2019/plugins/toolbar-lists-indentation/index.js +62 -38
- package/dist/es2019/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +6 -6
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/index.js +3 -3
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +5 -6
- package/dist/es2019/test-utils.js +1 -1
- package/dist/es2019/ui/ContentStyles/index.js +25 -3
- package/dist/es2019/ui/ToolbarFeedback/index.js +14 -9
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/create-editor/ReactEditorViewInternal.js +3 -3
- package/dist/esm/create-editor/create-plugins-list.js +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/plugins/base/index.js +2 -123
- package/dist/esm/plugins/base/plugin.js +128 -0
- package/dist/esm/plugins/base/pm-plugins/scroll-gutter.js +1 -4
- package/dist/esm/plugins/index.js +1 -1
- package/dist/esm/plugins/insert-block/types.js +1 -0
- package/dist/esm/plugins/list/index.js +19 -0
- package/dist/esm/plugins/list/utils/find.js +2 -2
- package/dist/esm/plugins/paste/handlers.js +25 -3
- package/dist/esm/plugins/paste/pm-plugins/analytics.js +2 -2
- package/dist/esm/plugins/paste/pm-plugins/main.js +2 -2
- package/dist/esm/plugins/toolbar-lists-indentation/index.js +60 -37
- package/dist/esm/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +6 -6
- package/dist/esm/plugins/toolbar-lists-indentation/ui/index.js +3 -3
- package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +5 -6
- package/dist/esm/test-utils.js +1 -1
- package/dist/esm/ui/ContentStyles/index.js +6 -5
- package/dist/esm/ui/ToolbarFeedback/index.js +20 -14
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/plugins/base/index.d.ts +4 -16
- package/dist/types/plugins/base/plugin.d.ts +23 -0
- package/dist/types/plugins/base/pm-plugins/scroll-gutter.d.ts +0 -3
- package/dist/types/plugins/index.d.ts +1 -1
- package/dist/types/plugins/insert-block/index.d.ts +3 -19
- package/dist/types/plugins/insert-block/types.d.ts +19 -0
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +3 -3
- package/dist/types/plugins/list/types.d.ts +1 -8
- package/dist/types/plugins/list/utils/find.d.ts +1 -1
- package/dist/types/plugins/paste/handlers.d.ts +4 -2
- package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +2 -1
- package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +5 -2
- package/dist/types/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +4 -1
- package/dist/types/plugins/toolbar-lists-indentation/ui/index.d.ts +3 -3
- package/dist/types/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +3 -2
- package/dist/types/ui/ToolbarFeedback/index.d.ts +1 -19
- package/dist/types/use-preset.d.ts +2 -8
- package/dist/types-ts4.5/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/base/index.d.ts +4 -18
- package/dist/types-ts4.5/plugins/base/plugin.d.ts +25 -0
- package/dist/types-ts4.5/plugins/base/pm-plugins/scroll-gutter.d.ts +0 -3
- package/dist/types-ts4.5/plugins/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/index.d.ts +3 -19
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +19 -0
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +3 -3
- package/dist/types-ts4.5/plugins/list/types.d.ts +1 -8
- package/dist/types-ts4.5/plugins/list/utils/find.d.ts +1 -1
- package/dist/types-ts4.5/plugins/paste/handlers.d.ts +4 -2
- package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +2 -1
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/index.d.ts +5 -2
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +4 -1
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/index.d.ts +3 -3
- package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +3 -2
- package/dist/types-ts4.5/ui/ToolbarFeedback/index.d.ts +1 -19
- package/dist/types-ts4.5/use-preset.d.ts +2 -8
- package/package.json +4 -4
- package/report.api.md +4 -58
- package/tmp/api-report-tmp.d.ts +4 -47
- package/dist/cjs/plugins/list/styles.js +0 -15
- package/dist/cjs/utils/list-commands.js +0 -17
- package/dist/cjs/utils/lists.js +0 -31
- package/dist/es2019/plugins/list/styles.js +0 -26
- package/dist/es2019/utils/list-commands.js +0 -11
- package/dist/es2019/utils/lists.js +0 -26
- package/dist/esm/plugins/list/styles.js +0 -7
- package/dist/esm/utils/list-commands.js +0 -11
- package/dist/esm/utils/lists.js +0 -24
- package/dist/types/plugins/list/styles.d.ts +0 -1
- package/dist/types/utils/list-commands.d.ts +0 -6
- package/dist/types/utils/lists.d.ts +0 -2
- package/dist/types-ts4.5/plugins/list/styles.d.ts +0 -1
- package/dist/types-ts4.5/utils/list-commands.d.ts +0 -6
- package/dist/types-ts4.5/utils/lists.d.ts +0 -2
|
@@ -35,7 +35,6 @@ import { getParticipantsCount } from '../plugins/collab-edit/get-participants-co
|
|
|
35
35
|
import { EVENT_NAME_DISPATCH_TRANSACTION, EVENT_NAME_STATE_APPLY, EVENT_NAME_UPDATE_STATE, EVENT_NAME_VIEW_STATE_UPDATED, EVENT_NAME_ON_CHANGE, TransactionTracker } from '../utils/performance/track-transactions';
|
|
36
36
|
import { countNodes as _countNodes } from '../utils/count-nodes';
|
|
37
37
|
import { PROSEMIRROR_RENDERED_NORMAL_SEVERITY_THRESHOLD, PROSEMIRROR_RENDERED_DEGRADED_SEVERITY_THRESHOLD, DEFAULT_SAMPLING_RATE_VALID_TRANSACTIONS } from './consts';
|
|
38
|
-
import { getContextIdentifier } from '../plugins/base/pm-plugins/context-identifier';
|
|
39
38
|
import ReactEditorViewContext from './ReactEditorViewContext';
|
|
40
39
|
import { EditorPluginInjectionAPI } from '@atlaskit/editor-common/preset';
|
|
41
40
|
import { EDIT_AREA_ID } from '@atlaskit/editor-common/ui';
|
|
@@ -395,9 +394,10 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
395
394
|
var forceSeverityTracking = typeof proseMirrorRenderedTracking === 'undefined' && shouldForceTracking();
|
|
396
395
|
_this.proseMirrorRenderedSeverity = !!forceSeverityTracking || proseMirrorRenderedTracking !== null && proseMirrorRenderedTracking !== void 0 && proseMirrorRenderedTracking.trackSeverity ? getAnalyticsEventSeverity(duration, (_proseMirrorRenderedT = proseMirrorRenderedTracking === null || proseMirrorRenderedTracking === void 0 ? void 0 : proseMirrorRenderedTracking.severityNormalThreshold) !== null && _proseMirrorRenderedT !== void 0 ? _proseMirrorRenderedT : PROSEMIRROR_RENDERED_NORMAL_SEVERITY_THRESHOLD, (_proseMirrorRenderedT2 = proseMirrorRenderedTracking === null || proseMirrorRenderedTracking === void 0 ? void 0 : proseMirrorRenderedTracking.severityDegradedThreshold) !== null && _proseMirrorRenderedT2 !== void 0 ? _proseMirrorRenderedT2 : PROSEMIRROR_RENDERED_DEGRADED_SEVERITY_THRESHOLD) : undefined;
|
|
397
396
|
if (_this.view) {
|
|
398
|
-
var
|
|
397
|
+
var _this$pluginInjection, _this$experienceStore10;
|
|
399
398
|
var nodes = getNodesCount(_this.view.state.doc);
|
|
400
399
|
var ttfb = getResponseEndTime();
|
|
400
|
+
var contextIdentifier = (_this$pluginInjection = _this.pluginInjectionAPI.api().dependencies.base) === null || _this$pluginInjection === void 0 ? void 0 : _this$pluginInjection.sharedState.currentState();
|
|
401
401
|
_this.dispatchAnalyticsEvent({
|
|
402
402
|
action: ACTION.PROSEMIRROR_RENDERED,
|
|
403
403
|
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
@@ -407,7 +407,7 @@ export var ReactEditorView = /*#__PURE__*/function (_React$Component) {
|
|
|
407
407
|
nodes: nodes,
|
|
408
408
|
ttfb: ttfb,
|
|
409
409
|
severity: _this.proseMirrorRenderedSeverity,
|
|
410
|
-
objectId:
|
|
410
|
+
objectId: contextIdentifier === null || contextIdentifier === void 0 ? void 0 : contextIdentifier.objectId,
|
|
411
411
|
distortedDuration: distortedDuration
|
|
412
412
|
},
|
|
413
413
|
eventType: EVENT_TYPE.OPERATIONAL
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
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; }
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
4
|
import createUniversalPreset from '../labs/next/presets/universal';
|
|
5
|
-
import { GUTTER_SIZE_MOBILE_IN_PX } from '
|
|
5
|
+
import { GUTTER_SIZE_MOBILE_IN_PX } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { isFullPage as fullPageCheck } from '../utils/is-full-page';
|
|
7
7
|
import { createFeatureFlagsFromProps } from './feature-flags-from-props';
|
|
8
8
|
var isCodeBlockAllowed = function isCodeBlockAllowed(options) {
|
package/dist/esm/index.js
CHANGED
|
@@ -41,7 +41,6 @@ export { setKeyboardHeight, setMobilePaddingTop, setIsExpanded } from './plugins
|
|
|
41
41
|
|
|
42
42
|
// Used in editor-test-helpers and mobile bridge
|
|
43
43
|
export { setTextSelection, dedupe, getNodesCount, measurements } from './utils';
|
|
44
|
-
export { getListCommands } from './utils/list-commands';
|
|
45
44
|
export { ReactEditorView, BaseReactEditorView } from './create-editor';
|
|
46
45
|
export { getDefaultPresetOptionsFromEditorProps } from './create-editor';
|
|
47
46
|
export { default as EditorActions } from './actions';
|
|
@@ -7,7 +7,7 @@ import { hyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
|
|
|
7
7
|
import { textFormattingPlugin } from '@atlaskit/editor-plugin-text-formatting';
|
|
8
8
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
9
9
|
import unsupportedContentPlugin from '../../../plugins/unsupported-content';
|
|
10
|
-
import basePlugin from '../../../plugins/base';
|
|
10
|
+
import { basePlugin } from '../../../plugins/base';
|
|
11
11
|
import { focusPlugin } from '@atlaskit/editor-plugin-focus';
|
|
12
12
|
import { editorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
13
13
|
import typeAheadPlugin from '../../../plugins/type-ahead';
|
|
@@ -1,123 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
import { baseKeymap } from '@atlaskit/editor-prosemirror/commands';
|
|
5
|
-
import { history } from '@atlaskit/editor-prosemirror/history';
|
|
6
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
|
-
import { browser } from '@atlaskit/editor-common/utils';
|
|
8
|
-
import { doc, paragraph, text } from '@atlaskit/adf-schema';
|
|
9
|
-
import filterStepsPlugin from './pm-plugins/filter-steps';
|
|
10
|
-
import fixChrome88SelectionPlugin from './pm-plugins/fix-chrome-88-selection';
|
|
11
|
-
import disableSpellcheckingPlugin from './pm-plugins/disable-spell-checking';
|
|
12
|
-
import contextIdentifierPlugin from './pm-plugins/context-identifier';
|
|
13
|
-
import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
|
|
14
|
-
import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
|
|
15
|
-
import scrollGutter from './pm-plugins/scroll-gutter';
|
|
16
|
-
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
17
|
-
import frozenEditor from './pm-plugins/frozen-editor';
|
|
18
|
-
// Chrome >= 88
|
|
19
|
-
export var isChromeWithSelectionBug = browser.chrome && browser.chrome_version >= 88;
|
|
20
|
-
var basePlugin = function basePlugin(options, api) {
|
|
21
|
-
var _api$dependencies, _api$dependencies$fea;
|
|
22
|
-
var featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
|
|
23
|
-
return {
|
|
24
|
-
name: 'base',
|
|
25
|
-
pmPlugins: function pmPlugins() {
|
|
26
|
-
var plugins = [{
|
|
27
|
-
name: 'filterStepsPlugin',
|
|
28
|
-
plugin: function plugin(_ref) {
|
|
29
|
-
var dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
|
|
30
|
-
return filterStepsPlugin(dispatchAnalyticsEvent);
|
|
31
|
-
}
|
|
32
|
-
}];
|
|
33
|
-
|
|
34
|
-
// In Chrome, when the selection is placed between adjacent nodes which are not contenteditatble
|
|
35
|
-
// the cursor appears at the right most point of the parent container.
|
|
36
|
-
// In Firefox, when the selection is placed between adjacent nodes which are not contenteditatble
|
|
37
|
-
// no cursor is presented to users.
|
|
38
|
-
// In Safari, when the selection is placed between adjacent nodes which are not contenteditatble
|
|
39
|
-
// it is not possible to navigate with arrow keys.
|
|
40
|
-
// This plugin works around the issues by inserting decorations between
|
|
41
|
-
// inline nodes which are set as contenteditable, and have a zero width space.
|
|
42
|
-
plugins.push({
|
|
43
|
-
name: 'inlineCursorTargetPlugin',
|
|
44
|
-
plugin: function plugin() {
|
|
45
|
-
return options && options.allowInlineCursorTarget ? inlineCursorTargetPlugin() : undefined;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
plugins.push({
|
|
49
|
-
name: 'newlinePreserveMarksPlugin',
|
|
50
|
-
plugin: newlinePreserveMarksPlugin
|
|
51
|
-
}, {
|
|
52
|
-
name: 'frozenEditor',
|
|
53
|
-
plugin: function plugin(_ref2) {
|
|
54
|
-
var _options$inputTrackin;
|
|
55
|
-
var dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
|
|
56
|
-
return options !== null && options !== void 0 && (_options$inputTrackin = options.inputTracking) !== null && _options$inputTrackin !== void 0 && _options$inputTrackin.enabled || options !== null && options !== void 0 && options.ufo ? frozenEditor(dispatchAnalyticsEvent, options.inputTracking, options.browserFreezeTracking, options.ufo) : undefined;
|
|
57
|
-
}
|
|
58
|
-
}, {
|
|
59
|
-
name: 'history',
|
|
60
|
-
plugin: function plugin() {
|
|
61
|
-
return history();
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
// should be last :(
|
|
65
|
-
{
|
|
66
|
-
name: 'codeBlockIndent',
|
|
67
|
-
plugin: function plugin() {
|
|
68
|
-
return keymap(_objectSpread(_objectSpread({}, baseKeymap), {}, {
|
|
69
|
-
'Mod-[': function Mod() {
|
|
70
|
-
return true;
|
|
71
|
-
},
|
|
72
|
-
'Mod-]': function Mod() {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
}, {
|
|
78
|
-
name: 'contextIdentifier',
|
|
79
|
-
plugin: function plugin(_ref3) {
|
|
80
|
-
var dispatch = _ref3.dispatch,
|
|
81
|
-
providerFactory = _ref3.providerFactory;
|
|
82
|
-
return contextIdentifierPlugin(dispatch, providerFactory);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
if (options && options.allowScrollGutter) {
|
|
86
|
-
plugins.push({
|
|
87
|
-
name: 'scrollGutterPlugin',
|
|
88
|
-
plugin: function plugin() {
|
|
89
|
-
return scrollGutter(options.allowScrollGutter);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
if (isChromeWithSelectionBug && !getBooleanFF('platform.editor.disable-chrome-88-selection-fix_uk53m')) {
|
|
94
|
-
plugins.push({
|
|
95
|
-
name: 'fixChrome88SelectionPlugin',
|
|
96
|
-
plugin: function plugin() {
|
|
97
|
-
return fixChrome88SelectionPlugin();
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
plugins.push({
|
|
102
|
-
name: 'disableSpellcheckingPlugin',
|
|
103
|
-
plugin: function plugin() {
|
|
104
|
-
return disableSpellcheckingPlugin(featureFlags);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
return plugins;
|
|
108
|
-
},
|
|
109
|
-
nodes: function nodes() {
|
|
110
|
-
return [{
|
|
111
|
-
name: 'doc',
|
|
112
|
-
node: doc
|
|
113
|
-
}, {
|
|
114
|
-
name: 'paragraph',
|
|
115
|
-
node: paragraph
|
|
116
|
-
}, {
|
|
117
|
-
name: 'text',
|
|
118
|
-
node: text
|
|
119
|
-
}];
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
export default basePlugin;
|
|
1
|
+
import basePlugin from './plugin';
|
|
2
|
+
export { basePlugin };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { baseKeymap } from '@atlaskit/editor-prosemirror/commands';
|
|
5
|
+
import { history } from '@atlaskit/editor-prosemirror/history';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { browser } from '@atlaskit/editor-common/utils';
|
|
8
|
+
import { doc, paragraph, text } from '@atlaskit/adf-schema';
|
|
9
|
+
import filterStepsPlugin from './pm-plugins/filter-steps';
|
|
10
|
+
import fixChrome88SelectionPlugin from './pm-plugins/fix-chrome-88-selection';
|
|
11
|
+
import disableSpellcheckingPlugin from './pm-plugins/disable-spell-checking';
|
|
12
|
+
import contextIdentifierPlugin, { getContextIdentifier } from './pm-plugins/context-identifier';
|
|
13
|
+
import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
|
|
14
|
+
import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
|
|
15
|
+
import scrollGutter from './pm-plugins/scroll-gutter';
|
|
16
|
+
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
17
|
+
import frozenEditor from './pm-plugins/frozen-editor';
|
|
18
|
+
// Chrome >= 88
|
|
19
|
+
export var isChromeWithSelectionBug = browser.chrome && browser.chrome_version >= 88;
|
|
20
|
+
var basePlugin = function basePlugin(options, api) {
|
|
21
|
+
var _api$dependencies, _api$dependencies$fea;
|
|
22
|
+
var featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
|
|
23
|
+
return {
|
|
24
|
+
name: 'base',
|
|
25
|
+
getSharedState: function getSharedState(editorState) {
|
|
26
|
+
return {
|
|
27
|
+
contextIdentifier: getContextIdentifier(editorState)
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
pmPlugins: function pmPlugins() {
|
|
31
|
+
var plugins = [{
|
|
32
|
+
name: 'filterStepsPlugin',
|
|
33
|
+
plugin: function plugin(_ref) {
|
|
34
|
+
var dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
|
|
35
|
+
return filterStepsPlugin(dispatchAnalyticsEvent);
|
|
36
|
+
}
|
|
37
|
+
}];
|
|
38
|
+
|
|
39
|
+
// In Chrome, when the selection is placed between adjacent nodes which are not contenteditatble
|
|
40
|
+
// the cursor appears at the right most point of the parent container.
|
|
41
|
+
// In Firefox, when the selection is placed between adjacent nodes which are not contenteditatble
|
|
42
|
+
// no cursor is presented to users.
|
|
43
|
+
// In Safari, when the selection is placed between adjacent nodes which are not contenteditatble
|
|
44
|
+
// it is not possible to navigate with arrow keys.
|
|
45
|
+
// This plugin works around the issues by inserting decorations between
|
|
46
|
+
// inline nodes which are set as contenteditable, and have a zero width space.
|
|
47
|
+
plugins.push({
|
|
48
|
+
name: 'inlineCursorTargetPlugin',
|
|
49
|
+
plugin: function plugin() {
|
|
50
|
+
return options && options.allowInlineCursorTarget ? inlineCursorTargetPlugin() : undefined;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
plugins.push({
|
|
54
|
+
name: 'newlinePreserveMarksPlugin',
|
|
55
|
+
plugin: newlinePreserveMarksPlugin
|
|
56
|
+
}, {
|
|
57
|
+
name: 'frozenEditor',
|
|
58
|
+
plugin: function plugin(_ref2) {
|
|
59
|
+
var _options$inputTrackin;
|
|
60
|
+
var dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
|
|
61
|
+
return options !== null && options !== void 0 && (_options$inputTrackin = options.inputTracking) !== null && _options$inputTrackin !== void 0 && _options$inputTrackin.enabled || options !== null && options !== void 0 && options.ufo ? frozenEditor(dispatchAnalyticsEvent, options.inputTracking, options.browserFreezeTracking, options.ufo) : undefined;
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
name: 'history',
|
|
65
|
+
plugin: function plugin() {
|
|
66
|
+
return history();
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
// should be last :(
|
|
70
|
+
{
|
|
71
|
+
name: 'codeBlockIndent',
|
|
72
|
+
plugin: function plugin() {
|
|
73
|
+
return keymap(_objectSpread(_objectSpread({}, baseKeymap), {}, {
|
|
74
|
+
'Mod-[': function Mod() {
|
|
75
|
+
return true;
|
|
76
|
+
},
|
|
77
|
+
'Mod-]': function Mod() {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
name: 'contextIdentifier',
|
|
84
|
+
plugin: function plugin(_ref3) {
|
|
85
|
+
var dispatch = _ref3.dispatch,
|
|
86
|
+
providerFactory = _ref3.providerFactory;
|
|
87
|
+
return contextIdentifierPlugin(dispatch, providerFactory);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
if (options && options.allowScrollGutter) {
|
|
91
|
+
plugins.push({
|
|
92
|
+
name: 'scrollGutterPlugin',
|
|
93
|
+
plugin: function plugin() {
|
|
94
|
+
return scrollGutter(options.allowScrollGutter);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (isChromeWithSelectionBug && !getBooleanFF('platform.editor.disable-chrome-88-selection-fix_uk53m')) {
|
|
99
|
+
plugins.push({
|
|
100
|
+
name: 'fixChrome88SelectionPlugin',
|
|
101
|
+
plugin: function plugin() {
|
|
102
|
+
return fixChrome88SelectionPlugin();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
plugins.push({
|
|
107
|
+
name: 'disableSpellcheckingPlugin',
|
|
108
|
+
plugin: function plugin() {
|
|
109
|
+
return disableSpellcheckingPlugin(featureFlags);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return plugins;
|
|
113
|
+
},
|
|
114
|
+
nodes: function nodes() {
|
|
115
|
+
return [{
|
|
116
|
+
name: 'doc',
|
|
117
|
+
node: doc
|
|
118
|
+
}, {
|
|
119
|
+
name: 'paragraph',
|
|
120
|
+
node: paragraph
|
|
121
|
+
}, {
|
|
122
|
+
name: 'text',
|
|
123
|
+
node: text
|
|
124
|
+
}];
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
export default basePlugin;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { isEmptyDocument } from '@atlaskit/editor-common/utils';
|
|
2
|
+
import { GUTTER_SELECTOR, GUTTER_SIZE_IN_PX, isEmptyDocument } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { getMobileDimensionsPluginState } from '../../mobile-dimensions/utils';
|
|
4
|
-
export var GUTTER_SIZE_IN_PX = 120; // Default gutter size
|
|
5
|
-
export var GUTTER_SIZE_MOBILE_IN_PX = 36; // Gutter size for Mobile
|
|
6
|
-
export var GUTTER_SELECTOR = '#editor-scroll-gutter';
|
|
7
4
|
var MIN_TAP_SIZE_IN_PX = 40;
|
|
8
5
|
function supportsIntersectionObserver() {
|
|
9
6
|
if (typeof window !== 'undefined' && 'IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { basePlugin } from './base';
|
|
2
2
|
export { default as blockTypePlugin } from './block-type';
|
|
3
3
|
export { pluginKey as blockPluginStateKey } from './block-type';
|
|
4
4
|
export { default as betterTypeHistoryPlugin } from './better-type-history';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,6 +7,11 @@ import { listMessages as messages } from '@atlaskit/editor-common/messages';
|
|
|
7
7
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '../analytics';
|
|
8
8
|
import { toggleBulletList, toggleOrderedList, tooltip } from '../../keymaps';
|
|
9
9
|
import { IconList, IconListNumber } from '@atlaskit/editor-common/quick-insert';
|
|
10
|
+
import { isInsideListItem } from './utils/selection';
|
|
11
|
+
import { indentList, outdentList, toggleBulletList as toggleBulletListCommand, toggleOrderedList as toggleOrderedListCommand } from './commands';
|
|
12
|
+
import { findRootParentListNode } from './utils/find';
|
|
13
|
+
import { pluginKey as listPluginKey } from './pm-plugins/main';
|
|
14
|
+
|
|
10
15
|
/*
|
|
11
16
|
Toolbar buttons to bullet and ordered list can be found in
|
|
12
17
|
packages/editor/editor-core/src/plugins/toolbar-lists-indentation/ui/Toolbar.tsx
|
|
@@ -17,6 +22,20 @@ var listPlugin = function listPlugin(options, api) {
|
|
|
17
22
|
var editorAnalyticsAPI = 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;
|
|
18
23
|
return {
|
|
19
24
|
name: 'list',
|
|
25
|
+
actions: {
|
|
26
|
+
indentList: indentList(editorAnalyticsAPI),
|
|
27
|
+
outdentList: outdentList(editorAnalyticsAPI),
|
|
28
|
+
toggleOrderedList: toggleOrderedListCommand(editorAnalyticsAPI),
|
|
29
|
+
toggleBulletList: toggleBulletListCommand(editorAnalyticsAPI),
|
|
30
|
+
isInsideListItem: isInsideListItem,
|
|
31
|
+
findRootParentListNode: findRootParentListNode
|
|
32
|
+
},
|
|
33
|
+
getSharedState: function getSharedState(editorState) {
|
|
34
|
+
if (!editorState) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
return listPluginKey.getState(editorState);
|
|
38
|
+
},
|
|
20
39
|
nodes: function nodes() {
|
|
21
40
|
return [{
|
|
22
41
|
name: 'bulletList',
|
|
@@ -36,7 +36,7 @@ export function findFirstParentListItemNode($pos) {
|
|
|
36
36
|
pos: listItemNodePosition.pos
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
export function findRootParentListNode($pos) {
|
|
39
|
+
export var findRootParentListNode = function findRootParentListNode($pos) {
|
|
40
40
|
var doc = $pos.doc;
|
|
41
41
|
if ($pos.pos + 1 > doc.content.size) {
|
|
42
42
|
return null;
|
|
@@ -56,4 +56,4 @@ export function findRootParentListNode($pos) {
|
|
|
56
56
|
}
|
|
57
57
|
var listNodePosition = doc.resolve(parentList.pos);
|
|
58
58
|
return findRootParentListNode(listNodePosition);
|
|
59
|
-
}
|
|
59
|
+
};
|
|
@@ -23,7 +23,6 @@ import { linkifyContent, isListItemNode, isListNode, canLinkBeCreatedInRange } f
|
|
|
23
23
|
import { insertSliceForLists } from './edge-cases';
|
|
24
24
|
import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from './commands';
|
|
25
25
|
import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
|
|
26
|
-
import { doesSelectionWhichStartsOrEndsInListContainEntireList } from '../../utils/lists';
|
|
27
26
|
import { anyMarkActive } from '@atlaskit/editor-common/mark';
|
|
28
27
|
// remove text attribute from mention for copy/paste (GDPR)
|
|
29
28
|
export function handleMention(slice, schema) {
|
|
@@ -224,7 +223,30 @@ export function handlePasteNonNestableBlockNodesIntoList(slice) {
|
|
|
224
223
|
return false;
|
|
225
224
|
};
|
|
226
225
|
}
|
|
227
|
-
export function
|
|
226
|
+
export var doesSelectionWhichStartsOrEndsInListContainEntireList = function doesSelectionWhichStartsOrEndsInListContainEntireList(selection, findRootParentListNode) {
|
|
227
|
+
var $from = selection.$from,
|
|
228
|
+
$to = selection.$to,
|
|
229
|
+
from = selection.from,
|
|
230
|
+
to = selection.to;
|
|
231
|
+
var selectionParentListItemNodeResolvedPos = findRootParentListNode ? findRootParentListNode($from) || findRootParentListNode($to) : null;
|
|
232
|
+
var selectionParentListNode = selectionParentListItemNodeResolvedPos === null || selectionParentListItemNodeResolvedPos === void 0 ? void 0 : selectionParentListItemNodeResolvedPos.parent;
|
|
233
|
+
if (!selectionParentListItemNodeResolvedPos || !selectionParentListNode) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
var startOfEntireList = $from.pos < $to.pos ? selectionParentListItemNodeResolvedPos.pos + $from.depth - 1 : selectionParentListItemNodeResolvedPos.pos + $to.depth - 1;
|
|
237
|
+
var endOfEntireList = $from.pos < $to.pos ? selectionParentListItemNodeResolvedPos.pos + selectionParentListNode.nodeSize - $to.depth - 1 : selectionParentListItemNodeResolvedPos.pos + selectionParentListNode.nodeSize - $from.depth - 1;
|
|
238
|
+
if (!startOfEntireList || !endOfEntireList) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
if (from < to) {
|
|
242
|
+
return startOfEntireList >= $from.pos && endOfEntireList <= $to.pos;
|
|
243
|
+
} else if (from > to) {
|
|
244
|
+
return startOfEntireList >= $to.pos && endOfEntireList <= $from.pos;
|
|
245
|
+
} else {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
export function handlePastePanelOrDecisionContentIntoList(slice, findRootParentListNode) {
|
|
228
250
|
return function (state, dispatch) {
|
|
229
251
|
var schema = state.schema,
|
|
230
252
|
tr = state.tr;
|
|
@@ -233,7 +255,7 @@ export function handlePastePanelOrDecisionContentIntoList(slice) {
|
|
|
233
255
|
var blockNode = slice.content.firstChild;
|
|
234
256
|
var isSliceWholeNode = slice.openStart === 0 && slice.openEnd === 0;
|
|
235
257
|
var selectionParentListItemNode = selection.$to.node(selection.$to.depth - 1);
|
|
236
|
-
var sliceIsWholeNodeButShouldNotReplaceSelection = isSliceWholeNode && !doesSelectionWhichStartsOrEndsInListContainEntireList(selection);
|
|
258
|
+
var sliceIsWholeNodeButShouldNotReplaceSelection = isSliceWholeNode && !doesSelectionWhichStartsOrEndsInListContainEntireList(selection, findRootParentListNode);
|
|
237
259
|
if (!selectionParentListItemNode || (selectionParentListItemNode === null || selectionParentListItemNode === void 0 ? void 0 : selectionParentListItemNode.type) !== schema.nodes.listItem || !blockNode || !['panel', 'decisionList'].includes(blockNode === null || blockNode === void 0 ? void 0 : blockNode.type.name) || slice.content.childCount > 1 || (blockNode === null || blockNode === void 0 ? void 0 : blockNode.content.firstChild) === undefined || sliceIsWholeNodeButShouldNotReplaceSelection) {
|
|
238
260
|
return false;
|
|
239
261
|
}
|
|
@@ -283,10 +283,10 @@ function injectAnalyticsPayloadBeforeCommand(createPayloadByTransaction) {
|
|
|
283
283
|
};
|
|
284
284
|
};
|
|
285
285
|
}
|
|
286
|
-
export var handlePastePanelOrDecisionIntoListWithAnalytics = function handlePastePanelOrDecisionIntoListWithAnalytics(view, event, slice) {
|
|
286
|
+
export var handlePastePanelOrDecisionIntoListWithAnalytics = function handlePastePanelOrDecisionIntoListWithAnalytics(view, event, slice, findRootParentListNode) {
|
|
287
287
|
return injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
288
288
|
type: PasteTypes.richText
|
|
289
|
-
}))(handlePastePanelOrDecisionContentIntoList(slice));
|
|
289
|
+
}))(handlePastePanelOrDecisionContentIntoList(slice, findRootParentListNode));
|
|
290
290
|
};
|
|
291
291
|
export var handlePasteNonNestableBlockNodesIntoListWithAnalytics = function handlePasteNonNestableBlockNodesIntoListWithAnalytics(view, event, slice) {
|
|
292
292
|
return injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
@@ -299,7 +299,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
299
299
|
|
|
300
300
|
// finally, handle rich-text copy-paste
|
|
301
301
|
if (isRichText) {
|
|
302
|
-
var _pluginInjectionApi$d6, _pluginInjectionApi$d7;
|
|
302
|
+
var _pluginInjectionApi$d6, _pluginInjectionApi$d7, _pluginInjectionApi$d8;
|
|
303
303
|
// linkify the text where possible
|
|
304
304
|
slice = linkifyContent(state.schema)(slice);
|
|
305
305
|
if (handlePasteLinkOnSelectedTextWithAnalytics(view, event, slice, PasteTypes.richText)(state, dispatch)) {
|
|
@@ -364,7 +364,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
364
364
|
if (handlePasteIntoCaptionWithAnalytics(view, event, slice, PasteTypes.richText)(state, dispatch)) {
|
|
365
365
|
return true;
|
|
366
366
|
}
|
|
367
|
-
if (handlePastePanelOrDecisionIntoListWithAnalytics(view, event, slice)(state, dispatch)) {
|
|
367
|
+
if (handlePastePanelOrDecisionIntoListWithAnalytics(view, event, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d8 = pluginInjectionApi.dependencies.list) === null || _pluginInjectionApi$d8 === void 0 ? void 0 : _pluginInjectionApi$d8.actions.findRootParentListNode)(state, dispatch)) {
|
|
368
368
|
return true;
|
|
369
369
|
}
|
|
370
370
|
if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && handlePasteNonNestableBlockNodesIntoListWithAnalytics(view, event, slice)(state, dispatch)) {
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
3
|
import ToolbarListsIndentation from './ui';
|
|
3
|
-
import WithPluginState from '../../ui/WithPluginState';
|
|
4
4
|
import { ToolbarSize } from '../../ui/Toolbar/types';
|
|
5
|
-
import {
|
|
6
|
-
import { pluginKey as
|
|
5
|
+
import { createPlugin as indentationButtonsPlugin } from './pm-plugins/indentation-buttons';
|
|
6
|
+
import { pluginKey as indentationButtonPluginKey } from './pm-plugins/indentation-buttons';
|
|
7
7
|
var toolbarListsIndentationPlugin = function toolbarListsIndentationPlugin(_ref, api) {
|
|
8
|
-
var _api$dependencies$
|
|
8
|
+
var _api$dependencies$fea;
|
|
9
9
|
var showIndentationButtons = _ref.showIndentationButtons,
|
|
10
10
|
allowHeadingAndParagraphIndentation = _ref.allowHeadingAndParagraphIndentation;
|
|
11
|
-
var featureFlags = (api === null || api === void 0 ? void 0 : api.dependencies.featureFlags.sharedState.currentState()) || {};
|
|
12
|
-
var editorAnalyticsAPI = 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;
|
|
11
|
+
var featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies$fea = api.dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
|
|
13
12
|
return {
|
|
14
13
|
name: 'toolbarListsIndentation',
|
|
14
|
+
getSharedState: function getSharedState(editorState) {
|
|
15
|
+
if (!editorState) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return indentationButtonPluginKey.getState(editorState);
|
|
19
|
+
},
|
|
15
20
|
pmPlugins: function pmPlugins() {
|
|
16
21
|
return [{
|
|
17
22
|
name: 'indentationButtons',
|
|
@@ -20,7 +25,8 @@ var toolbarListsIndentationPlugin = function toolbarListsIndentationPlugin(_ref,
|
|
|
20
25
|
return indentationButtonsPlugin({
|
|
21
26
|
dispatch: dispatch,
|
|
22
27
|
showIndentationButtons: showIndentationButtons,
|
|
23
|
-
allowHeadingAndParagraphIndentation: allowHeadingAndParagraphIndentation
|
|
28
|
+
allowHeadingAndParagraphIndentation: allowHeadingAndParagraphIndentation,
|
|
29
|
+
api: api
|
|
24
30
|
});
|
|
25
31
|
}
|
|
26
32
|
}];
|
|
@@ -34,38 +40,55 @@ var toolbarListsIndentationPlugin = function toolbarListsIndentationPlugin(_ref,
|
|
|
34
40
|
disabled = _ref3.disabled,
|
|
35
41
|
isToolbarReducedSpacing = _ref3.isToolbarReducedSpacing;
|
|
36
42
|
var isSmall = toolbarSize < ToolbarSize.L;
|
|
37
|
-
return /*#__PURE__*/React.createElement(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return /*#__PURE__*/React.createElement(ToolbarListsIndentation, {
|
|
49
|
-
featureFlags: featureFlags,
|
|
50
|
-
isSmall: isSmall,
|
|
51
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
52
|
-
disabled: disabled,
|
|
53
|
-
editorView: editorView,
|
|
54
|
-
popupsMountPoint: popupsMountPoint,
|
|
55
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
56
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
57
|
-
bulletListActive: listState.bulletListActive,
|
|
58
|
-
bulletListDisabled: listState.bulletListDisabled,
|
|
59
|
-
orderedListActive: listState.orderedListActive,
|
|
60
|
-
orderedListDisabled: listState.orderedListDisabled,
|
|
61
|
-
showIndentationButtons: !!showIndentationButtons,
|
|
62
|
-
indentDisabled: indentationState.indentDisabled,
|
|
63
|
-
outdentDisabled: indentationState.outdentDisabled,
|
|
64
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
65
|
-
});
|
|
66
|
-
}
|
|
43
|
+
return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
|
|
44
|
+
featureFlags: featureFlags,
|
|
45
|
+
popupsMountPoint: popupsMountPoint,
|
|
46
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
47
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
48
|
+
isSmall: isSmall,
|
|
49
|
+
isToolbarReducedSpacing: isToolbarReducedSpacing,
|
|
50
|
+
disabled: disabled,
|
|
51
|
+
editorView: editorView,
|
|
52
|
+
showIndentationButtons: showIndentationButtons,
|
|
53
|
+
pluginInjectionApi: api
|
|
67
54
|
});
|
|
68
55
|
}
|
|
69
56
|
};
|
|
70
57
|
};
|
|
58
|
+
function PrimaryToolbarComponent(_ref4) {
|
|
59
|
+
var featureFlags = _ref4.featureFlags,
|
|
60
|
+
popupsMountPoint = _ref4.popupsMountPoint,
|
|
61
|
+
popupsBoundariesElement = _ref4.popupsBoundariesElement,
|
|
62
|
+
popupsScrollableElement = _ref4.popupsScrollableElement,
|
|
63
|
+
isSmall = _ref4.isSmall,
|
|
64
|
+
isToolbarReducedSpacing = _ref4.isToolbarReducedSpacing,
|
|
65
|
+
disabled = _ref4.disabled,
|
|
66
|
+
editorView = _ref4.editorView,
|
|
67
|
+
showIndentationButtons = _ref4.showIndentationButtons,
|
|
68
|
+
pluginInjectionApi = _ref4.pluginInjectionApi;
|
|
69
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['list', 'toolbarListsIndentation']),
|
|
70
|
+
listState = _useSharedPluginState.listState,
|
|
71
|
+
toolbarListsIndentationState = _useSharedPluginState.toolbarListsIndentationState;
|
|
72
|
+
if (!listState) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return /*#__PURE__*/React.createElement(ToolbarListsIndentation, {
|
|
76
|
+
featureFlags: featureFlags,
|
|
77
|
+
isSmall: isSmall,
|
|
78
|
+
isReducedSpacing: isToolbarReducedSpacing,
|
|
79
|
+
disabled: disabled,
|
|
80
|
+
editorView: editorView,
|
|
81
|
+
popupsMountPoint: popupsMountPoint,
|
|
82
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
83
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
84
|
+
bulletListActive: listState.bulletListActive,
|
|
85
|
+
bulletListDisabled: listState.bulletListDisabled,
|
|
86
|
+
orderedListActive: listState.orderedListActive,
|
|
87
|
+
orderedListDisabled: listState.orderedListDisabled,
|
|
88
|
+
showIndentationButtons: !!showIndentationButtons,
|
|
89
|
+
indentDisabled: toolbarListsIndentationState.indentDisabled,
|
|
90
|
+
outdentDisabled: toolbarListsIndentationState.outdentDisabled,
|
|
91
|
+
pluginInjectionApi: pluginInjectionApi
|
|
92
|
+
});
|
|
93
|
+
}
|
|
71
94
|
export default toolbarListsIndentationPlugin;
|
|
@@ -2,12 +2,11 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
2
2
|
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import { shallowEqual } from '@atlaskit/editor-common/utils';
|
|
5
|
-
import { isInsideListItem } from '../../list/utils/selection';
|
|
6
5
|
import { getCurrentIndentLevel as getTaskListIndentLevel, getTaskItemIndex, isInsideTask } from '../../tasks-and-decisions/pm-plugins/helpers';
|
|
7
6
|
import { isIndentationAllowed, MAX_INDENTATION_LEVEL } from '../../indentation/commands';
|
|
8
7
|
import { getListItemAttributes } from '@atlaskit/editor-common/lists';
|
|
9
8
|
export var pluginKey = new PluginKey('indentationButtonsPlugin');
|
|
10
|
-
function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndentation) {
|
|
9
|
+
function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndentation, api) {
|
|
11
10
|
var state = {
|
|
12
11
|
indentDisabled: true,
|
|
13
12
|
outdentDisabled: true,
|
|
@@ -20,7 +19,7 @@ function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndenta
|
|
|
20
19
|
// not use the indentation mark.
|
|
21
20
|
// Check for lists before paragraphs and headings in case
|
|
22
21
|
// the selection is in a list nested in a layout column.
|
|
23
|
-
if (isInsideListItem(editorState)) {
|
|
22
|
+
if (api !== null && api !== void 0 && api.dependencies.list.actions.isInsideListItem(editorState)) {
|
|
24
23
|
var _getListItemAttribute = getListItemAttributes(selection.$head),
|
|
25
24
|
indentLevel = _getListItemAttribute.indentLevel,
|
|
26
25
|
itemIndex = _getListItemAttribute.itemIndex;
|
|
@@ -69,7 +68,8 @@ function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndenta
|
|
|
69
68
|
export var createPlugin = function createPlugin(_ref) {
|
|
70
69
|
var dispatch = _ref.dispatch,
|
|
71
70
|
showIndentationButtons = _ref.showIndentationButtons,
|
|
72
|
-
allowHeadingAndParagraphIndentation = _ref.allowHeadingAndParagraphIndentation
|
|
71
|
+
allowHeadingAndParagraphIndentation = _ref.allowHeadingAndParagraphIndentation,
|
|
72
|
+
api = _ref.api;
|
|
73
73
|
return new SafePlugin({
|
|
74
74
|
state: {
|
|
75
75
|
init: function init(_config, state) {
|
|
@@ -78,11 +78,11 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
78
78
|
outdentDisabled: true,
|
|
79
79
|
node: null
|
|
80
80
|
};
|
|
81
|
-
return showIndentationButtons ? getIndentationButtonsState(state, allowHeadingAndParagraphIndentation) : initialState;
|
|
81
|
+
return showIndentationButtons ? getIndentationButtonsState(state, allowHeadingAndParagraphIndentation, api) : initialState;
|
|
82
82
|
},
|
|
83
83
|
apply: function apply(_tr, pluginState, _oldState, newState) {
|
|
84
84
|
if (showIndentationButtons) {
|
|
85
|
-
var state = getIndentationButtonsState(newState, allowHeadingAndParagraphIndentation);
|
|
85
|
+
var state = getIndentationButtonsState(newState, allowHeadingAndParagraphIndentation, api);
|
|
86
86
|
if (!shallowEqual(pluginState, state)) {
|
|
87
87
|
dispatch(pluginKey, state);
|
|
88
88
|
return state;
|