@atlaskit/editor-plugin-ui-control-registry 0.0.0 → 1.0.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 +13 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-jira/tsconfig.json +3 -0
- package/afm-products/tsconfig.json +3 -0
- package/dist/cjs/uiControlRegistryPlugin.js +57 -1
- package/dist/es2019/uiControlRegistryPlugin.js +43 -3
- package/dist/esm/uiControlRegistryPlugin.js +57 -1
- package/dist/types/uiControlRegistryPluginType.d.ts +7 -1
- package/dist/types-ts4.5/uiControlRegistryPluginType.d.ts +7 -1
- package/package.json +3 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @atlaskit/editor-plugin-ui-control-registry
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`35fd4b17a4355`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/35fd4b17a4355) -
|
|
8
|
+
EDITOR-5598 Create initial implementation of Editor UI Control Registry, implementing its API for
|
|
9
|
+
adding elements to the registry and retrieving menu elements for a surface.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
package/afm-cc/tsconfig.json
CHANGED
package/afm-jira/tsconfig.json
CHANGED
|
@@ -4,8 +4,64 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.uiControlRegistryPlugin = void 0;
|
|
7
|
+
var _editorUiControlModel = require("@atlaskit/editor-ui-control-model");
|
|
8
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
9
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
11
|
+
/**
|
|
12
|
+
* Collect all components that belong to the tree rooted at `surfaceKey`.
|
|
13
|
+
*
|
|
14
|
+
* A surface is a root component (one with no `parents`). Starting from that
|
|
15
|
+
* root, every component whose parent chain leads back to it is included.
|
|
16
|
+
*/
|
|
17
|
+
function getComponentsForSurface(allComponents, surfaceKey) {
|
|
18
|
+
var root = allComponents.find(function (c) {
|
|
19
|
+
return c.key === surfaceKey && (!c.parents || c.parents.length === 0);
|
|
20
|
+
});
|
|
21
|
+
if (!root) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
var includedKeys = new Set([surfaceKey]);
|
|
25
|
+
var changed = true;
|
|
26
|
+
while (changed) {
|
|
27
|
+
changed = false;
|
|
28
|
+
var _iterator = _createForOfIteratorHelper(allComponents),
|
|
29
|
+
_step;
|
|
30
|
+
try {
|
|
31
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
32
|
+
var _component$parents;
|
|
33
|
+
var component = _step.value;
|
|
34
|
+
if (includedKeys.has(component.key)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if ((_component$parents = component.parents) !== null && _component$parents !== void 0 && _component$parents.some(function (p) {
|
|
38
|
+
return includedKeys.has(p.key);
|
|
39
|
+
})) {
|
|
40
|
+
includedKeys.add(component.key);
|
|
41
|
+
changed = true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} catch (err) {
|
|
45
|
+
_iterator.e(err);
|
|
46
|
+
} finally {
|
|
47
|
+
_iterator.f();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return allComponents.filter(function (c) {
|
|
51
|
+
return includedKeys.has(c.key);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
7
54
|
var uiControlRegistryPlugin = exports.uiControlRegistryPlugin = function uiControlRegistryPlugin() {
|
|
55
|
+
var registry = (0, _editorUiControlModel.createRegistry)();
|
|
8
56
|
return {
|
|
9
|
-
name: 'uiControlRegistry'
|
|
57
|
+
name: 'uiControlRegistry',
|
|
58
|
+
actions: {
|
|
59
|
+
register: function register(components) {
|
|
60
|
+
registry.register(components);
|
|
61
|
+
},
|
|
62
|
+
getComponents: function getComponents(surface) {
|
|
63
|
+
return getComponentsForSurface(registry.components, surface);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
10
66
|
};
|
|
11
67
|
};
|
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { createRegistry } from '@atlaskit/editor-ui-control-model';
|
|
2
|
+
/**
|
|
3
|
+
* Collect all components that belong to the tree rooted at `surfaceKey`.
|
|
4
|
+
*
|
|
5
|
+
* A surface is a root component (one with no `parents`). Starting from that
|
|
6
|
+
* root, every component whose parent chain leads back to it is included.
|
|
7
|
+
*/
|
|
8
|
+
function getComponentsForSurface(allComponents, surfaceKey) {
|
|
9
|
+
const root = allComponents.find(c => c.key === surfaceKey && (!c.parents || c.parents.length === 0));
|
|
10
|
+
if (!root) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
const includedKeys = new Set([surfaceKey]);
|
|
14
|
+
let changed = true;
|
|
15
|
+
while (changed) {
|
|
16
|
+
changed = false;
|
|
17
|
+
for (const component of allComponents) {
|
|
18
|
+
var _component$parents;
|
|
19
|
+
if (includedKeys.has(component.key)) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if ((_component$parents = component.parents) !== null && _component$parents !== void 0 && _component$parents.some(p => includedKeys.has(p.key))) {
|
|
23
|
+
includedKeys.add(component.key);
|
|
24
|
+
changed = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return allComponents.filter(c => includedKeys.has(c.key));
|
|
29
|
+
}
|
|
30
|
+
export const uiControlRegistryPlugin = () => {
|
|
31
|
+
const registry = createRegistry();
|
|
32
|
+
return {
|
|
33
|
+
name: 'uiControlRegistry',
|
|
34
|
+
actions: {
|
|
35
|
+
register: components => {
|
|
36
|
+
registry.register(components);
|
|
37
|
+
},
|
|
38
|
+
getComponents: surface => {
|
|
39
|
+
return getComponentsForSurface(registry.components, surface);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -1,5 +1,61 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
|
+
import { createRegistry } from '@atlaskit/editor-ui-control-model';
|
|
5
|
+
/**
|
|
6
|
+
* Collect all components that belong to the tree rooted at `surfaceKey`.
|
|
7
|
+
*
|
|
8
|
+
* A surface is a root component (one with no `parents`). Starting from that
|
|
9
|
+
* root, every component whose parent chain leads back to it is included.
|
|
10
|
+
*/
|
|
11
|
+
function getComponentsForSurface(allComponents, surfaceKey) {
|
|
12
|
+
var root = allComponents.find(function (c) {
|
|
13
|
+
return c.key === surfaceKey && (!c.parents || c.parents.length === 0);
|
|
14
|
+
});
|
|
15
|
+
if (!root) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
var includedKeys = new Set([surfaceKey]);
|
|
19
|
+
var changed = true;
|
|
20
|
+
while (changed) {
|
|
21
|
+
changed = false;
|
|
22
|
+
var _iterator = _createForOfIteratorHelper(allComponents),
|
|
23
|
+
_step;
|
|
24
|
+
try {
|
|
25
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
26
|
+
var _component$parents;
|
|
27
|
+
var component = _step.value;
|
|
28
|
+
if (includedKeys.has(component.key)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if ((_component$parents = component.parents) !== null && _component$parents !== void 0 && _component$parents.some(function (p) {
|
|
32
|
+
return includedKeys.has(p.key);
|
|
33
|
+
})) {
|
|
34
|
+
includedKeys.add(component.key);
|
|
35
|
+
changed = true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} catch (err) {
|
|
39
|
+
_iterator.e(err);
|
|
40
|
+
} finally {
|
|
41
|
+
_iterator.f();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return allComponents.filter(function (c) {
|
|
45
|
+
return includedKeys.has(c.key);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
1
48
|
export var uiControlRegistryPlugin = function uiControlRegistryPlugin() {
|
|
49
|
+
var registry = createRegistry();
|
|
2
50
|
return {
|
|
3
|
-
name: 'uiControlRegistry'
|
|
51
|
+
name: 'uiControlRegistry',
|
|
52
|
+
actions: {
|
|
53
|
+
register: function register(components) {
|
|
54
|
+
registry.register(components);
|
|
55
|
+
},
|
|
56
|
+
getComponents: function getComponents(surface) {
|
|
57
|
+
return getComponentsForSurface(registry.components, surface);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
4
60
|
};
|
|
5
61
|
};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
-
|
|
2
|
+
import type { RegisterComponent } from '@atlaskit/editor-ui-control-model';
|
|
3
|
+
export type UiControlRegistryPlugin = NextEditorPlugin<'uiControlRegistry', {
|
|
4
|
+
actions: {
|
|
5
|
+
getComponents: (surface: string) => RegisterComponent[];
|
|
6
|
+
register: (components: RegisterComponent[]) => void;
|
|
7
|
+
};
|
|
8
|
+
}>;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
-
|
|
2
|
+
import type { RegisterComponent } from '@atlaskit/editor-ui-control-model';
|
|
3
|
+
export type UiControlRegistryPlugin = NextEditorPlugin<'uiControlRegistry', {
|
|
4
|
+
actions: {
|
|
5
|
+
getComponents: (surface: string) => RegisterComponent[];
|
|
6
|
+
register: (components: RegisterComponent[]) => void;
|
|
7
|
+
};
|
|
8
|
+
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-ui-control-registry",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "UiControlRegistry plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,10 +28,11 @@
|
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"@atlaskit/editor-ui-control-model": "^1.0.0",
|
|
31
32
|
"@babel/runtime": "^7.0.0"
|
|
32
33
|
},
|
|
33
34
|
"peerDependencies": {
|
|
34
|
-
"@atlaskit/editor-common": "^111.
|
|
35
|
+
"@atlaskit/editor-common": "^111.20.0",
|
|
35
36
|
"react": "^18.2.0"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|