@portabletext/toolbar 2.2.26 → 2.2.28

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.
@@ -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
 
@@ -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)