@atlaskit/editor-plugin-expand 1.0.0 → 1.1.0
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 +16 -0
- package/dist/cjs/commands.js +57 -37
- package/dist/cjs/nodeviews/index.js +32 -10
- package/dist/cjs/plugin.js +4 -2
- package/dist/cjs/pm-plugins/keymap.js +6 -5
- package/dist/cjs/pm-plugins/main.js +5 -2
- package/dist/es2019/commands.js +39 -13
- package/dist/es2019/nodeviews/index.js +33 -12
- package/dist/es2019/plugin.js +4 -2
- package/dist/es2019/pm-plugins/keymap.js +6 -5
- package/dist/es2019/pm-plugins/main.js +5 -3
- package/dist/esm/commands.js +57 -37
- package/dist/esm/nodeviews/index.js +32 -10
- package/dist/esm/plugin.js +4 -2
- package/dist/esm/pm-plugins/keymap.js +6 -5
- package/dist/esm/pm-plugins/main.js +5 -2
- package/dist/types/commands.d.ts +12 -2
- package/dist/types/nodeviews/index.d.ts +4 -2
- package/dist/types/pm-plugins/keymap.d.ts +3 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/types.d.ts +10 -0
- package/dist/types-ts4.5/commands.d.ts +12 -2
- package/dist/types-ts4.5/nodeviews/index.d.ts +4 -2
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +10 -0
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-expand
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#75042](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/75042) [`ce823f018248`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ce823f018248) - [ux] ED-21987 Diverge expands in live pages so that they are not multiplayer, and are closed by default.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 1.0.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 1.0.0
|
|
4
20
|
|
|
5
21
|
### Major Changes
|
package/dist/cjs/commands.js
CHANGED
|
@@ -6,12 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.updateExpandTitle = exports.toggleExpandExpanded = exports.setSelectionInsideExpand = exports.setExpandRef = exports.insertExpand = exports.focusTitle = exports.deleteExpandAtPos = exports.deleteExpand = exports.createExpandNode = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _steps = require("@atlaskit/adf-schema/steps");
|
|
9
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
11
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
11
12
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
13
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
14
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
14
15
|
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
16
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
17
|
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
16
18
|
var _utils4 = require("./utils");
|
|
17
19
|
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; }
|
|
@@ -59,58 +61,76 @@ var deleteExpand = exports.deleteExpand = function deleteExpand(editorAnalyticsA
|
|
|
59
61
|
return deleteExpandAtPos(editorAnalyticsAPI)(expandNode.pos, expandNode.node)(state, dispatch);
|
|
60
62
|
};
|
|
61
63
|
};
|
|
62
|
-
var updateExpandTitle = exports.updateExpandTitle = function updateExpandTitle(
|
|
64
|
+
var updateExpandTitle = exports.updateExpandTitle = function updateExpandTitle(_ref) {
|
|
65
|
+
var title = _ref.title,
|
|
66
|
+
nodeType = _ref.nodeType,
|
|
67
|
+
pos = _ref.pos,
|
|
68
|
+
__livePage = _ref.__livePage;
|
|
63
69
|
return function (state, dispatch) {
|
|
64
70
|
var node = state.doc.nodeAt(pos);
|
|
65
71
|
if (node && node.type === nodeType && dispatch) {
|
|
66
72
|
var tr = state.tr;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && __livePage) {
|
|
74
|
+
tr.step(new _steps.SetAttrsStep(pos, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
75
|
+
title: title
|
|
76
|
+
})));
|
|
77
|
+
} else {
|
|
78
|
+
tr.setNodeMarkup(pos, node.type, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
79
|
+
title: title
|
|
80
|
+
}), node.marks);
|
|
81
|
+
}
|
|
70
82
|
dispatch(tr);
|
|
71
83
|
}
|
|
72
84
|
return true;
|
|
73
85
|
};
|
|
74
86
|
};
|
|
75
|
-
var toggleExpandExpanded = exports.toggleExpandExpanded = function toggleExpandExpanded(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
87
|
+
var toggleExpandExpanded = exports.toggleExpandExpanded = function toggleExpandExpanded(_ref2) {
|
|
88
|
+
var editorAnalyticsAPI = _ref2.editorAnalyticsAPI,
|
|
89
|
+
pos = _ref2.pos,
|
|
90
|
+
nodeType = _ref2.nodeType,
|
|
91
|
+
__livePage = _ref2.__livePage;
|
|
92
|
+
return function (state, dispatch) {
|
|
93
|
+
var node = state.doc.nodeAt(pos);
|
|
94
|
+
if (node && node.type === nodeType && dispatch) {
|
|
95
|
+
var tr = state.tr;
|
|
96
|
+
var isExpandedNext = !node.attrs.__expanded;
|
|
97
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && __livePage) {
|
|
98
|
+
tr.step(new _steps.SetAttrsStep(pos, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
99
|
+
__expanded: isExpandedNext
|
|
100
|
+
})));
|
|
101
|
+
} else {
|
|
82
102
|
tr.setNodeMarkup(pos, node.type, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
83
103
|
__expanded: isExpandedNext
|
|
84
104
|
}), node.marks);
|
|
105
|
+
}
|
|
85
106
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
107
|
+
// If we're going to collapse the expand and our cursor is currently inside
|
|
108
|
+
// Move to a right gap cursor, if the toolbar is interacted (or an API),
|
|
109
|
+
// it will insert below rather than inside (which will be invisible).
|
|
110
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && __livePage ? isExpandedNext === true : isExpandedNext === false && (0, _utils4.findExpand)(state)) {
|
|
111
|
+
tr.setSelection(new _selection.GapCursorSelection(tr.doc.resolve(pos + node.nodeSize), _selection.Side.RIGHT));
|
|
112
|
+
}
|
|
92
113
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
114
|
+
// log when people open/close expands
|
|
115
|
+
// TODO: ED-8523 make platform/mode global attributes?
|
|
116
|
+
var payload = {
|
|
117
|
+
action: _analytics.ACTION.TOGGLE_EXPAND,
|
|
118
|
+
actionSubject: nodeType === state.schema.nodes.expand ? _analytics.ACTION_SUBJECT.EXPAND : _analytics.ACTION_SUBJECT.NESTED_EXPAND,
|
|
119
|
+
attributes: {
|
|
120
|
+
platform: _analytics.PLATFORMS.WEB,
|
|
121
|
+
mode: _analytics.MODE.EDITOR,
|
|
122
|
+
expanded: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && __livePage ? !isExpandedNext : isExpandedNext
|
|
123
|
+
},
|
|
124
|
+
eventType: _analytics.EVENT_TYPE.TRACK
|
|
125
|
+
};
|
|
105
126
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
};
|
|
127
|
+
// `isRemote` meta prevents this step from being
|
|
128
|
+
// sync'd between sessions in synchrony collab edit
|
|
129
|
+
tr.setMeta('isRemote', true);
|
|
130
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
131
|
+
dispatch(tr);
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
114
134
|
};
|
|
115
135
|
};
|
|
116
136
|
|
|
@@ -18,15 +18,16 @@ var _ui = require("@atlaskit/editor-common/ui");
|
|
|
18
18
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
19
19
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
20
20
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
21
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
22
|
var _commands = require("../commands");
|
|
22
23
|
var _ExpandIconButton = require("../ui/ExpandIconButton");
|
|
23
24
|
function buildExpandClassName(type, expanded) {
|
|
24
25
|
return "".concat(_styles.expandClassNames.prefix, " ").concat(_styles.expandClassNames.type(type), " ").concat(expanded ? _styles.expandClassNames.expanded : '');
|
|
25
26
|
}
|
|
26
|
-
var toDOM = function toDOM(node, intl) {
|
|
27
|
+
var toDOM = function toDOM(node, __livePage, intl) {
|
|
27
28
|
return ['div', {
|
|
28
29
|
// prettier-ignore
|
|
29
|
-
'class': buildExpandClassName(node.type.name, node.attrs.__expanded),
|
|
30
|
+
'class': buildExpandClassName(node.type.name, (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && __livePage ? !node.attrs.__expanded : node.attrs.__expanded),
|
|
30
31
|
'data-node-type': node.type.name,
|
|
31
32
|
'data-title': node.attrs.title
|
|
32
33
|
}, ['div', {
|
|
@@ -60,6 +61,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
60
61
|
function ExpandNodeView(node, view, getPos, getIntl, isMobile, selectNearNode, api) {
|
|
61
62
|
var _this = this;
|
|
62
63
|
var allowInteractiveExpand = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : true;
|
|
64
|
+
var __livePage = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
63
65
|
(0, _classCallCheck2.default)(this, ExpandNodeView);
|
|
64
66
|
(0, _defineProperty2.default)(this, "allowInteractiveExpand", true);
|
|
65
67
|
(0, _defineProperty2.default)(this, "isMobile", false);
|
|
@@ -116,7 +118,12 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
116
118
|
if (_this.view.dom instanceof HTMLElement) {
|
|
117
119
|
_this.view.dom.blur();
|
|
118
120
|
}
|
|
119
|
-
(0, _commands.toggleExpandExpanded)(
|
|
121
|
+
(0, _commands.toggleExpandExpanded)({
|
|
122
|
+
editorAnalyticsAPI: (_this$api = _this.api) === null || _this$api === void 0 || (_this$api = _this$api.analytics) === null || _this$api === void 0 ? void 0 : _this$api.actions,
|
|
123
|
+
pos: pos,
|
|
124
|
+
nodeType: _this.node.type,
|
|
125
|
+
__livePage: _this.__livePage
|
|
126
|
+
})(state, dispatch);
|
|
120
127
|
return;
|
|
121
128
|
}
|
|
122
129
|
if (target === _this.input) {
|
|
@@ -136,7 +143,12 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
136
143
|
var _this$view3 = _this.view,
|
|
137
144
|
state = _this$view3.state,
|
|
138
145
|
dispatch = _this$view3.dispatch;
|
|
139
|
-
(0, _commands.updateExpandTitle)(
|
|
146
|
+
(0, _commands.updateExpandTitle)({
|
|
147
|
+
title: target.value,
|
|
148
|
+
pos: pos,
|
|
149
|
+
nodeType: _this.node.type,
|
|
150
|
+
__livePage: _this.__livePage
|
|
151
|
+
})(state, dispatch);
|
|
140
152
|
}
|
|
141
153
|
});
|
|
142
154
|
(0, _defineProperty2.default)(this, "handleFocus", function (event) {
|
|
@@ -196,7 +208,12 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
196
208
|
var _this$view4 = _this.view,
|
|
197
209
|
state = _this$view4.state,
|
|
198
210
|
dispatch = _this$view4.dispatch;
|
|
199
|
-
(0, _commands.toggleExpandExpanded)(
|
|
211
|
+
(0, _commands.toggleExpandExpanded)({
|
|
212
|
+
editorAnalyticsAPI: (_this$api3 = _this.api) === null || _this$api3 === void 0 || (_this$api3 = _this$api3.analytics) === null || _this$api3 === void 0 ? void 0 : _this$api3.actions,
|
|
213
|
+
pos: pos,
|
|
214
|
+
nodeType: _this.node.type,
|
|
215
|
+
__livePage: _this.__livePage
|
|
216
|
+
})(state, dispatch);
|
|
200
217
|
}
|
|
201
218
|
});
|
|
202
219
|
(0, _defineProperty2.default)(this, "moveToOutsideOfTitle", function (event) {
|
|
@@ -228,6 +245,9 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
228
245
|
}
|
|
229
246
|
});
|
|
230
247
|
(0, _defineProperty2.default)(this, "isCollapsed", function () {
|
|
248
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && _this.__livePage) {
|
|
249
|
+
return _this.node.attrs.__expanded;
|
|
250
|
+
}
|
|
231
251
|
return !_this.node.attrs.__expanded;
|
|
232
252
|
});
|
|
233
253
|
(0, _defineProperty2.default)(this, "setRightGapCursor", function (event) {
|
|
@@ -339,8 +359,9 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
339
359
|
}
|
|
340
360
|
});
|
|
341
361
|
this.selectNearNode = selectNearNode;
|
|
362
|
+
this.__livePage = __livePage;
|
|
342
363
|
this.intl = getIntl();
|
|
343
|
-
var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM(node, this.intl)),
|
|
364
|
+
var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM(node, this.__livePage, this.intl)),
|
|
344
365
|
dom = _DOMSerializer$render.dom,
|
|
345
366
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
346
367
|
this.allowInteractiveExpand = allowInteractiveExpand;
|
|
@@ -393,7 +414,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
393
414
|
_reactDom.default.render( /*#__PURE__*/_react.default.createElement(_ExpandIconButton.ExpandIconButton, {
|
|
394
415
|
intl: intl,
|
|
395
416
|
allowInteractiveExpand: this.allowInteractiveExpand,
|
|
396
|
-
expanded: __expanded
|
|
417
|
+
expanded: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && this.__livePage ? !__expanded : __expanded
|
|
397
418
|
}), this.icon);
|
|
398
419
|
}
|
|
399
420
|
}, {
|
|
@@ -429,7 +450,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
429
450
|
}
|
|
430
451
|
if (this.content) {
|
|
431
452
|
// Disallow interaction/selection inside when collapsed.
|
|
432
|
-
this.content.setAttribute('contenteditable', node.attrs.__expanded);
|
|
453
|
+
this.content.setAttribute('contenteditable', (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && this.__livePage ? !node.attrs.__expanded : node.attrs.__expanded);
|
|
433
454
|
}
|
|
434
455
|
}
|
|
435
456
|
|
|
@@ -485,9 +506,10 @@ function _default(_ref2) {
|
|
|
485
506
|
isMobile = _ref2.isMobile,
|
|
486
507
|
api = _ref2.api,
|
|
487
508
|
_ref2$allowInteractiv = _ref2.allowInteractiveExpand,
|
|
488
|
-
allowInteractiveExpand = _ref2$allowInteractiv === void 0 ? true : _ref2$allowInteractiv
|
|
509
|
+
allowInteractiveExpand = _ref2$allowInteractiv === void 0 ? true : _ref2$allowInteractiv,
|
|
510
|
+
__livePage = _ref2.__livePage;
|
|
489
511
|
return function (node, view, getPos) {
|
|
490
512
|
var _api$selection;
|
|
491
|
-
return new ExpandNodeView(node, view, getPos, getIntl, isMobile, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.actions) === null || _api$selection === void 0 ? void 0 : _api$selection.selectNearNode, api, allowInteractiveExpand);
|
|
513
|
+
return new ExpandNodeView(node, view, getPos, getIntl, isMobile, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 || (_api$selection = _api$selection.actions) === null || _api$selection === void 0 ? void 0 : _api$selection.selectNearNode, api, allowInteractiveExpand, __livePage);
|
|
492
514
|
};
|
|
493
515
|
}
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -50,12 +50,14 @@ var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
|
|
|
50
50
|
var _options$allowInterac;
|
|
51
51
|
var dispatch = _ref2.dispatch,
|
|
52
52
|
getIntl = _ref2.getIntl;
|
|
53
|
-
return (0, _main.createPlugin)(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true);
|
|
53
|
+
return (0, _main.createPlugin)(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true, options.__livePage);
|
|
54
54
|
}
|
|
55
55
|
}, {
|
|
56
56
|
name: 'expandKeymap',
|
|
57
57
|
plugin: function plugin() {
|
|
58
|
-
return (0, _keymap.expandKeymap)(api
|
|
58
|
+
return (0, _keymap.expandKeymap)(api, {
|
|
59
|
+
__livePage: options.__livePage
|
|
60
|
+
});
|
|
59
61
|
}
|
|
60
62
|
}];
|
|
61
63
|
},
|
|
@@ -10,6 +10,7 @@ var _styles = require("@atlaskit/editor-common/styles");
|
|
|
10
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
11
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
12
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _commands = require("../commands");
|
|
14
15
|
var _utils2 = require("../utils");
|
|
15
16
|
var isExpandNode = function isExpandNode(node) {
|
|
@@ -18,7 +19,7 @@ var isExpandNode = function isExpandNode(node) {
|
|
|
18
19
|
var isExpandSelected = function isExpandSelected(selection) {
|
|
19
20
|
return selection instanceof _state.NodeSelection && isExpandNode(selection.node);
|
|
20
21
|
};
|
|
21
|
-
function expandKeymap(api) {
|
|
22
|
+
function expandKeymap(api, options) {
|
|
22
23
|
var list = {};
|
|
23
24
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveRight.common, function (state, dispatch, editorView) {
|
|
24
25
|
var _api$selection;
|
|
@@ -75,7 +76,7 @@ function expandKeymap(api) {
|
|
|
75
76
|
var selection = state.selection,
|
|
76
77
|
schema = state.schema;
|
|
77
78
|
var nodeBefore = selection.$from.nodeBefore;
|
|
78
|
-
if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.RIGHT && nodeBefore && (nodeBefore.type === schema.nodes.expand || nodeBefore.type === schema.nodes.nestedExpand) && !nodeBefore.attrs.__expanded) {
|
|
79
|
+
if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.RIGHT && nodeBefore && (nodeBefore.type === schema.nodes.expand || nodeBefore.type === schema.nodes.nestedExpand) && ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && options.__livePage ? nodeBefore.attrs.__expanded : !nodeBefore.attrs.__expanded)) {
|
|
79
80
|
var _$from = selection.$from;
|
|
80
81
|
return (0, _commands.focusTitle)(Math.max(_$from.pos - 1, 0))(state, dispatch, editorView);
|
|
81
82
|
}
|
|
@@ -99,7 +100,7 @@ function expandKeymap(api) {
|
|
|
99
100
|
var expandBefore = (0, _utils2.findExpand)(state, sel);
|
|
100
101
|
if (sel && expandBefore) {
|
|
101
102
|
// moving cursor from outside of an expand to the title when it is collapsed
|
|
102
|
-
if (!expandBefore.node.attrs.__expanded) {
|
|
103
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded) {
|
|
103
104
|
return (0, _commands.focusTitle)(expandBefore.start)(state, dispatch, editorView);
|
|
104
105
|
}
|
|
105
106
|
// moving cursor from outside of an expand to the content when it is expanded
|
|
@@ -120,7 +121,7 @@ function expandKeymap(api) {
|
|
|
120
121
|
nestedExpand = _state$schema$nodes.nestedExpand;
|
|
121
122
|
var selection = state.selection;
|
|
122
123
|
var nodeAfter = selection.$from.nodeAfter;
|
|
123
|
-
if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && !nodeAfter.attrs.__expanded) {
|
|
124
|
+
if (selection instanceof _selection.GapCursorSelection && selection.side === _selection.Side.LEFT && nodeAfter && (nodeAfter.type === expand || nodeAfter.type === nestedExpand) && ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && options.__livePage ? nodeAfter.attrs.__expanded : !nodeAfter.attrs.__expanded)) {
|
|
124
125
|
var $from = selection.$from;
|
|
125
126
|
return (0, _commands.focusTitle)($from.pos + 1)(state, dispatch, editorView);
|
|
126
127
|
}
|
|
@@ -150,7 +151,7 @@ function expandKeymap(api) {
|
|
|
150
151
|
// @see ED-7977
|
|
151
152
|
var sel = _state.Selection.findFrom(state.doc.resolve(Math.max(selection.$from.pos - 1, 0)), -1);
|
|
152
153
|
var expandBefore = (0, _utils2.findExpand)(state, sel);
|
|
153
|
-
if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && !expandBefore.node.attrs.__expanded) {
|
|
154
|
+
if (expandBefore && (expandBefore.node.type === expand || expandBefore.node.type === nestedExpand) && ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && options.__livePage ? expandBefore.node.attrs.__expanded : !expandBefore.node.attrs.__expanded)) {
|
|
154
155
|
return (0, _commands.focusTitle)(expandBefore.start)(state, dispatch, editorView);
|
|
155
156
|
}
|
|
156
157
|
return false;
|
|
@@ -23,6 +23,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
|
|
|
23
23
|
var useLongPressSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
24
24
|
var api = arguments.length > 4 ? arguments[4] : undefined;
|
|
25
25
|
var allowInteractiveExpand = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
26
|
+
var __livePage = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
26
27
|
var state = (0, _pluginFactory.createPluginState)(dispatch, {});
|
|
27
28
|
var isMobile = appearance === 'mobile';
|
|
28
29
|
return new _safePlugin.SafePlugin({
|
|
@@ -34,13 +35,15 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
|
|
|
34
35
|
getIntl: getIntl,
|
|
35
36
|
isMobile: isMobile,
|
|
36
37
|
api: api,
|
|
37
|
-
allowInteractiveExpand: allowInteractiveExpand
|
|
38
|
+
allowInteractiveExpand: allowInteractiveExpand,
|
|
39
|
+
__livePage: __livePage
|
|
38
40
|
}),
|
|
39
41
|
nestedExpand: (0, _nodeviews.default)({
|
|
40
42
|
getIntl: getIntl,
|
|
41
43
|
isMobile: isMobile,
|
|
42
44
|
api: api,
|
|
43
|
-
allowInteractiveExpand: allowInteractiveExpand
|
|
45
|
+
allowInteractiveExpand: allowInteractiveExpand,
|
|
46
|
+
__livePage: __livePage
|
|
44
47
|
})
|
|
45
48
|
},
|
|
46
49
|
handleKeyDown: function handleKeyDown(_view, event) {
|
package/dist/es2019/commands.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
1
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, MODE, PLATFORMS } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
3
4
|
import { createWrapSelectionTransaction } from '@atlaskit/editor-common/utils';
|
|
4
5
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
5
6
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
6
7
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
8
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
9
|
import { createCommand } from './pm-plugins/plugin-factory';
|
|
8
10
|
import { findExpand } from './utils';
|
|
9
11
|
export const setExpandRef = ref => createCommand({
|
|
@@ -41,36 +43,60 @@ export const deleteExpand = editorAnalyticsAPI => (state, dispatch) => {
|
|
|
41
43
|
}
|
|
42
44
|
return deleteExpandAtPos(editorAnalyticsAPI)(expandNode.pos, expandNode.node)(state, dispatch);
|
|
43
45
|
};
|
|
44
|
-
export const updateExpandTitle = (
|
|
46
|
+
export const updateExpandTitle = ({
|
|
47
|
+
title,
|
|
48
|
+
nodeType,
|
|
49
|
+
pos,
|
|
50
|
+
__livePage
|
|
51
|
+
}) => (state, dispatch) => {
|
|
45
52
|
const node = state.doc.nodeAt(pos);
|
|
46
53
|
if (node && node.type === nodeType && dispatch) {
|
|
47
54
|
const {
|
|
48
55
|
tr
|
|
49
56
|
} = state;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
if (getBooleanFF('platform.editor.live-pages-expand-divergence') && __livePage) {
|
|
58
|
+
tr.step(new SetAttrsStep(pos, {
|
|
59
|
+
...node.attrs,
|
|
60
|
+
title
|
|
61
|
+
}));
|
|
62
|
+
} else {
|
|
63
|
+
tr.setNodeMarkup(pos, node.type, {
|
|
64
|
+
...node.attrs,
|
|
65
|
+
title
|
|
66
|
+
}, node.marks);
|
|
67
|
+
}
|
|
54
68
|
dispatch(tr);
|
|
55
69
|
}
|
|
56
70
|
return true;
|
|
57
71
|
};
|
|
58
|
-
export const toggleExpandExpanded =
|
|
72
|
+
export const toggleExpandExpanded = ({
|
|
73
|
+
editorAnalyticsAPI,
|
|
74
|
+
pos,
|
|
75
|
+
nodeType,
|
|
76
|
+
__livePage
|
|
77
|
+
}) => (state, dispatch) => {
|
|
59
78
|
const node = state.doc.nodeAt(pos);
|
|
60
79
|
if (node && node.type === nodeType && dispatch) {
|
|
61
80
|
const {
|
|
62
81
|
tr
|
|
63
82
|
} = state;
|
|
64
83
|
const isExpandedNext = !node.attrs.__expanded;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
84
|
+
if (getBooleanFF('platform.editor.live-pages-expand-divergence') && __livePage) {
|
|
85
|
+
tr.step(new SetAttrsStep(pos, {
|
|
86
|
+
...node.attrs,
|
|
87
|
+
__expanded: isExpandedNext
|
|
88
|
+
}));
|
|
89
|
+
} else {
|
|
90
|
+
tr.setNodeMarkup(pos, node.type, {
|
|
91
|
+
...node.attrs,
|
|
92
|
+
__expanded: isExpandedNext
|
|
93
|
+
}, node.marks);
|
|
94
|
+
}
|
|
69
95
|
|
|
70
96
|
// If we're going to collapse the expand and our cursor is currently inside
|
|
71
97
|
// Move to a right gap cursor, if the toolbar is interacted (or an API),
|
|
72
98
|
// it will insert below rather than inside (which will be invisible).
|
|
73
|
-
if (isExpandedNext === false && findExpand(state)) {
|
|
99
|
+
if (getBooleanFF('platform.editor.live-pages-expand-divergence') && __livePage ? isExpandedNext === true : isExpandedNext === false && findExpand(state)) {
|
|
74
100
|
tr.setSelection(new GapCursorSelection(tr.doc.resolve(pos + node.nodeSize), Side.RIGHT));
|
|
75
101
|
}
|
|
76
102
|
|
|
@@ -82,13 +108,13 @@ export const toggleExpandExpanded = editorAnalyticsAPI => (pos, nodeType) => (st
|
|
|
82
108
|
attributes: {
|
|
83
109
|
platform: PLATFORMS.WEB,
|
|
84
110
|
mode: MODE.EDITOR,
|
|
85
|
-
expanded: isExpandedNext
|
|
111
|
+
expanded: getBooleanFF('platform.editor.live-pages-expand-divergence') && __livePage ? !isExpandedNext : isExpandedNext
|
|
86
112
|
},
|
|
87
113
|
eventType: EVENT_TYPE.TRACK
|
|
88
114
|
};
|
|
89
115
|
|
|
90
116
|
// `isRemote` meta prevents this step from being
|
|
91
|
-
// sync'd between sessions in collab edit
|
|
117
|
+
// sync'd between sessions in synchrony collab edit
|
|
92
118
|
tr.setMeta('isRemote', true);
|
|
93
119
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
94
120
|
dispatch(tr);
|
|
@@ -8,14 +8,15 @@ import { expandMessages } from '@atlaskit/editor-common/ui';
|
|
|
8
8
|
import { closestElement, isEmptyNode } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
10
10
|
import { NodeSelection, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
11
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
12
|
import { deleteExpandAtPos, setSelectionInsideExpand, toggleExpandExpanded, updateExpandTitle } from '../commands';
|
|
12
13
|
import { ExpandIconButton } from '../ui/ExpandIconButton';
|
|
13
14
|
function buildExpandClassName(type, expanded) {
|
|
14
15
|
return `${expandClassNames.prefix} ${expandClassNames.type(type)} ${expanded ? expandClassNames.expanded : ''}`;
|
|
15
16
|
}
|
|
16
|
-
const toDOM = (node, intl) => ['div', {
|
|
17
|
+
const toDOM = (node, __livePage, intl) => ['div', {
|
|
17
18
|
// prettier-ignore
|
|
18
|
-
'class': buildExpandClassName(node.type.name, node.attrs.__expanded),
|
|
19
|
+
'class': buildExpandClassName(node.type.name, getBooleanFF('platform.editor.live-pages-expand-divergence') && __livePage ? !node.attrs.__expanded : node.attrs.__expanded),
|
|
19
20
|
'data-node-type': node.type.name,
|
|
20
21
|
'data-title': node.attrs.title
|
|
21
22
|
}, ['div', {
|
|
@@ -45,7 +46,7 @@ const toDOM = (node, intl) => ['div', {
|
|
|
45
46
|
'class': expandClassNames.content
|
|
46
47
|
}, 0]];
|
|
47
48
|
export class ExpandNodeView {
|
|
48
|
-
constructor(node, view, getPos, getIntl, isMobile, selectNearNode, api, allowInteractiveExpand = true) {
|
|
49
|
+
constructor(node, view, getPos, getIntl, isMobile, selectNearNode, api, allowInteractiveExpand = true, __livePage = false) {
|
|
49
50
|
_defineProperty(this, "allowInteractiveExpand", true);
|
|
50
51
|
_defineProperty(this, "isMobile", false);
|
|
51
52
|
_defineProperty(this, "focusTitle", () => {
|
|
@@ -103,7 +104,12 @@ export class ExpandNodeView {
|
|
|
103
104
|
if (this.view.dom instanceof HTMLElement) {
|
|
104
105
|
this.view.dom.blur();
|
|
105
106
|
}
|
|
106
|
-
toggleExpandExpanded(
|
|
107
|
+
toggleExpandExpanded({
|
|
108
|
+
editorAnalyticsAPI: (_this$api = this.api) === null || _this$api === void 0 ? void 0 : (_this$api$analytics = _this$api.analytics) === null || _this$api$analytics === void 0 ? void 0 : _this$api$analytics.actions,
|
|
109
|
+
pos,
|
|
110
|
+
nodeType: this.node.type,
|
|
111
|
+
__livePage: this.__livePage
|
|
112
|
+
})(state, dispatch);
|
|
107
113
|
return;
|
|
108
114
|
}
|
|
109
115
|
if (target === this.input) {
|
|
@@ -124,7 +130,12 @@ export class ExpandNodeView {
|
|
|
124
130
|
state,
|
|
125
131
|
dispatch
|
|
126
132
|
} = this.view;
|
|
127
|
-
updateExpandTitle(
|
|
133
|
+
updateExpandTitle({
|
|
134
|
+
title: target.value,
|
|
135
|
+
pos,
|
|
136
|
+
nodeType: this.node.type,
|
|
137
|
+
__livePage: this.__livePage
|
|
138
|
+
})(state, dispatch);
|
|
128
139
|
}
|
|
129
140
|
});
|
|
130
141
|
_defineProperty(this, "handleFocus", event => {
|
|
@@ -188,7 +199,12 @@ export class ExpandNodeView {
|
|
|
188
199
|
state,
|
|
189
200
|
dispatch
|
|
190
201
|
} = this.view;
|
|
191
|
-
toggleExpandExpanded(
|
|
202
|
+
toggleExpandExpanded({
|
|
203
|
+
editorAnalyticsAPI: (_this$api3 = this.api) === null || _this$api3 === void 0 ? void 0 : (_this$api3$analytics = _this$api3.analytics) === null || _this$api3$analytics === void 0 ? void 0 : _this$api3$analytics.actions,
|
|
204
|
+
pos,
|
|
205
|
+
nodeType: this.node.type,
|
|
206
|
+
__livePage: this.__livePage
|
|
207
|
+
})(state, dispatch);
|
|
192
208
|
}
|
|
193
209
|
});
|
|
194
210
|
_defineProperty(this, "moveToOutsideOfTitle", event => {
|
|
@@ -221,6 +237,9 @@ export class ExpandNodeView {
|
|
|
221
237
|
}
|
|
222
238
|
});
|
|
223
239
|
_defineProperty(this, "isCollapsed", () => {
|
|
240
|
+
if (getBooleanFF('platform.editor.live-pages-expand-divergence') && this.__livePage) {
|
|
241
|
+
return this.node.attrs.__expanded;
|
|
242
|
+
}
|
|
224
243
|
return !this.node.attrs.__expanded;
|
|
225
244
|
});
|
|
226
245
|
_defineProperty(this, "setRightGapCursor", event => {
|
|
@@ -340,11 +359,12 @@ export class ExpandNodeView {
|
|
|
340
359
|
}
|
|
341
360
|
});
|
|
342
361
|
this.selectNearNode = selectNearNode;
|
|
362
|
+
this.__livePage = __livePage;
|
|
343
363
|
this.intl = getIntl();
|
|
344
364
|
const {
|
|
345
365
|
dom,
|
|
346
366
|
contentDOM
|
|
347
|
-
} = DOMSerializer.renderSpec(document, toDOM(node, this.intl));
|
|
367
|
+
} = DOMSerializer.renderSpec(document, toDOM(node, this.__livePage, this.intl));
|
|
348
368
|
this.allowInteractiveExpand = allowInteractiveExpand;
|
|
349
369
|
this.getPos = getPos;
|
|
350
370
|
this.view = view;
|
|
@@ -386,13 +406,13 @@ export class ExpandNodeView {
|
|
|
386
406
|
if (!this.icon) {
|
|
387
407
|
return;
|
|
388
408
|
}
|
|
389
|
-
|
|
409
|
+
let {
|
|
390
410
|
__expanded
|
|
391
411
|
} = node && node.attrs || this.node.attrs;
|
|
392
412
|
ReactDOM.render( /*#__PURE__*/React.createElement(ExpandIconButton, {
|
|
393
413
|
intl: intl,
|
|
394
414
|
allowInteractiveExpand: this.allowInteractiveExpand,
|
|
395
|
-
expanded: __expanded
|
|
415
|
+
expanded: getBooleanFF('platform.editor.live-pages-expand-divergence') && this.__livePage ? !__expanded : __expanded
|
|
396
416
|
}), this.icon);
|
|
397
417
|
}
|
|
398
418
|
stopEvent(event) {
|
|
@@ -421,7 +441,7 @@ export class ExpandNodeView {
|
|
|
421
441
|
}
|
|
422
442
|
if (this.content) {
|
|
423
443
|
// Disallow interaction/selection inside when collapsed.
|
|
424
|
-
this.content.setAttribute('contenteditable', node.attrs.__expanded);
|
|
444
|
+
this.content.setAttribute('contenteditable', getBooleanFF('platform.editor.live-pages-expand-divergence') && this.__livePage ? !node.attrs.__expanded : node.attrs.__expanded);
|
|
425
445
|
}
|
|
426
446
|
}
|
|
427
447
|
|
|
@@ -472,10 +492,11 @@ export default function ({
|
|
|
472
492
|
getIntl,
|
|
473
493
|
isMobile,
|
|
474
494
|
api,
|
|
475
|
-
allowInteractiveExpand = true
|
|
495
|
+
allowInteractiveExpand = true,
|
|
496
|
+
__livePage
|
|
476
497
|
}) {
|
|
477
498
|
return (node, view, getPos) => {
|
|
478
499
|
var _api$selection, _api$selection$action;
|
|
479
|
-
return new ExpandNodeView(node, view, getPos, getIntl, isMobile, api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : (_api$selection$action = _api$selection.actions) === null || _api$selection$action === void 0 ? void 0 : _api$selection$action.selectNearNode, api, allowInteractiveExpand);
|
|
500
|
+
return new ExpandNodeView(node, view, getPos, getIntl, isMobile, api === null || api === void 0 ? void 0 : (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : (_api$selection$action = _api$selection.actions) === null || _api$selection$action === void 0 ? void 0 : _api$selection$action.selectNearNode, api, allowInteractiveExpand, __livePage);
|
|
480
501
|
};
|
|
481
502
|
}
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -37,11 +37,13 @@ export const expandPlugin = ({
|
|
|
37
37
|
getIntl
|
|
38
38
|
}) => {
|
|
39
39
|
var _options$allowInterac;
|
|
40
|
-
return createPlugin(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true);
|
|
40
|
+
return createPlugin(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true, options.__livePage);
|
|
41
41
|
}
|
|
42
42
|
}, {
|
|
43
43
|
name: 'expandKeymap',
|
|
44
|
-
plugin: () => expandKeymap(api
|
|
44
|
+
plugin: () => expandKeymap(api, {
|
|
45
|
+
__livePage: options.__livePage
|
|
46
|
+
})
|
|
45
47
|
}];
|
|
46
48
|
},
|
|
47
49
|
pluginsOptions: {
|