@atlaskit/editor-toolbar-model 0.1.2 → 0.2.1
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 +14 -0
- package/dist/cjs/create-registry.js +23 -0
- package/dist/es2019/create-registry.js +21 -0
- package/dist/esm/create-registry.js +23 -0
- package/dist/types/create-registry.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types-ts4.5/create-registry.d.ts +1 -0
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/package.json +5 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-toolbar-model
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 0.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`51f3f2db61f6e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/51f3f2db61f6e) -
|
|
14
|
+
Add ranks and keys for new collapsed text section component, add responsive container to
|
|
15
|
+
PrimaryToolbar export with new query selectors to hide empty elements, export types
|
|
16
|
+
|
|
3
17
|
## 0.1.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -42,8 +42,31 @@ var createComponentRegistry = exports.createComponentRegistry = function createC
|
|
|
42
42
|
var register = function register(newComponents) {
|
|
43
43
|
components.push.apply(components, (0, _toConsumableArray2.default)(newComponents));
|
|
44
44
|
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Similer to `register` but first checks the registry against `newComponents` using its
|
|
48
|
+
* key and type, if it already exists it replaces the item instead of simply appending it.
|
|
49
|
+
*
|
|
50
|
+
* Most likely you should avoid using this and just use the `register` method as it's preferred
|
|
51
|
+
* to register components statically.
|
|
52
|
+
*/
|
|
53
|
+
var safeRegister = function safeRegister(newComponents) {
|
|
54
|
+
newComponents.forEach(function (newComponent) {
|
|
55
|
+
var existingIndex = components.findIndex(function (existingComponent) {
|
|
56
|
+
return existingComponent.type === newComponent.type && existingComponent.key === newComponent.key;
|
|
57
|
+
});
|
|
58
|
+
if (existingIndex !== -1) {
|
|
59
|
+
// Replace existing component
|
|
60
|
+
components[existingIndex] = newComponent;
|
|
61
|
+
} else {
|
|
62
|
+
// Add new component
|
|
63
|
+
components.push(newComponent);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
};
|
|
45
67
|
return {
|
|
46
68
|
register: register,
|
|
69
|
+
safeRegister: safeRegister,
|
|
47
70
|
components: components
|
|
48
71
|
};
|
|
49
72
|
};
|
|
@@ -34,8 +34,29 @@ export const createComponentRegistry = () => {
|
|
|
34
34
|
const register = newComponents => {
|
|
35
35
|
components.push(...newComponents);
|
|
36
36
|
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Similer to `register` but first checks the registry against `newComponents` using its
|
|
40
|
+
* key and type, if it already exists it replaces the item instead of simply appending it.
|
|
41
|
+
*
|
|
42
|
+
* Most likely you should avoid using this and just use the `register` method as it's preferred
|
|
43
|
+
* to register components statically.
|
|
44
|
+
*/
|
|
45
|
+
const safeRegister = newComponents => {
|
|
46
|
+
newComponents.forEach(newComponent => {
|
|
47
|
+
const existingIndex = components.findIndex(existingComponent => existingComponent.type === newComponent.type && existingComponent.key === newComponent.key);
|
|
48
|
+
if (existingIndex !== -1) {
|
|
49
|
+
// Replace existing component
|
|
50
|
+
components[existingIndex] = newComponent;
|
|
51
|
+
} else {
|
|
52
|
+
// Add new component
|
|
53
|
+
components.push(newComponent);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
37
57
|
return {
|
|
38
58
|
register,
|
|
59
|
+
safeRegister,
|
|
39
60
|
components
|
|
40
61
|
};
|
|
41
62
|
};
|
|
@@ -35,8 +35,31 @@ export var createComponentRegistry = function createComponentRegistry() {
|
|
|
35
35
|
var register = function register(newComponents) {
|
|
36
36
|
components.push.apply(components, _toConsumableArray(newComponents));
|
|
37
37
|
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Similer to `register` but first checks the registry against `newComponents` using its
|
|
41
|
+
* key and type, if it already exists it replaces the item instead of simply appending it.
|
|
42
|
+
*
|
|
43
|
+
* Most likely you should avoid using this and just use the `register` method as it's preferred
|
|
44
|
+
* to register components statically.
|
|
45
|
+
*/
|
|
46
|
+
var safeRegister = function safeRegister(newComponents) {
|
|
47
|
+
newComponents.forEach(function (newComponent) {
|
|
48
|
+
var existingIndex = components.findIndex(function (existingComponent) {
|
|
49
|
+
return existingComponent.type === newComponent.type && existingComponent.key === newComponent.key;
|
|
50
|
+
});
|
|
51
|
+
if (existingIndex !== -1) {
|
|
52
|
+
// Replace existing component
|
|
53
|
+
components[existingIndex] = newComponent;
|
|
54
|
+
} else {
|
|
55
|
+
// Add new component
|
|
56
|
+
components.push(newComponent);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
38
60
|
return {
|
|
39
61
|
register: register,
|
|
62
|
+
safeRegister: safeRegister,
|
|
40
63
|
components: components
|
|
41
64
|
};
|
|
42
65
|
};
|
|
@@ -32,5 +32,6 @@ import type { RegisterComponent } from './types';
|
|
|
32
32
|
*/
|
|
33
33
|
export declare const createComponentRegistry: () => {
|
|
34
34
|
register: (newComponents: RegisterComponent[]) => void;
|
|
35
|
+
safeRegister: (newComponents: RegisterComponent[]) => void;
|
|
35
36
|
components: RegisterComponent[];
|
|
36
37
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { ToolbarModelRenderer } from './ui/toolbar-model-renderer';
|
|
2
|
-
export type { ToolbarComponentType, ToolbarComponentTypes, ToolbarType, ToolbarMenuComponent, ToolbarButtonComponent, ToolbarMenuItemComponent, ToolbarGroupComponent, RegisterToolbar, RegisterToolbarSection, RegisterToolbarGroup, RegisterToolbarButton, RegisterToolbarMenu, RegisterToolbarNestedMenu, RegisterToolbarMenuSection, RegisterToolbarMenuItem, RegisterComponent, } from './types';
|
|
2
|
+
export type { ToolbarComponentType, ToolbarComponentTypes, CommonComponentProps, ToolbarType, ToolbarMenuComponent, ToolbarButtonComponent, ToolbarMenuItemComponent, ToolbarGroupComponent, RegisterToolbar, RegisterToolbarSection, RegisterToolbarGroup, RegisterToolbarButton, RegisterToolbarMenu, RegisterToolbarNestedMenu, RegisterToolbarMenuSection, RegisterToolbarMenuItem, RegisterComponent, } from './types';
|
|
3
3
|
export { createComponentRegistry } from './create-registry';
|
|
@@ -4,7 +4,7 @@ type WithRank<T> = T & {
|
|
|
4
4
|
type Parents<T> = Array<WithRank<T>>;
|
|
5
5
|
export type ToolbarComponentType = ToolbarType | ToolbarSectionType | ToolbarGroupType | ToolbarButtonType | ToolbarMenuType | ToolbarNestedMenuType | ToolbarMenuSectionType | ToolbarMenuItemType;
|
|
6
6
|
export type ToolbarComponentTypes = Array<ToolbarComponentType>;
|
|
7
|
-
type CommonComponentProps = {
|
|
7
|
+
export type CommonComponentProps = {
|
|
8
8
|
/**
|
|
9
9
|
* Array of parent information including both keys and types
|
|
10
10
|
* Ordered from immediate parent to root parent
|
|
@@ -32,5 +32,6 @@ import type { RegisterComponent } from './types';
|
|
|
32
32
|
*/
|
|
33
33
|
export declare const createComponentRegistry: () => {
|
|
34
34
|
register: (newComponents: RegisterComponent[]) => void;
|
|
35
|
+
safeRegister: (newComponents: RegisterComponent[]) => void;
|
|
35
36
|
components: RegisterComponent[];
|
|
36
37
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { ToolbarModelRenderer } from './ui/toolbar-model-renderer';
|
|
2
|
-
export type { ToolbarComponentType, ToolbarComponentTypes, ToolbarType, ToolbarMenuComponent, ToolbarButtonComponent, ToolbarMenuItemComponent, ToolbarGroupComponent, RegisterToolbar, RegisterToolbarSection, RegisterToolbarGroup, RegisterToolbarButton, RegisterToolbarMenu, RegisterToolbarNestedMenu, RegisterToolbarMenuSection, RegisterToolbarMenuItem, RegisterComponent, } from './types';
|
|
2
|
+
export type { ToolbarComponentType, ToolbarComponentTypes, CommonComponentProps, ToolbarType, ToolbarMenuComponent, ToolbarButtonComponent, ToolbarMenuItemComponent, ToolbarGroupComponent, RegisterToolbar, RegisterToolbarSection, RegisterToolbarGroup, RegisterToolbarButton, RegisterToolbarMenu, RegisterToolbarNestedMenu, RegisterToolbarMenuSection, RegisterToolbarMenuItem, RegisterComponent, } from './types';
|
|
3
3
|
export { createComponentRegistry } from './create-registry';
|
|
@@ -4,7 +4,7 @@ type WithRank<T> = T & {
|
|
|
4
4
|
type Parents<T> = Array<WithRank<T>>;
|
|
5
5
|
export type ToolbarComponentType = ToolbarType | ToolbarSectionType | ToolbarGroupType | ToolbarButtonType | ToolbarMenuType | ToolbarNestedMenuType | ToolbarMenuSectionType | ToolbarMenuItemType;
|
|
6
6
|
export type ToolbarComponentTypes = Array<ToolbarComponentType>;
|
|
7
|
-
type CommonComponentProps = {
|
|
7
|
+
export type CommonComponentProps = {
|
|
8
8
|
/**
|
|
9
9
|
* Array of parent information including both keys and types
|
|
10
10
|
* Ordered from immediate parent to root parent
|
package/package.json
CHANGED
|
@@ -20,13 +20,10 @@
|
|
|
20
20
|
"*.compiled.css"
|
|
21
21
|
],
|
|
22
22
|
"atlaskit:src": "src/index.ts",
|
|
23
|
-
"af:exports": {
|
|
24
|
-
".": "./src/index.ts"
|
|
25
|
-
},
|
|
26
23
|
"dependencies": {
|
|
27
|
-
"@atlaskit/css": "^0.
|
|
28
|
-
"@atlaskit/primitives": "^14.
|
|
29
|
-
"@atlaskit/tokens": "^6.
|
|
24
|
+
"@atlaskit/css": "^0.13.0",
|
|
25
|
+
"@atlaskit/primitives": "^14.13.0",
|
|
26
|
+
"@atlaskit/tokens": "^6.2.0",
|
|
30
27
|
"@babel/runtime": "^7.0.0",
|
|
31
28
|
"@compiled/react": "^0.18.3"
|
|
32
29
|
},
|
|
@@ -36,7 +33,7 @@
|
|
|
36
33
|
"devDependencies": {
|
|
37
34
|
"@af/integration-testing": "workspace:^",
|
|
38
35
|
"@af/visual-regression": "workspace:^",
|
|
39
|
-
"@atlaskit/editor-toolbar": "^0.
|
|
36
|
+
"@atlaskit/editor-toolbar": "^0.8.0",
|
|
40
37
|
"@atlaskit/ssr": "workspace:^",
|
|
41
38
|
"@testing-library/react": "^13.4.0",
|
|
42
39
|
"react-dom": "^18.2.0"
|
|
@@ -77,7 +74,7 @@
|
|
|
77
74
|
}
|
|
78
75
|
},
|
|
79
76
|
"name": "@atlaskit/editor-toolbar-model",
|
|
80
|
-
"version": "0.1
|
|
77
|
+
"version": "0.2.1",
|
|
81
78
|
"description": "register and render toolbar component",
|
|
82
79
|
"author": "Atlassian Pty Ltd",
|
|
83
80
|
"license": "Apache-2.0",
|