@atlaskit/editor-core 189.1.11 → 189.1.12
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 +7 -0
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/presets/universal.js +2 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/presets/universal.js +2 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/presets/universal.js +2 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/insert-block/types.d.ts +1 -1
- package/dist/types/types/editor-props.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +1 -1
- package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
- package/package.json +2 -1
- package/report.api.md +1 -10
- package/tmp/api-report-tmp.d.ts +1 -10
- package/dist/cjs/plugins/layout/actions.js +0 -345
- package/dist/cjs/plugins/layout/index.js +0 -91
- package/dist/cjs/plugins/layout/pm-plugins/main.js +0 -148
- package/dist/cjs/plugins/layout/pm-plugins/plugin-key.js +0 -8
- package/dist/cjs/plugins/layout/pm-plugins/types.js +0 -5
- package/dist/cjs/plugins/layout/toolbar-messages.js +0 -39
- package/dist/cjs/plugins/layout/toolbar.js +0 -116
- package/dist/cjs/plugins/layout/types.js +0 -5
- package/dist/es2019/plugins/layout/actions.js +0 -328
- package/dist/es2019/plugins/layout/index.js +0 -75
- package/dist/es2019/plugins/layout/pm-plugins/main.js +0 -142
- package/dist/es2019/plugins/layout/pm-plugins/plugin-key.js +0 -2
- package/dist/es2019/plugins/layout/pm-plugins/types.js +0 -1
- package/dist/es2019/plugins/layout/toolbar-messages.js +0 -33
- package/dist/es2019/plugins/layout/toolbar.js +0 -101
- package/dist/es2019/plugins/layout/types.js +0 -1
- package/dist/esm/plugins/layout/actions.js +0 -336
- package/dist/esm/plugins/layout/index.js +0 -79
- package/dist/esm/plugins/layout/pm-plugins/main.js +0 -141
- package/dist/esm/plugins/layout/pm-plugins/plugin-key.js +0 -2
- package/dist/esm/plugins/layout/pm-plugins/types.js +0 -1
- package/dist/esm/plugins/layout/toolbar-messages.js +0 -33
- package/dist/esm/plugins/layout/toolbar.js +0 -109
- package/dist/esm/plugins/layout/types.js +0 -1
- package/dist/types/plugins/layout/actions.d.ts +0 -22
- package/dist/types/plugins/layout/index.d.ts +0 -15
- package/dist/types/plugins/layout/pm-plugins/main.d.ts +0 -6
- package/dist/types/plugins/layout/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types/plugins/layout/pm-plugins/types.d.ts +0 -14
- package/dist/types/plugins/layout/toolbar-messages.d.ts +0 -32
- package/dist/types/plugins/layout/toolbar.d.ts +0 -6
- package/dist/types/plugins/layout/types.d.ts +0 -13
- package/dist/types-ts4.5/plugins/layout/actions.d.ts +0 -22
- package/dist/types-ts4.5/plugins/layout/index.d.ts +0 -18
- package/dist/types-ts4.5/plugins/layout/pm-plugins/main.d.ts +0 -6
- package/dist/types-ts4.5/plugins/layout/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/layout/pm-plugins/types.d.ts +0 -14
- package/dist/types-ts4.5/plugins/layout/toolbar-messages.d.ts +0 -32
- package/dist/types-ts4.5/plugins/layout/toolbar.d.ts +0 -6
- package/dist/types-ts4.5/plugins/layout/types.d.ts +0 -13
|
@@ -1,91 +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.layoutPlugin = void 0;
|
|
8
|
-
Object.defineProperty(exports, "pluginKey", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function get() {
|
|
11
|
-
return _pluginKey.pluginKey;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
var _react = _interopRequireDefault(require("react"));
|
|
15
|
-
var _adfSchema = require("@atlaskit/adf-schema");
|
|
16
|
-
var _main = _interopRequireDefault(require("./pm-plugins/main"));
|
|
17
|
-
var _toolbar = require("./toolbar");
|
|
18
|
-
var _actions = require("./actions");
|
|
19
|
-
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
20
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
21
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
22
|
-
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
23
|
-
var layoutPlugin = exports.layoutPlugin = function layoutPlugin(_ref) {
|
|
24
|
-
var _api$analytics;
|
|
25
|
-
var _ref$config = _ref.config,
|
|
26
|
-
options = _ref$config === void 0 ? {} : _ref$config,
|
|
27
|
-
api = _ref.api;
|
|
28
|
-
return {
|
|
29
|
-
name: 'layout',
|
|
30
|
-
nodes: function nodes() {
|
|
31
|
-
return [{
|
|
32
|
-
name: 'layoutSection',
|
|
33
|
-
node: _adfSchema.layoutSection
|
|
34
|
-
}, {
|
|
35
|
-
name: 'layoutColumn',
|
|
36
|
-
node: _adfSchema.layoutColumn
|
|
37
|
-
}];
|
|
38
|
-
},
|
|
39
|
-
pmPlugins: function pmPlugins() {
|
|
40
|
-
return [{
|
|
41
|
-
name: 'layout',
|
|
42
|
-
plugin: function plugin() {
|
|
43
|
-
return (0, _main.default)(options);
|
|
44
|
-
}
|
|
45
|
-
}];
|
|
46
|
-
},
|
|
47
|
-
actions: {
|
|
48
|
-
insertLayoutColumns: (0, _actions.insertLayoutColumnsWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
|
|
49
|
-
},
|
|
50
|
-
pluginsOptions: {
|
|
51
|
-
floatingToolbar: function floatingToolbar(state, intl) {
|
|
52
|
-
var _ref2 = _pluginKey.pluginKey.getState(state),
|
|
53
|
-
pos = _ref2.pos,
|
|
54
|
-
allowBreakout = _ref2.allowBreakout,
|
|
55
|
-
addSidebarLayouts = _ref2.addSidebarLayouts,
|
|
56
|
-
allowSingleColumnLayout = _ref2.allowSingleColumnLayout;
|
|
57
|
-
if (pos !== null) {
|
|
58
|
-
return (0, _toolbar.buildToolbar)(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api);
|
|
59
|
-
}
|
|
60
|
-
return undefined;
|
|
61
|
-
},
|
|
62
|
-
quickInsert: function quickInsert(_ref3) {
|
|
63
|
-
var formatMessage = _ref3.formatMessage;
|
|
64
|
-
return [{
|
|
65
|
-
id: 'layout',
|
|
66
|
-
title: formatMessage(_messages.toolbarInsertBlockMessages.columns),
|
|
67
|
-
description: formatMessage(_messages.toolbarInsertBlockMessages.columnsDescription),
|
|
68
|
-
keywords: ['column', 'section'],
|
|
69
|
-
priority: 1100,
|
|
70
|
-
icon: function icon() {
|
|
71
|
-
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconLayout, null);
|
|
72
|
-
},
|
|
73
|
-
action: function action(insert, state) {
|
|
74
|
-
var _api$analytics2;
|
|
75
|
-
var tr = insert((0, _actions.createDefaultLayoutSection)(state));
|
|
76
|
-
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.attachAnalyticsEvent({
|
|
77
|
-
action: _analytics.ACTION.INSERTED,
|
|
78
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
79
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.LAYOUT,
|
|
80
|
-
attributes: {
|
|
81
|
-
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
|
|
82
|
-
},
|
|
83
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
84
|
-
})(tr);
|
|
85
|
-
return tr;
|
|
86
|
-
}
|
|
87
|
-
}];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
};
|
|
@@ -1,148 +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 = exports.DEFAULT_LAYOUT = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
-
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
12
|
-
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
13
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
14
|
-
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
15
|
-
var _selection = require("@atlaskit/editor-common/selection");
|
|
16
|
-
var _actions = require("../actions");
|
|
17
|
-
var _pluginKey = require("./plugin-key");
|
|
18
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
|
-
var DEFAULT_LAYOUT = exports.DEFAULT_LAYOUT = 'two_equal';
|
|
21
|
-
var isWholeSelectionInsideLayoutColumn = function isWholeSelectionInsideLayoutColumn(state) {
|
|
22
|
-
// Since findParentNodeOfType doesn't check if selection.to shares the parent, we do this check ourselves
|
|
23
|
-
var fromParent = (0, _utils.findParentNodeOfType)(state.schema.nodes.layoutColumn)(state.selection);
|
|
24
|
-
if (fromParent) {
|
|
25
|
-
var isToPosInsideSameLayoutColumn = state.selection.from < fromParent.pos + fromParent.node.nodeSize;
|
|
26
|
-
return isToPosInsideSameLayoutColumn;
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
};
|
|
30
|
-
var moveCursorToNextColumn = function moveCursorToNextColumn(state, dispatch) {
|
|
31
|
-
var selection = state.selection;
|
|
32
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
33
|
-
layoutColumn = _state$schema$nodes.layoutColumn,
|
|
34
|
-
layoutSection = _state$schema$nodes.layoutSection;
|
|
35
|
-
var section = (0, _utils.findParentNodeOfType)(layoutSection)(selection);
|
|
36
|
-
var column = (0, _utils.findParentNodeOfType)(layoutColumn)(selection);
|
|
37
|
-
if (column.node !== section.node.lastChild) {
|
|
38
|
-
var $nextColumn = state.doc.resolve(column.pos + column.node.nodeSize);
|
|
39
|
-
var shiftedSelection = _state.TextSelection.findFrom($nextColumn, 1);
|
|
40
|
-
if (dispatch) {
|
|
41
|
-
dispatch(state.tr.setSelection(shiftedSelection));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// TODO: Look at memoize-one-ing this fn
|
|
48
|
-
var getNodeDecoration = function getNodeDecoration(pos, node) {
|
|
49
|
-
return [_view.Decoration.node(pos, pos + node.nodeSize, {
|
|
50
|
-
class: 'selected'
|
|
51
|
-
})];
|
|
52
|
-
};
|
|
53
|
-
var getInitialPluginState = function getInitialPluginState(options, state) {
|
|
54
|
-
var maybeLayoutSection = (0, _utils.findParentNodeOfType)(state.schema.nodes.layoutSection)(state.selection);
|
|
55
|
-
var allowBreakout = options.allowBreakout || false;
|
|
56
|
-
var addSidebarLayouts = options.UNSAFE_addSidebarLayouts || false;
|
|
57
|
-
var allowSingleColumnLayout = options.UNSAFE_allowSingleColumnLayout || false;
|
|
58
|
-
var pos = maybeLayoutSection ? maybeLayoutSection.pos : null;
|
|
59
|
-
var selectedLayout = (0, _actions.getSelectedLayout)(maybeLayoutSection && maybeLayoutSection.node, DEFAULT_LAYOUT);
|
|
60
|
-
return {
|
|
61
|
-
pos: pos,
|
|
62
|
-
allowBreakout: allowBreakout,
|
|
63
|
-
addSidebarLayouts: addSidebarLayouts,
|
|
64
|
-
selectedLayout: selectedLayout,
|
|
65
|
-
allowSingleColumnLayout: allowSingleColumnLayout
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
var _default = exports.default = function _default(options) {
|
|
69
|
-
return new _safePlugin.SafePlugin({
|
|
70
|
-
key: _pluginKey.pluginKey,
|
|
71
|
-
state: {
|
|
72
|
-
init: function init(_, state) {
|
|
73
|
-
return getInitialPluginState(options, state);
|
|
74
|
-
},
|
|
75
|
-
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
76
|
-
if (tr.docChanged || tr.selectionSet) {
|
|
77
|
-
var layoutSection = newState.schema.nodes.layoutSection,
|
|
78
|
-
selection = newState.selection;
|
|
79
|
-
var maybeLayoutSection = (0, _utils.findParentNodeOfType)(layoutSection)(selection) || (0, _utils.findSelectedNodeOfType)([layoutSection])(selection);
|
|
80
|
-
var newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
81
|
-
pos: maybeLayoutSection ? maybeLayoutSection.pos : null,
|
|
82
|
-
selectedLayout: (0, _actions.getSelectedLayout)(maybeLayoutSection && maybeLayoutSection.node, pluginState.selectedLayout)
|
|
83
|
-
});
|
|
84
|
-
return newPluginState;
|
|
85
|
-
}
|
|
86
|
-
return pluginState;
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
props: {
|
|
90
|
-
decorations: function decorations(state) {
|
|
91
|
-
var layoutState = _pluginKey.pluginKey.getState(state);
|
|
92
|
-
if (layoutState.pos !== null) {
|
|
93
|
-
return _view.DecorationSet.create(state.doc, getNodeDecoration(layoutState.pos, state.doc.nodeAt(layoutState.pos)));
|
|
94
|
-
}
|
|
95
|
-
return undefined;
|
|
96
|
-
},
|
|
97
|
-
handleKeyDown: (0, _keymap.keydownHandler)({
|
|
98
|
-
Tab: (0, _utils2.filterCommand)(isWholeSelectionInsideLayoutColumn, moveCursorToNextColumn)
|
|
99
|
-
}),
|
|
100
|
-
handleClickOn: (0, _selection.createSelectionClickHandler)(['layoutColumn'], function (target) {
|
|
101
|
-
return target.hasAttribute('data-layout-section') || target.hasAttribute('data-layout-column');
|
|
102
|
-
}, {
|
|
103
|
-
useLongPressSelection: options.useLongPressSelection || false,
|
|
104
|
-
getNodeSelectionPos: function getNodeSelectionPos(state, nodePos) {
|
|
105
|
-
return state.doc.resolve(nodePos).before();
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
},
|
|
109
|
-
appendTransaction: function appendTransaction(transactions, _oldState, newState) {
|
|
110
|
-
var changes = [];
|
|
111
|
-
transactions.forEach(function (prevTr) {
|
|
112
|
-
// remap change segments across the transaction set
|
|
113
|
-
changes.forEach(function (change) {
|
|
114
|
-
return {
|
|
115
|
-
from: prevTr.mapping.map(change.from),
|
|
116
|
-
to: prevTr.mapping.map(change.to),
|
|
117
|
-
slice: change.slice
|
|
118
|
-
};
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// don't consider transactions that don't mutate
|
|
122
|
-
if (!prevTr.docChanged) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
var change = (0, _actions.fixColumnSizes)(prevTr, newState);
|
|
126
|
-
if (change) {
|
|
127
|
-
changes.push(change);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
if (changes.length) {
|
|
131
|
-
var tr = newState.tr;
|
|
132
|
-
var selection = newState.selection.toJSON();
|
|
133
|
-
changes.forEach(function (change) {
|
|
134
|
-
tr.replaceRange(change.from, change.to, change.slice);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// selecting and deleting across columns in 3 col layouts can remove
|
|
138
|
-
// a layoutColumn so we fix the structure here
|
|
139
|
-
tr = (0, _actions.fixColumnStructure)(newState) || tr;
|
|
140
|
-
if (tr.docChanged) {
|
|
141
|
-
tr.setSelection(_state.Selection.fromJSON(tr.doc, selection));
|
|
142
|
-
return tr;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.toolbarMessages = void 0;
|
|
7
|
-
var _reactIntlNext = require("react-intl-next");
|
|
8
|
-
var toolbarMessages = exports.toolbarMessages = (0, _reactIntlNext.defineMessages)({
|
|
9
|
-
singleColumn: {
|
|
10
|
-
id: 'fabric.editor.single',
|
|
11
|
-
defaultMessage: 'Single column',
|
|
12
|
-
description: 'Layout with one single column'
|
|
13
|
-
},
|
|
14
|
-
twoColumns: {
|
|
15
|
-
id: 'fabric.editor.twoColumns',
|
|
16
|
-
defaultMessage: 'Two columns',
|
|
17
|
-
description: 'Layout with two columns of equal width'
|
|
18
|
-
},
|
|
19
|
-
threeColumns: {
|
|
20
|
-
id: 'fabric.editor.threeColumns',
|
|
21
|
-
defaultMessage: 'Three columns',
|
|
22
|
-
description: 'Layout with three columns of equal width'
|
|
23
|
-
},
|
|
24
|
-
rightSidebar: {
|
|
25
|
-
id: 'fabric.editor.rightSidebar',
|
|
26
|
-
defaultMessage: 'Right sidebar',
|
|
27
|
-
description: 'Layout with two columns, left column is 2/3 and right is 1/3 of page'
|
|
28
|
-
},
|
|
29
|
-
leftSidebar: {
|
|
30
|
-
id: 'fabric.editor.leftSidebar',
|
|
31
|
-
defaultMessage: 'Left sidebar',
|
|
32
|
-
description: 'Layout with two columns, left column is 1/3 and right is 2/3 of page'
|
|
33
|
-
},
|
|
34
|
-
threeColumnsWithSidebars: {
|
|
35
|
-
id: 'fabric.editor.threeColumnsWithSidebars',
|
|
36
|
-
defaultMessage: 'Three columns with sidebars',
|
|
37
|
-
description: 'Layout with 3 columns laid out as 25% - 50% - 25%'
|
|
38
|
-
}
|
|
39
|
-
});
|
|
@@ -1,116 +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.layoutToolbarTitle = exports.buildToolbar = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
10
|
-
var _layoutSingle = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-single"));
|
|
11
|
-
var _layoutTwoEqual = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-two-equal"));
|
|
12
|
-
var _layoutThreeEqual = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-three-equal"));
|
|
13
|
-
var _layoutTwoLeftSidebar = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-two-left-sidebar"));
|
|
14
|
-
var _layoutTwoRightSidebar = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-two-right-sidebar"));
|
|
15
|
-
var _layoutThreeWithSidebars = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/layout-three-with-sidebars"));
|
|
16
|
-
var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
|
|
17
|
-
var _toolbarMessages = require("./toolbar-messages");
|
|
18
|
-
var _messages = _interopRequireDefault(require("@atlaskit/editor-common/messages"));
|
|
19
|
-
var _actions = require("./actions");
|
|
20
|
-
var LAYOUT_TYPES = [{
|
|
21
|
-
id: 'editor.layout.twoEquals',
|
|
22
|
-
type: 'two_equal',
|
|
23
|
-
title: _toolbarMessages.toolbarMessages.twoColumns,
|
|
24
|
-
icon: _layoutTwoEqual.default
|
|
25
|
-
}, {
|
|
26
|
-
id: 'editor.layout.threeEquals',
|
|
27
|
-
type: 'three_equal',
|
|
28
|
-
title: _toolbarMessages.toolbarMessages.threeColumns,
|
|
29
|
-
icon: _layoutThreeEqual.default
|
|
30
|
-
}];
|
|
31
|
-
var LAYOUT_TYPES_WITH_SINGLE_COL = [{
|
|
32
|
-
id: 'editor.layout.singeLayout',
|
|
33
|
-
type: 'single',
|
|
34
|
-
title: _toolbarMessages.toolbarMessages.singleColumn,
|
|
35
|
-
icon: _layoutSingle.default
|
|
36
|
-
}].concat(LAYOUT_TYPES);
|
|
37
|
-
var SIDEBAR_LAYOUT_TYPES = [{
|
|
38
|
-
id: 'editor.layout.twoRightSidebar',
|
|
39
|
-
type: 'two_right_sidebar',
|
|
40
|
-
title: _toolbarMessages.toolbarMessages.rightSidebar,
|
|
41
|
-
icon: _layoutTwoRightSidebar.default
|
|
42
|
-
}, {
|
|
43
|
-
id: 'editor.layout.twoLeftSidebar',
|
|
44
|
-
type: 'two_left_sidebar',
|
|
45
|
-
title: _toolbarMessages.toolbarMessages.leftSidebar,
|
|
46
|
-
icon: _layoutTwoLeftSidebar.default
|
|
47
|
-
}, {
|
|
48
|
-
id: 'editor.layout.threeWithSidebars',
|
|
49
|
-
type: 'three_with_sidebars',
|
|
50
|
-
title: _toolbarMessages.toolbarMessages.threeColumnsWithSidebars,
|
|
51
|
-
icon: _layoutThreeWithSidebars.default
|
|
52
|
-
}];
|
|
53
|
-
var buildLayoutButton = function buildLayoutButton(intl, item, currentLayout, editorAnalyticsAPI) {
|
|
54
|
-
return {
|
|
55
|
-
id: item.id,
|
|
56
|
-
type: 'button',
|
|
57
|
-
icon: item.icon,
|
|
58
|
-
testId: item.title.id ? "".concat(item.title.id) : undefined,
|
|
59
|
-
title: intl.formatMessage(item.title),
|
|
60
|
-
onClick: (0, _actions.setPresetLayout)(editorAnalyticsAPI)(item.type),
|
|
61
|
-
selected: !!currentLayout && currentLayout === item.type,
|
|
62
|
-
tabIndex: null
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
var layoutToolbarTitle = exports.layoutToolbarTitle = 'Layout floating controls';
|
|
66
|
-
var buildToolbar = exports.buildToolbar = function buildToolbar(state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api) {
|
|
67
|
-
var _api$decorations$acti, _api$decorations, _api$analytics;
|
|
68
|
-
var _ref = (_api$decorations$acti = api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions) !== null && _api$decorations$acti !== void 0 ? _api$decorations$acti : {},
|
|
69
|
-
hoverDecoration = _ref.hoverDecoration;
|
|
70
|
-
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
71
|
-
var node = state.doc.nodeAt(pos);
|
|
72
|
-
if (node) {
|
|
73
|
-
var currentLayout = (0, _actions.getPresetLayout)(node);
|
|
74
|
-
var separator = {
|
|
75
|
-
type: 'separator'
|
|
76
|
-
};
|
|
77
|
-
var nodeType = state.schema.nodes.layoutSection;
|
|
78
|
-
var deleteButton = {
|
|
79
|
-
id: 'editor.layout.delete',
|
|
80
|
-
type: 'button',
|
|
81
|
-
appearance: 'danger',
|
|
82
|
-
focusEditoronEnter: true,
|
|
83
|
-
icon: _remove.default,
|
|
84
|
-
testId: _messages.default.remove.id,
|
|
85
|
-
title: intl.formatMessage(_messages.default.remove),
|
|
86
|
-
onClick: (0, _actions.deleteActiveLayoutNode)(editorAnalyticsAPI),
|
|
87
|
-
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
88
|
-
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
89
|
-
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
90
|
-
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
91
|
-
tabIndex: null
|
|
92
|
-
};
|
|
93
|
-
var layoutTypes = allowSingleColumnLayout ? LAYOUT_TYPES_WITH_SINGLE_COL : LAYOUT_TYPES;
|
|
94
|
-
return {
|
|
95
|
-
title: layoutToolbarTitle,
|
|
96
|
-
getDomRef: function getDomRef(view) {
|
|
97
|
-
return (0, _utils.findDomRefAtPos)(pos, view.domAtPos.bind(view));
|
|
98
|
-
},
|
|
99
|
-
nodeType: nodeType,
|
|
100
|
-
items: [].concat((0, _toConsumableArray2.default)(layoutTypes.map(function (i) {
|
|
101
|
-
return buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI);
|
|
102
|
-
})), (0, _toConsumableArray2.default)(addSidebarLayouts ? SIDEBAR_LAYOUT_TYPES.map(function (i) {
|
|
103
|
-
return buildLayoutButton(intl, i, currentLayout, editorAnalyticsAPI);
|
|
104
|
-
}) : []), [{
|
|
105
|
-
type: 'copy-button',
|
|
106
|
-
items: [separator, {
|
|
107
|
-
state: state,
|
|
108
|
-
formatMessage: intl.formatMessage,
|
|
109
|
-
nodeType: nodeType
|
|
110
|
-
}]
|
|
111
|
-
}, separator, deleteButton]),
|
|
112
|
-
scrollable: true
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
return;
|
|
116
|
-
};
|