@atlaskit/editor-plugin-expand 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/legacyExpand/nodeviews/index.js +47 -14
- package/dist/es2019/legacyExpand/nodeviews/index.js +41 -10
- package/dist/esm/legacyExpand/nodeviews/index.js +47 -14
- package/dist/types/legacyExpand/nodeviews/index.d.ts +3 -1
- package/dist/types/types.d.ts +3 -1
- package/dist/types-ts4.5/legacyExpand/nodeviews/index.d.ts +3 -1
- package/dist/types-ts4.5/types.d.ts +3 -1
- package/package.json +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-expand
|
|
2
2
|
|
|
3
|
+
## 1.5.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#91461](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91461) [`1b353cb06cc8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1b353cb06cc8) - [ED-23042] Disable editing in code blocks and expand nodes when editorDisabled state is true
|
|
8
|
+
|
|
9
|
+
## 1.5.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#92426](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92426) [`32c76c7c225c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/32c76c7c225c) - Bump adf-schema to 35.9.2 to support table alignment options
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 1.5.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
@@ -24,7 +24,7 @@ var _ExpandIconButton = require("../ui/ExpandIconButton");
|
|
|
24
24
|
function buildExpandClassName(type, expanded) {
|
|
25
25
|
return "".concat(_styles.expandClassNames.prefix, " ").concat(_styles.expandClassNames.type(type), " ").concat(expanded ? _styles.expandClassNames.expanded : '');
|
|
26
26
|
}
|
|
27
|
-
var toDOM = function toDOM(node, __livePage, intl) {
|
|
27
|
+
var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditable) {
|
|
28
28
|
return ['div', {
|
|
29
29
|
// prettier-ignore
|
|
30
30
|
'class': buildExpandClassName(node.type.name, (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && __livePage ? !node.attrs.__expanded : node.attrs.__expanded),
|
|
@@ -50,18 +50,21 @@ var toDOM = function toDOM(node, __livePage, intl) {
|
|
|
50
50
|
'class': _styles.expandClassNames.titleInput,
|
|
51
51
|
value: node.attrs.title,
|
|
52
52
|
placeholder: intl && intl.formatMessage(_ui.expandMessages.expandPlaceholderText) || _ui.expandMessages.expandPlaceholderText.defaultMessage,
|
|
53
|
-
type: 'text'
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
type: 'text',
|
|
54
|
+
readonly: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && titleReadOnly ? 'true' : undefined
|
|
55
|
+
}]]], ['div', {
|
|
56
|
+
// prettier-ignore
|
|
57
|
+
class: _styles.expandClassNames.content,
|
|
58
|
+
contenteditable: (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && contentEditable ? contentEditable ? 'true' : 'false' : undefined
|
|
58
59
|
}, 0]];
|
|
59
60
|
};
|
|
60
61
|
var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
61
|
-
function ExpandNodeView(
|
|
62
|
-
var _this = this
|
|
62
|
+
function ExpandNodeView(_node, view, getPos, getIntl, isMobile, selectNearNode, api) {
|
|
63
|
+
var _this = this,
|
|
64
|
+
_api$editorDisabled;
|
|
63
65
|
var allowInteractiveExpand = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : true;
|
|
64
66
|
var __livePage = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
67
|
+
var cleanUpEditorDisabledOnChange = arguments.length > 9 ? arguments[9] : undefined;
|
|
65
68
|
(0, _classCallCheck2.default)(this, ExpandNodeView);
|
|
66
69
|
(0, _defineProperty2.default)(this, "allowInteractiveExpand", true);
|
|
67
70
|
(0, _defineProperty2.default)(this, "isMobile", false);
|
|
@@ -366,16 +369,25 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
366
369
|
}
|
|
367
370
|
}
|
|
368
371
|
});
|
|
372
|
+
(0, _defineProperty2.default)(this, "getContentEditable", function (node) {
|
|
373
|
+
var contentEditable = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && _this.__livePage ? !node.attrs.__expanded : node.attrs.__expanded;
|
|
374
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && _this.api && _this.api.editorDisabled) {
|
|
375
|
+
var _this$api$editorDisab;
|
|
376
|
+
return !((_this$api$editorDisab = _this.api.editorDisabled.sharedState.currentState()) !== null && _this$api$editorDisab !== void 0 && _this$api$editorDisab.editorDisabled) && contentEditable;
|
|
377
|
+
}
|
|
378
|
+
return contentEditable;
|
|
379
|
+
});
|
|
369
380
|
this.selectNearNode = selectNearNode;
|
|
370
381
|
this.__livePage = __livePage;
|
|
382
|
+
this.cleanUpEditorDisabledOnChange = cleanUpEditorDisabledOnChange;
|
|
371
383
|
this.intl = getIntl();
|
|
372
|
-
var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM(
|
|
384
|
+
var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOM(_node, this.__livePage, this.intl, api === null || api === void 0 || (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 || (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled === void 0 ? void 0 : _api$editorDisabled.editorDisabled)),
|
|
373
385
|
dom = _DOMSerializer$render.dom,
|
|
374
386
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
375
387
|
this.allowInteractiveExpand = allowInteractiveExpand;
|
|
376
388
|
this.getPos = getPos;
|
|
377
389
|
this.view = view;
|
|
378
|
-
this.node =
|
|
390
|
+
this.node = _node;
|
|
379
391
|
this.dom = dom;
|
|
380
392
|
this.contentDOM = contentDOM;
|
|
381
393
|
this.isMobile = isMobile;
|
|
@@ -390,6 +402,8 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
390
402
|
(0, _createClass2.default)(ExpandNodeView, [{
|
|
391
403
|
key: "initHandlers",
|
|
392
404
|
value: function initHandlers() {
|
|
405
|
+
var _this$api6,
|
|
406
|
+
_this2 = this;
|
|
393
407
|
if (this.dom) {
|
|
394
408
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
395
409
|
this.dom.addEventListener('click', this.handleClick);
|
|
@@ -414,6 +428,21 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
414
428
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
415
429
|
this.icon.addEventListener('keydown', this.handleIconKeyDown);
|
|
416
430
|
}
|
|
431
|
+
if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
|
|
432
|
+
this.cleanUpEditorDisabledOnChange = this.api.editorDisabled.sharedState.onChange(function (sharedState) {
|
|
433
|
+
var editorDisabled = sharedState.nextSharedState.editorDisabled;
|
|
434
|
+
if (_this2.input) {
|
|
435
|
+
if (editorDisabled) {
|
|
436
|
+
_this2.input.setAttribute('readonly', 'true');
|
|
437
|
+
} else {
|
|
438
|
+
_this2.input.removeAttribute('readonly');
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (_this2.content) {
|
|
442
|
+
_this2.content.setAttribute('contenteditable', _this2.getContentEditable(_this2.node) ? 'true' : 'false');
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
}
|
|
417
446
|
}
|
|
418
447
|
}, {
|
|
419
448
|
key: "renderIcon",
|
|
@@ -451,7 +480,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
451
480
|
}, {
|
|
452
481
|
key: "update",
|
|
453
482
|
value: function update(node, _decorations) {
|
|
454
|
-
var
|
|
483
|
+
var _this3 = this;
|
|
455
484
|
if (this.node.type === node.type) {
|
|
456
485
|
if (this.node.attrs.__expanded !== node.attrs.__expanded) {
|
|
457
486
|
// Instead of re-rendering the view on an expand toggle
|
|
@@ -462,7 +491,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
462
491
|
}
|
|
463
492
|
if (this.content) {
|
|
464
493
|
// Disallow interaction/selection inside when collapsed.
|
|
465
|
-
this.content.setAttribute('contenteditable',
|
|
494
|
+
this.content.setAttribute('contenteditable', this.getContentEditable(node) ? 'true' : 'false');
|
|
466
495
|
}
|
|
467
496
|
}
|
|
468
497
|
|
|
@@ -470,8 +499,8 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
470
499
|
// since we're intentionally being less aggressive about re-rendering.
|
|
471
500
|
// We also apply a rAF to avoid abrupt continuous replacement of the title.
|
|
472
501
|
window.requestAnimationFrame(function () {
|
|
473
|
-
if (
|
|
474
|
-
|
|
502
|
+
if (_this3.input && _this3.node.attrs.title !== _this3.input.value) {
|
|
503
|
+
_this3.input.value = _this3.node.attrs.title;
|
|
475
504
|
}
|
|
476
505
|
});
|
|
477
506
|
this.node = node;
|
|
@@ -507,6 +536,9 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
507
536
|
_reactDom.default.unmountComponentAtNode(this.icon);
|
|
508
537
|
}
|
|
509
538
|
(_this$decorationClean2 = this.decorationCleanup) === null || _this$decorationClean2 === void 0 || _this$decorationClean2.call(this);
|
|
539
|
+
if (this.cleanUpEditorDisabledOnChange) {
|
|
540
|
+
this.cleanUpEditorDisabledOnChange();
|
|
541
|
+
}
|
|
510
542
|
|
|
511
543
|
// @ts-ignore - [unblock prosemirror bump] reset non optional prop to undefined to clear reference
|
|
512
544
|
this.dom = undefined;
|
|
@@ -515,6 +547,7 @@ var ExpandNodeView = exports.ExpandNodeView = /*#__PURE__*/function () {
|
|
|
515
547
|
this.input = undefined;
|
|
516
548
|
this.titleContainer = undefined;
|
|
517
549
|
this.content = undefined;
|
|
550
|
+
this.cleanUpEditorDisabledOnChange = undefined;
|
|
518
551
|
}
|
|
519
552
|
}]);
|
|
520
553
|
return ExpandNodeView;
|
|
@@ -14,7 +14,7 @@ import { ExpandIconButton } from '../ui/ExpandIconButton';
|
|
|
14
14
|
function buildExpandClassName(type, expanded) {
|
|
15
15
|
return `${expandClassNames.prefix} ${expandClassNames.type(type)} ${expanded ? expandClassNames.expanded : ''}`;
|
|
16
16
|
}
|
|
17
|
-
const toDOM = (node, __livePage, intl) => ['div', {
|
|
17
|
+
const toDOM = (node, __livePage, intl, titleReadOnly, contentEditable) => ['div', {
|
|
18
18
|
// prettier-ignore
|
|
19
19
|
'class': buildExpandClassName(node.type.name, getBooleanFF('platform.editor.live-pages-expand-divergence') && __livePage ? !node.attrs.__expanded : node.attrs.__expanded),
|
|
20
20
|
'data-node-type': node.type.name,
|
|
@@ -39,14 +39,16 @@ const toDOM = (node, __livePage, intl) => ['div', {
|
|
|
39
39
|
'class': expandClassNames.titleInput,
|
|
40
40
|
value: node.attrs.title,
|
|
41
41
|
placeholder: intl && intl.formatMessage(expandMessages.expandPlaceholderText) || expandMessages.expandPlaceholderText.defaultMessage,
|
|
42
|
-
type: 'text'
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
type: 'text',
|
|
43
|
+
readonly: getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && titleReadOnly ? 'true' : undefined
|
|
44
|
+
}]]], ['div', {
|
|
45
|
+
// prettier-ignore
|
|
46
|
+
class: expandClassNames.content,
|
|
47
|
+
contenteditable: getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && contentEditable ? contentEditable ? 'true' : 'false' : undefined
|
|
47
48
|
}, 0]];
|
|
48
49
|
export class ExpandNodeView {
|
|
49
|
-
constructor(
|
|
50
|
+
constructor(_node, view, getPos, getIntl, isMobile, selectNearNode, api, allowInteractiveExpand = true, __livePage = false, cleanUpEditorDisabledOnChange) {
|
|
51
|
+
var _api$editorDisabled, _api$editorDisabled$s;
|
|
50
52
|
_defineProperty(this, "allowInteractiveExpand", true);
|
|
51
53
|
_defineProperty(this, "isMobile", false);
|
|
52
54
|
_defineProperty(this, "focusTitle", () => {
|
|
@@ -366,17 +368,26 @@ export class ExpandNodeView {
|
|
|
366
368
|
}
|
|
367
369
|
}
|
|
368
370
|
});
|
|
371
|
+
_defineProperty(this, "getContentEditable", node => {
|
|
372
|
+
const contentEditable = getBooleanFF('platform.editor.live-pages-expand-divergence') && this.__livePage ? !node.attrs.__expanded : node.attrs.__expanded;
|
|
373
|
+
if (getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && this.api && this.api.editorDisabled) {
|
|
374
|
+
var _this$api$editorDisab;
|
|
375
|
+
return !((_this$api$editorDisab = this.api.editorDisabled.sharedState.currentState()) !== null && _this$api$editorDisab !== void 0 && _this$api$editorDisab.editorDisabled) && contentEditable;
|
|
376
|
+
}
|
|
377
|
+
return contentEditable;
|
|
378
|
+
});
|
|
369
379
|
this.selectNearNode = selectNearNode;
|
|
370
380
|
this.__livePage = __livePage;
|
|
381
|
+
this.cleanUpEditorDisabledOnChange = cleanUpEditorDisabledOnChange;
|
|
371
382
|
this.intl = getIntl();
|
|
372
383
|
const {
|
|
373
384
|
dom,
|
|
374
385
|
contentDOM
|
|
375
|
-
} = DOMSerializer.renderSpec(document, toDOM(
|
|
386
|
+
} = DOMSerializer.renderSpec(document, toDOM(_node, this.__livePage, this.intl, api === null || api === void 0 ? void 0 : (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 ? void 0 : (_api$editorDisabled$s = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled$s === void 0 ? void 0 : _api$editorDisabled$s.editorDisabled));
|
|
376
387
|
this.allowInteractiveExpand = allowInteractiveExpand;
|
|
377
388
|
this.getPos = getPos;
|
|
378
389
|
this.view = view;
|
|
379
|
-
this.node =
|
|
390
|
+
this.node = _node;
|
|
380
391
|
this.dom = dom;
|
|
381
392
|
this.contentDOM = contentDOM;
|
|
382
393
|
this.isMobile = isMobile;
|
|
@@ -389,6 +400,7 @@ export class ExpandNodeView {
|
|
|
389
400
|
this.initHandlers();
|
|
390
401
|
}
|
|
391
402
|
initHandlers() {
|
|
403
|
+
var _this$api6;
|
|
392
404
|
if (this.dom) {
|
|
393
405
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
394
406
|
this.dom.addEventListener('click', this.handleClick);
|
|
@@ -413,6 +425,21 @@ export class ExpandNodeView {
|
|
|
413
425
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
414
426
|
this.icon.addEventListener('keydown', this.handleIconKeyDown);
|
|
415
427
|
}
|
|
428
|
+
if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
|
|
429
|
+
this.cleanUpEditorDisabledOnChange = this.api.editorDisabled.sharedState.onChange(sharedState => {
|
|
430
|
+
const editorDisabled = sharedState.nextSharedState.editorDisabled;
|
|
431
|
+
if (this.input) {
|
|
432
|
+
if (editorDisabled) {
|
|
433
|
+
this.input.setAttribute('readonly', 'true');
|
|
434
|
+
} else {
|
|
435
|
+
this.input.removeAttribute('readonly');
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
if (this.content) {
|
|
439
|
+
this.content.setAttribute('contenteditable', this.getContentEditable(this.node) ? 'true' : 'false');
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
}
|
|
416
443
|
}
|
|
417
444
|
renderIcon(intl, node) {
|
|
418
445
|
if (!this.icon) {
|
|
@@ -453,7 +480,7 @@ export class ExpandNodeView {
|
|
|
453
480
|
}
|
|
454
481
|
if (this.content) {
|
|
455
482
|
// Disallow interaction/selection inside when collapsed.
|
|
456
|
-
this.content.setAttribute('contenteditable',
|
|
483
|
+
this.content.setAttribute('contenteditable', this.getContentEditable(node) ? 'true' : 'false');
|
|
457
484
|
}
|
|
458
485
|
}
|
|
459
486
|
|
|
@@ -496,6 +523,9 @@ export class ExpandNodeView {
|
|
|
496
523
|
ReactDOM.unmountComponentAtNode(this.icon);
|
|
497
524
|
}
|
|
498
525
|
(_this$decorationClean2 = this.decorationCleanup) === null || _this$decorationClean2 === void 0 ? void 0 : _this$decorationClean2.call(this);
|
|
526
|
+
if (this.cleanUpEditorDisabledOnChange) {
|
|
527
|
+
this.cleanUpEditorDisabledOnChange();
|
|
528
|
+
}
|
|
499
529
|
|
|
500
530
|
// @ts-ignore - [unblock prosemirror bump] reset non optional prop to undefined to clear reference
|
|
501
531
|
this.dom = undefined;
|
|
@@ -504,6 +534,7 @@ export class ExpandNodeView {
|
|
|
504
534
|
this.input = undefined;
|
|
505
535
|
this.titleContainer = undefined;
|
|
506
536
|
this.content = undefined;
|
|
537
|
+
this.cleanUpEditorDisabledOnChange = undefined;
|
|
507
538
|
}
|
|
508
539
|
}
|
|
509
540
|
export default function ({
|
|
@@ -16,7 +16,7 @@ import { ExpandIconButton } from '../ui/ExpandIconButton';
|
|
|
16
16
|
function buildExpandClassName(type, expanded) {
|
|
17
17
|
return "".concat(expandClassNames.prefix, " ").concat(expandClassNames.type(type), " ").concat(expanded ? expandClassNames.expanded : '');
|
|
18
18
|
}
|
|
19
|
-
var toDOM = function toDOM(node, __livePage, intl) {
|
|
19
|
+
var toDOM = function toDOM(node, __livePage, intl, titleReadOnly, contentEditable) {
|
|
20
20
|
return ['div', {
|
|
21
21
|
// prettier-ignore
|
|
22
22
|
'class': buildExpandClassName(node.type.name, getBooleanFF('platform.editor.live-pages-expand-divergence') && __livePage ? !node.attrs.__expanded : node.attrs.__expanded),
|
|
@@ -42,18 +42,21 @@ var toDOM = function toDOM(node, __livePage, intl) {
|
|
|
42
42
|
'class': expandClassNames.titleInput,
|
|
43
43
|
value: node.attrs.title,
|
|
44
44
|
placeholder: intl && intl.formatMessage(expandMessages.expandPlaceholderText) || expandMessages.expandPlaceholderText.defaultMessage,
|
|
45
|
-
type: 'text'
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
type: 'text',
|
|
46
|
+
readonly: getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && titleReadOnly ? 'true' : undefined
|
|
47
|
+
}]]], ['div', {
|
|
48
|
+
// prettier-ignore
|
|
49
|
+
class: expandClassNames.content,
|
|
50
|
+
contenteditable: getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && contentEditable ? contentEditable ? 'true' : 'false' : undefined
|
|
50
51
|
}, 0]];
|
|
51
52
|
};
|
|
52
53
|
export var ExpandNodeView = /*#__PURE__*/function () {
|
|
53
|
-
function ExpandNodeView(
|
|
54
|
-
var _this = this
|
|
54
|
+
function ExpandNodeView(_node, view, getPos, getIntl, isMobile, selectNearNode, api) {
|
|
55
|
+
var _this = this,
|
|
56
|
+
_api$editorDisabled;
|
|
55
57
|
var allowInteractiveExpand = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : true;
|
|
56
58
|
var __livePage = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
59
|
+
var cleanUpEditorDisabledOnChange = arguments.length > 9 ? arguments[9] : undefined;
|
|
57
60
|
_classCallCheck(this, ExpandNodeView);
|
|
58
61
|
_defineProperty(this, "allowInteractiveExpand", true);
|
|
59
62
|
_defineProperty(this, "isMobile", false);
|
|
@@ -358,16 +361,25 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
358
361
|
}
|
|
359
362
|
}
|
|
360
363
|
});
|
|
364
|
+
_defineProperty(this, "getContentEditable", function (node) {
|
|
365
|
+
var contentEditable = getBooleanFF('platform.editor.live-pages-expand-divergence') && _this.__livePage ? !node.attrs.__expanded : node.attrs.__expanded;
|
|
366
|
+
if (getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx') && _this.api && _this.api.editorDisabled) {
|
|
367
|
+
var _this$api$editorDisab;
|
|
368
|
+
return !((_this$api$editorDisab = _this.api.editorDisabled.sharedState.currentState()) !== null && _this$api$editorDisab !== void 0 && _this$api$editorDisab.editorDisabled) && contentEditable;
|
|
369
|
+
}
|
|
370
|
+
return contentEditable;
|
|
371
|
+
});
|
|
361
372
|
this.selectNearNode = selectNearNode;
|
|
362
373
|
this.__livePage = __livePage;
|
|
374
|
+
this.cleanUpEditorDisabledOnChange = cleanUpEditorDisabledOnChange;
|
|
363
375
|
this.intl = getIntl();
|
|
364
|
-
var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(
|
|
376
|
+
var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(_node, this.__livePage, this.intl, api === null || api === void 0 || (_api$editorDisabled = api.editorDisabled) === null || _api$editorDisabled === void 0 || (_api$editorDisabled = _api$editorDisabled.sharedState.currentState()) === null || _api$editorDisabled === void 0 ? void 0 : _api$editorDisabled.editorDisabled)),
|
|
365
377
|
dom = _DOMSerializer$render.dom,
|
|
366
378
|
contentDOM = _DOMSerializer$render.contentDOM;
|
|
367
379
|
this.allowInteractiveExpand = allowInteractiveExpand;
|
|
368
380
|
this.getPos = getPos;
|
|
369
381
|
this.view = view;
|
|
370
|
-
this.node =
|
|
382
|
+
this.node = _node;
|
|
371
383
|
this.dom = dom;
|
|
372
384
|
this.contentDOM = contentDOM;
|
|
373
385
|
this.isMobile = isMobile;
|
|
@@ -382,6 +394,8 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
382
394
|
_createClass(ExpandNodeView, [{
|
|
383
395
|
key: "initHandlers",
|
|
384
396
|
value: function initHandlers() {
|
|
397
|
+
var _this$api6,
|
|
398
|
+
_this2 = this;
|
|
385
399
|
if (this.dom) {
|
|
386
400
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
387
401
|
this.dom.addEventListener('click', this.handleClick);
|
|
@@ -406,6 +420,21 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
406
420
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
407
421
|
this.icon.addEventListener('keydown', this.handleIconKeyDown);
|
|
408
422
|
}
|
|
423
|
+
if ((_this$api6 = this.api) !== null && _this$api6 !== void 0 && _this$api6.editorDisabled && getBooleanFF('platform.editor.live-view.disable-editing-in-view-mode_fi1rx')) {
|
|
424
|
+
this.cleanUpEditorDisabledOnChange = this.api.editorDisabled.sharedState.onChange(function (sharedState) {
|
|
425
|
+
var editorDisabled = sharedState.nextSharedState.editorDisabled;
|
|
426
|
+
if (_this2.input) {
|
|
427
|
+
if (editorDisabled) {
|
|
428
|
+
_this2.input.setAttribute('readonly', 'true');
|
|
429
|
+
} else {
|
|
430
|
+
_this2.input.removeAttribute('readonly');
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
if (_this2.content) {
|
|
434
|
+
_this2.content.setAttribute('contenteditable', _this2.getContentEditable(_this2.node) ? 'true' : 'false');
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
}
|
|
409
438
|
}
|
|
410
439
|
}, {
|
|
411
440
|
key: "renderIcon",
|
|
@@ -443,7 +472,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
443
472
|
}, {
|
|
444
473
|
key: "update",
|
|
445
474
|
value: function update(node, _decorations) {
|
|
446
|
-
var
|
|
475
|
+
var _this3 = this;
|
|
447
476
|
if (this.node.type === node.type) {
|
|
448
477
|
if (this.node.attrs.__expanded !== node.attrs.__expanded) {
|
|
449
478
|
// Instead of re-rendering the view on an expand toggle
|
|
@@ -454,7 +483,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
454
483
|
}
|
|
455
484
|
if (this.content) {
|
|
456
485
|
// Disallow interaction/selection inside when collapsed.
|
|
457
|
-
this.content.setAttribute('contenteditable',
|
|
486
|
+
this.content.setAttribute('contenteditable', this.getContentEditable(node) ? 'true' : 'false');
|
|
458
487
|
}
|
|
459
488
|
}
|
|
460
489
|
|
|
@@ -462,8 +491,8 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
462
491
|
// since we're intentionally being less aggressive about re-rendering.
|
|
463
492
|
// We also apply a rAF to avoid abrupt continuous replacement of the title.
|
|
464
493
|
window.requestAnimationFrame(function () {
|
|
465
|
-
if (
|
|
466
|
-
|
|
494
|
+
if (_this3.input && _this3.node.attrs.title !== _this3.input.value) {
|
|
495
|
+
_this3.input.value = _this3.node.attrs.title;
|
|
467
496
|
}
|
|
468
497
|
});
|
|
469
498
|
this.node = node;
|
|
@@ -499,6 +528,9 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
499
528
|
ReactDOM.unmountComponentAtNode(this.icon);
|
|
500
529
|
}
|
|
501
530
|
(_this$decorationClean2 = this.decorationCleanup) === null || _this$decorationClean2 === void 0 || _this$decorationClean2.call(this);
|
|
531
|
+
if (this.cleanUpEditorDisabledOnChange) {
|
|
532
|
+
this.cleanUpEditorDisabledOnChange();
|
|
533
|
+
}
|
|
502
534
|
|
|
503
535
|
// @ts-ignore - [unblock prosemirror bump] reset non optional prop to undefined to clear reference
|
|
504
536
|
this.dom = undefined;
|
|
@@ -507,6 +539,7 @@ export var ExpandNodeView = /*#__PURE__*/function () {
|
|
|
507
539
|
this.input = undefined;
|
|
508
540
|
this.titleContainer = undefined;
|
|
509
541
|
this.content = undefined;
|
|
542
|
+
this.cleanUpEditorDisabledOnChange = undefined;
|
|
510
543
|
}
|
|
511
544
|
}]);
|
|
512
545
|
return ExpandNodeView;
|
|
@@ -7,6 +7,7 @@ import type { ExpandPlugin } from '../../types';
|
|
|
7
7
|
export declare class ExpandNodeView implements NodeView {
|
|
8
8
|
private selectNearNode;
|
|
9
9
|
private __livePage;
|
|
10
|
+
private cleanUpEditorDisabledOnChange?;
|
|
10
11
|
node: PmNode;
|
|
11
12
|
view: EditorView;
|
|
12
13
|
dom: HTMLElement;
|
|
@@ -21,7 +22,7 @@ export declare class ExpandNodeView implements NodeView {
|
|
|
21
22
|
isMobile: boolean;
|
|
22
23
|
api: ExtractInjectionAPI<ExpandPlugin> | undefined;
|
|
23
24
|
decorationCleanup?: () => boolean | undefined;
|
|
24
|
-
constructor(node: PmNode, view: EditorView, getPos: getPosHandlerNode, getIntl: () => IntlShape, isMobile: boolean, selectNearNode: SetSelectionRelativeToNode | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean, __livePage?: boolean);
|
|
25
|
+
constructor(node: PmNode, view: EditorView, getPos: getPosHandlerNode, getIntl: () => IntlShape, isMobile: boolean, selectNearNode: SetSelectionRelativeToNode | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean, __livePage?: boolean, cleanUpEditorDisabledOnChange?: (() => void) | undefined);
|
|
25
26
|
private initHandlers;
|
|
26
27
|
private focusTitle;
|
|
27
28
|
private handleIconKeyDown;
|
|
@@ -40,6 +41,7 @@ export declare class ExpandNodeView implements NodeView {
|
|
|
40
41
|
private setLeftGapCursor;
|
|
41
42
|
private handleArrowRightFromTitle;
|
|
42
43
|
private handleArrowLeftFromTitle;
|
|
44
|
+
private getContentEditable;
|
|
43
45
|
stopEvent(event: Event): boolean;
|
|
44
46
|
ignoreMutation(mutationRecord: MutationRecord | {
|
|
45
47
|
type: 'selection';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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 { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
4
5
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
5
6
|
import type { SelectionMarkerPlugin } from '@atlaskit/editor-plugin-selection-marker';
|
|
6
7
|
import type { insertExpand } from './legacyExpand/commands';
|
|
@@ -39,7 +40,8 @@ export type ExpandPlugin = NextEditorPlugin<'expand', {
|
|
|
39
40
|
DecorationsPlugin,
|
|
40
41
|
SelectionPlugin,
|
|
41
42
|
OptionalPlugin<AnalyticsPlugin>,
|
|
42
|
-
OptionalPlugin<SelectionMarkerPlugin
|
|
43
|
+
OptionalPlugin<SelectionMarkerPlugin>,
|
|
44
|
+
OptionalPlugin<EditorDisabledPlugin>
|
|
43
45
|
];
|
|
44
46
|
actions: {
|
|
45
47
|
insertExpand: ReturnType<typeof insertExpand>;
|
|
@@ -7,6 +7,7 @@ import type { ExpandPlugin } from '../../types';
|
|
|
7
7
|
export declare class ExpandNodeView implements NodeView {
|
|
8
8
|
private selectNearNode;
|
|
9
9
|
private __livePage;
|
|
10
|
+
private cleanUpEditorDisabledOnChange?;
|
|
10
11
|
node: PmNode;
|
|
11
12
|
view: EditorView;
|
|
12
13
|
dom: HTMLElement;
|
|
@@ -21,7 +22,7 @@ export declare class ExpandNodeView implements NodeView {
|
|
|
21
22
|
isMobile: boolean;
|
|
22
23
|
api: ExtractInjectionAPI<ExpandPlugin> | undefined;
|
|
23
24
|
decorationCleanup?: () => boolean | undefined;
|
|
24
|
-
constructor(node: PmNode, view: EditorView, getPos: getPosHandlerNode, getIntl: () => IntlShape, isMobile: boolean, selectNearNode: SetSelectionRelativeToNode | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean, __livePage?: boolean);
|
|
25
|
+
constructor(node: PmNode, view: EditorView, getPos: getPosHandlerNode, getIntl: () => IntlShape, isMobile: boolean, selectNearNode: SetSelectionRelativeToNode | undefined, api: ExtractInjectionAPI<ExpandPlugin> | undefined, allowInteractiveExpand?: boolean, __livePage?: boolean, cleanUpEditorDisabledOnChange?: (() => void) | undefined);
|
|
25
26
|
private initHandlers;
|
|
26
27
|
private focusTitle;
|
|
27
28
|
private handleIconKeyDown;
|
|
@@ -40,6 +41,7 @@ export declare class ExpandNodeView implements NodeView {
|
|
|
40
41
|
private setLeftGapCursor;
|
|
41
42
|
private handleArrowRightFromTitle;
|
|
42
43
|
private handleArrowLeftFromTitle;
|
|
44
|
+
private getContentEditable;
|
|
43
45
|
stopEvent(event: Event): boolean;
|
|
44
46
|
ignoreMutation(mutationRecord: MutationRecord | {
|
|
45
47
|
type: 'selection';
|
|
@@ -1,6 +1,7 @@
|
|
|
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 { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
4
5
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
5
6
|
import type { SelectionMarkerPlugin } from '@atlaskit/editor-plugin-selection-marker';
|
|
6
7
|
import type { insertExpand } from './legacyExpand/commands';
|
|
@@ -39,7 +40,8 @@ export type ExpandPlugin = NextEditorPlugin<'expand', {
|
|
|
39
40
|
DecorationsPlugin,
|
|
40
41
|
SelectionPlugin,
|
|
41
42
|
OptionalPlugin<AnalyticsPlugin>,
|
|
42
|
-
OptionalPlugin<SelectionMarkerPlugin
|
|
43
|
+
OptionalPlugin<SelectionMarkerPlugin>,
|
|
44
|
+
OptionalPlugin<EditorDisabledPlugin>
|
|
43
45
|
];
|
|
44
46
|
actions: {
|
|
45
47
|
insertExpand: ReturnType<typeof insertExpand>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-expand",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Expand plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,11 +33,12 @@
|
|
|
33
33
|
".": "./src/index.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/adf-schema": "^35.9.
|
|
37
|
-
"@atlaskit/button": "^17.
|
|
36
|
+
"@atlaskit/adf-schema": "^35.9.2",
|
|
37
|
+
"@atlaskit/button": "^17.13.0",
|
|
38
38
|
"@atlaskit/editor-common": "^78.30.0",
|
|
39
39
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
40
40
|
"@atlaskit/editor-plugin-decorations": "^1.0.0",
|
|
41
|
+
"@atlaskit/editor-plugin-editor-disabled": "^1.0.0",
|
|
41
42
|
"@atlaskit/editor-plugin-selection": "^1.1.0",
|
|
42
43
|
"@atlaskit/editor-plugin-selection-marker": "^1.2.0",
|
|
43
44
|
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
@@ -111,6 +112,9 @@
|
|
|
111
112
|
},
|
|
112
113
|
"platform.editor.single-player-expand": {
|
|
113
114
|
"type": "boolean"
|
|
115
|
+
},
|
|
116
|
+
"platform.editor.live-view.disable-editing-in-view-mode_fi1rx": {
|
|
117
|
+
"type": "boolean"
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
120
|
}
|