@portabletext/editor 1.18.3 → 1.18.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "1.18.3",
3
+ "version": "1.18.5",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -70,11 +70,11 @@
70
70
  },
71
71
  "devDependencies": {
72
72
  "@portabletext/toolkit": "^2.0.16",
73
- "@sanity/block-tools": "^3.68.1",
73
+ "@sanity/block-tools": "^3.68.3",
74
74
  "@sanity/diff-match-patch": "^3.1.2",
75
75
  "@sanity/pkg-utils": "^6.12.2",
76
- "@sanity/schema": "^3.68.1",
77
- "@sanity/types": "^3.68.1",
76
+ "@sanity/schema": "^3.68.3",
77
+ "@sanity/types": "^3.68.3",
78
78
  "@testing-library/jest-dom": "^6.6.3",
79
79
  "@testing-library/react": "^16.1.0",
80
80
  "@types/debug": "^4.1.5",
@@ -103,9 +103,9 @@
103
103
  "racejar": "1.1.1"
104
104
  },
105
105
  "peerDependencies": {
106
- "@sanity/block-tools": "^3.68.1",
107
- "@sanity/schema": "^3.68.1",
108
- "@sanity/types": "^3.68.1",
106
+ "@sanity/block-tools": "^3.68.3",
107
+ "@sanity/schema": "^3.68.3",
108
+ "@sanity/types": "^3.68.3",
109
109
  "react": "^16.9 || ^17 || ^18 || ^19",
110
110
  "rxjs": "^7.8.1",
111
111
  "styled-components": "^6.1.13"
@@ -156,16 +156,12 @@ export function createEmojiPickerBehaviors<TEmojiMatch>(
156
156
  return false
157
157
  }
158
158
 
159
- const isShift = isHotkey('Shift', event.keyboardEvent)
160
- const isColon = event.keyboardEvent.key === ':'
161
- const isEmojiChar = emojiCharRegEx.test(event.keyboardEvent.key)
159
+ const isEscape = isHotkey('Escape', event.keyboardEvent)
162
160
 
163
- if (isShift || isColon || isEmojiChar) {
164
- return false
161
+ if (isEscape) {
162
+ return {action: 'reset' as const}
165
163
  }
166
164
 
167
- const isArrowDown = isHotkey('ArrowDown', event.keyboardEvent)
168
- const isArrowUp = isHotkey('ArrowUp', event.keyboardEvent)
169
165
  const isEnter = isHotkey('Enter', event.keyboardEvent)
170
166
  const isTab = isHotkey('Tab', event.keyboardEvent)
171
167
 
@@ -204,6 +200,9 @@ export function createEmojiPickerBehaviors<TEmojiMatch>(
204
200
  return false
205
201
  }
206
202
 
203
+ const isArrowDown = isHotkey('ArrowDown', event.keyboardEvent)
204
+ const isArrowUp = isHotkey('ArrowUp', event.keyboardEvent)
205
+
207
206
  if (isArrowDown && matches.length > 0) {
208
207
  return {action: 'navigate down' as const}
209
208
  }
@@ -212,7 +211,7 @@ export function createEmojiPickerBehaviors<TEmojiMatch>(
212
211
  return {action: 'navigate up' as const}
213
212
  }
214
213
 
215
- return {action: 'reset' as const}
214
+ return false
216
215
  },
217
216
  actions: [
218
217
  (_, params) => {
@@ -1,10 +1,5 @@
1
1
  import {Schema as SanitySchema} from '@sanity/schema'
2
- import {
3
- defineField,
4
- defineType,
5
- type BlockDecoratorDefinition,
6
- type ObjectSchemaType,
7
- } from '@sanity/types'
2
+ import {defineField, defineType, type ObjectSchemaType} from '@sanity/types'
8
3
  import startCase from 'lodash.startcase'
9
4
  import type {PortableTextMemberSchemaTypes} from '../types/editor'
10
5
  import {createEditorSchema} from './create-editor-schema'
@@ -15,7 +10,6 @@ import {createEditorSchema} from './create-editor-schema'
15
10
  export type BaseDefinition = {
16
11
  name: string
17
12
  title?: string
18
- icon?: BlockDecoratorDefinition['icon']
19
13
  }
20
14
 
21
15
  /**
@@ -57,7 +51,6 @@ export function compileSchemaDefinition<
57
51
  // fields to objects with the name `image`
58
52
  name: blockObject.name === 'image' ? 'tmp-image' : blockObject.name,
59
53
  title: blockObject.title,
60
- icon: blockObject.icon,
61
54
  fields: [],
62
55
  }),
63
56
  ) ?? []
@@ -67,7 +60,6 @@ export function compileSchemaDefinition<
67
60
  type: 'object',
68
61
  name: inlineObject.name,
69
62
  title: inlineObject.title,
70
- icon: inlineObject.icon,
71
63
  fields: [],
72
64
  }),
73
65
  ) ?? []
@@ -86,27 +78,23 @@ export function compileSchemaDefinition<
86
78
  definition?.decorators?.map((decorator) => ({
87
79
  title: decorator.title ?? startCase(decorator.name),
88
80
  value: decorator.name,
89
- icon: decorator.icon,
90
81
  })) ?? [],
91
82
  annotations:
92
83
  definition?.annotations?.map((annotation) => ({
93
84
  name: annotation.name,
94
85
  type: 'object',
95
86
  title: annotation.title,
96
- icon: annotation.icon,
97
87
  })) ?? [],
98
88
  },
99
89
  lists:
100
90
  definition?.lists?.map((list) => ({
101
91
  value: list.name,
102
92
  title: list.title ?? startCase(list.name),
103
- icon: list.icon,
104
93
  })) ?? [],
105
94
  styles:
106
95
  definition?.styles?.map((style) => ({
107
96
  value: style.name,
108
97
  title: style.title ?? startCase(style.name),
109
- icon: style.icon,
110
98
  })) ?? [],
111
99
  },
112
100
  ],
@@ -49,16 +49,20 @@ export function toSlatePath(path: Path, editor: Editor): SlatePath {
49
49
  isKeySegment(path[0]) && (n as Descendant)._key === path[0]._key,
50
50
  }),
51
51
  )[0] || [undefined, undefined]
52
+
52
53
  if (!block || !Element.isElement(block)) {
53
54
  return []
54
55
  }
56
+
55
57
  if (editor.isVoid(block)) {
56
58
  return [blockPath[0], 0]
57
59
  }
60
+
58
61
  const childPath = [path[2]]
59
62
  const childIndex = block.children.findIndex((child) =>
60
63
  isEqual([{_key: child._key}], childPath),
61
64
  )
65
+
62
66
  if (childIndex >= 0 && block.children[childIndex]) {
63
67
  const child = block.children[childIndex]
64
68
  if (Element.isElement(child) && editor.isVoid(child)) {
@@ -66,5 +70,6 @@ export function toSlatePath(path: Path, editor: Editor): SlatePath {
66
70
  }
67
71
  return blockPath.concat(childIndex)
68
72
  }
69
- return blockPath
73
+
74
+ return [blockPath[0], 0]
70
75
  }