@atlaskit/editor-ui-control-model 0.0.1 → 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 +8 -0
- package/dist/cjs/createRegistry.js +48 -0
- package/dist/cjs/index.js +7 -3
- package/dist/cjs/types.js +5 -0
- package/dist/es2019/createRegistry.js +40 -0
- package/dist/es2019/index.js +4 -2
- package/dist/es2019/types.js +1 -0
- package/dist/esm/createRegistry.js +41 -0
- package/dist/esm/index.js +4 -2
- package/dist/esm/types.js +1 -0
- package/dist/types/createRegistry.d.ts +35 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/types.d.ts +13 -0
- package/dist/types-ts4.5/createRegistry.d.ts +35 -0
- package/dist/types-ts4.5/index.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +13 -0
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
1
|
# @atlaskit/editor-ui-control-model
|
|
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.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createRegistry = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
/**
|
|
10
|
+
* Create a registry for UI control components (toolbar buttons, menu items, etc.).
|
|
11
|
+
*
|
|
12
|
+
* Follows the same pattern as `createBlockMenuRegistry` from `editor-plugin-block-menu`
|
|
13
|
+
* but uses generic types to support any surface (toolbars, menus, etc.).
|
|
14
|
+
*
|
|
15
|
+
* Each component should have a unique `type` + `key` combination. The parent-child
|
|
16
|
+
* model relies on key-based lookup, so duplicate keys lead to undefined behaviour.
|
|
17
|
+
*
|
|
18
|
+
* @returns A registry object with a `register` method and a `components` array.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const registry = createRegistry();
|
|
23
|
+
*
|
|
24
|
+
* registry.register([
|
|
25
|
+
* {
|
|
26
|
+
* type: 'toolbar',
|
|
27
|
+
* key: 'primary-toolbar',
|
|
28
|
+
* component: ({ children }) => <div>{children}</div>,
|
|
29
|
+
* },
|
|
30
|
+
* {
|
|
31
|
+
* type: 'section',
|
|
32
|
+
* key: 'section-1',
|
|
33
|
+
* parents: [{ type: 'toolbar', key: 'primary-toolbar', rank: 1 }],
|
|
34
|
+
* component: ({ children }) => <div>{children}</div>,
|
|
35
|
+
* },
|
|
36
|
+
* ]);
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
var createRegistry = exports.createRegistry = function createRegistry() {
|
|
40
|
+
var components = [];
|
|
41
|
+
var register = function register(newComponents) {
|
|
42
|
+
components.push.apply(components, (0, _toConsumableArray2.default)(newComponents));
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
register: register,
|
|
46
|
+
components: components
|
|
47
|
+
};
|
|
48
|
+
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
Object.defineProperty(exports, "createRegistry", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _createRegistry.createRegistry;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _createRegistry = require("./createRegistry");
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a registry for UI control components (toolbar buttons, menu items, etc.).
|
|
3
|
+
*
|
|
4
|
+
* Follows the same pattern as `createBlockMenuRegistry` from `editor-plugin-block-menu`
|
|
5
|
+
* but uses generic types to support any surface (toolbars, menus, etc.).
|
|
6
|
+
*
|
|
7
|
+
* Each component should have a unique `type` + `key` combination. The parent-child
|
|
8
|
+
* model relies on key-based lookup, so duplicate keys lead to undefined behaviour.
|
|
9
|
+
*
|
|
10
|
+
* @returns A registry object with a `register` method and a `components` array.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const registry = createRegistry();
|
|
15
|
+
*
|
|
16
|
+
* registry.register([
|
|
17
|
+
* {
|
|
18
|
+
* type: 'toolbar',
|
|
19
|
+
* key: 'primary-toolbar',
|
|
20
|
+
* component: ({ children }) => <div>{children}</div>,
|
|
21
|
+
* },
|
|
22
|
+
* {
|
|
23
|
+
* type: 'section',
|
|
24
|
+
* key: 'section-1',
|
|
25
|
+
* parents: [{ type: 'toolbar', key: 'primary-toolbar', rank: 1 }],
|
|
26
|
+
* component: ({ children }) => <div>{children}</div>,
|
|
27
|
+
* },
|
|
28
|
+
* ]);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export const createRegistry = () => {
|
|
32
|
+
const components = [];
|
|
33
|
+
const register = newComponents => {
|
|
34
|
+
components.push(...newComponents);
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
register,
|
|
38
|
+
components
|
|
39
|
+
};
|
|
40
|
+
};
|
package/dist/es2019/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
/**
|
|
3
|
+
* Create a registry for UI control components (toolbar buttons, menu items, etc.).
|
|
4
|
+
*
|
|
5
|
+
* Follows the same pattern as `createBlockMenuRegistry` from `editor-plugin-block-menu`
|
|
6
|
+
* but uses generic types to support any surface (toolbars, menus, etc.).
|
|
7
|
+
*
|
|
8
|
+
* Each component should have a unique `type` + `key` combination. The parent-child
|
|
9
|
+
* model relies on key-based lookup, so duplicate keys lead to undefined behaviour.
|
|
10
|
+
*
|
|
11
|
+
* @returns A registry object with a `register` method and a `components` array.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const registry = createRegistry();
|
|
16
|
+
*
|
|
17
|
+
* registry.register([
|
|
18
|
+
* {
|
|
19
|
+
* type: 'toolbar',
|
|
20
|
+
* key: 'primary-toolbar',
|
|
21
|
+
* component: ({ children }) => <div>{children}</div>,
|
|
22
|
+
* },
|
|
23
|
+
* {
|
|
24
|
+
* type: 'section',
|
|
25
|
+
* key: 'section-1',
|
|
26
|
+
* parents: [{ type: 'toolbar', key: 'primary-toolbar', rank: 1 }],
|
|
27
|
+
* component: ({ children }) => <div>{children}</div>,
|
|
28
|
+
* },
|
|
29
|
+
* ]);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export var createRegistry = function createRegistry() {
|
|
33
|
+
var components = [];
|
|
34
|
+
var register = function register(newComponents) {
|
|
35
|
+
components.push.apply(components, _toConsumableArray(newComponents));
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
register: register,
|
|
39
|
+
components: components
|
|
40
|
+
};
|
|
41
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { RegisterComponent } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Create a registry for UI control components (toolbar buttons, menu items, etc.).
|
|
4
|
+
*
|
|
5
|
+
* Follows the same pattern as `createBlockMenuRegistry` from `editor-plugin-block-menu`
|
|
6
|
+
* but uses generic types to support any surface (toolbars, menus, etc.).
|
|
7
|
+
*
|
|
8
|
+
* Each component should have a unique `type` + `key` combination. The parent-child
|
|
9
|
+
* model relies on key-based lookup, so duplicate keys lead to undefined behaviour.
|
|
10
|
+
*
|
|
11
|
+
* @returns A registry object with a `register` method and a `components` array.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const registry = createRegistry();
|
|
16
|
+
*
|
|
17
|
+
* registry.register([
|
|
18
|
+
* {
|
|
19
|
+
* type: 'toolbar',
|
|
20
|
+
* key: 'primary-toolbar',
|
|
21
|
+
* component: ({ children }) => <div>{children}</div>,
|
|
22
|
+
* },
|
|
23
|
+
* {
|
|
24
|
+
* type: 'section',
|
|
25
|
+
* key: 'section-1',
|
|
26
|
+
* parents: [{ type: 'toolbar', key: 'primary-toolbar', rank: 1 }],
|
|
27
|
+
* component: ({ children }) => <div>{children}</div>,
|
|
28
|
+
* },
|
|
29
|
+
* ]);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const createRegistry: () => {
|
|
33
|
+
register: (newComponents: RegisterComponent[]) => void;
|
|
34
|
+
components: RegisterComponent[];
|
|
35
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
export { createRegistry } from './createRegistry';
|
|
2
|
+
export type { RegisterComponent, RegisterComponentParent } from './types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export type RegisterComponentParent = {
|
|
3
|
+
key: string;
|
|
4
|
+
rank: number;
|
|
5
|
+
type: string;
|
|
6
|
+
};
|
|
7
|
+
export type RegisterComponent = {
|
|
8
|
+
component?: (props: Record<string, unknown>) => React.ReactNode;
|
|
9
|
+
isHidden?: () => boolean;
|
|
10
|
+
key: string;
|
|
11
|
+
parents?: RegisterComponentParent[];
|
|
12
|
+
type: string;
|
|
13
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { RegisterComponent } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Create a registry for UI control components (toolbar buttons, menu items, etc.).
|
|
4
|
+
*
|
|
5
|
+
* Follows the same pattern as `createBlockMenuRegistry` from `editor-plugin-block-menu`
|
|
6
|
+
* but uses generic types to support any surface (toolbars, menus, etc.).
|
|
7
|
+
*
|
|
8
|
+
* Each component should have a unique `type` + `key` combination. The parent-child
|
|
9
|
+
* model relies on key-based lookup, so duplicate keys lead to undefined behaviour.
|
|
10
|
+
*
|
|
11
|
+
* @returns A registry object with a `register` method and a `components` array.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const registry = createRegistry();
|
|
16
|
+
*
|
|
17
|
+
* registry.register([
|
|
18
|
+
* {
|
|
19
|
+
* type: 'toolbar',
|
|
20
|
+
* key: 'primary-toolbar',
|
|
21
|
+
* component: ({ children }) => <div>{children}</div>,
|
|
22
|
+
* },
|
|
23
|
+
* {
|
|
24
|
+
* type: 'section',
|
|
25
|
+
* key: 'section-1',
|
|
26
|
+
* parents: [{ type: 'toolbar', key: 'primary-toolbar', rank: 1 }],
|
|
27
|
+
* component: ({ children }) => <div>{children}</div>,
|
|
28
|
+
* },
|
|
29
|
+
* ]);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const createRegistry: () => {
|
|
33
|
+
register: (newComponents: RegisterComponent[]) => void;
|
|
34
|
+
components: RegisterComponent[];
|
|
35
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
export { createRegistry } from './createRegistry';
|
|
2
|
+
export type { RegisterComponent, RegisterComponentParent } from './types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export type RegisterComponentParent = {
|
|
3
|
+
key: string;
|
|
4
|
+
rank: number;
|
|
5
|
+
type: string;
|
|
6
|
+
};
|
|
7
|
+
export type RegisterComponent = {
|
|
8
|
+
component?: (props: Record<string, unknown>) => React.ReactNode;
|
|
9
|
+
isHidden?: () => boolean;
|
|
10
|
+
key: string;
|
|
11
|
+
parents?: RegisterComponentParent[];
|
|
12
|
+
type: string;
|
|
13
|
+
};
|
package/package.json
CHANGED
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@babel/runtime": "^7.0.0"
|
|
25
25
|
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"react": "^18.2.0"
|
|
28
|
+
},
|
|
26
29
|
"techstack": {
|
|
27
30
|
"@atlassian/frontend": {
|
|
28
31
|
"import-structure": [
|
|
@@ -59,7 +62,7 @@
|
|
|
59
62
|
}
|
|
60
63
|
},
|
|
61
64
|
"name": "@atlaskit/editor-ui-control-model",
|
|
62
|
-
"version": "0.0
|
|
65
|
+
"version": "1.0.0",
|
|
63
66
|
"description": "Rendering logic and model-types for Editor controls registry ( editor-plugin-ui-control-registry)",
|
|
64
67
|
"author": "Atlassian Pty Ltd",
|
|
65
68
|
"license": "Apache-2.0",
|