@atlaskit/editor-core 189.1.11 → 189.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/plugins/index.js +0 -14
- package/dist/cjs/plugins/insert-block/index.js +6 -10
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -38
- package/dist/cjs/presets/universal.js +4 -2
- package/dist/cjs/ui/ContentStyles/index.js +1 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -2
- package/dist/es2019/plugins/insert-block/index.js +5 -9
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
- package/dist/es2019/presets/universal.js +3 -1
- package/dist/es2019/ui/ContentStyles/index.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -2
- package/dist/esm/plugins/insert-block/index.js +5 -9
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +40 -38
- package/dist/esm/presets/universal.js +3 -1
- package/dist/esm/ui/ContentStyles/index.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -2
- package/dist/types/plugins/insert-block/types.d.ts +4 -2
- package/dist/types/types/editor-props.d.ts +2 -2
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +4 -2
- package/dist/types-ts4.5/types/editor-props.d.ts +2 -2
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +1 -1
- package/package.json +4 -2
- package/report.api.md +2 -16
- package/tmp/api-report-tmp.d.ts +2 -16
- 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/cjs/plugins/placeholder-text/actions.js +0 -35
- package/dist/cjs/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -107
- package/dist/cjs/plugins/placeholder-text/index.js +0 -20
- package/dist/cjs/plugins/placeholder-text/placeholder-text-nodeview.js +0 -89
- package/dist/cjs/plugins/placeholder-text/plugin-key.js +0 -8
- package/dist/cjs/plugins/placeholder-text/plugin.js +0 -267
- package/dist/cjs/plugins/placeholder-text/selection-utils.js +0 -14
- package/dist/cjs/plugins/placeholder-text/styles.js +0 -13
- package/dist/cjs/plugins/placeholder-text/types.js +0 -5
- package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -86
- package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -15
- package/dist/cjs/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -54
- package/dist/cjs/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -89
- 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/es2019/plugins/placeholder-text/actions.js +0 -27
- package/dist/es2019/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -77
- package/dist/es2019/plugins/placeholder-text/index.js +0 -2
- package/dist/es2019/plugins/placeholder-text/placeholder-text-nodeview.js +0 -77
- package/dist/es2019/plugins/placeholder-text/plugin-key.js +0 -2
- package/dist/es2019/plugins/placeholder-text/plugin.js +0 -247
- package/dist/es2019/plugins/placeholder-text/selection-utils.js +0 -8
- package/dist/es2019/plugins/placeholder-text/styles.js +0 -52
- package/dist/es2019/plugins/placeholder-text/types.js +0 -1
- package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -45
- package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -15
- package/dist/es2019/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -41
- package/dist/es2019/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -60
- 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/esm/plugins/placeholder-text/actions.js +0 -29
- package/dist/esm/plugins/placeholder-text/fake-text-cursor/cursor.js +0 -100
- package/dist/esm/plugins/placeholder-text/index.js +0 -2
- package/dist/esm/plugins/placeholder-text/placeholder-text-nodeview.js +0 -82
- package/dist/esm/plugins/placeholder-text/plugin-key.js +0 -2
- package/dist/esm/plugins/placeholder-text/plugin.js +0 -259
- package/dist/esm/plugins/placeholder-text/selection-utils.js +0 -8
- package/dist/esm/plugins/placeholder-text/styles.js +0 -6
- package/dist/esm/plugins/placeholder-text/types.js +0 -1
- package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/index.js +0 -63
- package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/styles.js +0 -8
- package/dist/esm/plugins/placeholder-text/ui/FloatingToolbar/utils.js +0 -48
- package/dist/esm/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.js +0 -79
- 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/plugins/placeholder-text/actions.d.ts +0 -4
- package/dist/types/plugins/placeholder-text/fake-text-cursor/cursor.d.ts +0 -30
- package/dist/types/plugins/placeholder-text/index.d.ts +0 -3
- package/dist/types/plugins/placeholder-text/placeholder-text-nodeview.d.ts +0 -17
- package/dist/types/plugins/placeholder-text/plugin-key.d.ts +0 -3
- package/dist/types/plugins/placeholder-text/plugin.d.ts +0 -7
- package/dist/types/plugins/placeholder-text/selection-utils.d.ts +0 -2
- package/dist/types/plugins/placeholder-text/styles.d.ts +0 -1
- package/dist/types/plugins/placeholder-text/types.d.ts +0 -18
- package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/index.d.ts +0 -28
- package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/styles.d.ts +0 -1
- package/dist/types/plugins/placeholder-text/ui/FloatingToolbar/utils.d.ts +0 -13
- package/dist/types/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +0 -25
- 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
- package/dist/types-ts4.5/plugins/placeholder-text/actions.d.ts +0 -4
- package/dist/types-ts4.5/plugins/placeholder-text/fake-text-cursor/cursor.d.ts +0 -30
- package/dist/types-ts4.5/plugins/placeholder-text/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/placeholder-text/placeholder-text-nodeview.d.ts +0 -17
- package/dist/types-ts4.5/plugins/placeholder-text/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/placeholder-text/plugin.d.ts +0 -7
- package/dist/types-ts4.5/plugins/placeholder-text/selection-utils.d.ts +0 -2
- package/dist/types-ts4.5/plugins/placeholder-text/styles.d.ts +0 -1
- package/dist/types-ts4.5/plugins/placeholder-text/types.d.ts +0 -18
- package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/index.d.ts +0 -28
- package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/styles.d.ts +0 -1
- package/dist/types-ts4.5/plugins/placeholder-text/ui/FloatingToolbar/utils.d.ts +0 -13
- package/dist/types-ts4.5/plugins/placeholder-text/ui/PlaceholderFloatingToolbar/index.d.ts +0 -25
|
@@ -1,345 +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.fixColumnStructure = exports.fixColumnSizes = exports.deleteActiveLayoutNode = exports.createDefaultLayoutSection = exports.TWO_COL_LAYOUTS = exports.THREE_COL_LAYOUTS = exports.ONE_COL_LAYOUTS = void 0;
|
|
8
|
-
exports.forceSectionToPresetLayout = forceSectionToPresetLayout;
|
|
9
|
-
exports.setPresetLayout = exports.insertLayoutColumnsWithAnalytics = exports.insertLayoutColumns = exports.getSelectedLayout = exports.getPresetLayout = void 0;
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
|
-
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
13
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
|
-
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
15
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
16
|
-
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
17
|
-
var _pluginKey = require("./pm-plugins/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 ONE_COL_LAYOUTS = exports.ONE_COL_LAYOUTS = ['single'];
|
|
21
|
-
var TWO_COL_LAYOUTS = exports.TWO_COL_LAYOUTS = ['two_equal', 'two_left_sidebar', 'two_right_sidebar'];
|
|
22
|
-
var THREE_COL_LAYOUTS = exports.THREE_COL_LAYOUTS = ['three_equal', 'three_with_sidebars'];
|
|
23
|
-
var getWidthsForPreset = function getWidthsForPreset(presetLayout) {
|
|
24
|
-
switch (presetLayout) {
|
|
25
|
-
case 'single':
|
|
26
|
-
return [100];
|
|
27
|
-
case 'two_equal':
|
|
28
|
-
return [50, 50];
|
|
29
|
-
case 'three_equal':
|
|
30
|
-
return [33.33, 33.33, 33.33];
|
|
31
|
-
case 'two_left_sidebar':
|
|
32
|
-
return [33.33, 66.66];
|
|
33
|
-
case 'two_right_sidebar':
|
|
34
|
-
return [66.66, 33.33];
|
|
35
|
-
case 'three_with_sidebars':
|
|
36
|
-
return [25, 50, 25];
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Finds layout preset based on the width attrs of all the layoutColumn nodes
|
|
42
|
-
* inside the layoutSection node
|
|
43
|
-
*/
|
|
44
|
-
var getPresetLayout = exports.getPresetLayout = function getPresetLayout(section) {
|
|
45
|
-
var widths = (0, _utils2.mapChildren)(section, function (column) {
|
|
46
|
-
return column.attrs.width;
|
|
47
|
-
}).join(',');
|
|
48
|
-
switch (widths) {
|
|
49
|
-
case '100':
|
|
50
|
-
return 'single';
|
|
51
|
-
case '33.33,33.33,33.33':
|
|
52
|
-
return 'three_equal';
|
|
53
|
-
case '25,50,25':
|
|
54
|
-
return 'three_with_sidebars';
|
|
55
|
-
case '50,50':
|
|
56
|
-
return 'two_equal';
|
|
57
|
-
case '33.33,66.66':
|
|
58
|
-
return 'two_left_sidebar';
|
|
59
|
-
case '66.66,33.33':
|
|
60
|
-
return 'two_right_sidebar';
|
|
61
|
-
}
|
|
62
|
-
return;
|
|
63
|
-
};
|
|
64
|
-
var getSelectedLayout = exports.getSelectedLayout = function getSelectedLayout(maybeLayoutSection, current) {
|
|
65
|
-
if (maybeLayoutSection && getPresetLayout(maybeLayoutSection)) {
|
|
66
|
-
return getPresetLayout(maybeLayoutSection) || current;
|
|
67
|
-
}
|
|
68
|
-
return current;
|
|
69
|
-
};
|
|
70
|
-
var createDefaultLayoutSection = exports.createDefaultLayoutSection = function createDefaultLayoutSection(state) {
|
|
71
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
72
|
-
layoutSection = _state$schema$nodes.layoutSection,
|
|
73
|
-
layoutColumn = _state$schema$nodes.layoutColumn;
|
|
74
|
-
|
|
75
|
-
// create a 50-50 layout by default
|
|
76
|
-
var columns = _model.Fragment.fromArray([layoutColumn.createAndFill({
|
|
77
|
-
width: 50
|
|
78
|
-
}), layoutColumn.createAndFill({
|
|
79
|
-
width: 50
|
|
80
|
-
})]);
|
|
81
|
-
return layoutSection.createAndFill(undefined, columns);
|
|
82
|
-
};
|
|
83
|
-
var insertLayoutColumns = exports.insertLayoutColumns = function insertLayoutColumns(state, dispatch) {
|
|
84
|
-
if (dispatch) {
|
|
85
|
-
dispatch((0, _utils.safeInsert)(createDefaultLayoutSection(state))(state.tr));
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
};
|
|
89
|
-
var insertLayoutColumnsWithAnalytics = exports.insertLayoutColumnsWithAnalytics = function insertLayoutColumnsWithAnalytics(editorAnalyticsAPI) {
|
|
90
|
-
return function (inputMethod) {
|
|
91
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
92
|
-
action: _analytics.ACTION.INSERTED,
|
|
93
|
-
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
94
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.LAYOUT,
|
|
95
|
-
attributes: {
|
|
96
|
-
inputMethod: inputMethod
|
|
97
|
-
},
|
|
98
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
99
|
-
})(insertLayoutColumns);
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Add a column to the right of existing layout
|
|
105
|
-
*/
|
|
106
|
-
function addColumn(schema, pos) {
|
|
107
|
-
return function (tr) {
|
|
108
|
-
tr.replaceWith(tr.mapping.map(pos), tr.mapping.map(pos), schema.nodes.layoutColumn.createAndFill());
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function removeLastColumnInLayout(column, columnPos, insideRightEdgePos) {
|
|
112
|
-
return function (tr) {
|
|
113
|
-
if ((0, _utils2.isEmptyDocument)(column)) {
|
|
114
|
-
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(insideRightEdgePos), _model.Slice.empty);
|
|
115
|
-
} else {
|
|
116
|
-
tr.replaceRange(tr.mapping.map(columnPos - 1), tr.mapping.map(columnPos + 1), _model.Slice.empty);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
var fromTwoColsToThree = addColumn;
|
|
121
|
-
var fromOneColToTwo = addColumn;
|
|
122
|
-
var fromTwoColsToOne = removeLastColumnInLayout;
|
|
123
|
-
var fromThreeColsToTwo = removeLastColumnInLayout;
|
|
124
|
-
var fromOneColToThree = function fromOneColToThree(schema, pos) {
|
|
125
|
-
return function (tr) {
|
|
126
|
-
addColumn(schema, pos)(tr);
|
|
127
|
-
addColumn(schema, pos)(tr);
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
var fromThreeColstoOne = function fromThreeColstoOne(node, tr, insideRightEdgePos) {
|
|
131
|
-
var thirdColumn = node.content.child(2);
|
|
132
|
-
fromThreeColsToTwo(thirdColumn, insideRightEdgePos - thirdColumn.nodeSize, insideRightEdgePos)(tr);
|
|
133
|
-
var secondColumn = node.content.child(1);
|
|
134
|
-
fromTwoColsToOne(secondColumn, insideRightEdgePos - thirdColumn.nodeSize - secondColumn.nodeSize, insideRightEdgePos)(tr);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Handles switching from 2 -> 3 cols, or 3 -> 2 cols
|
|
139
|
-
* Switching from 2 -> 3 just adds a new one at the end
|
|
140
|
-
* Switching from 3 -> 2 moves all the content of the third col inside the second before
|
|
141
|
-
* removing it
|
|
142
|
-
*/
|
|
143
|
-
function forceColumnStructure(state, node, pos, presetLayout) {
|
|
144
|
-
var tr = state.tr;
|
|
145
|
-
var insideRightEdgeOfLayoutSection = pos + node.nodeSize - 1;
|
|
146
|
-
var numCols = node.childCount;
|
|
147
|
-
|
|
148
|
-
// 3 columns -> 2 columns
|
|
149
|
-
if (TWO_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 3) {
|
|
150
|
-
var thirdColumn = node.content.child(2);
|
|
151
|
-
var columnPos = insideRightEdgeOfLayoutSection - thirdColumn.nodeSize;
|
|
152
|
-
fromThreeColsToTwo(thirdColumn, columnPos, insideRightEdgeOfLayoutSection)(tr);
|
|
153
|
-
|
|
154
|
-
// 2 columns -> 3 columns
|
|
155
|
-
} else if (THREE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 2) {
|
|
156
|
-
fromTwoColsToThree(state.schema, insideRightEdgeOfLayoutSection)(tr);
|
|
157
|
-
|
|
158
|
-
// 2 columns -> 1 column
|
|
159
|
-
} else if (ONE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 2) {
|
|
160
|
-
var secondColumn = node.content.child(1);
|
|
161
|
-
var _columnPos = insideRightEdgeOfLayoutSection - secondColumn.nodeSize;
|
|
162
|
-
fromTwoColsToOne(secondColumn, _columnPos, insideRightEdgeOfLayoutSection)(tr);
|
|
163
|
-
|
|
164
|
-
// 3 columns -> 1 column
|
|
165
|
-
} else if (ONE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 3) {
|
|
166
|
-
fromThreeColstoOne(node, tr, insideRightEdgeOfLayoutSection);
|
|
167
|
-
|
|
168
|
-
// 1 column -> 2 columns
|
|
169
|
-
} else if (TWO_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 1) {
|
|
170
|
-
fromOneColToTwo(state.schema, insideRightEdgeOfLayoutSection)(tr);
|
|
171
|
-
// 1 column -> 3 columns
|
|
172
|
-
} else if (THREE_COL_LAYOUTS.indexOf(presetLayout) >= 0 && numCols === 1) {
|
|
173
|
-
fromOneColToThree(state.schema, insideRightEdgeOfLayoutSection)(tr);
|
|
174
|
-
}
|
|
175
|
-
return tr;
|
|
176
|
-
}
|
|
177
|
-
function columnWidth(node, schema, widths) {
|
|
178
|
-
var layoutColumn = schema.nodes.layoutColumn;
|
|
179
|
-
var truncatedWidths = widths.map(function (w) {
|
|
180
|
-
return Number(w.toFixed(2));
|
|
181
|
-
});
|
|
182
|
-
return (0, _utils2.flatmap)(node.content, function (column, idx) {
|
|
183
|
-
if (column.type === layoutColumn) {
|
|
184
|
-
return layoutColumn.create(_objectSpread(_objectSpread({}, column.attrs), {}, {
|
|
185
|
-
width: truncatedWidths[idx]
|
|
186
|
-
}), column.content, column.marks);
|
|
187
|
-
} else {
|
|
188
|
-
return column;
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
function forceColumnWidths(state, tr, pos, presetLayout) {
|
|
193
|
-
var node = tr.doc.nodeAt(pos);
|
|
194
|
-
if (!node) {
|
|
195
|
-
return tr;
|
|
196
|
-
}
|
|
197
|
-
return tr.replaceWith(pos + 1, pos + node.nodeSize - 1, columnWidth(node, state.schema, getWidthsForPreset(presetLayout)));
|
|
198
|
-
}
|
|
199
|
-
function forceSectionToPresetLayout(state, node, pos, presetLayout) {
|
|
200
|
-
var tr = forceColumnStructure(state, node, pos, presetLayout);
|
|
201
|
-
|
|
202
|
-
// save the selection here, since forcing column widths causes a change over the
|
|
203
|
-
// entire layoutSection, which remaps selection to the end. not remapping here
|
|
204
|
-
// is safe because the structure is no longer changing.
|
|
205
|
-
var selection = tr.selection;
|
|
206
|
-
tr = forceColumnWidths(state, tr, pos, presetLayout);
|
|
207
|
-
var selectionPos$ = tr.doc.resolve(selection.$from.pos);
|
|
208
|
-
return tr.setSelection(state.selection instanceof _state.NodeSelection ? new _state.NodeSelection(selectionPos$) : new _state.TextSelection(selectionPos$));
|
|
209
|
-
}
|
|
210
|
-
var setPresetLayout = exports.setPresetLayout = function setPresetLayout(editorAnalyticsAPI) {
|
|
211
|
-
return function (layout) {
|
|
212
|
-
return function (state, dispatch) {
|
|
213
|
-
var _ref = _pluginKey.pluginKey.getState(state),
|
|
214
|
-
pos = _ref.pos,
|
|
215
|
-
selectedLayout = _ref.selectedLayout;
|
|
216
|
-
if (selectedLayout === layout || pos === null) {
|
|
217
|
-
return false;
|
|
218
|
-
}
|
|
219
|
-
var node = state.doc.nodeAt(pos);
|
|
220
|
-
if (!node) {
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
var tr = forceSectionToPresetLayout(state, node, pos, layout);
|
|
224
|
-
if (tr) {
|
|
225
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
226
|
-
action: _analytics.ACTION.CHANGED_LAYOUT,
|
|
227
|
-
actionSubject: _analytics.ACTION_SUBJECT.LAYOUT,
|
|
228
|
-
attributes: {
|
|
229
|
-
previousLayout: formatLayoutName(selectedLayout),
|
|
230
|
-
newLayout: formatLayoutName(layout)
|
|
231
|
-
},
|
|
232
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
233
|
-
})(tr);
|
|
234
|
-
tr.setMeta('scrollIntoView', false);
|
|
235
|
-
if (dispatch) {
|
|
236
|
-
dispatch(tr);
|
|
237
|
-
}
|
|
238
|
-
return true;
|
|
239
|
-
}
|
|
240
|
-
return false;
|
|
241
|
-
};
|
|
242
|
-
};
|
|
243
|
-
};
|
|
244
|
-
function layoutNeedChanges(node) {
|
|
245
|
-
return !getPresetLayout(node);
|
|
246
|
-
}
|
|
247
|
-
function getLayoutChange(node, pos, schema) {
|
|
248
|
-
if (node.type === schema.nodes.layoutSection) {
|
|
249
|
-
if (!layoutNeedChanges(node)) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
var presetLayout = node.childCount === 2 ? 'two_equal' : node.childCount === 3 ? 'three_equal' : 'single';
|
|
253
|
-
var fixedColumns = columnWidth(node, schema, getWidthsForPreset(presetLayout));
|
|
254
|
-
return {
|
|
255
|
-
from: pos + 1,
|
|
256
|
-
to: pos + node.nodeSize - 1,
|
|
257
|
-
slice: new _model.Slice(fixedColumns, 0, 0)
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
var fixColumnSizes = exports.fixColumnSizes = function fixColumnSizes(changedTr, state) {
|
|
262
|
-
var layoutSection = state.schema.nodes.layoutSection;
|
|
263
|
-
var change;
|
|
264
|
-
var range = (0, _utils2.getStepRange)(changedTr);
|
|
265
|
-
if (!range) {
|
|
266
|
-
return undefined;
|
|
267
|
-
}
|
|
268
|
-
changedTr.doc.nodesBetween(range.from, range.to, function (node, pos) {
|
|
269
|
-
if (node.type !== layoutSection) {
|
|
270
|
-
return true; // Check all internal nodes expect for layout section
|
|
271
|
-
}
|
|
272
|
-
// Node is a section
|
|
273
|
-
if (layoutNeedChanges(node)) {
|
|
274
|
-
change = getLayoutChange(node, pos, state.schema);
|
|
275
|
-
}
|
|
276
|
-
return false; // We dont go deep, We dont accept nested layouts
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
// Hack to prevent: https://product-fabric.atlassian.net/browse/ED-7523
|
|
280
|
-
// By default prosemirror try to recreate the node with the default attributes
|
|
281
|
-
// The default attribute is invalid adf though. when this happen the node after
|
|
282
|
-
// current position is a layout section
|
|
283
|
-
var $pos = changedTr.doc.resolve(range.to);
|
|
284
|
-
if ($pos.depth > 0) {
|
|
285
|
-
// 'range.to' position could resolve to doc, in this ResolvedPos.after will throws
|
|
286
|
-
var pos = $pos.after();
|
|
287
|
-
var node = changedTr.doc.nodeAt(pos);
|
|
288
|
-
if (node && node.type === layoutSection && layoutNeedChanges(node)) {
|
|
289
|
-
change = getLayoutChange(node, pos, state.schema);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return change;
|
|
293
|
-
};
|
|
294
|
-
var fixColumnStructure = exports.fixColumnStructure = function fixColumnStructure(state) {
|
|
295
|
-
var _ref2 = _pluginKey.pluginKey.getState(state),
|
|
296
|
-
pos = _ref2.pos,
|
|
297
|
-
selectedLayout = _ref2.selectedLayout;
|
|
298
|
-
if (pos !== null && selectedLayout) {
|
|
299
|
-
var node = state.doc.nodeAt(pos);
|
|
300
|
-
if (node && node.childCount !== getWidthsForPreset(selectedLayout).length) {
|
|
301
|
-
return forceSectionToPresetLayout(state, node, pos, selectedLayout);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return;
|
|
305
|
-
};
|
|
306
|
-
var deleteActiveLayoutNode = exports.deleteActiveLayoutNode = function deleteActiveLayoutNode(editorAnalyticsAPI) {
|
|
307
|
-
return function (state, dispatch) {
|
|
308
|
-
var _ref3 = _pluginKey.pluginKey.getState(state),
|
|
309
|
-
pos = _ref3.pos,
|
|
310
|
-
selectedLayout = _ref3.selectedLayout;
|
|
311
|
-
if (pos !== null) {
|
|
312
|
-
var node = state.doc.nodeAt(pos);
|
|
313
|
-
if (dispatch) {
|
|
314
|
-
var tr = state.tr.delete(pos, pos + node.nodeSize);
|
|
315
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
316
|
-
action: _analytics.ACTION.DELETED,
|
|
317
|
-
actionSubject: _analytics.ACTION_SUBJECT.LAYOUT,
|
|
318
|
-
attributes: {
|
|
319
|
-
layout: formatLayoutName(selectedLayout)
|
|
320
|
-
},
|
|
321
|
-
eventType: _analytics.EVENT_TYPE.TRACK
|
|
322
|
-
})(tr);
|
|
323
|
-
dispatch(tr);
|
|
324
|
-
}
|
|
325
|
-
return true;
|
|
326
|
-
}
|
|
327
|
-
return false;
|
|
328
|
-
};
|
|
329
|
-
};
|
|
330
|
-
var formatLayoutName = function formatLayoutName(layout) {
|
|
331
|
-
switch (layout) {
|
|
332
|
-
case 'single':
|
|
333
|
-
return _analytics.LAYOUT_TYPE.SINGLE_COL;
|
|
334
|
-
case 'two_equal':
|
|
335
|
-
return _analytics.LAYOUT_TYPE.TWO_COLS_EQUAL;
|
|
336
|
-
case 'three_equal':
|
|
337
|
-
return _analytics.LAYOUT_TYPE.THREE_COLS_EQUAL;
|
|
338
|
-
case 'two_left_sidebar':
|
|
339
|
-
return _analytics.LAYOUT_TYPE.LEFT_SIDEBAR;
|
|
340
|
-
case 'two_right_sidebar':
|
|
341
|
-
return _analytics.LAYOUT_TYPE.RIGHT_SIDEBAR;
|
|
342
|
-
case 'three_with_sidebars':
|
|
343
|
-
return _analytics.LAYOUT_TYPE.THREE_WITH_SIDEBARS;
|
|
344
|
-
}
|
|
345
|
-
};
|
|
@@ -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
|
-
});
|