@portabletext/editor 1.0.15 → 1.0.17

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.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -51,18 +51,19 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@jest/globals": "^29.7.0",
54
- "@playwright/test": "1.46.0",
54
+ "@jest/types": "^29.6.3",
55
+ "@playwright/test": "1.46.1",
55
56
  "@portabletext/toolkit": "^2.0.15",
56
- "@sanity/block-tools": "^3.54.0",
57
+ "@sanity/block-tools": "^3.55.0",
57
58
  "@sanity/diff-match-patch": "^3.1.1",
58
59
  "@sanity/eslint-config-i18n": "^1.1.0",
59
60
  "@sanity/eslint-config-studio": "^4.0.0",
60
- "@sanity/pkg-utils": "^6.10.9",
61
- "@sanity/schema": "^3.54.0",
61
+ "@sanity/pkg-utils": "^6.10.10",
62
+ "@sanity/schema": "^3.55.0",
62
63
  "@sanity/test": "0.0.1-alpha.1",
63
- "@sanity/types": "^3.54.0",
64
+ "@sanity/types": "^3.55.0",
64
65
  "@sanity/ui": "^2.8.8",
65
- "@sanity/util": "^3.54.0",
66
+ "@sanity/util": "^3.55.0",
66
67
  "@testing-library/dom": "^10.4.0",
67
68
  "@testing-library/react": "^16.0.0",
68
69
  "@types/debug": "^4.1.5",
@@ -74,8 +75,8 @@
74
75
  "@types/react": "^18.3.3",
75
76
  "@types/react-dom": "^18.3.0",
76
77
  "@types/ws": "~8.5.12",
77
- "@typescript-eslint/eslint-plugin": "^8.1.0",
78
- "@typescript-eslint/parser": "^8.1.0",
78
+ "@typescript-eslint/eslint-plugin": "^8.2.0",
79
+ "@typescript-eslint/parser": "^8.2.0",
79
80
  "@vitejs/plugin-react": "^4.3.1",
80
81
  "dotenv": "^16.4.5",
81
82
  "eslint": "^8.57.0",
@@ -84,14 +85,14 @@
84
85
  "eslint-import-resolver-typescript": "^3.6.1",
85
86
  "eslint-plugin-import": "^2.29.1",
86
87
  "eslint-plugin-prettier": "^5.2.1",
87
- "eslint-plugin-react-compiler": "0.0.0-experimental-d0e920e-20240815",
88
+ "eslint-plugin-react-compiler": "0.0.0-experimental-eeb1b2a-20240818",
88
89
  "eslint-plugin-tsdoc": "^0.3.0",
89
90
  "eslint-plugin-unicorn": "^55.0.0",
90
91
  "eslint-plugin-unused-imports": "^4.1.3",
91
92
  "express": "^4.19.2",
92
93
  "express-ws": "^5.0.2",
93
94
  "jest": "^29.7.0",
94
- "jest-dev-server": "^10.0.0",
95
+ "jest-dev-server": "^10.1.0",
95
96
  "jest-environment-jsdom": "^29.7.0",
96
97
  "jest-environment-node": "^29.7.0",
97
98
  "node-ipc": "npm:@node-ipc/compat@9.2.5",
@@ -101,7 +102,7 @@
101
102
  "styled-components": "^6.1.12",
102
103
  "tsx": "^4.17.0",
103
104
  "typescript": "5.5.4",
104
- "vite": "^5.4.1"
105
+ "vite": "^5.4.2"
105
106
  },
106
107
  "peerDependencies": {
107
108
  "@sanity/block-tools": "^3.47.1",
@@ -419,16 +419,7 @@ export function createWithEditableAPI(
419
419
  )
420
420
  }
421
421
  editor.onChange()
422
- if (editor.selection) {
423
- // Insert an empty string to continue writing non-annotated text
424
- Transforms.insertNodes(
425
- editor,
426
- [{_type: 'span', text: '', marks: [], _key: keyGenerator()}],
427
- {
428
- at: Range.end(editor.selection),
429
- },
430
- )
431
- }
422
+
432
423
  const newPortableTextEditorSelection = toPortableTextRange(
433
424
  fromSlateValue(editor.children, types.block.name, KEY_TO_VALUE_ELEMENT.get(editor)),
434
425
  editor.selection,
@@ -205,15 +205,6 @@ export function createWithPortableTextMarkModel(
205
205
  }
206
206
  }
207
207
  }
208
- // Empty marks if text is empty
209
- if (
210
- isSpan &&
211
- Array.isArray(node.marks) &&
212
- (!node.marks || (node.marks.length > 0 && node.text === ''))
213
- ) {
214
- Transforms.setNodes(editor, {marks: []}, {at: path, voids: false})
215
- return
216
- }
217
208
  }
218
209
  // Check consistency of markDefs (unless we are merging two nodes)
219
210
  if (
@@ -354,6 +345,18 @@ export function createWithPortableTextMarkModel(
354
345
  editor.onChange()
355
346
  return
356
347
  }
348
+
349
+ const nodeHasMarks = node.marks !== undefined && node.marks.length > 0
350
+
351
+ if (nodeHasMarks && deletingAllText) {
352
+ Editor.withoutNormalizing(editor, () => {
353
+ apply(op)
354
+ Transforms.setNodes(editor, {marks: []}, {at: op.path})
355
+ })
356
+
357
+ editor.onChange()
358
+ return
359
+ }
357
360
  }
358
361
  }
359
362