@portabletext/editor 1.48.13 → 1.48.15
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/editor-provider.cjs +682 -609
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/editor-provider.js +683 -610
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.d.cts +226 -2772
- package/lib/behaviors/index.d.ts +226 -2772
- package/lib/behaviors/index.js.map +1 -1
- package/lib/index.cjs +22 -6
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +227 -2780
- package/lib/index.d.ts +227 -2780
- package/lib/index.js +23 -7
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +1 -7
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +226 -2785
- package/lib/plugins/index.d.ts +226 -2785
- package/lib/plugins/index.js +2 -8
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.d.cts +225 -2771
- package/lib/selectors/index.d.ts +225 -2771
- package/lib/utils/index.d.cts +227 -2772
- package/lib/utils/index.d.ts +227 -2772
- package/package.json +1 -1
- package/src/behaviors/behavior.abstract.keyboard.ts +16 -0
- package/src/behaviors/{behavior.default.ts → behavior.abstract.ts} +3 -3
- package/src/behaviors/behavior.config.ts +7 -0
- package/src/behaviors/behavior.core.ts +6 -5
- package/src/behaviors/behavior.perform-event.ts +27 -51
- package/src/behaviors/behavior.types.action.ts +1 -11
- package/src/editor/PortableTextEditor.tsx +1 -1
- package/src/editor/components/Element.tsx +30 -4
- package/src/editor/create-editor.ts +17 -5
- package/src/editor/editor-machine.ts +23 -17
- package/src/editor/mutation-machine.ts +6 -6
- package/src/editor/plugins/create-with-event-listeners.ts +25 -25
- package/src/editor/plugins/createWithEditableAPI.ts +3 -3
- package/src/editor/plugins/createWithPatches.ts +13 -5
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +5 -5
- package/src/editor/plugins/createWithUndoRedo.ts +8 -8
- package/src/editor/with-applying-behavior-operations.ts +18 -0
- package/src/editor/{with-applying-behavior-actions.ts → with-undo-step.ts} +1 -19
- package/src/index.ts +1 -1
- package/src/{behavior-actions/behavior.action.annotation.add.ts → operations/behavior.operation.annotation.add.ts} +7 -7
- package/src/{behavior-actions/behavior.action.annotation.remove.ts → operations/behavior.operation.annotation.remove.ts} +6 -6
- package/src/{behavior-actions/behavior.action.block.set.ts → operations/behavior.operation.block.set.ts} +14 -14
- package/src/{behavior-actions/behavior.action.block.unset.ts → operations/behavior.operation.block.unset.ts} +19 -17
- package/src/{behavior-actions/behavior.action.decorator.add.ts → operations/behavior.operation.decorator.add.ts} +10 -10
- package/src/operations/behavior.operation.delete.backward.ts +8 -0
- package/src/operations/behavior.operation.delete.block.ts +24 -0
- package/src/operations/behavior.operation.delete.forward.ts +8 -0
- package/src/{behavior-actions/behavior.action.delete.ts → operations/behavior.operation.delete.ts} +8 -8
- package/src/{behavior-actions/behavior.action.insert-inline-object.ts → operations/behavior.operation.insert-inline-object.ts} +11 -11
- package/src/{behavior-actions/behavior.action.insert-span.ts → operations/behavior.operation.insert-span.ts} +15 -15
- package/src/{behavior-actions/behavior.action.insert.block.ts → operations/behavior.operation.insert.block.ts} +8 -8
- package/src/operations/behavior.operation.insert.text.ts +17 -0
- package/src/operations/behavior.operation.move.backward.ts +12 -0
- package/src/operations/behavior.operation.move.block.ts +16 -0
- package/src/operations/behavior.operation.move.forward.ts +11 -0
- package/src/operations/behavior.operation.select.ts +15 -0
- package/src/operations/behavior.operations.ts +239 -0
- package/src/plugins/index.ts +0 -1
- package/src/priority/priority.core.ts +3 -0
- package/src/priority/priority.sort.test.ts +319 -0
- package/src/priority/priority.sort.ts +121 -0
- package/src/priority/priority.types.ts +24 -0
- package/src/behavior-actions/behavior.action.delete.backward.ts +0 -7
- package/src/behavior-actions/behavior.action.delete.block.ts +0 -24
- package/src/behavior-actions/behavior.action.delete.forward.ts +0 -7
- package/src/behavior-actions/behavior.action.insert.text.ts +0 -17
- package/src/behavior-actions/behavior.action.move.backward.ts +0 -12
- package/src/behavior-actions/behavior.action.move.block.ts +0 -16
- package/src/behavior-actions/behavior.action.move.forward.ts +0 -11
- package/src/behavior-actions/behavior.action.select.ts +0 -15
- package/src/behavior-actions/behavior.actions.ts +0 -219
- package/src/behaviors/behavior.default.raise-soft-break.ts +0 -14
- package/src/plugins/plugin.core.tsx +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/behaviors/behavior.types.action.ts","../../src/behaviors/behavior.types.behavior.ts"],"sourcesContent":["import type {EditorSnapshot} from '../editor/editor-snapshot'\nimport type {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/behaviors/behavior.types.action.ts","../../src/behaviors/behavior.types.behavior.ts"],"sourcesContent":["import type {EditorSnapshot} from '../editor/editor-snapshot'\nimport type {PickFromUnion} from '../type-utils'\nimport type {\n CustomBehaviorEvent,\n NativeBehaviorEvent,\n SyntheticBehaviorEvent,\n} from './behavior.types.event'\n\n/**\n * @beta\n */\nexport type BehaviorAction =\n | {\n type: 'execute'\n event: SyntheticBehaviorEvent\n }\n | {\n type: 'forward'\n event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent\n }\n | {\n type: 'raise'\n event: SyntheticBehaviorEvent | CustomBehaviorEvent\n }\n | {\n type: 'effect'\n effect: () => void\n }\n\n/**\n * @beta\n */\nexport function execute(\n event: SyntheticBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'execute'> {\n return {type: 'execute', event}\n}\n\n/**\n * @beta\n */\nexport function forward(\n event: NativeBehaviorEvent | SyntheticBehaviorEvent | CustomBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'forward'> {\n return {type: 'forward', event}\n}\n\n/**\n * @beta\n */\nexport function raise(\n event: SyntheticBehaviorEvent | CustomBehaviorEvent,\n): PickFromUnion<BehaviorAction, 'type', 'raise'> {\n return {type: 'raise', event}\n}\n\n/**\n * @beta\n */\nexport function effect(\n effect: () => void,\n): PickFromUnion<BehaviorAction, 'type', 'effect'> {\n return {type: 'effect', effect}\n}\n\n/**\n * @beta\n */\nexport type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (\n payload: {\n snapshot: EditorSnapshot\n event: TBehaviorEvent\n },\n guardResponse: TGuardResponse,\n) => Array<BehaviorAction>\n","import type {BehaviorActionSet} from './behavior.types.action'\nimport type {\n BehaviorEvent,\n BehaviorEventTypeNamespace,\n CustomBehaviorEvent,\n ResolveBehaviorEvent,\n} from './behavior.types.event'\nimport type {BehaviorGuard} from './behavior.types.guard'\n\n/**\n * @beta\n */\nexport type Behavior<\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] =\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'],\n TGuardResponse = true,\n TBehaviorEvent extends\n ResolveBehaviorEvent<TBehaviorEventType> = ResolveBehaviorEvent<TBehaviorEventType>,\n> = {\n /**\n * Editor Event that triggers this Behavior.\n */\n on: TBehaviorEventType\n /**\n * Predicate function that determines if the Behavior should be executed.\n * Returning a non-nullable value from the guard will pass the value to the\n * actions and execute them.\n */\n guard?: BehaviorGuard<TBehaviorEvent, TGuardResponse>\n /**\n * Array of Behavior Action sets.\n * Each set represents a step in the history stack.\n */\n actions: Array<BehaviorActionSet<TBehaviorEvent, TGuardResponse>>\n}\n\n/**\n * @beta\n *\n * @example\n *\n * ```tsx\n * const noLowerCaseA = defineBehavior({\n * on: 'insert.text',\n * guard: ({event, snapshot}) => event.text === 'a',\n * actions: [({event, snapshot}) => [{type: 'insert.text', text: 'A'}]],\n * })\n * ```\n *\n */\nexport function defineBehavior<\n TPayload extends Record<string, unknown>,\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] = CustomBehaviorEvent['type'],\n TGuardResponse = true,\n>(\n behavior: Behavior<\n TBehaviorEventType,\n TGuardResponse,\n ResolveBehaviorEvent<TBehaviorEventType, TPayload>\n >,\n): Behavior\nexport function defineBehavior<\n TPayload extends never = never,\n TBehaviorEventType extends\n | '*'\n | `${BehaviorEventTypeNamespace}.*`\n | BehaviorEvent['type'] = BehaviorEvent['type'],\n TGuardResponse = true,\n TBehaviorEvent extends ResolveBehaviorEvent<\n TBehaviorEventType,\n TPayload\n > = ResolveBehaviorEvent<TBehaviorEventType, TPayload>,\n>(\n behavior: Behavior<TBehaviorEventType, TGuardResponse, TBehaviorEvent>,\n): Behavior {\n return behavior as unknown as Behavior\n}\n"],"names":["execute","event","type","forward","raise","effect","defineBehavior","behavior"],"mappings":"AAgCO,SAASA,QACdC,OACkD;AAC3C,SAAA;AAAA,IAACC,MAAM;AAAA,IAAWD;AAAAA,EAAK;AAChC;AAKO,SAASE,QACdF,OACkD;AAC3C,SAAA;AAAA,IAACC,MAAM;AAAA,IAAWD;AAAAA,EAAK;AAChC;AAKO,SAASG,MACdH,OACgD;AACzC,SAAA;AAAA,IAACC,MAAM;AAAA,IAASD;AAAAA,EAAK;AAC9B;AAKO,SAASI,OACdA,SACiD;AAC1C,SAAA;AAAA,IAACH,MAAM;AAAA,IAAUG,QAAAA;AAAAA,EAAM;AAChC;ACMO,SAASC,eAYdC,UACU;AACHA,SAAAA;AACT;"}
|
package/lib/index.cjs
CHANGED
|
@@ -423,14 +423,22 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
|
|
|
423
423
|
setDragPositionBlock(event_0.position.block);
|
|
424
424
|
}
|
|
425
425
|
}]]
|
|
426
|
-
})
|
|
426
|
+
}), priority = editorProvider.createEditorPriority({
|
|
427
|
+
reference: {
|
|
428
|
+
priority: editorProvider.corePriority,
|
|
429
|
+
importance: "lower"
|
|
430
|
+
}
|
|
431
|
+
}), behaviorConfig = {
|
|
432
|
+
behavior,
|
|
433
|
+
priority
|
|
434
|
+
};
|
|
427
435
|
return editorActor.send({
|
|
428
436
|
type: "add behavior",
|
|
429
|
-
|
|
437
|
+
behaviorConfig
|
|
430
438
|
}), () => {
|
|
431
439
|
editorActor.send({
|
|
432
440
|
type: "remove behavior",
|
|
433
|
-
|
|
441
|
+
behaviorConfig
|
|
434
442
|
});
|
|
435
443
|
};
|
|
436
444
|
}, [editorActor, element._key]), React.useEffect(() => {
|
|
@@ -447,14 +455,22 @@ const EMPTY_ANNOTATIONS = [], inlineBlockStyle = {
|
|
|
447
455
|
setDragPositionBlock(void 0);
|
|
448
456
|
}
|
|
449
457
|
}, behaviors_index.forward(event_2)]]
|
|
450
|
-
})
|
|
458
|
+
}), priority_0 = editorProvider.createEditorPriority({
|
|
459
|
+
reference: {
|
|
460
|
+
priority: editorProvider.corePriority,
|
|
461
|
+
importance: "lower"
|
|
462
|
+
}
|
|
463
|
+
}), behaviorConfig_0 = {
|
|
464
|
+
behavior: behavior_0,
|
|
465
|
+
priority: priority_0
|
|
466
|
+
};
|
|
451
467
|
return editorActor.send({
|
|
452
468
|
type: "add behavior",
|
|
453
|
-
|
|
469
|
+
behaviorConfig: behaviorConfig_0
|
|
454
470
|
}), () => {
|
|
455
471
|
editorActor.send({
|
|
456
472
|
type: "remove behavior",
|
|
457
|
-
|
|
473
|
+
behaviorConfig: behaviorConfig_0
|
|
458
474
|
});
|
|
459
475
|
};
|
|
460
476
|
}, [editorActor]);
|