@portabletext/editor 2.1.4 → 2.1.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/lib/_chunks-dts/behavior.types.action.d.ts +9 -9
- package/lib/index.cjs +1 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.ts +3 -3
- package/package.json +3 -3
- package/src/internal-utils/build-index-maps.test.ts +41 -24
- package/src/internal-utils/build-index-maps.ts +4 -1
package/lib/plugins/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Behavior, Editor, EditorEmittedEvent, EditorSchema } from "../_chunks-dts/behavior.types.action.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react12 from "react";
|
|
3
3
|
import React from "react";
|
|
4
4
|
/**
|
|
5
5
|
* @beta
|
|
@@ -181,7 +181,7 @@ type MarkdownPluginConfig = MarkdownBehaviorsConfig & {
|
|
|
181
181
|
*/
|
|
182
182
|
declare function MarkdownPlugin(props: {
|
|
183
183
|
config: MarkdownPluginConfig;
|
|
184
|
-
}):
|
|
184
|
+
}): react12.JSX.Element;
|
|
185
185
|
/**
|
|
186
186
|
* @beta
|
|
187
187
|
* Restrict the editor to one line. The plugin takes care of blocking
|
|
@@ -192,5 +192,5 @@ declare function MarkdownPlugin(props: {
|
|
|
192
192
|
*
|
|
193
193
|
* @deprecated Install the plugin from `@portabletext/plugin-one-line`
|
|
194
194
|
*/
|
|
195
|
-
declare function OneLinePlugin():
|
|
195
|
+
declare function OneLinePlugin(): react12.JSX.Element;
|
|
196
196
|
export { BehaviorPlugin, DecoratorShortcutPlugin, EditorRefPlugin, EventListenerPlugin, MarkdownPlugin, type MarkdownPluginConfig, OneLinePlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portabletext/editor",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"description": "Portable Text Editor made in React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"use-effect-event": "^1.0.2",
|
|
82
82
|
"xstate": "^5.20.1",
|
|
83
83
|
"@portabletext/block-tools": "2.0.5",
|
|
84
|
-
"@portabletext/
|
|
85
|
-
"@portabletext/
|
|
84
|
+
"@portabletext/patches": "1.1.6",
|
|
85
|
+
"@portabletext/keyboard-shortcuts": "1.1.1"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@portabletext/toolkit": "^2.0.17",
|
|
@@ -139,18 +139,16 @@ describe(buildIndexMaps.name, () => {
|
|
|
139
139
|
})
|
|
140
140
|
|
|
141
141
|
test('numbered lists broken up by a bulleted list', () => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
{blockIndexMap, listIndexMap},
|
|
153
|
-
),
|
|
142
|
+
buildIndexMaps(
|
|
143
|
+
{
|
|
144
|
+
schema,
|
|
145
|
+
value: [
|
|
146
|
+
textBlock('k0', {listItem: 'number', level: 1}),
|
|
147
|
+
textBlock('k1', {listItem: 'bullet', level: 1}),
|
|
148
|
+
textBlock('k2', {listItem: 'number', level: 1}),
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
{blockIndexMap, listIndexMap},
|
|
154
152
|
)
|
|
155
153
|
expect(blockIndexMap).toEqual(
|
|
156
154
|
new Map([
|
|
@@ -168,6 +166,27 @@ describe(buildIndexMaps.name, () => {
|
|
|
168
166
|
)
|
|
169
167
|
})
|
|
170
168
|
|
|
169
|
+
test('numbered list broken up by an indented bulleted list', () => {
|
|
170
|
+
buildIndexMaps(
|
|
171
|
+
{
|
|
172
|
+
schema,
|
|
173
|
+
value: [
|
|
174
|
+
textBlock('k0', {listItem: 'number', level: 1}),
|
|
175
|
+
textBlock('k1', {listItem: 'bullet', level: 2}),
|
|
176
|
+
textBlock('k2', {listItem: 'number', level: 1}),
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
{blockIndexMap, listIndexMap},
|
|
180
|
+
)
|
|
181
|
+
expect(listIndexMap).toEqual(
|
|
182
|
+
new Map([
|
|
183
|
+
['k0', 1],
|
|
184
|
+
['k1', 1],
|
|
185
|
+
['k2', 2],
|
|
186
|
+
]),
|
|
187
|
+
)
|
|
188
|
+
})
|
|
189
|
+
|
|
171
190
|
test('simple indented list', () => {
|
|
172
191
|
buildIndexMaps(
|
|
173
192
|
{
|
|
@@ -200,18 +219,16 @@ describe(buildIndexMaps.name, () => {
|
|
|
200
219
|
})
|
|
201
220
|
|
|
202
221
|
test('reverse indented list', () => {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
{blockIndexMap, listIndexMap},
|
|
214
|
-
),
|
|
222
|
+
buildIndexMaps(
|
|
223
|
+
{
|
|
224
|
+
schema,
|
|
225
|
+
value: [
|
|
226
|
+
textBlock('k0', {listItem: 'number', level: 2}),
|
|
227
|
+
textBlock('k1', {listItem: 'number', level: 1}),
|
|
228
|
+
textBlock('k2', {listItem: 'number', level: 2}),
|
|
229
|
+
],
|
|
230
|
+
},
|
|
231
|
+
{blockIndexMap, listIndexMap},
|
|
215
232
|
)
|
|
216
233
|
expect(blockIndexMap).toEqual(
|
|
217
234
|
new Map([
|
|
@@ -58,7 +58,10 @@ export function buildIndexMaps(
|
|
|
58
58
|
continue
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
if (
|
|
61
|
+
if (
|
|
62
|
+
previousListItem.listItem !== block.listItem &&
|
|
63
|
+
previousListItem.level === block.level
|
|
64
|
+
) {
|
|
62
65
|
levelIndexMap.clear()
|
|
63
66
|
previousListItem = {
|
|
64
67
|
listItem: block.listItem,
|