@portabletext/toolbar 2.2.25 → 2.2.27
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/dist/index.cjs +35 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -13
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/disable-listener.ts +7 -0
- package/src/use-annotation-button.ts +11 -0
- package/src/use-decorator-button.ts +11 -0
- package/src/use-list-button.ts +11 -0
- package/src/use-style-selector.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/toolbar",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.27",
|
|
4
4
|
"description": "Utilities for building a toolbar for the Portable Text Editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portabletext",
|
|
@@ -37,24 +37,24 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@xstate/react": "^6.0.0",
|
|
40
|
-
"react-compiler-runtime": "
|
|
40
|
+
"react-compiler-runtime": "1.0.0",
|
|
41
41
|
"xstate": "^5.23.0",
|
|
42
42
|
"@portabletext/keyboard-shortcuts": "^1.1.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@sanity/pkg-utils": "^8.1.14",
|
|
46
46
|
"@types/react": "^19.2.0",
|
|
47
|
-
"babel-plugin-react-compiler": "
|
|
48
|
-
"eslint": "^9.
|
|
47
|
+
"babel-plugin-react-compiler": "1.0.0",
|
|
48
|
+
"eslint": "^9.38.0",
|
|
49
49
|
"eslint-formatter-gha": "^1.6.0",
|
|
50
|
-
"eslint-plugin-react-hooks": "
|
|
50
|
+
"eslint-plugin-react-hooks": "7.0.0",
|
|
51
51
|
"react": "^19.2.0",
|
|
52
52
|
"typescript": "5.9.3",
|
|
53
|
-
"typescript-eslint": "^8.
|
|
54
|
-
"@portabletext/editor": "2.
|
|
53
|
+
"typescript-eslint": "^8.46.1",
|
|
54
|
+
"@portabletext/editor": "2.15.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@portabletext/editor": "^2.
|
|
57
|
+
"@portabletext/editor": "^2.15.0",
|
|
58
58
|
"react": "^19.2.0"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
package/src/disable-listener.ts
CHANGED
|
@@ -8,6 +8,13 @@ export const disableListener = fromCallback<
|
|
|
8
8
|
{editor: Editor},
|
|
9
9
|
DisableListenerEvent
|
|
10
10
|
>(({input, sendBack}) => {
|
|
11
|
+
// Send back the initial state
|
|
12
|
+
if (input.editor.getSnapshot().context.readOnly) {
|
|
13
|
+
sendBack({type: 'disable'})
|
|
14
|
+
} else {
|
|
15
|
+
sendBack({type: 'enable'})
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
return input.editor.on('*', () => {
|
|
12
19
|
if (input.editor.getSnapshot().context.readOnly) {
|
|
13
20
|
sendBack({type: 'disable'})
|
|
@@ -12,6 +12,17 @@ const activeListener = fromCallback<
|
|
|
12
12
|
{editor: Editor; schemaType: ToolbarAnnotationSchemaType},
|
|
13
13
|
{type: 'set active'} | {type: 'set inactive'}
|
|
14
14
|
>(({input, sendBack}) => {
|
|
15
|
+
// Send back the initial state
|
|
16
|
+
if (
|
|
17
|
+
selectors.isActiveAnnotation(input.schemaType.name)(
|
|
18
|
+
input.editor.getSnapshot(),
|
|
19
|
+
)
|
|
20
|
+
) {
|
|
21
|
+
sendBack({type: 'set active'})
|
|
22
|
+
} else {
|
|
23
|
+
sendBack({type: 'set inactive'})
|
|
24
|
+
}
|
|
25
|
+
|
|
15
26
|
return input.editor.on('*', () => {
|
|
16
27
|
const snapshot = input.editor.getSnapshot()
|
|
17
28
|
|
|
@@ -16,6 +16,17 @@ const activeListener = fromCallback<
|
|
|
16
16
|
{editor: Editor; schemaType: DecoratorSchemaType},
|
|
17
17
|
{type: 'set active'} | {type: 'set inactive'}
|
|
18
18
|
>(({input, sendBack}) => {
|
|
19
|
+
// Send back the initial state
|
|
20
|
+
if (
|
|
21
|
+
selectors.isActiveDecorator(input.schemaType.name)(
|
|
22
|
+
input.editor.getSnapshot(),
|
|
23
|
+
)
|
|
24
|
+
) {
|
|
25
|
+
sendBack({type: 'set active'})
|
|
26
|
+
} else {
|
|
27
|
+
sendBack({type: 'set inactive'})
|
|
28
|
+
}
|
|
29
|
+
|
|
19
30
|
return input.editor.on('*', () => {
|
|
20
31
|
const snapshot = input.editor.getSnapshot()
|
|
21
32
|
|
package/src/use-list-button.ts
CHANGED
|
@@ -10,6 +10,17 @@ const activeListener = fromCallback<
|
|
|
10
10
|
{editor: Editor; schemaType: ListSchemaType},
|
|
11
11
|
{type: 'set active'} | {type: 'set inactive'}
|
|
12
12
|
>(({input, sendBack}) => {
|
|
13
|
+
// Send back the initial state
|
|
14
|
+
if (
|
|
15
|
+
selectors.isActiveListItem(input.schemaType.name)(
|
|
16
|
+
input.editor.getSnapshot(),
|
|
17
|
+
)
|
|
18
|
+
) {
|
|
19
|
+
sendBack({type: 'set active'})
|
|
20
|
+
} else {
|
|
21
|
+
sendBack({type: 'set inactive'})
|
|
22
|
+
}
|
|
23
|
+
|
|
13
24
|
return input.editor.on('*', () => {
|
|
14
25
|
const snapshot = input.editor.getSnapshot()
|
|
15
26
|
|
|
@@ -20,6 +20,10 @@ const activeListener = fromCallback<
|
|
|
20
20
|
{editor: Editor},
|
|
21
21
|
ActiveStyleListenerEvent
|
|
22
22
|
>(({input, sendBack}) => {
|
|
23
|
+
// Send back the initial state
|
|
24
|
+
const activeStyle = selectors.getActiveStyle(input.editor.getSnapshot())
|
|
25
|
+
sendBack({type: 'set active style', style: activeStyle})
|
|
26
|
+
|
|
23
27
|
return input.editor.on('*', () => {
|
|
24
28
|
const snapshot = input.editor.getSnapshot()
|
|
25
29
|
const activeStyle = selectors.getActiveStyle(snapshot)
|