@portabletext/editor 1.35.3 → 1.36.0
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-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +211 -74
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +212 -75
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/behaviors/index.d.cts +150 -354
- package/lib/behaviors/index.d.ts +150 -354
- package/lib/index.d.cts +145 -77
- package/lib/index.d.ts +145 -77
- package/lib/plugins/index.cjs +19 -19
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +134 -77
- package/lib/plugins/index.d.ts +134 -77
- package/lib/plugins/index.js +21 -21
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.d.cts +123 -77
- package/lib/selectors/index.d.ts +123 -77
- package/lib/utils/index.d.cts +123 -77
- package/lib/utils/index.d.ts +123 -77
- package/package.json +6 -6
- package/src/behavior-actions/behavior.actions.ts +2 -2
- package/src/behaviors/behavior.types.ts +10 -7
- package/src/editor/PortableTextEditor.tsx +22 -0
- package/src/editor/__tests__/self-solving.test.tsx +33 -1
- package/src/editor/components/Synchronizer.tsx +17 -3
- package/src/editor/editor-machine.ts +31 -15
- package/src/editor/mutation-machine.ts +160 -46
- package/src/editor/plugins/create-with-event-listeners.ts +1 -0
- package/src/editor/plugins/createWithPatches.ts +10 -3
- package/src/editor/with-applying-behavior-actions.ts +8 -6
- package/src/plugins/index.ts +2 -1
- package/src/plugins/plugin.decorator-shortcut.ts +3 -0
- package/src/utils/util.slice-blocks.test.ts +64 -0
package/src/plugins/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export {BehaviorPlugin} from './plugin.behavior'
|
|
2
|
-
export {
|
|
2
|
+
export {DecoratorShortcutPlugin} from './plugin.decorator-shortcut'
|
|
3
3
|
export {EditorRefPlugin} from './plugin.editor-ref'
|
|
4
|
+
export {EventListenerPlugin} from './plugin.event-listener'
|
|
4
5
|
export {MarkdownPlugin, type MarkdownPluginConfig} from './plugin.markdown'
|
|
5
6
|
export {OneLinePlugin} from './plugin.one-line'
|
|
@@ -15,6 +15,9 @@ import type {EditorSchema} from '../selectors'
|
|
|
15
15
|
import type {BlockOffset} from '../types/block-offset'
|
|
16
16
|
import * as utils from '../utils'
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
18
21
|
export function DecoratorShortcutPlugin(config: {
|
|
19
22
|
decorator: ({schema}: {schema: EditorSchema}) => string | undefined
|
|
20
23
|
pair: {char: string; amount: number}
|
|
@@ -341,4 +341,68 @@ describe(sliceBlocks.name, () => {
|
|
|
341
341
|
},
|
|
342
342
|
])
|
|
343
343
|
})
|
|
344
|
+
|
|
345
|
+
test('slicing text block with custom props', () => {
|
|
346
|
+
expect(
|
|
347
|
+
sliceBlocks({
|
|
348
|
+
blocks: [
|
|
349
|
+
{
|
|
350
|
+
_key: 'b0',
|
|
351
|
+
_type: 'block',
|
|
352
|
+
children: [{_key: 's0', _type: 'span', text: 'Hello, world!'}],
|
|
353
|
+
_map: {},
|
|
354
|
+
},
|
|
355
|
+
],
|
|
356
|
+
selection: {
|
|
357
|
+
anchor: {
|
|
358
|
+
path: [{_key: 'b0'}, 'children', {_key: 's0'}],
|
|
359
|
+
offset: 7,
|
|
360
|
+
},
|
|
361
|
+
focus: {
|
|
362
|
+
path: [{_key: 'b0'}, 'children', {_key: 's0'}],
|
|
363
|
+
offset: 12,
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
}),
|
|
367
|
+
).toEqual([
|
|
368
|
+
{
|
|
369
|
+
_key: 'b0',
|
|
370
|
+
_type: 'block',
|
|
371
|
+
children: [{_key: 's0', _type: 'span', text: 'world'}],
|
|
372
|
+
_map: {},
|
|
373
|
+
},
|
|
374
|
+
])
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
test('slicing span with custom props', () => {
|
|
378
|
+
expect(
|
|
379
|
+
sliceBlocks({
|
|
380
|
+
blocks: [
|
|
381
|
+
{
|
|
382
|
+
_key: 'b0',
|
|
383
|
+
_type: 'block',
|
|
384
|
+
children: [
|
|
385
|
+
{_key: 's0', _type: 'span', text: 'Hello, world!', _map: {}},
|
|
386
|
+
],
|
|
387
|
+
},
|
|
388
|
+
],
|
|
389
|
+
selection: {
|
|
390
|
+
anchor: {
|
|
391
|
+
path: [{_key: 'b0'}, 'children', {_key: 's0'}],
|
|
392
|
+
offset: 7,
|
|
393
|
+
},
|
|
394
|
+
focus: {
|
|
395
|
+
path: [{_key: 'b0'}, 'children', {_key: 's0'}],
|
|
396
|
+
offset: 12,
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
}),
|
|
400
|
+
).toEqual([
|
|
401
|
+
{
|
|
402
|
+
_key: 'b0',
|
|
403
|
+
_type: 'block',
|
|
404
|
+
children: [{_key: 's0', _type: 'span', text: 'world', _map: {}}],
|
|
405
|
+
},
|
|
406
|
+
])
|
|
407
|
+
})
|
|
344
408
|
})
|