@atlaskit/editor-plugin-expand 0.2.1 → 0.4.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/nodeviews/index.js +10 -11
- package/dist/cjs/plugin.js +3 -3
- package/dist/cjs/pm-plugins/main.js +6 -6
- package/dist/es2019/nodeviews/index.js +8 -11
- package/dist/es2019/plugin.js +3 -3
- package/dist/es2019/pm-plugins/main.js +5 -5
- package/dist/esm/nodeviews/index.js +10 -11
- package/dist/esm/plugin.js +3 -3
- package/dist/esm/pm-plugins/main.js +6 -6
- package/dist/types/index.d.ts +1 -2
- package/dist/types/nodeviews/index.d.ts +4 -6
- package/dist/types/plugin.d.ts +1 -22
- package/dist/types/pm-plugins/main.d.ts +2 -2
- package/dist/types/types.d.ts +6 -2
- package/dist/types-ts4.5/index.d.ts +1 -2
- package/dist/types-ts4.5/nodeviews/index.d.ts +4 -6
- package/dist/types-ts4.5/plugin.d.ts +1 -22
- package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +6 -2
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-expand
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#64335](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/64335) [`efc8826c907f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/efc8826c907f) - [ux] [ED-16509] Restart numbered list inserting nodes via QUICK INSERT, nodes including : panels, expands, decisions, tables, layout, quotes, actions, dividers, headings. Changes are being guarded behind feature flag platform.editor.ordered-list-inserting-nodes_bh0vo
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 0.3.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- [#62737](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/62737) [`2a6280e4e570`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2a6280e4e570) - Add new configuration option to expand plugin (`allowInteractiveExpand`) to configure the plugin. Previously the consumer would have to set the `interactiveExpand` feature flag in the expand plugin to configure this behaviour. It is also now set by default.
|
|
18
|
+
|
|
3
19
|
## 0.2.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -57,8 +57,9 @@ var toDOM = function toDOM(node, intl) {
|
|
|
57
57
|
}, 0]];
|
|
58
58
|
};
|
|
59
59
|
var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
60
|
-
function ExpandNodeView(node, view, getPos, getIntl, isMobile,
|
|
60
|
+
function ExpandNodeView(node, view, getPos, getIntl, isMobile, selectNearNode, api) {
|
|
61
61
|
var _this = this;
|
|
62
|
+
var allowInteractiveExpand = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : true;
|
|
62
63
|
(0, _classCallCheck2.default)(this, ExpandNodeView);
|
|
63
64
|
(0, _defineProperty2.default)(this, "allowInteractiveExpand", true);
|
|
64
65
|
(0, _defineProperty2.default)(this, "isMobile", false);
|
|
@@ -94,9 +95,6 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
94
95
|
break;
|
|
95
96
|
}
|
|
96
97
|
});
|
|
97
|
-
(0, _defineProperty2.default)(this, "isAllowInteractiveExpandEnabled", function () {
|
|
98
|
-
return _this.featureFlags && !!_this.featureFlags.interactiveExpand;
|
|
99
|
-
});
|
|
100
98
|
(0, _defineProperty2.default)(this, "handleClick", function (event) {
|
|
101
99
|
var pos = _this.getPos();
|
|
102
100
|
if (typeof pos !== 'number') {
|
|
@@ -108,7 +106,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
108
106
|
dispatch = _this$view2.dispatch;
|
|
109
107
|
if ((0, _utils.closestElement)(target, ".".concat(_styles.expandClassNames.icon))) {
|
|
110
108
|
var _this$api;
|
|
111
|
-
if (!_this.
|
|
109
|
+
if (!_this.allowInteractiveExpand) {
|
|
112
110
|
return;
|
|
113
111
|
}
|
|
114
112
|
event.stopPropagation();
|
|
@@ -193,7 +191,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
193
191
|
if (typeof pos !== 'number') {
|
|
194
192
|
return;
|
|
195
193
|
}
|
|
196
|
-
if (_this.
|
|
194
|
+
if (_this.allowInteractiveExpand) {
|
|
197
195
|
var _this$api3;
|
|
198
196
|
var _this$view4 = _this.view,
|
|
199
197
|
state = _this$view4.state,
|
|
@@ -345,13 +343,13 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
345
343
|
var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM(node, this.intl)),
|
|
346
344
|
dom = _DOMSerializer$render.dom,
|
|
347
345
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
346
|
+
this.allowInteractiveExpand = allowInteractiveExpand;
|
|
348
347
|
this.getPos = getPos;
|
|
349
348
|
this.view = view;
|
|
350
349
|
this.node = node;
|
|
351
350
|
this.dom = dom;
|
|
352
351
|
this.contentDOM = contentDOM;
|
|
353
352
|
this.isMobile = isMobile;
|
|
354
|
-
this.featureFlags = featureFlags;
|
|
355
353
|
this.api = api;
|
|
356
354
|
this.icon = this.dom.querySelector(".".concat(_styles.expandClassNames.icon));
|
|
357
355
|
this.input = this.dom.querySelector(".".concat(_styles.expandClassNames.titleInput));
|
|
@@ -394,7 +392,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
394
392
|
__expanded = _ref.__expanded;
|
|
395
393
|
_reactDom.default.render( /*#__PURE__*/_react.default.createElement(_ExpandIconButton.ExpandIconButton, {
|
|
396
394
|
intl: intl,
|
|
397
|
-
allowInteractiveExpand: this.
|
|
395
|
+
allowInteractiveExpand: this.allowInteractiveExpand,
|
|
398
396
|
expanded: __expanded
|
|
399
397
|
}), this.icon);
|
|
400
398
|
}
|
|
@@ -485,10 +483,11 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
485
483
|
function _default(_ref2) {
|
|
486
484
|
var getIntl = _ref2.getIntl,
|
|
487
485
|
isMobile = _ref2.isMobile,
|
|
488
|
-
|
|
489
|
-
|
|
486
|
+
api = _ref2.api,
|
|
487
|
+
_ref2$allowInteractiv = _ref2.allowInteractiveExpand,
|
|
488
|
+
allowInteractiveExpand = _ref2$allowInteractiv === void 0 ? true : _ref2$allowInteractiv;
|
|
490
489
|
return function (node, view, getPos) {
|
|
491
490
|
var _api$selection;
|
|
492
|
-
return new ExpandNodeView(node, view, getPos, getIntl, isMobile,
|
|
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);
|
|
493
492
|
};
|
|
494
493
|
}
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -23,11 +23,10 @@ var _main = require("./pm-plugins/main");
|
|
|
23
23
|
var _toolbar = require("./toolbar");
|
|
24
24
|
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
25
25
|
var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
|
|
26
|
-
var _api$
|
|
26
|
+
var _api$analytics;
|
|
27
27
|
var _ref$config = _ref.config,
|
|
28
28
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
29
29
|
api = _ref.api;
|
|
30
|
-
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
31
30
|
return {
|
|
32
31
|
name: 'expand',
|
|
33
32
|
nodes: function nodes() {
|
|
@@ -46,9 +45,10 @@ var expandPlugin = exports.expandPlugin = function expandPlugin(_ref) {
|
|
|
46
45
|
return [{
|
|
47
46
|
name: 'expand',
|
|
48
47
|
plugin: function plugin(_ref2) {
|
|
48
|
+
var _options$allowInterac;
|
|
49
49
|
var dispatch = _ref2.dispatch,
|
|
50
50
|
getIntl = _ref2.getIntl;
|
|
51
|
-
return (0, _main.createPlugin)(dispatch, getIntl, options.appearance, options.useLongPressSelection,
|
|
51
|
+
return (0, _main.createPlugin)(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true);
|
|
52
52
|
}
|
|
53
53
|
}, {
|
|
54
54
|
name: 'expandKeymap',
|
|
@@ -21,8 +21,8 @@ function containsClass(element, className) {
|
|
|
21
21
|
var createPlugin = exports.createPlugin = function createPlugin(dispatch, getIntl) {
|
|
22
22
|
var appearance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'full-page';
|
|
23
23
|
var useLongPressSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
24
|
-
var
|
|
25
|
-
var
|
|
24
|
+
var api = arguments.length > 4 ? arguments[4] : undefined;
|
|
25
|
+
var allowInteractiveExpand = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
26
26
|
var state = (0, _pluginFactory.createPluginState)(dispatch, {});
|
|
27
27
|
var isMobile = appearance === 'mobile';
|
|
28
28
|
return new _safePlugin.SafePlugin({
|
|
@@ -33,14 +33,14 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, getInt
|
|
|
33
33
|
expand: (0, _nodeviews.default)({
|
|
34
34
|
getIntl: getIntl,
|
|
35
35
|
isMobile: isMobile,
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
api: api,
|
|
37
|
+
allowInteractiveExpand: allowInteractiveExpand
|
|
38
38
|
}),
|
|
39
39
|
nestedExpand: (0, _nodeviews.default)({
|
|
40
40
|
getIntl: getIntl,
|
|
41
41
|
isMobile: isMobile,
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
api: api,
|
|
43
|
+
allowInteractiveExpand: allowInteractiveExpand
|
|
44
44
|
})
|
|
45
45
|
},
|
|
46
46
|
handleKeyDown: function handleKeyDown(_view, event) {
|
|
@@ -45,7 +45,7 @@ const toDOM = (node, intl) => ['div', {
|
|
|
45
45
|
'class': expandClassNames.content
|
|
46
46
|
}, 0]];
|
|
47
47
|
export class ExpandNodeView {
|
|
48
|
-
constructor(node, view, getPos, getIntl, isMobile,
|
|
48
|
+
constructor(node, view, getPos, getIntl, isMobile, selectNearNode, api, allowInteractiveExpand = true) {
|
|
49
49
|
_defineProperty(this, "allowInteractiveExpand", true);
|
|
50
50
|
_defineProperty(this, "isMobile", false);
|
|
51
51
|
_defineProperty(this, "focusTitle", () => {
|
|
@@ -81,9 +81,6 @@ export class ExpandNodeView {
|
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
|
-
_defineProperty(this, "isAllowInteractiveExpandEnabled", () => {
|
|
85
|
-
return this.featureFlags && !!this.featureFlags.interactiveExpand;
|
|
86
|
-
});
|
|
87
84
|
_defineProperty(this, "handleClick", event => {
|
|
88
85
|
const pos = this.getPos();
|
|
89
86
|
if (typeof pos !== 'number') {
|
|
@@ -96,7 +93,7 @@ export class ExpandNodeView {
|
|
|
96
93
|
} = this.view;
|
|
97
94
|
if (closestElement(target, `.${expandClassNames.icon}`)) {
|
|
98
95
|
var _this$api, _this$api$analytics;
|
|
99
|
-
if (!this.
|
|
96
|
+
if (!this.allowInteractiveExpand) {
|
|
100
97
|
return;
|
|
101
98
|
}
|
|
102
99
|
event.stopPropagation();
|
|
@@ -185,7 +182,7 @@ export class ExpandNodeView {
|
|
|
185
182
|
if (typeof pos !== 'number') {
|
|
186
183
|
return;
|
|
187
184
|
}
|
|
188
|
-
if (this.
|
|
185
|
+
if (this.allowInteractiveExpand) {
|
|
189
186
|
var _this$api3, _this$api3$analytics;
|
|
190
187
|
const {
|
|
191
188
|
state,
|
|
@@ -348,13 +345,13 @@ export class ExpandNodeView {
|
|
|
348
345
|
dom,
|
|
349
346
|
contentDOM
|
|
350
347
|
} = DOMSerializer.renderSpec(document, toDOM(node, this.intl));
|
|
348
|
+
this.allowInteractiveExpand = allowInteractiveExpand;
|
|
351
349
|
this.getPos = getPos;
|
|
352
350
|
this.view = view;
|
|
353
351
|
this.node = node;
|
|
354
352
|
this.dom = dom;
|
|
355
353
|
this.contentDOM = contentDOM;
|
|
356
354
|
this.isMobile = isMobile;
|
|
357
|
-
this.featureFlags = featureFlags;
|
|
358
355
|
this.api = api;
|
|
359
356
|
this.icon = this.dom.querySelector(`.${expandClassNames.icon}`);
|
|
360
357
|
this.input = this.dom.querySelector(`.${expandClassNames.titleInput}`);
|
|
@@ -394,7 +391,7 @@ export class ExpandNodeView {
|
|
|
394
391
|
} = node && node.attrs || this.node.attrs;
|
|
395
392
|
ReactDOM.render( /*#__PURE__*/React.createElement(ExpandIconButton, {
|
|
396
393
|
intl: intl,
|
|
397
|
-
allowInteractiveExpand: this.
|
|
394
|
+
allowInteractiveExpand: this.allowInteractiveExpand,
|
|
398
395
|
expanded: __expanded
|
|
399
396
|
}), this.icon);
|
|
400
397
|
}
|
|
@@ -474,11 +471,11 @@ export class ExpandNodeView {
|
|
|
474
471
|
export default function ({
|
|
475
472
|
getIntl,
|
|
476
473
|
isMobile,
|
|
477
|
-
|
|
478
|
-
|
|
474
|
+
api,
|
|
475
|
+
allowInteractiveExpand = true
|
|
479
476
|
}) {
|
|
480
477
|
return (node, view, getPos) => {
|
|
481
478
|
var _api$selection, _api$selection$action;
|
|
482
|
-
return new ExpandNodeView(node, view, getPos, getIntl, isMobile,
|
|
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);
|
|
483
480
|
};
|
|
484
481
|
}
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -12,8 +12,7 @@ export const expandPlugin = ({
|
|
|
12
12
|
config: options = {},
|
|
13
13
|
api
|
|
14
14
|
}) => {
|
|
15
|
-
var _api$
|
|
16
|
-
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
15
|
+
var _api$analytics;
|
|
17
16
|
return {
|
|
18
17
|
name: 'expand',
|
|
19
18
|
nodes() {
|
|
@@ -35,7 +34,8 @@ export const expandPlugin = ({
|
|
|
35
34
|
dispatch,
|
|
36
35
|
getIntl
|
|
37
36
|
}) => {
|
|
38
|
-
|
|
37
|
+
var _options$allowInterac;
|
|
38
|
+
return createPlugin(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true);
|
|
39
39
|
}
|
|
40
40
|
}, {
|
|
41
41
|
name: 'expandKeymap',
|
|
@@ -10,7 +10,7 @@ export function containsClass(element, className) {
|
|
|
10
10
|
var _element$classList;
|
|
11
11
|
return Boolean(element === null || element === void 0 ? void 0 : (_element$classList = element.classList) === null || _element$classList === void 0 ? void 0 : _element$classList.contains(className));
|
|
12
12
|
}
|
|
13
|
-
export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLongPressSelection = false,
|
|
13
|
+
export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLongPressSelection = false, api, allowInteractiveExpand = true) => {
|
|
14
14
|
const state = createPluginState(dispatch, {});
|
|
15
15
|
const isMobile = appearance === 'mobile';
|
|
16
16
|
return new SafePlugin({
|
|
@@ -21,14 +21,14 @@ export const createPlugin = (dispatch, getIntl, appearance = 'full-page', useLon
|
|
|
21
21
|
expand: ExpandNodeView({
|
|
22
22
|
getIntl,
|
|
23
23
|
isMobile,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
api,
|
|
25
|
+
allowInteractiveExpand
|
|
26
26
|
}),
|
|
27
27
|
nestedExpand: ExpandNodeView({
|
|
28
28
|
getIntl,
|
|
29
29
|
isMobile,
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
api,
|
|
31
|
+
allowInteractiveExpand
|
|
32
32
|
})
|
|
33
33
|
},
|
|
34
34
|
handleKeyDown(_view, event) {
|
|
@@ -49,8 +49,9 @@ var toDOM = function toDOM(node, intl) {
|
|
|
49
49
|
}, 0]];
|
|
50
50
|
};
|
|
51
51
|
export var ExpandNodeView = /*#__PURE__*/function () {
|
|
52
|
-
function ExpandNodeView(node, view, getPos, getIntl, isMobile,
|
|
52
|
+
function ExpandNodeView(node, view, getPos, getIntl, isMobile, selectNearNode, api) {
|
|
53
53
|
var _this = this;
|
|
54
|
+
var allowInteractiveExpand = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : true;
|
|
54
55
|
_classCallCheck(this, ExpandNodeView);
|
|
55
56
|
_defineProperty(this, "allowInteractiveExpand", true);
|
|
56
57
|
_defineProperty(this, "isMobile", false);
|
|
@@ -86,9 +87,6 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
86
87
|
break;
|
|
87
88
|
}
|
|
88
89
|
});
|
|
89
|
-
_defineProperty(this, "isAllowInteractiveExpandEnabled", function () {
|
|
90
|
-
return _this.featureFlags && !!_this.featureFlags.interactiveExpand;
|
|
91
|
-
});
|
|
92
90
|
_defineProperty(this, "handleClick", function (event) {
|
|
93
91
|
var pos = _this.getPos();
|
|
94
92
|
if (typeof pos !== 'number') {
|
|
@@ -100,7 +98,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
100
98
|
dispatch = _this$view2.dispatch;
|
|
101
99
|
if (closestElement(target, ".".concat(expandClassNames.icon))) {
|
|
102
100
|
var _this$api;
|
|
103
|
-
if (!_this.
|
|
101
|
+
if (!_this.allowInteractiveExpand) {
|
|
104
102
|
return;
|
|
105
103
|
}
|
|
106
104
|
event.stopPropagation();
|
|
@@ -185,7 +183,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
185
183
|
if (typeof pos !== 'number') {
|
|
186
184
|
return;
|
|
187
185
|
}
|
|
188
|
-
if (_this.
|
|
186
|
+
if (_this.allowInteractiveExpand) {
|
|
189
187
|
var _this$api3;
|
|
190
188
|
var _this$view4 = _this.view,
|
|
191
189
|
state = _this$view4.state,
|
|
@@ -337,13 +335,13 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
337
335
|
var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(node, this.intl)),
|
|
338
336
|
dom = _DOMSerializer$render.dom,
|
|
339
337
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
338
|
+
this.allowInteractiveExpand = allowInteractiveExpand;
|
|
340
339
|
this.getPos = getPos;
|
|
341
340
|
this.view = view;
|
|
342
341
|
this.node = node;
|
|
343
342
|
this.dom = dom;
|
|
344
343
|
this.contentDOM = contentDOM;
|
|
345
344
|
this.isMobile = isMobile;
|
|
346
|
-
this.featureFlags = featureFlags;
|
|
347
345
|
this.api = api;
|
|
348
346
|
this.icon = this.dom.querySelector(".".concat(expandClassNames.icon));
|
|
349
347
|
this.input = this.dom.querySelector(".".concat(expandClassNames.titleInput));
|
|
@@ -386,7 +384,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
386
384
|
__expanded = _ref.__expanded;
|
|
387
385
|
ReactDOM.render( /*#__PURE__*/React.createElement(ExpandIconButton, {
|
|
388
386
|
intl: intl,
|
|
389
|
-
allowInteractiveExpand: this.
|
|
387
|
+
allowInteractiveExpand: this.allowInteractiveExpand,
|
|
390
388
|
expanded: __expanded
|
|
391
389
|
}), this.icon);
|
|
392
390
|
}
|
|
@@ -477,10 +475,11 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
477
475
|
export default function (_ref2) {
|
|
478
476
|
var getIntl = _ref2.getIntl,
|
|
479
477
|
isMobile = _ref2.isMobile,
|
|
480
|
-
|
|
481
|
-
|
|
478
|
+
api = _ref2.api,
|
|
479
|
+
_ref2$allowInteractiv = _ref2.allowInteractiveExpand,
|
|
480
|
+
allowInteractiveExpand = _ref2$allowInteractiv === void 0 ? true : _ref2$allowInteractiv;
|
|
482
481
|
return function (node, view, getPos) {
|
|
483
482
|
var _api$selection;
|
|
484
|
-
return new ExpandNodeView(node, view, getPos, getIntl, isMobile,
|
|
483
|
+
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);
|
|
485
484
|
};
|
|
486
485
|
}
|
package/dist/esm/plugin.js
CHANGED
|
@@ -9,11 +9,10 @@ import { expandKeymap } from './pm-plugins/keymap';
|
|
|
9
9
|
import { createPlugin } from './pm-plugins/main';
|
|
10
10
|
import { getToolbarConfig } from './toolbar';
|
|
11
11
|
export var expandPlugin = function expandPlugin(_ref) {
|
|
12
|
-
var _api$
|
|
12
|
+
var _api$analytics;
|
|
13
13
|
var _ref$config = _ref.config,
|
|
14
14
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
15
15
|
api = _ref.api;
|
|
16
|
-
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
17
16
|
return {
|
|
18
17
|
name: 'expand',
|
|
19
18
|
nodes: function nodes() {
|
|
@@ -32,9 +31,10 @@ export var expandPlugin = function expandPlugin(_ref) {
|
|
|
32
31
|
return [{
|
|
33
32
|
name: 'expand',
|
|
34
33
|
plugin: function plugin(_ref2) {
|
|
34
|
+
var _options$allowInterac;
|
|
35
35
|
var dispatch = _ref2.dispatch,
|
|
36
36
|
getIntl = _ref2.getIntl;
|
|
37
|
-
return createPlugin(dispatch, getIntl, options.appearance, options.useLongPressSelection,
|
|
37
|
+
return createPlugin(dispatch, getIntl, options.appearance, options.useLongPressSelection, api, (_options$allowInterac = options.allowInteractiveExpand) !== null && _options$allowInterac !== void 0 ? _options$allowInterac : true);
|
|
38
38
|
}
|
|
39
39
|
}, {
|
|
40
40
|
name: 'expandKeymap',
|
|
@@ -13,8 +13,8 @@ export function containsClass(element, className) {
|
|
|
13
13
|
export var createPlugin = function createPlugin(dispatch, getIntl) {
|
|
14
14
|
var appearance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'full-page';
|
|
15
15
|
var useLongPressSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
16
|
-
var
|
|
17
|
-
var
|
|
16
|
+
var api = arguments.length > 4 ? arguments[4] : undefined;
|
|
17
|
+
var allowInteractiveExpand = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
|
18
18
|
var state = createPluginState(dispatch, {});
|
|
19
19
|
var isMobile = appearance === 'mobile';
|
|
20
20
|
return new SafePlugin({
|
|
@@ -25,14 +25,14 @@ export var createPlugin = function createPlugin(dispatch, getIntl) {
|
|
|
25
25
|
expand: ExpandNodeView({
|
|
26
26
|
getIntl: getIntl,
|
|
27
27
|
isMobile: isMobile,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
api: api,
|
|
29
|
+
allowInteractiveExpand: allowInteractiveExpand
|
|
30
30
|
}),
|
|
31
31
|
nestedExpand: ExpandNodeView({
|
|
32
32
|
getIntl: getIntl,
|
|
33
33
|
isMobile: isMobile,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
api: api,
|
|
35
|
+
allowInteractiveExpand: allowInteractiveExpand
|
|
36
36
|
})
|
|
37
37
|
},
|
|
38
38
|
handleKeyDown: function handleKeyDown(_view, event) {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { SetSelectionRelativeToNode } from '@atlaskit/editor-common/selection';
|
|
3
|
-
import type { ExtractInjectionAPI
|
|
3
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { getPosHandler, getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
5
5
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import type { Decoration, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -19,14 +19,12 @@ export declare class ExpandNodeView implements NodeView {
|
|
|
19
19
|
intl: IntlShape;
|
|
20
20
|
allowInteractiveExpand: boolean;
|
|
21
21
|
isMobile: boolean;
|
|
22
|
-
featureFlags: FeatureFlags;
|
|
23
22
|
api: ExtractInjectionAPI<ExpandPlugin> | undefined;
|
|
24
|
-
constructor(node: PmNode, view: EditorView, getPos: getPosHandlerNode, getIntl: () => IntlShape, isMobile: boolean,
|
|
23
|
+
constructor(node: PmNode, view: EditorView, getPos: getPosHandlerNode, getIntl: () => IntlShape, isMobile: boolean, selectNearNode: SetSelectionRelativeToNode | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean);
|
|
25
24
|
private initHandlers;
|
|
26
25
|
private focusTitle;
|
|
27
26
|
private handleIconKeyDown;
|
|
28
27
|
private renderIcon;
|
|
29
|
-
private isAllowInteractiveExpandEnabled;
|
|
30
28
|
private handleClick;
|
|
31
29
|
private handleInput;
|
|
32
30
|
private handleFocus;
|
|
@@ -47,9 +45,9 @@ export declare class ExpandNodeView implements NodeView {
|
|
|
47
45
|
update(node: PmNode, _decorations: readonly Decoration[]): boolean;
|
|
48
46
|
destroy(): void;
|
|
49
47
|
}
|
|
50
|
-
export default function ({ getIntl, isMobile,
|
|
48
|
+
export default function ({ getIntl, isMobile, api, allowInteractiveExpand, }: {
|
|
51
49
|
getIntl: () => IntlShape;
|
|
52
50
|
isMobile: boolean;
|
|
53
|
-
featureFlags: FeatureFlags;
|
|
54
51
|
api: ExtractInjectionAPI<ExpandPlugin> | undefined;
|
|
52
|
+
allowInteractiveExpand: boolean;
|
|
55
53
|
}): (node: PmNode, view: EditorView, getPos: getPosHandler) => NodeView;
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
-
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
4
|
-
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
5
|
-
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
6
|
-
import { insertExpand } from './commands';
|
|
7
|
-
interface ExpandPluginOptions extends LongPressSelectionPluginOptions {
|
|
8
|
-
allowInsertion?: boolean;
|
|
9
|
-
appearance?: EditorAppearance;
|
|
10
|
-
}
|
|
11
|
-
export type ExpandPlugin = NextEditorPlugin<'expand', {
|
|
12
|
-
pluginConfiguration: ExpandPluginOptions | undefined;
|
|
13
|
-
dependencies: [
|
|
14
|
-
OptionalPlugin<FeatureFlagsPlugin>,
|
|
15
|
-
DecorationsPlugin,
|
|
16
|
-
SelectionPlugin,
|
|
17
|
-
OptionalPlugin<AnalyticsPlugin>
|
|
18
|
-
];
|
|
19
|
-
actions: {
|
|
20
|
-
insertExpand: ReturnType<typeof insertExpand>;
|
|
21
|
-
};
|
|
22
|
-
}>;
|
|
1
|
+
import type { ExpandPlugin } from './types';
|
|
23
2
|
export declare const expandPlugin: ExpandPlugin;
|
|
24
3
|
export { pluginKey } from './pm-plugins/plugin-factory';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
-
import type { EditorAppearance, ExtractInjectionAPI
|
|
4
|
+
import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
5
|
import type { ExpandPlugin } from '../types';
|
|
6
6
|
export declare function containsClass(element: Element | null, className: string): boolean;
|
|
7
|
-
export declare const createPlugin: (dispatch: Dispatch, getIntl: () => IntlShape, appearance: EditorAppearance | undefined, useLongPressSelection: boolean | undefined,
|
|
7
|
+
export declare const createPlugin: (dispatch: Dispatch, getIntl: () => IntlShape, appearance: EditorAppearance | undefined, useLongPressSelection: boolean | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean) => SafePlugin<import("../types").ExpandPluginState>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { EditorAppearance, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
3
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
4
|
-
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
5
4
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
6
5
|
import type { insertExpand } from './commands';
|
|
7
6
|
export interface ExpandPluginState {
|
|
@@ -15,12 +14,17 @@ export type ExpandPluginAction = {
|
|
|
15
14
|
};
|
|
16
15
|
export interface ExpandPluginOptions extends LongPressSelectionPluginOptions {
|
|
17
16
|
allowInsertion?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Allows the expand button to toggle. Previously this was set via the editor prop featureFlag (`interactiveExpand`)
|
|
19
|
+
*
|
|
20
|
+
* Defaults to true
|
|
21
|
+
*/
|
|
22
|
+
allowInteractiveExpand?: boolean;
|
|
18
23
|
appearance?: EditorAppearance;
|
|
19
24
|
}
|
|
20
25
|
export type ExpandPlugin = NextEditorPlugin<'expand', {
|
|
21
26
|
pluginConfiguration: ExpandPluginOptions | undefined;
|
|
22
27
|
dependencies: [
|
|
23
|
-
OptionalPlugin<FeatureFlagsPlugin>,
|
|
24
28
|
DecorationsPlugin,
|
|
25
29
|
SelectionPlugin,
|
|
26
30
|
OptionalPlugin<AnalyticsPlugin>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { SetSelectionRelativeToNode } from '@atlaskit/editor-common/selection';
|
|
3
|
-
import type { ExtractInjectionAPI
|
|
3
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { getPosHandler, getPosHandlerNode } from '@atlaskit/editor-common/types';
|
|
5
5
|
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import type { Decoration, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
@@ -19,14 +19,12 @@ export declare class ExpandNodeView implements NodeView {
|
|
|
19
19
|
intl: IntlShape;
|
|
20
20
|
allowInteractiveExpand: boolean;
|
|
21
21
|
isMobile: boolean;
|
|
22
|
-
featureFlags: FeatureFlags;
|
|
23
22
|
api: ExtractInjectionAPI<ExpandPlugin> | undefined;
|
|
24
|
-
constructor(node: PmNode, view: EditorView, getPos: getPosHandlerNode, getIntl: () => IntlShape, isMobile: boolean,
|
|
23
|
+
constructor(node: PmNode, view: EditorView, getPos: getPosHandlerNode, getIntl: () => IntlShape, isMobile: boolean, selectNearNode: SetSelectionRelativeToNode | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean);
|
|
25
24
|
private initHandlers;
|
|
26
25
|
private focusTitle;
|
|
27
26
|
private handleIconKeyDown;
|
|
28
27
|
private renderIcon;
|
|
29
|
-
private isAllowInteractiveExpandEnabled;
|
|
30
28
|
private handleClick;
|
|
31
29
|
private handleInput;
|
|
32
30
|
private handleFocus;
|
|
@@ -47,9 +45,9 @@ export declare class ExpandNodeView implements NodeView {
|
|
|
47
45
|
update(node: PmNode, _decorations: readonly Decoration[]): boolean;
|
|
48
46
|
destroy(): void;
|
|
49
47
|
}
|
|
50
|
-
export default function ({ getIntl, isMobile,
|
|
48
|
+
export default function ({ getIntl, isMobile, api, allowInteractiveExpand, }: {
|
|
51
49
|
getIntl: () => IntlShape;
|
|
52
50
|
isMobile: boolean;
|
|
53
|
-
featureFlags: FeatureFlags;
|
|
54
51
|
api: ExtractInjectionAPI<ExpandPlugin> | undefined;
|
|
52
|
+
allowInteractiveExpand: boolean;
|
|
55
53
|
}): (node: PmNode, view: EditorView, getPos: getPosHandler) => NodeView;
|
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
-
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
4
|
-
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
5
|
-
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
6
|
-
import { insertExpand } from './commands';
|
|
7
|
-
interface ExpandPluginOptions extends LongPressSelectionPluginOptions {
|
|
8
|
-
allowInsertion?: boolean;
|
|
9
|
-
appearance?: EditorAppearance;
|
|
10
|
-
}
|
|
11
|
-
export type ExpandPlugin = NextEditorPlugin<'expand', {
|
|
12
|
-
pluginConfiguration: ExpandPluginOptions | undefined;
|
|
13
|
-
dependencies: [
|
|
14
|
-
OptionalPlugin<FeatureFlagsPlugin>,
|
|
15
|
-
DecorationsPlugin,
|
|
16
|
-
SelectionPlugin,
|
|
17
|
-
OptionalPlugin<AnalyticsPlugin>
|
|
18
|
-
];
|
|
19
|
-
actions: {
|
|
20
|
-
insertExpand: ReturnType<typeof insertExpand>;
|
|
21
|
-
};
|
|
22
|
-
}>;
|
|
1
|
+
import type { ExpandPlugin } from './types';
|
|
23
2
|
export declare const expandPlugin: ExpandPlugin;
|
|
24
3
|
export { pluginKey } from './pm-plugins/plugin-factory';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
-
import type { EditorAppearance, ExtractInjectionAPI
|
|
4
|
+
import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
5
|
import type { ExpandPlugin } from '../types';
|
|
6
6
|
export declare function containsClass(element: Element | null, className: string): boolean;
|
|
7
|
-
export declare const createPlugin: (dispatch: Dispatch, getIntl: () => IntlShape, appearance: EditorAppearance | undefined, useLongPressSelection: boolean | undefined,
|
|
7
|
+
export declare const createPlugin: (dispatch: Dispatch, getIntl: () => IntlShape, appearance: EditorAppearance | undefined, useLongPressSelection: boolean | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean) => SafePlugin<import("../types").ExpandPluginState>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { EditorAppearance, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
3
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
4
|
-
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
5
4
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
6
5
|
import type { insertExpand } from './commands';
|
|
7
6
|
export interface ExpandPluginState {
|
|
@@ -15,12 +14,17 @@ export type ExpandPluginAction = {
|
|
|
15
14
|
};
|
|
16
15
|
export interface ExpandPluginOptions extends LongPressSelectionPluginOptions {
|
|
17
16
|
allowInsertion?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Allows the expand button to toggle. Previously this was set via the editor prop featureFlag (`interactiveExpand`)
|
|
19
|
+
*
|
|
20
|
+
* Defaults to true
|
|
21
|
+
*/
|
|
22
|
+
allowInteractiveExpand?: boolean;
|
|
18
23
|
appearance?: EditorAppearance;
|
|
19
24
|
}
|
|
20
25
|
export type ExpandPlugin = NextEditorPlugin<'expand', {
|
|
21
26
|
pluginConfiguration: ExpandPluginOptions | undefined;
|
|
22
27
|
dependencies: [
|
|
23
|
-
OptionalPlugin<FeatureFlagsPlugin>,
|
|
24
28
|
DecorationsPlugin,
|
|
25
29
|
SelectionPlugin,
|
|
26
30
|
OptionalPlugin<AnalyticsPlugin>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-expand",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Expand plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"atlassian": {
|
|
11
11
|
"team": "Editor: Jenga",
|
|
12
12
|
"inPublicMirror": false,
|
|
13
|
-
"releaseModel": "continuous"
|
|
13
|
+
"releaseModel": "continuous",
|
|
14
|
+
"runReact18": false
|
|
14
15
|
},
|
|
15
16
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
16
17
|
"main": "dist/cjs/index.js",
|
|
@@ -32,17 +33,16 @@
|
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@atlaskit/adf-schema": "^35.2.0",
|
|
35
|
-
"@atlaskit/button": "^17.
|
|
36
|
-
"@atlaskit/editor-common": "^76.
|
|
36
|
+
"@atlaskit/button": "^17.2.0",
|
|
37
|
+
"@atlaskit/editor-common": "^76.34.0",
|
|
37
38
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
38
39
|
"@atlaskit/editor-plugin-decorations": "^0.2.0",
|
|
39
|
-
"@atlaskit/editor-plugin-feature-flags": "^1.0.1",
|
|
40
40
|
"@atlaskit/editor-plugin-selection": "^0.1.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
42
|
-
"@atlaskit/editor-shared-styles": "^2.
|
|
42
|
+
"@atlaskit/editor-shared-styles": "^2.9.0",
|
|
43
43
|
"@atlaskit/editor-tables": "^2.3.0",
|
|
44
44
|
"@atlaskit/icon": "^22.0.0",
|
|
45
|
-
"@atlaskit/tooltip": "^18.
|
|
45
|
+
"@atlaskit/tooltip": "^18.1.0",
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
47
47
|
"@emotion/react": "^11.7.1",
|
|
48
48
|
"w3c-keyname": "^2.1.0"
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.0",
|
|
58
58
|
"@atlaskit/editor-plugin-guideline": "^0.5.0",
|
|
59
59
|
"@atlaskit/editor-plugin-quick-insert": "^0.2.0",
|
|
60
|
-
"@atlaskit/editor-plugin-table": "^5.
|
|
61
|
-
"@atlaskit/editor-plugin-type-ahead": "^0.
|
|
60
|
+
"@atlaskit/editor-plugin-table": "^5.7.0",
|
|
61
|
+
"@atlaskit/editor-plugin-type-ahead": "^0.9.0",
|
|
62
62
|
"@atlaskit/editor-plugin-width": "^0.2.0",
|
|
63
63
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
64
64
|
"@testing-library/react": "^12.1.5",
|