@atlaskit/editor-core 190.1.6 → 190.1.8
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 +13 -0
- package/afm-cc/tsconfig.json +3 -0
- package/dist/cjs/plugins/index.js +0 -28
- package/dist/cjs/presets/universal.js +2 -16
- package/dist/cjs/ui/Addon/ClickAreaInline/index.js +1 -1
- package/dist/cjs/ui/AppearanceComponents/Mobile.js +3 -0
- package/dist/cjs/utils/action.js +0 -28
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -4
- package/dist/es2019/presets/universal.js +2 -16
- package/dist/es2019/ui/Addon/ClickAreaInline/index.js +1 -1
- package/dist/es2019/ui/AppearanceComponents/Mobile.js +4 -0
- package/dist/es2019/utils/action.js +0 -28
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -4
- package/dist/esm/presets/universal.js +2 -16
- package/dist/esm/ui/Addon/ClickAreaInline/index.js +1 -1
- package/dist/esm/ui/AppearanceComponents/Mobile.js +4 -0
- package/dist/esm/utils/action.js +0 -28
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -4
- package/dist/types/utils/action.d.ts +0 -6
- package/dist/types-ts4.5/plugins/index.d.ts +0 -4
- package/dist/types-ts4.5/utils/action.d.ts +0 -6
- package/package.json +2 -1
- package/dist/cjs/commands/index.js +0 -42
- package/dist/cjs/plugins/alignment/commands/index.js +0 -36
- package/dist/cjs/plugins/alignment/index.js +0 -70
- package/dist/cjs/plugins/alignment/pm-plugins/keymap.js +0 -14
- package/dist/cjs/plugins/alignment/pm-plugins/main.js +0 -45
- package/dist/cjs/plugins/alignment/pm-plugins/types.js +0 -5
- package/dist/cjs/plugins/alignment/ui/ToolbarAlignment/icon-map.js +0 -36
- package/dist/cjs/plugins/alignment/ui/ToolbarAlignment/index.js +0 -169
- package/dist/cjs/plugins/alignment/ui/ToolbarAlignment/messages.js +0 -29
- package/dist/cjs/plugins/alignment/ui/ToolbarAlignment/styles.js +0 -13
- package/dist/cjs/plugins/alignment/utils/index.js +0 -27
- package/dist/cjs/plugins/mobile-dimensions/actions.js +0 -12
- package/dist/cjs/plugins/mobile-dimensions/commands.js +0 -26
- package/dist/cjs/plugins/mobile-dimensions/index.js +0 -99
- package/dist/cjs/plugins/mobile-dimensions/plugin-factory.js +0 -15
- package/dist/cjs/plugins/mobile-dimensions/reducer.js +0 -28
- package/dist/cjs/plugins/mobile-dimensions/types.js +0 -5
- package/dist/cjs/plugins/mobile-selection/content-in-selection.js +0 -24
- package/dist/cjs/plugins/mobile-selection/index.js +0 -18
- package/dist/cjs/plugins/mobile-selection/mobile-selection-plugin.js +0 -59
- package/dist/cjs/plugins/mobile-selection/types.js +0 -5
- package/dist/cjs/plugins/view-update-subscription/index.js +0 -90
- package/dist/cjs/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +0 -109
- package/dist/cjs/ui/Alignment/AlignmentButton/index.js +0 -71
- package/dist/cjs/ui/Alignment/index.js +0 -74
- package/dist/cjs/ui/Alignment/styles.js +0 -11
- package/dist/es2019/commands/index.js +0 -1
- package/dist/es2019/plugins/alignment/commands/index.js +0 -30
- package/dist/es2019/plugins/alignment/index.js +0 -58
- package/dist/es2019/plugins/alignment/pm-plugins/keymap.js +0 -8
- package/dist/es2019/plugins/alignment/pm-plugins/main.js +0 -34
- package/dist/es2019/plugins/alignment/pm-plugins/types.js +0 -1
- package/dist/es2019/plugins/alignment/ui/ToolbarAlignment/icon-map.js +0 -30
- package/dist/es2019/plugins/alignment/ui/ToolbarAlignment/index.js +0 -140
- package/dist/es2019/plugins/alignment/ui/ToolbarAlignment/messages.js +0 -23
- package/dist/es2019/plugins/alignment/ui/ToolbarAlignment/styles.js +0 -14
- package/dist/es2019/plugins/alignment/utils/index.js +0 -15
- package/dist/es2019/plugins/mobile-dimensions/actions.js +0 -6
- package/dist/es2019/plugins/mobile-dimensions/commands.js +0 -14
- package/dist/es2019/plugins/mobile-dimensions/index.js +0 -88
- package/dist/es2019/plugins/mobile-dimensions/plugin-factory.js +0 -9
- package/dist/es2019/plugins/mobile-dimensions/reducer.js +0 -21
- package/dist/es2019/plugins/mobile-dimensions/types.js +0 -1
- package/dist/es2019/plugins/mobile-selection/content-in-selection.js +0 -17
- package/dist/es2019/plugins/mobile-selection/index.js +0 -1
- package/dist/es2019/plugins/mobile-selection/mobile-selection-plugin.js +0 -53
- package/dist/es2019/plugins/mobile-selection/types.js +0 -1
- package/dist/es2019/plugins/view-update-subscription/index.js +0 -73
- package/dist/es2019/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +0 -106
- package/dist/es2019/ui/Alignment/AlignmentButton/index.js +0 -44
- package/dist/es2019/ui/Alignment/index.js +0 -54
- package/dist/es2019/ui/Alignment/styles.js +0 -7
- package/dist/esm/commands/index.js +0 -1
- package/dist/esm/plugins/alignment/commands/index.js +0 -30
- package/dist/esm/plugins/alignment/index.js +0 -63
- package/dist/esm/plugins/alignment/pm-plugins/keymap.js +0 -8
- package/dist/esm/plugins/alignment/pm-plugins/main.js +0 -36
- package/dist/esm/plugins/alignment/pm-plugins/types.js +0 -1
- package/dist/esm/plugins/alignment/ui/ToolbarAlignment/icon-map.js +0 -29
- package/dist/esm/plugins/alignment/ui/ToolbarAlignment/index.js +0 -163
- package/dist/esm/plugins/alignment/ui/ToolbarAlignment/messages.js +0 -23
- package/dist/esm/plugins/alignment/ui/ToolbarAlignment/styles.js +0 -6
- package/dist/esm/plugins/alignment/utils/index.js +0 -21
- package/dist/esm/plugins/mobile-dimensions/actions.js +0 -6
- package/dist/esm/plugins/mobile-dimensions/commands.js +0 -20
- package/dist/esm/plugins/mobile-dimensions/index.js +0 -93
- package/dist/esm/plugins/mobile-dimensions/plugin-factory.js +0 -9
- package/dist/esm/plugins/mobile-dimensions/reducer.js +0 -21
- package/dist/esm/plugins/mobile-dimensions/types.js +0 -1
- package/dist/esm/plugins/mobile-selection/content-in-selection.js +0 -18
- package/dist/esm/plugins/mobile-selection/index.js +0 -1
- package/dist/esm/plugins/mobile-selection/mobile-selection-plugin.js +0 -53
- package/dist/esm/plugins/mobile-selection/types.js +0 -1
- package/dist/esm/plugins/view-update-subscription/index.js +0 -83
- package/dist/esm/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +0 -103
- package/dist/esm/ui/Alignment/AlignmentButton/index.js +0 -62
- package/dist/esm/ui/Alignment/index.js +0 -68
- package/dist/esm/ui/Alignment/styles.js +0 -4
- package/dist/types/commands/index.d.ts +0 -1
- package/dist/types/plugins/alignment/commands/index.d.ts +0 -4
- package/dist/types/plugins/alignment/index.d.ts +0 -5
- package/dist/types/plugins/alignment/pm-plugins/keymap.d.ts +0 -2
- package/dist/types/plugins/alignment/pm-plugins/main.d.ts +0 -8
- package/dist/types/plugins/alignment/pm-plugins/types.d.ts +0 -5
- package/dist/types/plugins/alignment/ui/ToolbarAlignment/icon-map.d.ts +0 -6
- package/dist/types/plugins/alignment/ui/ToolbarAlignment/index.d.ts +0 -33
- package/dist/types/plugins/alignment/ui/ToolbarAlignment/messages.d.ts +0 -22
- package/dist/types/plugins/alignment/ui/ToolbarAlignment/styles.d.ts +0 -3
- package/dist/types/plugins/alignment/utils/index.d.ts +0 -3
- package/dist/types/plugins/mobile-dimensions/actions.d.ts +0 -18
- package/dist/types/plugins/mobile-dimensions/commands.d.ts +0 -3
- package/dist/types/plugins/mobile-dimensions/index.d.ts +0 -7
- package/dist/types/plugins/mobile-dimensions/plugin-factory.d.ts +0 -5
- package/dist/types/plugins/mobile-dimensions/reducer.d.ts +0 -3
- package/dist/types/plugins/mobile-dimensions/types.d.ts +0 -8
- package/dist/types/plugins/mobile-selection/content-in-selection.d.ts +0 -5
- package/dist/types/plugins/mobile-selection/index.d.ts +0 -2
- package/dist/types/plugins/mobile-selection/mobile-selection-plugin.d.ts +0 -7
- package/dist/types/plugins/mobile-selection/types.d.ts +0 -32
- package/dist/types/plugins/view-update-subscription/index.d.ts +0 -19
- package/dist/types/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +0 -12
- package/dist/types/ui/Alignment/AlignmentButton/index.d.ts +0 -17
- package/dist/types/ui/Alignment/index.d.ts +0 -12
- package/dist/types/ui/Alignment/styles.d.ts +0 -1
- package/dist/types-ts4.5/commands/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/alignment/commands/index.d.ts +0 -4
- package/dist/types-ts4.5/plugins/alignment/index.d.ts +0 -5
- package/dist/types-ts4.5/plugins/alignment/pm-plugins/keymap.d.ts +0 -2
- package/dist/types-ts4.5/plugins/alignment/pm-plugins/main.d.ts +0 -8
- package/dist/types-ts4.5/plugins/alignment/pm-plugins/types.d.ts +0 -5
- package/dist/types-ts4.5/plugins/alignment/ui/ToolbarAlignment/icon-map.d.ts +0 -6
- package/dist/types-ts4.5/plugins/alignment/ui/ToolbarAlignment/index.d.ts +0 -33
- package/dist/types-ts4.5/plugins/alignment/ui/ToolbarAlignment/messages.d.ts +0 -22
- package/dist/types-ts4.5/plugins/alignment/ui/ToolbarAlignment/styles.d.ts +0 -3
- package/dist/types-ts4.5/plugins/alignment/utils/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/mobile-dimensions/actions.d.ts +0 -18
- package/dist/types-ts4.5/plugins/mobile-dimensions/commands.d.ts +0 -3
- package/dist/types-ts4.5/plugins/mobile-dimensions/index.d.ts +0 -7
- package/dist/types-ts4.5/plugins/mobile-dimensions/plugin-factory.d.ts +0 -5
- package/dist/types-ts4.5/plugins/mobile-dimensions/reducer.d.ts +0 -3
- package/dist/types-ts4.5/plugins/mobile-dimensions/types.d.ts +0 -8
- package/dist/types-ts4.5/plugins/mobile-selection/content-in-selection.d.ts +0 -5
- package/dist/types-ts4.5/plugins/mobile-selection/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/mobile-selection/mobile-selection-plugin.d.ts +0 -7
- package/dist/types-ts4.5/plugins/mobile-selection/types.d.ts +0 -32
- package/dist/types-ts4.5/plugins/view-update-subscription/index.d.ts +0 -19
- package/dist/types-ts4.5/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.d.ts +0 -12
- package/dist/types-ts4.5/ui/Alignment/AlignmentButton/index.d.ts +0 -17
- package/dist/types-ts4.5/ui/Alignment/index.d.ts +0 -12
- package/dist/types-ts4.5/ui/Alignment/styles.d.ts +0 -1
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.selectionPluginKey = exports.mobileSelectionPlugin = exports.createProseMirrorPlugin = void 0;
|
|
7
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
|
-
var _contentInSelection2 = require("./content-in-selection");
|
|
11
|
-
var selectionPluginKey = exports.selectionPluginKey = new _state.PluginKey('mobile-selection');
|
|
12
|
-
var createProseMirrorPlugin = exports.createProseMirrorPlugin = function createProseMirrorPlugin(dispatch) {
|
|
13
|
-
return new _safePlugin.SafePlugin({
|
|
14
|
-
view: function view(editorView) {
|
|
15
|
-
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
16
|
-
return {
|
|
17
|
-
update: function update(view, previousState) {
|
|
18
|
-
var state = view.state,
|
|
19
|
-
_view$state = view.state,
|
|
20
|
-
selection = _view$state.selection,
|
|
21
|
-
doc = _view$state.doc;
|
|
22
|
-
if (previousState.doc.eq(doc) && previousState.selection.eq(selection)) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
var ref = (0, _utils.findDomRefAtPos)(selection.$anchor.pos, domAtPos);
|
|
26
|
-
var _ref$getBoundingClien = ref.getBoundingClientRect(),
|
|
27
|
-
top = _ref$getBoundingClien.top,
|
|
28
|
-
left = _ref$getBoundingClien.left;
|
|
29
|
-
var _contentInSelection = (0, _contentInSelection2.contentInSelection)(state),
|
|
30
|
-
nodeTypes = _contentInSelection.nodeTypes,
|
|
31
|
-
markTypes = _contentInSelection.markTypes;
|
|
32
|
-
dispatch(selectionPluginKey, {
|
|
33
|
-
rect: {
|
|
34
|
-
top: Math.round(top),
|
|
35
|
-
left: Math.round(left)
|
|
36
|
-
},
|
|
37
|
-
selection: state.selection.toJSON(),
|
|
38
|
-
nodeTypes: nodeTypes,
|
|
39
|
-
markTypes: markTypes
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
var mobileSelectionPlugin = exports.mobileSelectionPlugin = function mobileSelectionPlugin() {
|
|
47
|
-
return {
|
|
48
|
-
name: 'mobileSelection',
|
|
49
|
-
pmPlugins: function pmPlugins() {
|
|
50
|
-
return [{
|
|
51
|
-
name: 'mobileSelection',
|
|
52
|
-
plugin: function plugin(_ref) {
|
|
53
|
-
var dispatch = _ref.dispatch;
|
|
54
|
-
return createProseMirrorPlugin(dispatch);
|
|
55
|
-
}
|
|
56
|
-
}];
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.trackerStore = exports.default = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
13
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
|
-
var trackerStore = exports.trackerStore = new WeakMap();
|
|
15
|
-
var Tracker = /*#__PURE__*/(0, _createClass2.default)(function Tracker() {
|
|
16
|
-
var _this = this;
|
|
17
|
-
(0, _classCallCheck2.default)(this, Tracker);
|
|
18
|
-
(0, _defineProperty2.default)(this, "update", function (props) {
|
|
19
|
-
_this.subscriptions.forEach(function (cb) {
|
|
20
|
-
return cb(props);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
(0, _defineProperty2.default)(this, "add", function (subscription) {
|
|
24
|
-
_this.subscriptions.push(subscription);
|
|
25
|
-
});
|
|
26
|
-
(0, _defineProperty2.default)(this, "remove", function (subscription) {
|
|
27
|
-
_this.subscriptions = _this.subscriptions.filter(function (s) {
|
|
28
|
-
return s !== subscription;
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
this.subscriptions = [];
|
|
32
|
-
});
|
|
33
|
-
var pluginKey = new _state.PluginKey('viewUpdateSubscriptionKey');
|
|
34
|
-
var createViewUpdateSubscriptionPlugin = function createViewUpdateSubscriptionPlugin() {
|
|
35
|
-
var tracker;
|
|
36
|
-
var lastUpdateRef = {
|
|
37
|
-
current: null,
|
|
38
|
-
initial: null,
|
|
39
|
-
transactions: [],
|
|
40
|
-
queued: false
|
|
41
|
-
};
|
|
42
|
-
return {
|
|
43
|
-
name: 'viewUpdateSubscription',
|
|
44
|
-
pmPlugins: function pmPlugins() {
|
|
45
|
-
var createPlugin = function createPlugin() {
|
|
46
|
-
return new _safePlugin.SafePlugin({
|
|
47
|
-
key: pluginKey,
|
|
48
|
-
view: function view(editorView) {
|
|
49
|
-
tracker = trackerStore.get(editorView);
|
|
50
|
-
if (!tracker) {
|
|
51
|
-
tracker = new Tracker();
|
|
52
|
-
trackerStore.set(editorView, tracker);
|
|
53
|
-
}
|
|
54
|
-
return {};
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
return [{
|
|
59
|
-
name: 'viewUpdateSubscription',
|
|
60
|
-
plugin: createPlugin
|
|
61
|
-
}];
|
|
62
|
-
},
|
|
63
|
-
onEditorViewStateUpdated: function onEditorViewStateUpdated(props) {
|
|
64
|
-
var _lastUpdateRef$transa;
|
|
65
|
-
lastUpdateRef.current = props;
|
|
66
|
-
(_lastUpdateRef$transa = lastUpdateRef.transactions).push.apply(_lastUpdateRef$transa, (0, _toConsumableArray2.default)(props.transactions));
|
|
67
|
-
if (!lastUpdateRef.queued) {
|
|
68
|
-
lastUpdateRef.initial = props;
|
|
69
|
-
lastUpdateRef.queued = true;
|
|
70
|
-
queueMicrotask(function () {
|
|
71
|
-
if (!lastUpdateRef.current || !lastUpdateRef.initial) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
if (tracker) {
|
|
75
|
-
var _lastUpdateRef$initia;
|
|
76
|
-
tracker.update({
|
|
77
|
-
newEditorState: lastUpdateRef.current.newEditorState,
|
|
78
|
-
oldEditorState: (_lastUpdateRef$initia = lastUpdateRef.initial) === null || _lastUpdateRef$initia === void 0 ? void 0 : _lastUpdateRef$initia.oldEditorState,
|
|
79
|
-
transactions: lastUpdateRef.transactions
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
lastUpdateRef.queued = false;
|
|
83
|
-
lastUpdateRef.current = null;
|
|
84
|
-
lastUpdateRef.transactions = [];
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
var _default = exports.default = createViewUpdateSubscriptionPlugin;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.subscribeToToolbarAndPickerUpdates = void 0;
|
|
7
|
-
var _floatingToolbar = require("@atlaskit/editor-common/floating-toolbar");
|
|
8
|
-
var _ = require("..");
|
|
9
|
-
var areToolbarsSame = function areToolbarsSame(left, right) {
|
|
10
|
-
if (!left && !right) {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
if (left && !right || !left && right) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
var leftConfig = left.config;
|
|
17
|
-
var rightConfig = right.config;
|
|
18
|
-
if (!leftConfig && !rightConfig) {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
if (!leftConfig && rightConfig || leftConfig && !rightConfig) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
var leftItems = Array.isArray(leftConfig.items) ? leftConfig.items : leftConfig.items(left.node);
|
|
25
|
-
var rightItems = Array.isArray(rightConfig.items) ? rightConfig.items : rightConfig.items(right.node);
|
|
26
|
-
return (0, _floatingToolbar.areSameItems)(leftItems, rightItems);
|
|
27
|
-
};
|
|
28
|
-
var subscribeToToolbarAndPickerUpdates = exports.subscribeToToolbarAndPickerUpdates = function subscribeToToolbarAndPickerUpdates(editorView, cb) {
|
|
29
|
-
var lastUpdatedState = null;
|
|
30
|
-
var subscription = function subscription(_ref) {
|
|
31
|
-
var newEditorState = _ref.newEditorState;
|
|
32
|
-
// Creating fake plugin keys for these plugins for the mean time until all these plugins are extracted.
|
|
33
|
-
var typeAheadPluginKey = {
|
|
34
|
-
key: 'typeAheadPlugin$',
|
|
35
|
-
getState: function getState(state) {
|
|
36
|
-
return state['typeAheadPlugin$'];
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
var datePluginKey = {
|
|
40
|
-
key: 'datePlugin$',
|
|
41
|
-
getState: function getState(state) {
|
|
42
|
-
return state['datePlugin$'];
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var statusPluginKey = {
|
|
46
|
-
key: 'statusPlugin$',
|
|
47
|
-
getState: function getState(state) {
|
|
48
|
-
return state['statusPlugin$'];
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
var floatingToolbarPluginKey = {
|
|
52
|
-
key: 'floatingToolbarPluginKey$',
|
|
53
|
-
getState: function getState(state) {
|
|
54
|
-
return state['floatingToolbarPluginKey$'];
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
var isTypeAheadOpen = function isTypeAheadOpen(editorState) {
|
|
58
|
-
var _typeAheadState$decor;
|
|
59
|
-
var typeAheadState = typeAheadPluginKey.getState(newEditorState);
|
|
60
|
-
return !!((_typeAheadState$decor = typeAheadState.decorationSet) !== null && _typeAheadState$decor !== void 0 && _typeAheadState$decor.find().length);
|
|
61
|
-
};
|
|
62
|
-
// TypeAhead has priority in the mobile-bridge
|
|
63
|
-
// In case it is open we don't need to send
|
|
64
|
-
// any toolbar updates don't need to be send
|
|
65
|
-
if (isTypeAheadOpen(newEditorState)) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
var dateState = datePluginKey.getState(newEditorState);
|
|
69
|
-
var statusState = statusPluginKey.getState(newEditorState);
|
|
70
|
-
var _ref2 = floatingToolbarPluginKey.getState(newEditorState),
|
|
71
|
-
getConfigWithNodeInfo = _ref2.getConfigWithNodeInfo;
|
|
72
|
-
var toolbarConfig = getConfigWithNodeInfo(newEditorState);
|
|
73
|
-
var shouldCallback = false;
|
|
74
|
-
if (lastUpdatedState) {
|
|
75
|
-
var oldDateState = datePluginKey.getState(lastUpdatedState);
|
|
76
|
-
var oldStatusState = statusPluginKey.getState(lastUpdatedState);
|
|
77
|
-
var _ref3 = floatingToolbarPluginKey.getState(lastUpdatedState),
|
|
78
|
-
getOldConfigWithNodeInfo = _ref3.getConfigWithNodeInfo;
|
|
79
|
-
var oldToolbarConfig = getOldConfigWithNodeInfo(lastUpdatedState);
|
|
80
|
-
var isToolbarEqual = areToolbarsSame(toolbarConfig, oldToolbarConfig);
|
|
81
|
-
if (dateState !== oldDateState || statusState !== oldStatusState ||
|
|
82
|
-
// Sometimes the toolbar changes while a picker is open, we dont care about this
|
|
83
|
-
// EG A nested status or date node in a table
|
|
84
|
-
!isToolbarEqual && !(statusState !== null && statusState !== void 0 && statusState.showStatusPickerAt) && !(dateState !== null && dateState !== void 0 && dateState.showDatePickerAt)) {
|
|
85
|
-
shouldCallback = true;
|
|
86
|
-
}
|
|
87
|
-
} else {
|
|
88
|
-
shouldCallback = true;
|
|
89
|
-
}
|
|
90
|
-
if (shouldCallback) {
|
|
91
|
-
cb({
|
|
92
|
-
dateState: dateState,
|
|
93
|
-
statusState: statusState,
|
|
94
|
-
toolbarConfig: toolbarConfig
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
lastUpdatedState = newEditorState;
|
|
98
|
-
};
|
|
99
|
-
var tracker = _.trackerStore.get(editorView);
|
|
100
|
-
if (tracker) {
|
|
101
|
-
tracker.add(subscription);
|
|
102
|
-
}
|
|
103
|
-
return function () {
|
|
104
|
-
var tracker = _.trackerStore.get(editorView);
|
|
105
|
-
if (tracker) {
|
|
106
|
-
tracker.remove(subscription);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
var _ToolbarButton = _interopRequireDefault(require("../../ToolbarButton"));
|
|
18
|
-
var _keymaps = require("../../../keymaps");
|
|
19
|
-
var _keymaps2 = require("@atlaskit/editor-common/keymaps");
|
|
20
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
-
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); }; }
|
|
23
|
-
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; } }
|
|
24
|
-
var AlignmentButton = /*#__PURE__*/function (_PureComponent) {
|
|
25
|
-
(0, _inherits2.default)(AlignmentButton, _PureComponent);
|
|
26
|
-
var _super = _createSuper(AlignmentButton);
|
|
27
|
-
function AlignmentButton() {
|
|
28
|
-
var _this;
|
|
29
|
-
(0, _classCallCheck2.default)(this, AlignmentButton);
|
|
30
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
31
|
-
args[_key] = arguments[_key];
|
|
32
|
-
}
|
|
33
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClick", function (e) {
|
|
35
|
-
var _this$props = _this.props,
|
|
36
|
-
onClick = _this$props.onClick,
|
|
37
|
-
value = _this$props.value;
|
|
38
|
-
|
|
39
|
-
// detect if the click event comes from keyboard where screenX and screenY are 0
|
|
40
|
-
var isMouseEvent = e instanceof MouseEvent;
|
|
41
|
-
e.preventDefault();
|
|
42
|
-
onClick(value, isMouseEvent);
|
|
43
|
-
});
|
|
44
|
-
return _this;
|
|
45
|
-
}
|
|
46
|
-
(0, _createClass2.default)(AlignmentButton, [{
|
|
47
|
-
key: "render",
|
|
48
|
-
value: function render() {
|
|
49
|
-
var _this$props2 = this.props,
|
|
50
|
-
label = _this$props2.label,
|
|
51
|
-
isSelected = _this$props2.isSelected,
|
|
52
|
-
content = _this$props2.content,
|
|
53
|
-
shortcut = _this$props2.shortcut;
|
|
54
|
-
return /*#__PURE__*/_react.default.createElement(_ToolbarButton.default, {
|
|
55
|
-
disabled: false,
|
|
56
|
-
selected: isSelected,
|
|
57
|
-
title: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
|
|
58
|
-
description: label,
|
|
59
|
-
keymap: shortcut
|
|
60
|
-
}),
|
|
61
|
-
"aria-label": shortcut ? (0, _keymaps.tooltip)(shortcut, label) : label,
|
|
62
|
-
"aria-pressed": isSelected,
|
|
63
|
-
"aria-keyshortcuts": (0, _keymaps2.getAriaKeyshortcuts)(shortcut),
|
|
64
|
-
onClick: this.onClick,
|
|
65
|
-
iconBefore: content
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}]);
|
|
69
|
-
return AlignmentButton;
|
|
70
|
-
}(_react.PureComponent);
|
|
71
|
-
var _default = exports.default = AlignmentButton;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
11
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
12
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
|
-
var _react = require("@emotion/react");
|
|
14
|
-
var _react2 = require("react");
|
|
15
|
-
var _reactIntlNext = require("react-intl-next");
|
|
16
|
-
var _iconMap = require("../../plugins/alignment/ui/ToolbarAlignment/icon-map");
|
|
17
|
-
var _AlignmentButton = _interopRequireDefault(require("./AlignmentButton"));
|
|
18
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
19
|
-
var _styles = require("./styles");
|
|
20
|
-
var _keymaps = require("../../keymaps");
|
|
21
|
-
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); }; }
|
|
22
|
-
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; } } /** @jsx jsx */
|
|
23
|
-
var alignmentOptions = [{
|
|
24
|
-
title: _messages.alignmentMessages.alignLeft,
|
|
25
|
-
shortcut: _keymaps.alignLeft,
|
|
26
|
-
value: 'start'
|
|
27
|
-
}, {
|
|
28
|
-
title: _messages.alignmentMessages.alignCenter,
|
|
29
|
-
value: 'center'
|
|
30
|
-
}, {
|
|
31
|
-
title: _messages.alignmentMessages.alignRight,
|
|
32
|
-
value: 'end'
|
|
33
|
-
}];
|
|
34
|
-
var Alignment = /*#__PURE__*/function (_PureComponent) {
|
|
35
|
-
(0, _inherits2.default)(Alignment, _PureComponent);
|
|
36
|
-
var _super = _createSuper(Alignment);
|
|
37
|
-
function Alignment() {
|
|
38
|
-
(0, _classCallCheck2.default)(this, Alignment);
|
|
39
|
-
return _super.apply(this, arguments);
|
|
40
|
-
}
|
|
41
|
-
(0, _createClass2.default)(Alignment, [{
|
|
42
|
-
key: "render",
|
|
43
|
-
value: function render() {
|
|
44
|
-
var _this$props = this.props,
|
|
45
|
-
onClick = _this$props.onClick,
|
|
46
|
-
selectedAlignment = _this$props.selectedAlignment,
|
|
47
|
-
className = _this$props.className,
|
|
48
|
-
intl = _this$props.intl;
|
|
49
|
-
return (0, _react.jsx)("div", {
|
|
50
|
-
"data-testid": "alignment-buttons",
|
|
51
|
-
css: _styles.alignmentWrapper,
|
|
52
|
-
className: className
|
|
53
|
-
}, alignmentOptions.map(function (alignment) {
|
|
54
|
-
var value = alignment.value,
|
|
55
|
-
title = alignment.title,
|
|
56
|
-
shortcut = alignment.shortcut;
|
|
57
|
-
var message = intl.formatMessage(title);
|
|
58
|
-
return (0, _react.jsx)(_AlignmentButton.default, {
|
|
59
|
-
content: (0, _react.jsx)(_iconMap.IconMap, {
|
|
60
|
-
alignment: value
|
|
61
|
-
}),
|
|
62
|
-
key: value,
|
|
63
|
-
value: value,
|
|
64
|
-
label: message,
|
|
65
|
-
shortcut: shortcut,
|
|
66
|
-
onClick: onClick,
|
|
67
|
-
isSelected: value === selectedAlignment
|
|
68
|
-
});
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
}]);
|
|
72
|
-
return Alignment;
|
|
73
|
-
}(_react2.PureComponent);
|
|
74
|
-
var _default = exports.default = (0, _reactIntlNext.injectIntl)(Alignment);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.alignmentWrapper = void 0;
|
|
8
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
-
var _react = require("@emotion/react");
|
|
10
|
-
var _templateObject;
|
|
11
|
-
var alignmentWrapper = exports.alignmentWrapper = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n padding: 0 ", ";\n display: flex;\n flex-wrap: wrap;\n max-width: ", "px;\n"])), "var(--ds-space-100, 8px)", 3 * 32);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { addParagraphAtEnd, createParagraphAtEnd, changeImageAlignment, createToggleBlockMarkOnRange, toggleBlockMark, clearEditorContent } from '@atlaskit/editor-common/commands';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { toggleBlockMark, changeImageAlignment } from '../../../commands';
|
|
2
|
-
import { cascadeCommands } from '../../../utils/action';
|
|
3
|
-
export const isAlignable = align => (state, dispatch) => {
|
|
4
|
-
const {
|
|
5
|
-
nodes: {
|
|
6
|
-
paragraph,
|
|
7
|
-
heading
|
|
8
|
-
},
|
|
9
|
-
marks: {
|
|
10
|
-
alignment
|
|
11
|
-
}
|
|
12
|
-
} = state.schema;
|
|
13
|
-
return toggleBlockMark(alignment, () => !align ? undefined : align === 'start' ? false : {
|
|
14
|
-
align
|
|
15
|
-
}, [paragraph, heading])(state, dispatch);
|
|
16
|
-
};
|
|
17
|
-
export const changeAlignment = align => (state, dispatch) => {
|
|
18
|
-
const {
|
|
19
|
-
nodes: {
|
|
20
|
-
paragraph,
|
|
21
|
-
heading
|
|
22
|
-
},
|
|
23
|
-
marks: {
|
|
24
|
-
alignment
|
|
25
|
-
}
|
|
26
|
-
} = state.schema;
|
|
27
|
-
return cascadeCommands([changeImageAlignment(align), toggleBlockMark(alignment, () => !align ? undefined : align === 'start' ? false : {
|
|
28
|
-
align
|
|
29
|
-
}, [paragraph, heading])])(state, dispatch);
|
|
30
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { alignment } from '@atlaskit/adf-schema';
|
|
3
|
-
import WithPluginState from '../../ui/WithPluginState';
|
|
4
|
-
import { pluginKey, createPlugin } from './pm-plugins/main';
|
|
5
|
-
import { changeAlignment } from './commands';
|
|
6
|
-
import ToolbarAlignment from './ui/ToolbarAlignment';
|
|
7
|
-
import { keymapPlugin } from './pm-plugins/keymap';
|
|
8
|
-
export const defaultConfig = {
|
|
9
|
-
align: 'start'
|
|
10
|
-
};
|
|
11
|
-
const alignmentPlugin = () => ({
|
|
12
|
-
name: 'alignment',
|
|
13
|
-
marks() {
|
|
14
|
-
return [{
|
|
15
|
-
name: 'alignment',
|
|
16
|
-
mark: alignment
|
|
17
|
-
}];
|
|
18
|
-
},
|
|
19
|
-
pmPlugins() {
|
|
20
|
-
return [{
|
|
21
|
-
name: 'alignmentPlugin',
|
|
22
|
-
plugin: ({
|
|
23
|
-
dispatch
|
|
24
|
-
}) => createPlugin(dispatch, defaultConfig)
|
|
25
|
-
}, {
|
|
26
|
-
name: 'annotationKeymap',
|
|
27
|
-
plugin: () => keymapPlugin()
|
|
28
|
-
}];
|
|
29
|
-
},
|
|
30
|
-
primaryToolbarComponent({
|
|
31
|
-
editorView,
|
|
32
|
-
popupsMountPoint,
|
|
33
|
-
popupsBoundariesElement,
|
|
34
|
-
popupsScrollableElement,
|
|
35
|
-
disabled,
|
|
36
|
-
isToolbarReducedSpacing
|
|
37
|
-
}) {
|
|
38
|
-
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
39
|
-
plugins: {
|
|
40
|
-
align: pluginKey
|
|
41
|
-
},
|
|
42
|
-
render: ({
|
|
43
|
-
align
|
|
44
|
-
}) => {
|
|
45
|
-
return /*#__PURE__*/React.createElement(ToolbarAlignment, {
|
|
46
|
-
pluginState: align,
|
|
47
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
48
|
-
changeAlignment: align => changeAlignment(align)(editorView.state, editorView.dispatch),
|
|
49
|
-
disabled: disabled || !align.isEnabled,
|
|
50
|
-
popupsMountPoint: popupsMountPoint,
|
|
51
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
52
|
-
popupsScrollableElement: popupsScrollableElement
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
export default alignmentPlugin;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
|
-
import { bindKeymapWithCommand, alignLeft } from '../../../keymaps';
|
|
3
|
-
import { changeAlignment } from '../commands';
|
|
4
|
-
export function keymapPlugin() {
|
|
5
|
-
const list = {};
|
|
6
|
-
bindKeymapWithCommand(alignLeft.common, changeAlignment('start'), list);
|
|
7
|
-
return keymap(list);
|
|
8
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { isAlignable } from '../commands';
|
|
4
|
-
import { getActiveAlignment } from '../utils';
|
|
5
|
-
export function createInitialPluginState(editorState, pluginConfig) {
|
|
6
|
-
return {
|
|
7
|
-
align: getActiveAlignment(editorState) || pluginConfig.align,
|
|
8
|
-
isEnabled: true
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export const pluginKey = new PluginKey('alignmentPlugin');
|
|
12
|
-
export function createPlugin(dispatch, pluginConfig) {
|
|
13
|
-
return new SafePlugin({
|
|
14
|
-
key: pluginKey,
|
|
15
|
-
state: {
|
|
16
|
-
init(_config, editorState) {
|
|
17
|
-
return createInitialPluginState(editorState, pluginConfig);
|
|
18
|
-
},
|
|
19
|
-
apply(_tr, state, _prevState, nextState) {
|
|
20
|
-
const nextPluginState = getActiveAlignment(nextState);
|
|
21
|
-
const isEnabled = isAlignable(nextPluginState)(nextState);
|
|
22
|
-
const newState = {
|
|
23
|
-
...state,
|
|
24
|
-
align: nextPluginState,
|
|
25
|
-
isEnabled
|
|
26
|
-
};
|
|
27
|
-
if (nextPluginState !== state.align || isEnabled !== state.isEnabled) {
|
|
28
|
-
dispatch(pluginKey, newState);
|
|
29
|
-
}
|
|
30
|
-
return newState;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import EditorAlignLeftIcon from '@atlaskit/icon/glyph/editor/align-left';
|
|
2
|
-
import EditorAlignRightIcon from '@atlaskit/icon/glyph/editor/align-right';
|
|
3
|
-
import EditorAlignCenterIcon from '@atlaskit/icon/glyph/editor/align-center';
|
|
4
|
-
import { useIntl } from 'react-intl-next';
|
|
5
|
-
import { messages } from './messages';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
const iconAndMessageMap = {
|
|
8
|
-
start: {
|
|
9
|
-
Component: EditorAlignLeftIcon,
|
|
10
|
-
label: messages.alignLeft
|
|
11
|
-
},
|
|
12
|
-
end: {
|
|
13
|
-
Component: EditorAlignRightIcon,
|
|
14
|
-
label: messages.alignRight
|
|
15
|
-
},
|
|
16
|
-
center: {
|
|
17
|
-
Component: EditorAlignCenterIcon,
|
|
18
|
-
label: messages.alignCenter
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
export const IconMap = props => {
|
|
22
|
-
const {
|
|
23
|
-
Component,
|
|
24
|
-
label
|
|
25
|
-
} = iconAndMessageMap[props.alignment];
|
|
26
|
-
const intl = useIntl();
|
|
27
|
-
return /*#__PURE__*/React.createElement(Component, {
|
|
28
|
-
label: intl.formatMessage(label)
|
|
29
|
-
});
|
|
30
|
-
};
|