@atlaskit/editor-plugin-block-controls 2.13.4 → 2.13.5
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 +12 -0
- package/dist/cjs/commands/move-to-layout.js +2 -2
- package/dist/cjs/consts.js +5 -2
- package/dist/cjs/pm-plugins/decorations-drop-target.js +1 -1
- package/dist/cjs/pm-plugins/main.js +3 -3
- package/dist/cjs/utils/active-anchor-tracker.js +16 -5
- package/dist/cjs/utils/inline-drop-target.js +1 -1
- package/dist/es2019/commands/move-to-layout.js +3 -3
- package/dist/es2019/consts.js +4 -1
- package/dist/es2019/pm-plugins/decorations-drop-target.js +2 -2
- package/dist/es2019/pm-plugins/main.js +3 -3
- package/dist/es2019/utils/active-anchor-tracker.js +17 -4
- package/dist/es2019/utils/inline-drop-target.js +2 -2
- package/dist/esm/commands/move-to-layout.js +3 -3
- package/dist/esm/consts.js +4 -1
- package/dist/esm/pm-plugins/decorations-drop-target.js +2 -2
- package/dist/esm/pm-plugins/main.js +3 -3
- package/dist/esm/utils/active-anchor-tracker.js +17 -4
- package/dist/esm/utils/inline-drop-target.js +2 -2
- package/dist/types/consts.d.ts +1 -1
- package/dist/types/utils/active-anchor-tracker.d.ts +1 -1
- package/dist/types-ts4.5/consts.d.ts +1 -1
- package/dist/types-ts4.5/utils/active-anchor-tracker.d.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 2.13.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#158691](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/158691)
|
|
8
|
+
[`f71feb1fedb07`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f71feb1fedb07) -
|
|
9
|
+
ED-25618 enable 5 columns for pre release 2
|
|
10
|
+
- [#158691](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/158691)
|
|
11
|
+
[`70ef661bbbb4d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/70ef661bbbb4d) -
|
|
12
|
+
Update feature flag to gate
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 2.13.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -9,7 +9,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
9
9
|
var _consts = require("../consts");
|
|
10
10
|
var _consts2 = require("../ui/consts");
|
|
11
11
|
var createNewLayout = function createNewLayout(schema, layoutContents) {
|
|
12
|
-
if (layoutContents.length === 0 || layoutContents.length > _consts.
|
|
12
|
+
if (layoutContents.length === 0 || layoutContents.length > (0, _consts.maxLayoutColumnSupported)()) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
15
|
var width = _consts2.DEFAULT_COLUMN_DISTRIBUTIONS[layoutContents.length];
|
|
@@ -54,7 +54,7 @@ var moveNode = function moveNode(from, to, newNode, sourceNodeSize, tr) {
|
|
|
54
54
|
return tr;
|
|
55
55
|
};
|
|
56
56
|
var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos, sourceNode, from, to, tr) {
|
|
57
|
-
if (toLayout.childCount < _consts.
|
|
57
|
+
if (toLayout.childCount < (0, _consts.maxLayoutColumnSupported)()) {
|
|
58
58
|
var newColumnWidth = _consts2.DEFAULT_COLUMN_DISTRIBUTIONS[toLayout.childCount + 1];
|
|
59
59
|
updateColumnWidths(tr, toLayout, toLayoutPos, newColumnWidth);
|
|
60
60
|
var _ref2 = tr.doc.type.schema.nodes || {},
|
package/dist/cjs/consts.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.maxLayoutColumnSupported = exports.DIRECTION = void 0;
|
|
7
|
+
var _advancedLayoutsFlags = require("./utils/advanced-layouts-flags");
|
|
7
8
|
var DIRECTION = exports.DIRECTION = /*#__PURE__*/function (DIRECTION) {
|
|
8
9
|
DIRECTION["UP"] = "up";
|
|
9
10
|
DIRECTION["DOWN"] = "down";
|
|
@@ -11,4 +12,6 @@ var DIRECTION = exports.DIRECTION = /*#__PURE__*/function (DIRECTION) {
|
|
|
11
12
|
DIRECTION["RIGHT"] = "right";
|
|
12
13
|
return DIRECTION;
|
|
13
14
|
}({});
|
|
14
|
-
var
|
|
15
|
+
var maxLayoutColumnSupported = exports.maxLayoutColumnSupported = function maxLayoutColumnSupported() {
|
|
16
|
+
return (0, _advancedLayoutsFlags.isPreRelease2)() ? 5 : 3;
|
|
17
|
+
};
|
|
@@ -161,7 +161,7 @@ var dropTargetDecorations = exports.dropTargetDecorations = function dropTargetD
|
|
|
161
161
|
if (isAdvancedLayoutsPreRelease2) {
|
|
162
162
|
if (node.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && (parent === null || parent === void 0 ? void 0 : parent.firstChild) !== node &&
|
|
163
163
|
// Not the first node
|
|
164
|
-
(parent === null || parent === void 0 ? void 0 : parent.childCount) < _consts.
|
|
164
|
+
(parent === null || parent === void 0 ? void 0 : parent.childCount) < (0, _consts.maxLayoutColumnSupported)()) {
|
|
165
165
|
decs.push(createLayoutDropTargetDecoration(pos, {
|
|
166
166
|
api: api,
|
|
167
167
|
parent: parent,
|
|
@@ -58,9 +58,6 @@ var destroyFn = function destroyFn(api) {
|
|
|
58
58
|
if (isHTMLElement(scrollable)) {
|
|
59
59
|
scrollable.style.setProperty('scroll-behavior', null);
|
|
60
60
|
}
|
|
61
|
-
if ((0, _advancedLayoutsFlags.isPreRelease2)()) {
|
|
62
|
-
_activeAnchorTracker.defaultActiveAnchorTracker.reset();
|
|
63
|
-
}
|
|
64
61
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
|
|
65
62
|
var tr = _ref3.tr;
|
|
66
63
|
var _ref4 = source.data,
|
|
@@ -519,6 +516,9 @@ var createPlugin = exports.createPlugin = function createPlugin(api, getIntl) {
|
|
|
519
516
|
},
|
|
520
517
|
dragstart: function dragstart(view) {
|
|
521
518
|
var _anchorRectCache;
|
|
519
|
+
if ((0, _advancedLayoutsFlags.isPreRelease2)()) {
|
|
520
|
+
_activeAnchorTracker.defaultActiveAnchorTracker.reset();
|
|
521
|
+
}
|
|
522
522
|
(_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 || _anchorRectCache.setEditorView(view);
|
|
523
523
|
view.dispatch(view.state.tr.setMeta(key, {
|
|
524
524
|
isPMDragging: true
|
|
@@ -21,17 +21,21 @@ var ActiveAnchorTracker = exports.ActiveAnchorTracker = /*#__PURE__*/function ()
|
|
|
21
21
|
(0, _createClass2.default)(ActiveAnchorTracker, [{
|
|
22
22
|
key: "subscribe",
|
|
23
23
|
value: function subscribe(anchorName, callback) {
|
|
24
|
-
this.emitter
|
|
24
|
+
if (this.emitter) {
|
|
25
|
+
this.emitter.on(anchorName, callback);
|
|
26
|
+
}
|
|
25
27
|
}
|
|
26
28
|
}, {
|
|
27
29
|
key: "unsubscribe",
|
|
28
30
|
value: function unsubscribe(anchorName, callback) {
|
|
29
|
-
this.emitter
|
|
31
|
+
if (this.emitter) {
|
|
32
|
+
this.emitter.removeListener(anchorName, callback);
|
|
33
|
+
}
|
|
30
34
|
}
|
|
31
35
|
}, {
|
|
32
36
|
key: "emit",
|
|
33
37
|
value: function emit(anchorName) {
|
|
34
|
-
if (this.lastActiveAnchor !== anchorName) {
|
|
38
|
+
if (this.lastActiveAnchor !== anchorName && this.emitter) {
|
|
35
39
|
this.emitter.emit(this.lastActiveAnchor, false);
|
|
36
40
|
this.emitter.emit(anchorName, true);
|
|
37
41
|
this.lastActiveAnchor = anchorName;
|
|
@@ -40,11 +44,18 @@ var ActiveAnchorTracker = exports.ActiveAnchorTracker = /*#__PURE__*/function ()
|
|
|
40
44
|
}, {
|
|
41
45
|
key: "reset",
|
|
42
46
|
value: function reset() {
|
|
43
|
-
this.emitter
|
|
47
|
+
if (this.emitter) {
|
|
48
|
+
// To prevent any potential memory leaks,
|
|
49
|
+
// we set the event emitter to null and then create a new event emitter.
|
|
50
|
+
this.emitter.removeAllListeners();
|
|
51
|
+
this.emitter = null;
|
|
52
|
+
this.emitter = new _events.EventEmitter();
|
|
53
|
+
}
|
|
44
54
|
}
|
|
45
55
|
}]);
|
|
46
56
|
return ActiveAnchorTracker;
|
|
47
|
-
}();
|
|
57
|
+
}(); // TODO We should use a scoped ActiveAnchorTracker rather than the global static object.
|
|
58
|
+
// Move this into the plugin scope once the newApply functions becomes default apply.
|
|
48
59
|
var defaultActiveAnchorTracker = exports.defaultActiveAnchorTracker = new ActiveAnchorTracker();
|
|
49
60
|
var useActiveAnchorTracker = exports.useActiveAnchorTracker = function useActiveAnchorTracker(anchorName) {
|
|
50
61
|
var activeAnchorTracker = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultActiveAnchorTracker;
|
|
@@ -16,7 +16,7 @@ var shouldAllowInlineDropTarget = exports.shouldAllowInlineDropTarget = function
|
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
18
|
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
|
|
19
|
-
return node.childCount < _consts.
|
|
19
|
+
return node.childCount < (0, _consts.maxLayoutColumnSupported)();
|
|
20
20
|
}
|
|
21
21
|
return !(0, _utils.isEmptyParagraph)(node);
|
|
22
22
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import {
|
|
3
|
+
import { maxLayoutColumnSupported } from '../consts';
|
|
4
4
|
import { DEFAULT_COLUMN_DISTRIBUTIONS } from '../ui/consts';
|
|
5
5
|
const createNewLayout = (schema, layoutContents) => {
|
|
6
|
-
if (layoutContents.length === 0 || layoutContents.length >
|
|
6
|
+
if (layoutContents.length === 0 || layoutContents.length > maxLayoutColumnSupported()) {
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
9
|
const width = DEFAULT_COLUMN_DISTRIBUTIONS[layoutContents.length];
|
|
@@ -49,7 +49,7 @@ const moveNode = (from, to, newNode, sourceNodeSize, tr) => {
|
|
|
49
49
|
return tr;
|
|
50
50
|
};
|
|
51
51
|
const moveToExistingLayout = (toLayout, toLayoutPos, sourceNode, from, to, tr) => {
|
|
52
|
-
if (toLayout.childCount <
|
|
52
|
+
if (toLayout.childCount < maxLayoutColumnSupported()) {
|
|
53
53
|
const newColumnWidth = DEFAULT_COLUMN_DISTRIBUTIONS[toLayout.childCount + 1];
|
|
54
54
|
updateColumnWidths(tr, toLayout, toLayoutPos, newColumnWidth);
|
|
55
55
|
const {
|
package/dist/es2019/consts.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPreRelease2 } from './utils/advanced-layouts-flags';
|
|
1
2
|
export let DIRECTION = /*#__PURE__*/function (DIRECTION) {
|
|
2
3
|
DIRECTION["UP"] = "up";
|
|
3
4
|
DIRECTION["DOWN"] = "down";
|
|
@@ -5,4 +6,6 @@ export let DIRECTION = /*#__PURE__*/function (DIRECTION) {
|
|
|
5
6
|
DIRECTION["RIGHT"] = "right";
|
|
6
7
|
return DIRECTION;
|
|
7
8
|
}({});
|
|
8
|
-
export const
|
|
9
|
+
export const maxLayoutColumnSupported = () => {
|
|
10
|
+
return isPreRelease2() ? 5 : 3;
|
|
11
|
+
};
|
|
@@ -4,7 +4,7 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
|
4
4
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
|
-
import {
|
|
7
|
+
import { maxLayoutColumnSupported } from '../consts';
|
|
8
8
|
import { nodeMargins } from '../ui/consts';
|
|
9
9
|
import { DropTarget } from '../ui/drop-target';
|
|
10
10
|
import { DropTargetLayout } from '../ui/drop-target-layout';
|
|
@@ -153,7 +153,7 @@ export const dropTargetDecorations = (newState, api, formatMessage, activeNode,
|
|
|
153
153
|
if (isAdvancedLayoutsPreRelease2) {
|
|
154
154
|
if (node.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && (parent === null || parent === void 0 ? void 0 : parent.firstChild) !== node &&
|
|
155
155
|
// Not the first node
|
|
156
|
-
(parent === null || parent === void 0 ? void 0 : parent.childCount) <
|
|
156
|
+
(parent === null || parent === void 0 ? void 0 : parent.childCount) < maxLayoutColumnSupported()) {
|
|
157
157
|
decs.push(createLayoutDropTargetDecoration(pos, {
|
|
158
158
|
api,
|
|
159
159
|
parent,
|
|
@@ -50,9 +50,6 @@ const destroyFn = api => {
|
|
|
50
50
|
if (isHTMLElement(scrollable)) {
|
|
51
51
|
scrollable.style.setProperty('scroll-behavior', null);
|
|
52
52
|
}
|
|
53
|
-
if (isPreRelease2()) {
|
|
54
|
-
defaultActiveAnchorTracker.reset();
|
|
55
|
-
}
|
|
56
53
|
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
|
|
57
54
|
tr
|
|
58
55
|
}) => {
|
|
@@ -496,6 +493,9 @@ export const createPlugin = (api, getIntl) => {
|
|
|
496
493
|
},
|
|
497
494
|
dragstart(view) {
|
|
498
495
|
var _anchorRectCache;
|
|
496
|
+
if (isPreRelease2()) {
|
|
497
|
+
defaultActiveAnchorTracker.reset();
|
|
498
|
+
}
|
|
499
499
|
(_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 ? void 0 : _anchorRectCache.setEditorView(view);
|
|
500
500
|
view.dispatch(view.state.tr.setMeta(key, {
|
|
501
501
|
isPMDragging: true
|
|
@@ -8,22 +8,35 @@ export class ActiveAnchorTracker {
|
|
|
8
8
|
this.emitter = new EventEmitter();
|
|
9
9
|
}
|
|
10
10
|
subscribe(anchorName, callback) {
|
|
11
|
-
this.emitter
|
|
11
|
+
if (this.emitter) {
|
|
12
|
+
this.emitter.on(anchorName, callback);
|
|
13
|
+
}
|
|
12
14
|
}
|
|
13
15
|
unsubscribe(anchorName, callback) {
|
|
14
|
-
this.emitter
|
|
16
|
+
if (this.emitter) {
|
|
17
|
+
this.emitter.removeListener(anchorName, callback);
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
emit(anchorName) {
|
|
17
|
-
if (this.lastActiveAnchor !== anchorName) {
|
|
21
|
+
if (this.lastActiveAnchor !== anchorName && this.emitter) {
|
|
18
22
|
this.emitter.emit(this.lastActiveAnchor, false);
|
|
19
23
|
this.emitter.emit(anchorName, true);
|
|
20
24
|
this.lastActiveAnchor = anchorName;
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
reset() {
|
|
24
|
-
this.emitter
|
|
28
|
+
if (this.emitter) {
|
|
29
|
+
// To prevent any potential memory leaks,
|
|
30
|
+
// we set the event emitter to null and then create a new event emitter.
|
|
31
|
+
this.emitter.removeAllListeners();
|
|
32
|
+
this.emitter = null;
|
|
33
|
+
this.emitter = new EventEmitter();
|
|
34
|
+
}
|
|
25
35
|
}
|
|
26
36
|
}
|
|
37
|
+
|
|
38
|
+
// TODO We should use a scoped ActiveAnchorTracker rather than the global static object.
|
|
39
|
+
// Move this into the plugin scope once the newApply functions becomes default apply.
|
|
27
40
|
export const defaultActiveAnchorTracker = new ActiveAnchorTracker();
|
|
28
41
|
export const useActiveAnchorTracker = (anchorName, activeAnchorTracker = defaultActiveAnchorTracker) => {
|
|
29
42
|
const [isActive, setIsActive] = useState(false);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
2
|
-
import {
|
|
2
|
+
import { maxLayoutColumnSupported } from '../consts';
|
|
3
3
|
import { isPreRelease1 } from './advanced-layouts-flags';
|
|
4
4
|
import { isWrappedMedia } from './check-media-layout';
|
|
5
5
|
export const shouldAllowInlineDropTarget = (isNested, node) => {
|
|
@@ -10,7 +10,7 @@ export const shouldAllowInlineDropTarget = (isNested, node) => {
|
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
12
|
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
|
|
13
|
-
return node.childCount <
|
|
13
|
+
return node.childCount < maxLayoutColumnSupported();
|
|
14
14
|
}
|
|
15
15
|
return !isEmptyParagraph(node);
|
|
16
16
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import {
|
|
3
|
+
import { maxLayoutColumnSupported } from '../consts';
|
|
4
4
|
import { DEFAULT_COLUMN_DISTRIBUTIONS } from '../ui/consts';
|
|
5
5
|
var createNewLayout = function createNewLayout(schema, layoutContents) {
|
|
6
|
-
if (layoutContents.length === 0 || layoutContents.length >
|
|
6
|
+
if (layoutContents.length === 0 || layoutContents.length > maxLayoutColumnSupported()) {
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
9
|
var width = DEFAULT_COLUMN_DISTRIBUTIONS[layoutContents.length];
|
|
@@ -48,7 +48,7 @@ var moveNode = function moveNode(from, to, newNode, sourceNodeSize, tr) {
|
|
|
48
48
|
return tr;
|
|
49
49
|
};
|
|
50
50
|
var moveToExistingLayout = function moveToExistingLayout(toLayout, toLayoutPos, sourceNode, from, to, tr) {
|
|
51
|
-
if (toLayout.childCount <
|
|
51
|
+
if (toLayout.childCount < maxLayoutColumnSupported()) {
|
|
52
52
|
var newColumnWidth = DEFAULT_COLUMN_DISTRIBUTIONS[toLayout.childCount + 1];
|
|
53
53
|
updateColumnWidths(tr, toLayout, toLayoutPos, newColumnWidth);
|
|
54
54
|
var _ref2 = tr.doc.type.schema.nodes || {},
|
package/dist/esm/consts.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPreRelease2 } from './utils/advanced-layouts-flags';
|
|
1
2
|
export var DIRECTION = /*#__PURE__*/function (DIRECTION) {
|
|
2
3
|
DIRECTION["UP"] = "up";
|
|
3
4
|
DIRECTION["DOWN"] = "down";
|
|
@@ -5,4 +6,6 @@ export var DIRECTION = /*#__PURE__*/function (DIRECTION) {
|
|
|
5
6
|
DIRECTION["RIGHT"] = "right";
|
|
6
7
|
return DIRECTION;
|
|
7
8
|
}({});
|
|
8
|
-
export var
|
|
9
|
+
export var maxLayoutColumnSupported = function maxLayoutColumnSupported() {
|
|
10
|
+
return isPreRelease2() ? 5 : 3;
|
|
11
|
+
};
|
|
@@ -7,7 +7,7 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
|
7
7
|
import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
10
|
-
import {
|
|
10
|
+
import { maxLayoutColumnSupported } from '../consts';
|
|
11
11
|
import { nodeMargins } from '../ui/consts';
|
|
12
12
|
import { DropTarget } from '../ui/drop-target';
|
|
13
13
|
import { DropTargetLayout } from '../ui/drop-target-layout';
|
|
@@ -154,7 +154,7 @@ export var dropTargetDecorations = function dropTargetDecorations(newState, api,
|
|
|
154
154
|
if (isAdvancedLayoutsPreRelease2) {
|
|
155
155
|
if (node.type.name === 'layoutColumn' && (parent === null || parent === void 0 ? void 0 : parent.type.name) === 'layoutSection' && (parent === null || parent === void 0 ? void 0 : parent.firstChild) !== node &&
|
|
156
156
|
// Not the first node
|
|
157
|
-
(parent === null || parent === void 0 ? void 0 : parent.childCount) <
|
|
157
|
+
(parent === null || parent === void 0 ? void 0 : parent.childCount) < maxLayoutColumnSupported()) {
|
|
158
158
|
decs.push(createLayoutDropTargetDecoration(pos, {
|
|
159
159
|
api: api,
|
|
160
160
|
parent: parent,
|
|
@@ -51,9 +51,6 @@ var destroyFn = function destroyFn(api) {
|
|
|
51
51
|
if (isHTMLElement(scrollable)) {
|
|
52
52
|
scrollable.style.setProperty('scroll-behavior', null);
|
|
53
53
|
}
|
|
54
|
-
if (isPreRelease2()) {
|
|
55
|
-
defaultActiveAnchorTracker.reset();
|
|
56
|
-
}
|
|
57
54
|
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref3) {
|
|
58
55
|
var tr = _ref3.tr;
|
|
59
56
|
var _ref4 = source.data,
|
|
@@ -512,6 +509,9 @@ export var createPlugin = function createPlugin(api, getIntl) {
|
|
|
512
509
|
},
|
|
513
510
|
dragstart: function dragstart(view) {
|
|
514
511
|
var _anchorRectCache;
|
|
512
|
+
if (isPreRelease2()) {
|
|
513
|
+
defaultActiveAnchorTracker.reset();
|
|
514
|
+
}
|
|
515
515
|
(_anchorRectCache = anchorRectCache) === null || _anchorRectCache === void 0 || _anchorRectCache.setEditorView(view);
|
|
516
516
|
view.dispatch(view.state.tr.setMeta(key, {
|
|
517
517
|
isPMDragging: true
|
|
@@ -14,17 +14,21 @@ export var ActiveAnchorTracker = /*#__PURE__*/function () {
|
|
|
14
14
|
_createClass(ActiveAnchorTracker, [{
|
|
15
15
|
key: "subscribe",
|
|
16
16
|
value: function subscribe(anchorName, callback) {
|
|
17
|
-
this.emitter
|
|
17
|
+
if (this.emitter) {
|
|
18
|
+
this.emitter.on(anchorName, callback);
|
|
19
|
+
}
|
|
18
20
|
}
|
|
19
21
|
}, {
|
|
20
22
|
key: "unsubscribe",
|
|
21
23
|
value: function unsubscribe(anchorName, callback) {
|
|
22
|
-
this.emitter
|
|
24
|
+
if (this.emitter) {
|
|
25
|
+
this.emitter.removeListener(anchorName, callback);
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
28
|
}, {
|
|
25
29
|
key: "emit",
|
|
26
30
|
value: function emit(anchorName) {
|
|
27
|
-
if (this.lastActiveAnchor !== anchorName) {
|
|
31
|
+
if (this.lastActiveAnchor !== anchorName && this.emitter) {
|
|
28
32
|
this.emitter.emit(this.lastActiveAnchor, false);
|
|
29
33
|
this.emitter.emit(anchorName, true);
|
|
30
34
|
this.lastActiveAnchor = anchorName;
|
|
@@ -33,11 +37,20 @@ export var ActiveAnchorTracker = /*#__PURE__*/function () {
|
|
|
33
37
|
}, {
|
|
34
38
|
key: "reset",
|
|
35
39
|
value: function reset() {
|
|
36
|
-
this.emitter
|
|
40
|
+
if (this.emitter) {
|
|
41
|
+
// To prevent any potential memory leaks,
|
|
42
|
+
// we set the event emitter to null and then create a new event emitter.
|
|
43
|
+
this.emitter.removeAllListeners();
|
|
44
|
+
this.emitter = null;
|
|
45
|
+
this.emitter = new EventEmitter();
|
|
46
|
+
}
|
|
37
47
|
}
|
|
38
48
|
}]);
|
|
39
49
|
return ActiveAnchorTracker;
|
|
40
50
|
}();
|
|
51
|
+
|
|
52
|
+
// TODO We should use a scoped ActiveAnchorTracker rather than the global static object.
|
|
53
|
+
// Move this into the plugin scope once the newApply functions becomes default apply.
|
|
41
54
|
export var defaultActiveAnchorTracker = new ActiveAnchorTracker();
|
|
42
55
|
export var useActiveAnchorTracker = function useActiveAnchorTracker(anchorName) {
|
|
43
56
|
var activeAnchorTracker = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultActiveAnchorTracker;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
2
|
-
import {
|
|
2
|
+
import { maxLayoutColumnSupported } from '../consts';
|
|
3
3
|
import { isPreRelease1 } from './advanced-layouts-flags';
|
|
4
4
|
import { isWrappedMedia } from './check-media-layout';
|
|
5
5
|
export var shouldAllowInlineDropTarget = function shouldAllowInlineDropTarget(isNested, node) {
|
|
@@ -10,7 +10,7 @@ export var shouldAllowInlineDropTarget = function shouldAllowInlineDropTarget(is
|
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
12
|
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
|
|
13
|
-
return node.childCount <
|
|
13
|
+
return node.childCount < maxLayoutColumnSupported();
|
|
14
14
|
}
|
|
15
15
|
return !isEmptyParagraph(node);
|
|
16
16
|
};
|
package/dist/types/consts.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/// <reference types="node/events" />
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
5
|
export declare class ActiveAnchorTracker {
|
|
6
|
-
emitter: EventEmitter;
|
|
6
|
+
emitter: EventEmitter | null;
|
|
7
7
|
lastActiveAnchor: string;
|
|
8
8
|
constructor();
|
|
9
9
|
subscribe(anchorName: string, callback: (isActive: boolean) => void): void;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/// <reference types="node/events" />
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
5
|
export declare class ActiveAnchorTracker {
|
|
6
|
-
emitter: EventEmitter;
|
|
6
|
+
emitter: EventEmitter | null;
|
|
7
7
|
lastActiveAnchor: string;
|
|
8
8
|
constructor();
|
|
9
9
|
subscribe(anchorName: string, callback: (isActive: boolean) => void): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.5",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@atlaskit/adf-schema": "^44.2.0",
|
|
34
|
-
"@atlaskit/editor-common": "^94.
|
|
34
|
+
"@atlaskit/editor-common": "^94.12.0",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^1.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
37
37
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
"platform-feature-flags": {
|
|
102
|
-
"
|
|
102
|
+
"platform_editor_media_extended_resize_experience": {
|
|
103
103
|
"type": "boolean",
|
|
104
104
|
"referenceOnly": true
|
|
105
105
|
},
|