@portabletext/editor 2.17.2 → 2.18.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-dts/{behavior.types.action.d.ts → index.d.ts} +9 -9
- package/lib/behaviors/index.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/plugins/index.d.ts +2 -2
- package/lib/selectors/index.d.ts +2 -2
- package/lib/utils/index.d.ts +1 -1
- package/package.json +14 -25
- package/src/test/vitest/step-definitions.tsx +2 -0
- package/src/test/vitest/test-editor.tsx +18 -4
- package/lib/_chunks-cjs/selector.get-selection-text.cjs +0 -89
- package/lib/_chunks-cjs/selector.get-selection-text.cjs.map +0 -1
- package/lib/_chunks-cjs/selector.get-text-before.cjs +0 -34
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +0 -1
- package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs +0 -875
- package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs.map +0 -1
- package/lib/_chunks-cjs/use-editor.cjs +0 -28
- package/lib/_chunks-cjs/use-editor.cjs.map +0 -1
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs +0 -79
- package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs.map +0 -1
- package/lib/_chunks-cjs/util.get-text-block-text.cjs +0 -473
- package/lib/_chunks-cjs/util.get-text-block-text.cjs.map +0 -1
- package/lib/_chunks-cjs/util.is-empty-text-block.cjs +0 -38
- package/lib/_chunks-cjs/util.is-empty-text-block.cjs.map +0 -1
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs +0 -23
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +0 -1
- package/lib/_chunks-cjs/util.slice-text-block.cjs +0 -63
- package/lib/_chunks-cjs/util.slice-text-block.cjs.map +0 -1
- package/lib/_chunks-dts/behavior.types.action.d.cts +0 -3650
- package/lib/behaviors/index.cjs +0 -35
- package/lib/behaviors/index.cjs.map +0 -1
- package/lib/behaviors/index.d.cts +0 -2
- package/lib/index.cjs +0 -12952
- package/lib/index.cjs.map +0 -1
- package/lib/index.d.cts +0 -2
- package/lib/plugins/index.cjs +0 -826
- package/lib/plugins/index.cjs.map +0 -1
- package/lib/plugins/index.d.cts +0 -196
- package/lib/selectors/index.cjs +0 -243
- package/lib/selectors/index.cjs.map +0 -1
- package/lib/selectors/index.d.cts +0 -357
- package/lib/utils/index.cjs +0 -97
- package/lib/utils/index.cjs.map +0 -1
- package/lib/utils/index.d.cts +0 -186
package/lib/behaviors/index.cjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
function execute(event) {
|
|
4
|
-
return {
|
|
5
|
-
type: "execute",
|
|
6
|
-
event
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
function forward(event) {
|
|
10
|
-
return {
|
|
11
|
-
type: "forward",
|
|
12
|
-
event
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function raise(event) {
|
|
16
|
-
return {
|
|
17
|
-
type: "raise",
|
|
18
|
-
event
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function effect(effect2) {
|
|
22
|
-
return {
|
|
23
|
-
type: "effect",
|
|
24
|
-
effect: effect2
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function defineBehavior(behavior) {
|
|
28
|
-
return behavior;
|
|
29
|
-
}
|
|
30
|
-
exports.defineBehavior = defineBehavior;
|
|
31
|
-
exports.effect = effect;
|
|
32
|
-
exports.execute = execute;
|
|
33
|
-
exports.forward = forward;
|
|
34
|
-
exports.raise = raise;
|
|
35
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/behaviors/behavior.types.action.ts","../../src/behaviors/behavior.types.behavior.ts"],"sourcesContent":["import type {EditorDom} from '../editor/editor-dom'\nimport type {EditorSnapshot} from '../editor/editor-snapshot'\nimport type {PickFromUnion} from '../type-utils'\nimport type {\n CustomBehaviorEvent,\n ExternalBehaviorEvent,\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: (payload: {\n /**\n * Send a Behavior Event back into the Editor.\n *\n * @example\n * ```ts\n * defineBehavior({\n * on: '...',\n * actions: [\n * () => [\n * effect(({send}) => {\n * doSomethingAsync()\n * .then(() => {\n * send({\n * type: '...',\n * })\n * })\n * })\n * ],\n * ],\n * })\n * ```\n */\n send: (event: ExternalBehaviorEvent) => void\n }) => 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: PickFromUnion<BehaviorAction, 'type', 'effect'>['effect'],\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 dom: EditorDom\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":";;AA0DO,SAASA,QACdC,OACkD;AAClD,SAAO;AAAA,IAACC,MAAM;AAAA,IAAWD;AAAAA,EAAAA;AAC3B;AAKO,SAASE,QACdF,OACkD;AAClD,SAAO;AAAA,IAACC,MAAM;AAAA,IAAWD;AAAAA,EAAAA;AAC3B;AAKO,SAASG,MACdH,OACgD;AAChD,SAAO;AAAA,IAACC,MAAM;AAAA,IAASD;AAAAA,EAAAA;AACzB;AAKO,SAASI,OACdA,SACiD;AACjD,SAAO;AAAA,IAACH,MAAM;AAAA,IAAUG,QAAAA;AAAAA,EAAAA;AAC1B;ACpBO,SAASC,eAYdC,UACU;AACV,SAAOA;AACT;;;;;;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { Behavior, BehaviorAction, BehaviorActionSet, BehaviorEvent, BehaviorGuard, CustomBehaviorEvent, InsertPlacement, NativeBehaviorEvent, SyntheticBehaviorEvent, defineBehavior, effect, execute, forward, raise } from "../_chunks-dts/behavior.types.action.cjs";
|
|
2
|
-
export { Behavior, BehaviorAction, BehaviorActionSet, BehaviorEvent, BehaviorGuard, CustomBehaviorEvent, InsertPlacement, NativeBehaviorEvent, SyntheticBehaviorEvent, defineBehavior, effect, execute, forward, raise };
|