@portabletext/editor 7.11.0 → 7.12.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/README.md +57 -67
- package/lib/{behavior.types.action-DXkAaEGS.d.ts → behavior.types.action-DH6ujvaH.d.ts} +244 -16
- package/lib/behavior.types.action-DH6ujvaH.d.ts.map +1 -0
- package/lib/behaviors/index.d.ts +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +281 -89
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.ts +3 -3
- package/lib/plugins/index.js +2 -2
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.d.ts +1 -1
- package/lib/traversal/index.d.ts +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/package.json +1 -1
- package/lib/behavior.types.action-DXkAaEGS.d.ts.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $t as
|
|
2
|
-
export { type AddedAnnotationPaths, type AnnotationDefinition, type AnnotationPath, type AnnotationSchemaType, type BaseDefinition, type BlockAnnotationRenderProps, type BlockChildRenderProps, type BlockDecoratorRenderProps, type BlockListItemRenderProps, type BlockObject, type BlockObjectDefinition, type BlockObjectRender, type BlockObjectRenderProps, type BlockObjectSchemaType, type BlockOffset, type BlockPath, type BlockRenderProps, type BlockStyleRenderProps, type ChildPath, type Container, type ContainerRender, type ContainerRenderProps, type Containers, type DecoratorDefinition, type DecoratorSchemaType, type EditableAPIDeleteOptions, type Editor, type EditorConfig, type EditorContext, type EditorEmittedEvent, type EditorEvent, EditorProvider, type EditorProviderProps, type EditorSchema, type EditorSelection, type EditorSelectionPoint, type EditorSelector, type EditorSnapshot, type FieldDefinition, type HotkeyOptions, type InlineObject, type InlineObjectDefinition, type InlineObjectRender, type InlineObjectRenderProps, type InlineObjectSchemaType, type InvalidValueResolution, type ListDefinition, type ListSchemaType, type MutationEvent, type OfDefinition, type OnCopyFn, type OnPasteFn, type OnPasteResult, type OnPasteResultOrPromise, type Operation, type PasteData, type Patch, type PatchesEvent, type Path, type PortableTextBlock, type PortableTextChild, PortableTextEditable, type PortableTextEditableProps, PortableTextEditor, type PortableTextObject, type PortableTextSpan, type PortableTextTextBlock, type RangeDecoration, type RangeDecorationOnMovedDetails, type RegisteredBlockObject, type RegisteredContainer, type RegisteredInlineObject, type RegisteredPositional, type RegisteredSpan, type RegistrableNode, type RenderAnnotationFunction, type RenderBlockFunction, type RenderChildFunction, type RenderDecoratorFunction, type RenderEditableFunction, type RenderListItemFunction, type RenderPlaceholderFunction, type RenderStyleFunction, type SchemaDefinition, type ScrollSelectionIntoViewFunction, type Span, type SpanRender, type SpanRenderProps, type StyleDefinition, type StyleSchemaType, type TextBlock, type TextBlockRender, type TextBlockRenderProps, defineBlockObject, defineContainer, defineInlineObject, defineSchema, defineSpan, defineTextBlock, defaultKeyGenerator as keyGenerator, resolveContainerAt, useEditor, useEditorSelector, usePortableTextEditor, usePortableTextEditorSelection };
|
|
1
|
+
import { $t as DecoratorRender, A as PortableTextSpan, At as PortableTextEditableProps, B as usePortableTextEditor, Bt as RegisteredInlineObject, C as ListDefinition, Ct as RenderDecoratorFunction, D as PortableTextBlock, Dt as RenderStyleFunction, E as Patch, Et as RenderPlaceholderFunction, F as defineSchema, G as Editor, Gt as AnnotationRenderProps, H as useEditorSelector, Ht as RegisteredSpan, I as BlockOffset, It as EditorSchema, J as EditorEmittedEvent, Jt as BlockObjectRenderProps, K as EditorConfig, Kt as BlockObject, L as useEditor, Lt as Containers, M as SchemaDefinition, Mt as PortableTextEditor, N as StyleDefinition, Nt as resolveContainerAt, O as PortableTextChild, Ot as ScrollSelectionIntoViewFunction, P as StyleSchemaType, Qt as Decorator, R as defaultKeyGenerator, Rt as RegisteredBlockObject, S as InlineObjectSchemaType, Sn as Path, St as RenderChildFunction, T as OfDefinition, Tt as RenderListItemFunction, U as EditorProvider, Ut as Annotation, V as EditorSelector, Vt as RegisteredPositional, W as EditorProviderProps, Wt as AnnotationRender, X as Operation, Xt as ContainerRender, Y as MutationEvent, Yt as Container, Zt as ContainerRenderProps, _ as BlockObjectSchemaType, _n as defineTextBlock, _t as PasteData, an as Span, at as BlockDecoratorRenderProps, b as FieldDefinition, bn as ChildPath, bt as RenderAnnotationFunction, cn as TextBlock, ct as BlockStyleRenderProps, dn as defineAnnotation, dt as EditorSelectionPoint, en as DecoratorRenderProps, et as EditorContext, f as PatchesEvent, fn as defineBlockObject, ft as InvalidValueResolution, g as BlockObjectDefinition, gn as defineSpan, gt as OnPasteResultOrPromise, h as BaseDefinition, hn as defineInlineObject, ht as OnPasteResult, in as RegistrableNode, it as BlockChildRenderProps, j as PortableTextTextBlock, jt as HotkeyOptions, k as PortableTextObject, kt as PortableTextEditable, ln as TextBlockRender, lt as EditableAPIDeleteOptions, m as AnnotationSchemaType, mn as defineDecorator, mt as OnPasteFn, nn as InlineObjectRender, nt as AddedAnnotationPaths, on as SpanRender, ot as BlockListItemRenderProps, p as AnnotationDefinition, pn as defineContainer, pt as OnCopyFn, q as EditorEvent, qt as BlockObjectRender, rn as InlineObjectRenderProps, rt as BlockAnnotationRenderProps, sn as SpanRenderProps, st as BlockRenderProps, tn as InlineObject, tt as EditorSnapshot, un as TextBlockRenderProps, ut as EditorSelection, v as DecoratorDefinition, vn as AnnotationPath, vt as RangeDecoration, w as ListSchemaType, wt as RenderEditableFunction, x as InlineObjectDefinition, xt as RenderBlockFunction, y as DecoratorSchemaType, yn as BlockPath, yt as RangeDecorationOnMovedDetails, z as usePortableTextEditorSelection, zt as RegisteredContainer } from "./behavior.types.action-DH6ujvaH.js";
|
|
2
|
+
export { type AddedAnnotationPaths, type Annotation, type AnnotationDefinition, type AnnotationPath, type AnnotationRender, type AnnotationRenderProps, type AnnotationSchemaType, type BaseDefinition, type BlockAnnotationRenderProps, type BlockChildRenderProps, type BlockDecoratorRenderProps, type BlockListItemRenderProps, type BlockObject, type BlockObjectDefinition, type BlockObjectRender, type BlockObjectRenderProps, type BlockObjectSchemaType, type BlockOffset, type BlockPath, type BlockRenderProps, type BlockStyleRenderProps, type ChildPath, type Container, type ContainerRender, type ContainerRenderProps, type Containers, type Decorator, type DecoratorDefinition, type DecoratorRender, type DecoratorRenderProps, type DecoratorSchemaType, type EditableAPIDeleteOptions, type Editor, type EditorConfig, type EditorContext, type EditorEmittedEvent, type EditorEvent, EditorProvider, type EditorProviderProps, type EditorSchema, type EditorSelection, type EditorSelectionPoint, type EditorSelector, type EditorSnapshot, type FieldDefinition, type HotkeyOptions, type InlineObject, type InlineObjectDefinition, type InlineObjectRender, type InlineObjectRenderProps, type InlineObjectSchemaType, type InvalidValueResolution, type ListDefinition, type ListSchemaType, type MutationEvent, type OfDefinition, type OnCopyFn, type OnPasteFn, type OnPasteResult, type OnPasteResultOrPromise, type Operation, type PasteData, type Patch, type PatchesEvent, type Path, type PortableTextBlock, type PortableTextChild, PortableTextEditable, type PortableTextEditableProps, PortableTextEditor, type PortableTextObject, type PortableTextSpan, type PortableTextTextBlock, type RangeDecoration, type RangeDecorationOnMovedDetails, type RegisteredBlockObject, type RegisteredContainer, type RegisteredInlineObject, type RegisteredPositional, type RegisteredSpan, type RegistrableNode, type RenderAnnotationFunction, type RenderBlockFunction, type RenderChildFunction, type RenderDecoratorFunction, type RenderEditableFunction, type RenderListItemFunction, type RenderPlaceholderFunction, type RenderStyleFunction, type SchemaDefinition, type ScrollSelectionIntoViewFunction, type Span, type SpanRender, type SpanRenderProps, type StyleDefinition, type StyleSchemaType, type TextBlock, type TextBlockRender, type TextBlockRenderProps, defineAnnotation, defineBlockObject, defineContainer, defineDecorator, defineInlineObject, defineSchema, defineSpan, defineTextBlock, defaultKeyGenerator as keyGenerator, resolveContainerAt, useEditor, useEditorSelector, usePortableTextEditor, usePortableTextEditorSelection };
|
package/lib/index.js
CHANGED
|
@@ -1993,7 +1993,7 @@ const DecorateContext = createContext({}), useDecorations = (node, path, parentD
|
|
|
1993
1993
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ new Set(), $[0] = t0) : t0 = $[0];
|
|
1994
1994
|
let eventListeners = useRef(t0), latestDecorate = useRef(decorateProp), t1, t2;
|
|
1995
1995
|
$[1] === decorateProp ? (t1 = $[2], t2 = $[3]) : (t1 = () => {
|
|
1996
|
-
latestDecorate.current = decorateProp, eventListeners.current.forEach(_temp$
|
|
1996
|
+
latestDecorate.current = decorateProp, eventListeners.current.forEach(_temp$5);
|
|
1997
1997
|
}, t2 = [decorateProp], $[1] = decorateProp, $[2] = t1, $[3] = t2), useIsomorphicLayoutEffect(t1, t2);
|
|
1998
1998
|
let t3;
|
|
1999
1999
|
$[4] === Symbol.for("react.memo_cache_sentinel") ? (t3 = (entry) => latestDecorate.current(entry), $[4] = t3) : t3 = $[4];
|
|
@@ -2007,7 +2007,7 @@ const DecorateContext = createContext({}), useDecorations = (node, path, parentD
|
|
|
2007
2007
|
addEventListener
|
|
2008
2008
|
}, $[6] = t5) : t5 = $[6], t5;
|
|
2009
2009
|
};
|
|
2010
|
-
function _temp$
|
|
2010
|
+
function _temp$5(listener) {
|
|
2011
2011
|
listener();
|
|
2012
2012
|
}
|
|
2013
2013
|
const rtlRange = "֑-߿יִ-﷽ﹰ-ﻼ", ltrRange = "A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--", rtl = RegExp(`^[^${ltrRange}]*[${rtlRange}]`), ltr = RegExp(`^[^${rtlRange}]*[${ltrRange}]`);
|
|
@@ -2554,7 +2554,7 @@ const useChildren = (props) => {
|
|
|
2554
2554
|
* selector re-runs on its component's renders and when a renderer
|
|
2555
2555
|
* registration map is swapped, not on document or selection changes.
|
|
2556
2556
|
* Only for selectors that read the registration maps
|
|
2557
|
-
* (`engine.containers/spans/textBlocks/blockObjects/inlineObjects`)
|
|
2557
|
+
* (`engine.containers/spans/textBlocks/blockObjects/inlineObjects/decorators/annotations`)
|
|
2558
2558
|
* exclusively; those maps are mutated only in
|
|
2559
2559
|
* `register-node-on-engine.ts`, which arms this channel.
|
|
2560
2560
|
*/
|
|
@@ -4057,7 +4057,7 @@ const DropPositionStoreContext = createContext({
|
|
|
4057
4057
|
* gaining or losing the indicator. Mirrors `SelectionStateProvider`.
|
|
4058
4058
|
*/
|
|
4059
4059
|
function DropPositionStateProvider(t0) {
|
|
4060
|
-
let $ = c(6), { children } = t0, editorActor = useContext(EditorActorContext), [initialSubscribers] = useState(_temp$
|
|
4060
|
+
let $ = c(6), { children } = t0, editorActor = useContext(EditorActorContext), [initialSubscribers] = useState(_temp$4), subscribersRef = useRef(initialSubscribers), stateRef = useRef(void 0), t1, t2;
|
|
4061
4061
|
$[0] === editorActor ? (t1 = $[1], t2 = $[2]) : (t1 = () => {
|
|
4062
4062
|
let behaviorConfigs = createDropPositionBehaviorsConfig({ setDropPosition: (next) => {
|
|
4063
4063
|
let prev = stateRef.current;
|
|
@@ -4095,7 +4095,7 @@ function DropPositionStateProvider(t0) {
|
|
|
4095
4095
|
* when no drag is hovering this block. Re-renders only when this block's slice
|
|
4096
4096
|
* flips, not when the position moves between other blocks.
|
|
4097
4097
|
*/
|
|
4098
|
-
function _temp$
|
|
4098
|
+
function _temp$4() {
|
|
4099
4099
|
return /* @__PURE__ */ new Set();
|
|
4100
4100
|
}
|
|
4101
4101
|
function useElementDropPosition(path) {
|
|
@@ -4526,14 +4526,40 @@ function findBlockPositionalOverride(parentConfig, type) {
|
|
|
4526
4526
|
* for a matching `_type`.
|
|
4527
4527
|
*/
|
|
4528
4528
|
function findInlinePositionalOverride(parentTextBlock, type) {
|
|
4529
|
-
return parentTextBlock?.of ? parentTextBlock.of.find((entry) =>
|
|
4529
|
+
return parentTextBlock?.of ? parentTextBlock.of.find((entry) => isMatchingSpanOrInlineObject(entry, type)) || parentTextBlock.of.find((entry) => isMatchingSpanOrInlineObject(entry, "*")) : void 0;
|
|
4530
|
+
}
|
|
4531
|
+
function isMatchingSpanOrInlineObject(entry, type) {
|
|
4532
|
+
return "span" in entry ? entry.span.type === type : "inlineObject" in entry && entry.inlineObject.type === type;
|
|
4533
|
+
}
|
|
4534
|
+
/**
|
|
4535
|
+
* Decorator positional override lookup. Walks the immediate parent
|
|
4536
|
+
* text block's `of` array (decorator kind) for a matching decorator
|
|
4537
|
+
* name: exact first, then a `'*'` entry.
|
|
4538
|
+
*/
|
|
4539
|
+
function findPositionalDecoratorOverride(parentTextBlock, decorator) {
|
|
4540
|
+
return parentTextBlock?.of ? parentTextBlock.of.find((entry) => isMatchingDecorator(entry, decorator)) || parentTextBlock.of.find((entry) => isMatchingDecorator(entry, "*")) : void 0;
|
|
4541
|
+
}
|
|
4542
|
+
function isMatchingDecorator(entry, decorator) {
|
|
4543
|
+
return "decorator" in entry && entry.decorator.type === decorator;
|
|
4544
|
+
}
|
|
4545
|
+
/**
|
|
4546
|
+
* Annotation positional override lookup. Walks the immediate parent
|
|
4547
|
+
* text block's `of` array (annotation kind) for a matching annotation
|
|
4548
|
+
* `_type`: exact first, then a `'*'` entry.
|
|
4549
|
+
*/
|
|
4550
|
+
function findPositionalAnnotationOverride(parentTextBlock, type) {
|
|
4551
|
+
return parentTextBlock?.of ? parentTextBlock.of.find((entry) => isMatchingAnnotation(entry, type)) || parentTextBlock.of.find((entry) => isMatchingAnnotation(entry, "*")) : void 0;
|
|
4552
|
+
}
|
|
4553
|
+
function isMatchingAnnotation(entry, type) {
|
|
4554
|
+
return "annotation" in entry && entry.annotation.type === type;
|
|
4530
4555
|
}
|
|
4531
4556
|
/**
|
|
4532
4557
|
* The active text block's resolved config at this render position.
|
|
4533
4558
|
* Provided by the text-block render branch in `render.element.tsx`;
|
|
4534
4559
|
* consumed by inline-level dispatch (`useSpanConfig` + the
|
|
4535
|
-
* inline-object branch of `render.element.tsx`) for positional
|
|
4536
|
-
* override lookup
|
|
4560
|
+
* inline-object branch of `render.element.tsx`) for positional span/
|
|
4561
|
+
* inline-object override lookup, and directly by `RenderSpan` for
|
|
4562
|
+
* positional decorator/annotation override lookup.
|
|
4537
4563
|
*
|
|
4538
4564
|
* Separate from `ParentContainerContext` so inline subscribers only
|
|
4539
4565
|
* re-render on text-block `of` changes, and block subscribers only
|
|
@@ -4574,6 +4600,24 @@ function renderDefaultSpan(props) {
|
|
|
4574
4600
|
});
|
|
4575
4601
|
}
|
|
4576
4602
|
/**
|
|
4603
|
+
* Engine-default wrapper for Decorator marks: identity. The engine
|
|
4604
|
+
* applies no decorator markup of its own; a decorator's whole visual
|
|
4605
|
+
* effect comes from its `render`.
|
|
4606
|
+
*/
|
|
4607
|
+
function renderDefaultDecorator(props) {
|
|
4608
|
+
return props.children;
|
|
4609
|
+
}
|
|
4610
|
+
/**
|
|
4611
|
+
* Engine-default wrapper for Annotation marks: identity. The engine
|
|
4612
|
+
* always anchors the annotated text in a `<span ref>` outside this
|
|
4613
|
+
* render, kept for structural parity with the legacy `renderAnnotation`
|
|
4614
|
+
* path (which hands that anchor to consumers as `editorElementRef`);
|
|
4615
|
+
* the render itself owns no markup by default.
|
|
4616
|
+
*/
|
|
4617
|
+
function renderDefaultAnnotation(props) {
|
|
4618
|
+
return props.children;
|
|
4619
|
+
}
|
|
4620
|
+
/**
|
|
4577
4621
|
* Engine-default wrapper for void block objects. Renders the zero-width
|
|
4578
4622
|
* editor children plus a non-editable `[_type: _key]` placeholder so the
|
|
4579
4623
|
* object is visible before a consumer provides a custom `render`.
|
|
@@ -4816,7 +4860,7 @@ function SelectionStateProvider(t0) {
|
|
|
4816
4860
|
blockIndexMap: editorEngine.blockIndexMap
|
|
4817
4861
|
}, selection);
|
|
4818
4862
|
}, $[0] = editorEngine.blockIndexMap, $[1] = editorEngine.snapshot, $[2] = t1) : t1 = $[2];
|
|
4819
|
-
let computeCurrent = t1, [seed] = useState(computeCurrent), stateRef = useRef(seed), [initialSubscribers] = useState(_temp$
|
|
4863
|
+
let computeCurrent = t1, [seed] = useState(computeCurrent), stateRef = useRef(seed), [initialSubscribers] = useState(_temp$3), subscribersRef = useRef(initialSubscribers), t2, t3;
|
|
4820
4864
|
$[3] !== computeCurrent || $[4] !== editorActor ? (t2 = () => {
|
|
4821
4865
|
let next = computeCurrent();
|
|
4822
4866
|
if (!selectionStatesEqual(stateRef.current, next)) {
|
|
@@ -4850,7 +4894,7 @@ function SelectionStateProvider(t0) {
|
|
|
4850
4894
|
* focused. Re-renders only when this boolean flips - not when other
|
|
4851
4895
|
* containers' focused state changes.
|
|
4852
4896
|
*/
|
|
4853
|
-
function _temp$
|
|
4897
|
+
function _temp$3() {
|
|
4854
4898
|
return /* @__PURE__ */ new Set();
|
|
4855
4899
|
}
|
|
4856
4900
|
function useIsFocusedContainer(serializedPath) {
|
|
@@ -5626,8 +5670,43 @@ function useSpanConfig(node, _path) {
|
|
|
5626
5670
|
let [globalSpan, globalSpanCatchAll] = useRegistrationsSelector(t1, tupleRefEqual);
|
|
5627
5671
|
return positional && "span" in positional ? positional.span.render === void 0 ? globalSpan ?? globalSpanCatchAll : positional : globalSpan ?? globalSpanCatchAll;
|
|
5628
5672
|
}
|
|
5673
|
+
/**
|
|
5674
|
+
* Hook: the engine's registered GLOBAL decorator map. Positional
|
|
5675
|
+
* (in-parent) decorator overrides are a separate layer: the caller
|
|
5676
|
+
* resolves them from `ParentTextBlockContext` via
|
|
5677
|
+
* `findPositionalDecoratorOverride` and combines that result with
|
|
5678
|
+
* this map's.
|
|
5679
|
+
*
|
|
5680
|
+
* The per-mark exact-then-`'*'` lookup against this map happens as a
|
|
5681
|
+
* plain `Map` read rather than as one hook call per mark: a span
|
|
5682
|
+
* carries a variable number of decorator marks, and hooks cannot be
|
|
5683
|
+
* called a variable number of times.
|
|
5684
|
+
*/
|
|
5685
|
+
function useDecoratorConfigs() {
|
|
5686
|
+
return useRegistrationsSelector(_temp$2);
|
|
5687
|
+
}
|
|
5688
|
+
/**
|
|
5689
|
+
* Hook: the engine's registered GLOBAL annotation map. Positional
|
|
5690
|
+
* (in-parent) annotation overrides are a separate layer: the caller
|
|
5691
|
+
* resolves them from `ParentTextBlockContext` via
|
|
5692
|
+
* `findPositionalAnnotationOverride` and combines that result with
|
|
5693
|
+
* this map's.
|
|
5694
|
+
*
|
|
5695
|
+
* Same plain-`Map`-read reasoning as {@link useDecoratorConfigs}: a
|
|
5696
|
+
* span's marks resolve to a variable number of annotation `markDef`s
|
|
5697
|
+
* per render.
|
|
5698
|
+
*/
|
|
5699
|
+
function _temp$2(engine) {
|
|
5700
|
+
return engine.decorators;
|
|
5701
|
+
}
|
|
5702
|
+
function useAnnotationConfigs() {
|
|
5703
|
+
return useRegistrationsSelector(_temp2$1);
|
|
5704
|
+
}
|
|
5705
|
+
function _temp2$1(engine) {
|
|
5706
|
+
return engine.annotations;
|
|
5707
|
+
}
|
|
5629
5708
|
function RenderSpan(props) {
|
|
5630
|
-
let $ = c(
|
|
5709
|
+
let $ = c(33), schema = props.schema, spanRef = useRef(null), t0;
|
|
5631
5710
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[0] = t0) : t0 = $[0];
|
|
5632
5711
|
let t1;
|
|
5633
5712
|
$[1] === schema.span.name ? t1 = $[2] : (t1 = {
|
|
@@ -5636,88 +5715,119 @@ function RenderSpan(props) {
|
|
|
5636
5715
|
}, $[1] = schema.span.name, $[2] = t1);
|
|
5637
5716
|
let schemaType = t1, parent = props.children.props.parent, block = parent && isTextBlock({ schema }, parent) ? parent : void 0, t2;
|
|
5638
5717
|
$[3] !== block?.children || $[4] !== props.leaf._key ? (t2 = block?.children.find((_child) => _child._key === props.leaf._key), $[3] = block?.children, $[4] = props.leaf._key, $[5] = t2) : t2 = $[5];
|
|
5639
|
-
let child = t2, subSchema = useBlockSubSchema(props.path), spanConfig = useSpanConfig(child ?? props.leaf, props.path), isInNewPipeline = useContext(NewPipelineContext), t3;
|
|
5718
|
+
let child = t2, subSchema = useBlockSubSchema(props.path), spanConfig = useSpanConfig(child ?? props.leaf, props.path), decoratorConfigs = useDecoratorConfigs(), annotationConfigs = useAnnotationConfigs(), parentTextBlock = useContext(ParentTextBlockContext), isInNewPipeline = useContext(NewPipelineContext), t3;
|
|
5640
5719
|
$[6] === props.path ? t3 = $[7] : (t3 = serializePath(props.path), $[6] = props.path, $[7] = t3);
|
|
5641
|
-
let serializedPath = t3, focused = useIsFocusedLeaf(serializedPath), selected = useIsSelectedLeaf(serializedPath),
|
|
5642
|
-
if ($[8] !==
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5720
|
+
let serializedPath = t3, focused = useIsFocusedLeaf(serializedPath), selected = useIsSelectedLeaf(serializedPath), t4 = subSchema.decorators, children, t5;
|
|
5721
|
+
if ($[8] !== annotationConfigs || $[9] !== block || $[10] !== child || $[11] !== decoratorConfigs || $[12] !== focused || $[13] !== isInNewPipeline || $[14] !== parentTextBlock || $[15] !== props.attributes || $[16] !== props.children || $[17] !== props.leaf || $[18] !== props.path || $[19] !== props.readOnly || $[20] !== props.renderAnnotation || $[21] !== props.renderChild || $[22] !== props.renderDecorator || $[23] !== schemaType || $[24] !== selected || $[25] !== spanConfig || $[26] !== subSchema.annotations || $[27] !== subSchema.decorators) {
|
|
5722
|
+
t5 = Symbol.for("react.early_return_sentinel");
|
|
5723
|
+
bb0: {
|
|
5724
|
+
let decoratorSchemaTypes = t4.map(_temp$1), decorators = [...new Set((props.leaf.marks ?? []).filter((mark) => decoratorSchemaTypes.includes(mark)))], annotationMarkDefs = (props.leaf.marks ?? []).flatMap((mark_0) => {
|
|
5725
|
+
if (decoratorSchemaTypes.includes(mark_0)) return [];
|
|
5726
|
+
let markDef_0 = block?.markDefs?.find((markDef) => markDef._key === mark_0);
|
|
5727
|
+
return markDef_0 ? [markDef_0] : [];
|
|
5728
|
+
});
|
|
5729
|
+
children = props.children;
|
|
5730
|
+
for (let mark_1 of decorators) {
|
|
5731
|
+
let decoratorSchemaType = subSchema.decorators.find((dec) => dec.name === mark_1);
|
|
5732
|
+
if (!decoratorSchemaType) continue;
|
|
5733
|
+
let globalDecoratorConfig = decoratorConfigs.get(mark_1) ?? decoratorConfigs.get("*"), positionalDecorator = findPositionalDecoratorOverride(parentTextBlock, mark_1), decoratorConfig = positionalDecorator ? positionalDecorator.decorator.render === void 0 ? globalDecoratorConfig : positionalDecorator : globalDecoratorConfig;
|
|
5734
|
+
if (decoratorConfig) {
|
|
5735
|
+
let render = decoratorConfig.decorator.render, renderProps = {
|
|
5736
|
+
children,
|
|
5737
|
+
decorator: mark_1,
|
|
5738
|
+
focused,
|
|
5739
|
+
path: props.path,
|
|
5740
|
+
readOnly: props.readOnly,
|
|
5741
|
+
renderDefault: renderDefaultDecorator,
|
|
5742
|
+
selected
|
|
5743
|
+
};
|
|
5744
|
+
children = render ? render(renderProps) : renderDefaultDecorator(renderProps);
|
|
5745
|
+
continue;
|
|
5746
|
+
}
|
|
5747
|
+
props.renderDecorator && (children = /* @__PURE__ */ jsx(RenderDecorator, {
|
|
5748
|
+
renderDecorator: props.renderDecorator,
|
|
5749
|
+
editorElementRef: spanRef,
|
|
5750
|
+
focused,
|
|
5751
|
+
path: props.path,
|
|
5752
|
+
selected,
|
|
5753
|
+
schemaType: decoratorSchemaType,
|
|
5754
|
+
value: mark_1,
|
|
5755
|
+
children
|
|
5756
|
+
}));
|
|
5757
|
+
}
|
|
5758
|
+
for (let annotationMarkDef of annotationMarkDefs) {
|
|
5759
|
+
let annotationSchemaType = subSchema.annotations.find((t) => t.name === annotationMarkDef._type);
|
|
5760
|
+
if (annotationSchemaType) {
|
|
5761
|
+
let globalAnnotationConfig = annotationConfigs.get(annotationMarkDef._type) ?? annotationConfigs.get("*"), positionalAnnotation = findPositionalAnnotationOverride(parentTextBlock, annotationMarkDef._type), annotationConfig = positionalAnnotation ? positionalAnnotation.annotation.render === void 0 ? globalAnnotationConfig : positionalAnnotation : globalAnnotationConfig;
|
|
5762
|
+
if (annotationConfig) {
|
|
5763
|
+
let render_0 = annotationConfig.annotation.render, renderProps_0 = {
|
|
5764
|
+
children,
|
|
5765
|
+
focused,
|
|
5766
|
+
annotation: annotationMarkDef,
|
|
5767
|
+
path: props.path,
|
|
5768
|
+
readOnly: props.readOnly,
|
|
5769
|
+
renderDefault: renderDefaultAnnotation,
|
|
5770
|
+
selected
|
|
5771
|
+
};
|
|
5772
|
+
children = /* @__PURE__ */ jsx("span", {
|
|
5773
|
+
ref: spanRef,
|
|
5774
|
+
children: render_0 ? render_0(renderProps_0) : renderDefaultAnnotation(renderProps_0)
|
|
5775
|
+
});
|
|
5776
|
+
continue;
|
|
5777
|
+
}
|
|
5778
|
+
children = block && props.renderAnnotation ? /* @__PURE__ */ jsx("span", {
|
|
5779
|
+
ref: spanRef,
|
|
5780
|
+
children: /* @__PURE__ */ jsx(RenderAnnotation, {
|
|
5781
|
+
renderAnnotation: props.renderAnnotation,
|
|
5782
|
+
block,
|
|
5783
|
+
editorElementRef: spanRef,
|
|
5784
|
+
focused,
|
|
5785
|
+
path: props.path,
|
|
5786
|
+
selected,
|
|
5787
|
+
schemaType: annotationSchemaType,
|
|
5788
|
+
value: annotationMarkDef,
|
|
5789
|
+
children
|
|
5790
|
+
})
|
|
5791
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
5792
|
+
ref: spanRef,
|
|
5793
|
+
children
|
|
5794
|
+
});
|
|
5795
|
+
}
|
|
5796
|
+
}
|
|
5797
|
+
if (block && props.renderChild && child && !spanConfig && !isInNewPipeline && (children = /* @__PURE__ */ jsx(RenderChild, {
|
|
5798
|
+
renderChild: props.renderChild,
|
|
5799
|
+
annotations: annotationMarkDefs,
|
|
5653
5800
|
editorElementRef: spanRef,
|
|
5654
5801
|
focused,
|
|
5655
5802
|
path: props.path,
|
|
5803
|
+
schemaType,
|
|
5656
5804
|
selected,
|
|
5657
|
-
|
|
5658
|
-
value: mark_1,
|
|
5805
|
+
value: child,
|
|
5659
5806
|
children
|
|
5660
|
-
}))
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
annotationSchemaType && (children = block && props.renderAnnotation ? /* @__PURE__ */ jsx("span", {
|
|
5665
|
-
ref: spanRef,
|
|
5666
|
-
children: /* @__PURE__ */ jsx(RenderAnnotation, {
|
|
5667
|
-
renderAnnotation: props.renderAnnotation,
|
|
5668
|
-
block,
|
|
5669
|
-
editorElementRef: spanRef,
|
|
5807
|
+
})), spanConfig) {
|
|
5808
|
+
let render_1 = spanConfig.span.render, renderProps_1 = {
|
|
5809
|
+
attributes: props.attributes,
|
|
5810
|
+
children,
|
|
5670
5811
|
focused,
|
|
5812
|
+
node: child ?? props.leaf,
|
|
5671
5813
|
path: props.path,
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
children
|
|
5680
|
-
}));
|
|
5814
|
+
readOnly: props.readOnly,
|
|
5815
|
+
renderDefault: renderDefaultSpan,
|
|
5816
|
+
selected
|
|
5817
|
+
};
|
|
5818
|
+
t5 = render_1 ? render_1(renderProps_1) : renderDefaultSpan(renderProps_1);
|
|
5819
|
+
break bb0;
|
|
5820
|
+
}
|
|
5681
5821
|
}
|
|
5682
|
-
$[8] =
|
|
5683
|
-
} else
|
|
5684
|
-
if (
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
renderChild: props.renderChild,
|
|
5688
|
-
annotations: annotationMarkDefs,
|
|
5689
|
-
editorElementRef: spanRef,
|
|
5690
|
-
focused,
|
|
5691
|
-
path: props.path,
|
|
5692
|
-
schemaType,
|
|
5693
|
-
selected,
|
|
5694
|
-
value: child,
|
|
5695
|
-
children
|
|
5696
|
-
}), $[20] = annotationMarkDefs, $[21] = child, $[22] = children, $[23] = focused, $[24] = props.path, $[25] = props.renderChild, $[26] = schemaType, $[27] = selected, $[28] = t4) : t4 = $[28], children = t4;
|
|
5697
|
-
}
|
|
5698
|
-
if (spanConfig) {
|
|
5699
|
-
let render = spanConfig.span.render, t4 = child ?? props.leaf, t5;
|
|
5700
|
-
if ($[29] !== children || $[30] !== focused || $[31] !== props.attributes || $[32] !== props.path || $[33] !== props.readOnly || $[34] !== render || $[35] !== selected || $[36] !== t4) {
|
|
5701
|
-
let renderProps = {
|
|
5702
|
-
attributes: props.attributes,
|
|
5703
|
-
children,
|
|
5704
|
-
focused,
|
|
5705
|
-
node: t4,
|
|
5706
|
-
path: props.path,
|
|
5707
|
-
readOnly: props.readOnly,
|
|
5708
|
-
renderDefault: renderDefaultSpan,
|
|
5709
|
-
selected
|
|
5710
|
-
};
|
|
5711
|
-
t5 = render ? render(renderProps) : renderDefaultSpan(renderProps), $[29] = children, $[30] = focused, $[31] = props.attributes, $[32] = props.path, $[33] = props.readOnly, $[34] = render, $[35] = selected, $[36] = t4, $[37] = t5;
|
|
5712
|
-
} else t5 = $[37];
|
|
5713
|
-
return t5;
|
|
5714
|
-
}
|
|
5715
|
-
let t4;
|
|
5716
|
-
return $[38] !== children || $[39] !== props.attributes ? (t4 = /* @__PURE__ */ jsx("span", {
|
|
5822
|
+
$[8] = annotationConfigs, $[9] = block, $[10] = child, $[11] = decoratorConfigs, $[12] = focused, $[13] = isInNewPipeline, $[14] = parentTextBlock, $[15] = props.attributes, $[16] = props.children, $[17] = props.leaf, $[18] = props.path, $[19] = props.readOnly, $[20] = props.renderAnnotation, $[21] = props.renderChild, $[22] = props.renderDecorator, $[23] = schemaType, $[24] = selected, $[25] = spanConfig, $[26] = subSchema.annotations, $[27] = subSchema.decorators, $[28] = children, $[29] = t5;
|
|
5823
|
+
} else children = $[28], t5 = $[29];
|
|
5824
|
+
if (t5 !== Symbol.for("react.early_return_sentinel")) return t5;
|
|
5825
|
+
let t6;
|
|
5826
|
+
return $[30] !== children || $[31] !== props.attributes ? (t6 = /* @__PURE__ */ jsx("span", {
|
|
5717
5827
|
...props.attributes,
|
|
5718
5828
|
ref: spanRef,
|
|
5719
5829
|
children
|
|
5720
|
-
}), $[
|
|
5830
|
+
}), $[30] = children, $[31] = props.attributes, $[32] = t6) : t6 = $[32], t6;
|
|
5721
5831
|
}
|
|
5722
5832
|
function _temp$1(decorator) {
|
|
5723
5833
|
return decorator.name;
|
|
@@ -10329,7 +10439,7 @@ function createEditorEngine(config) {
|
|
|
10329
10439
|
value: [placeholderBlock]
|
|
10330
10440
|
},
|
|
10331
10441
|
decoratorState: {}
|
|
10332
|
-
}, editor.containers = /* @__PURE__ */ new Map(), editor.blockObjects = /* @__PURE__ */ new Map(), editor.inlineObjects = /* @__PURE__ */ new Map(), editor.spans = /* @__PURE__ */ new Map(), editor.textBlocks = /* @__PURE__ */ new Map(), editor.decoratedRanges = [], editor.blockIndexMap = blockIndexMap, editor.history = {
|
|
10442
|
+
}, editor.containers = /* @__PURE__ */ new Map(), editor.annotations = /* @__PURE__ */ new Map(), editor.blockObjects = /* @__PURE__ */ new Map(), editor.decorators = /* @__PURE__ */ new Map(), editor.inlineObjects = /* @__PURE__ */ new Map(), editor.spans = /* @__PURE__ */ new Map(), editor.textBlocks = /* @__PURE__ */ new Map(), editor.decoratedRanges = [], editor.blockIndexMap = blockIndexMap, editor.history = {
|
|
10333
10443
|
undos: [],
|
|
10334
10444
|
redos: []
|
|
10335
10445
|
}, editor.listIndexMap = /* @__PURE__ */ new Map(), editor.listIndexMapDirty = !1, editor.selectorChannelsPending = {
|
|
@@ -15415,7 +15525,7 @@ function describeContainerFailure(failure, container) {
|
|
|
15415
15525
|
* (if present) for inline-content positional overrides.
|
|
15416
15526
|
*/
|
|
15417
15527
|
function resolveTextBlockConfig(textBlock) {
|
|
15418
|
-
let resolvedOf = textBlock.of ? textBlock.of.flatMap((entry) => entry.kind === "span" ? [{ span: entry }] : [{ inlineObject: entry }]) : void 0;
|
|
15528
|
+
let resolvedOf = textBlock.of ? textBlock.of.flatMap((entry) => entry.kind === "span" ? [{ span: entry }] : entry.kind === "inlineObject" ? [{ inlineObject: entry }] : entry.kind === "decorator" ? [{ decorator: entry }] : [{ annotation: entry }]) : void 0;
|
|
15419
15529
|
return {
|
|
15420
15530
|
textBlock,
|
|
15421
15531
|
...resolvedOf ? { of: resolvedOf } : {}
|
|
@@ -15507,9 +15617,27 @@ function registerNodeOnEngine(engine, node) {
|
|
|
15507
15617
|
blockObjects.set(node.type, { blockObject: node }), engine.blockObjects = blockObjects, notifyRegistrationsChanged(engine);
|
|
15508
15618
|
return;
|
|
15509
15619
|
}
|
|
15510
|
-
if (
|
|
15511
|
-
|
|
15512
|
-
|
|
15620
|
+
if (node.kind === "inlineObject") {
|
|
15621
|
+
if (isTypeAlreadyRegistered(engine, "inlineObject", node.type)) return;
|
|
15622
|
+
let inlineObjects = new Map(engine.inlineObjects);
|
|
15623
|
+
inlineObjects.set(node.type, { inlineObject: node }), engine.inlineObjects = inlineObjects, notifyRegistrationsChanged(engine);
|
|
15624
|
+
return;
|
|
15625
|
+
}
|
|
15626
|
+
if (node.kind === "decorator") {
|
|
15627
|
+
if (engine.decorators.has(node.type)) {
|
|
15628
|
+
console.warn(`registerNode: type "${node.type}" is already registered as a decorator. Registration skipped.`);
|
|
15629
|
+
return;
|
|
15630
|
+
}
|
|
15631
|
+
let decorators = new Map(engine.decorators);
|
|
15632
|
+
decorators.set(node.type, { decorator: node }), engine.decorators = decorators, notifyRegistrationsChanged(engine);
|
|
15633
|
+
return;
|
|
15634
|
+
}
|
|
15635
|
+
if (engine.annotations.has(node.type)) {
|
|
15636
|
+
console.warn(`registerNode: type "${node.type}" is already registered as an annotation. Registration skipped.`);
|
|
15637
|
+
return;
|
|
15638
|
+
}
|
|
15639
|
+
let annotations = new Map(engine.annotations);
|
|
15640
|
+
annotations.set(node.type, { annotation: node }), engine.annotations = annotations, notifyRegistrationsChanged(engine);
|
|
15513
15641
|
}
|
|
15514
15642
|
/**
|
|
15515
15643
|
* Mutate the engine's registration maps to remove a registered node.
|
|
@@ -15537,8 +15665,18 @@ function unregisterNodeOnEngine(engine, node) {
|
|
|
15537
15665
|
blockObjects.delete(node.type), engine.blockObjects = blockObjects, notifyRegistrationsChanged(engine);
|
|
15538
15666
|
return;
|
|
15539
15667
|
}
|
|
15540
|
-
|
|
15541
|
-
|
|
15668
|
+
if (node.kind === "inlineObject") {
|
|
15669
|
+
let inlineObjects = new Map(engine.inlineObjects);
|
|
15670
|
+
inlineObjects.delete(node.type), engine.inlineObjects = inlineObjects, notifyRegistrationsChanged(engine);
|
|
15671
|
+
return;
|
|
15672
|
+
}
|
|
15673
|
+
if (node.kind === "decorator") {
|
|
15674
|
+
let decorators = new Map(engine.decorators);
|
|
15675
|
+
decorators.delete(node.type), engine.decorators = decorators, notifyRegistrationsChanged(engine);
|
|
15676
|
+
return;
|
|
15677
|
+
}
|
|
15678
|
+
let annotations = new Map(engine.annotations);
|
|
15679
|
+
annotations.delete(node.type), engine.annotations = annotations, notifyRegistrationsChanged(engine);
|
|
15542
15680
|
}
|
|
15543
15681
|
/**
|
|
15544
15682
|
* The registration maps are mutated only in this module, so the React
|
|
@@ -17348,6 +17486,60 @@ function defineSpan(config) {
|
|
|
17348
17486
|
/**
|
|
17349
17487
|
* @public
|
|
17350
17488
|
*
|
|
17489
|
+
* Define a decorator renderer for a decorator name declared in the
|
|
17490
|
+
* schema's `decorators` array, or `'*'` to match every decorator.
|
|
17491
|
+
* The returned registration is mounted via the `<NodePlugin>`
|
|
17492
|
+
* component.
|
|
17493
|
+
*
|
|
17494
|
+
* Decorator names live in a different namespace than node
|
|
17495
|
+
* `_type`s, so `type` has no forbidden values here (unlike
|
|
17496
|
+
* `defineSpan`/`defineTextBlock`).
|
|
17497
|
+
*
|
|
17498
|
+
* @example
|
|
17499
|
+
* ```ts
|
|
17500
|
+
* defineDecorator({
|
|
17501
|
+
* type: 'strong',
|
|
17502
|
+
* render: ({children}) => <strong>{children}</strong>,
|
|
17503
|
+
* })
|
|
17504
|
+
* ```
|
|
17505
|
+
*/
|
|
17506
|
+
function defineDecorator(config) {
|
|
17507
|
+
return {
|
|
17508
|
+
kind: "decorator",
|
|
17509
|
+
...config
|
|
17510
|
+
};
|
|
17511
|
+
}
|
|
17512
|
+
/**
|
|
17513
|
+
* @public
|
|
17514
|
+
*
|
|
17515
|
+
* Define an annotation renderer for a `_type` declared in the
|
|
17516
|
+
* schema's `annotations` array, or `'*'` to match every annotation
|
|
17517
|
+
* type. The returned registration is mounted via the `<NodePlugin>`
|
|
17518
|
+
* component.
|
|
17519
|
+
*
|
|
17520
|
+
* Annotation `_type`s live in a different namespace than node
|
|
17521
|
+
* `_type`s, so `type` has no forbidden values here (unlike
|
|
17522
|
+
* `defineInlineObject`/`defineBlockObject`).
|
|
17523
|
+
*
|
|
17524
|
+
* @example
|
|
17525
|
+
* ```ts
|
|
17526
|
+
* defineAnnotation({
|
|
17527
|
+
* type: 'link',
|
|
17528
|
+
* render: ({annotation, children}) => (
|
|
17529
|
+
* <a href={(annotation as {href?: string}).href}>{children}</a>
|
|
17530
|
+
* ),
|
|
17531
|
+
* })
|
|
17532
|
+
* ```
|
|
17533
|
+
*/
|
|
17534
|
+
function defineAnnotation(config) {
|
|
17535
|
+
return {
|
|
17536
|
+
kind: "annotation",
|
|
17537
|
+
...config
|
|
17538
|
+
};
|
|
17539
|
+
}
|
|
17540
|
+
/**
|
|
17541
|
+
* @public
|
|
17542
|
+
*
|
|
17351
17543
|
* Define a non-editable block-level object renderer for a `_type`
|
|
17352
17544
|
* declared in the schema's `blockObjects` array.
|
|
17353
17545
|
*
|
|
@@ -17433,6 +17625,6 @@ function defineTextBlock(config) {
|
|
|
17433
17625
|
...config
|
|
17434
17626
|
};
|
|
17435
17627
|
}
|
|
17436
|
-
export { EditorProvider, PortableTextEditable, PortableTextEditor, defineBlockObject, defineContainer, defineInlineObject, defineSchema, defineSpan, defineTextBlock, defaultKeyGenerator as keyGenerator, resolveContainerAt, useEditor, useEditorSelector, usePortableTextEditor, usePortableTextEditorSelection };
|
|
17628
|
+
export { EditorProvider, PortableTextEditable, PortableTextEditor, defineAnnotation, defineBlockObject, defineContainer, defineDecorator, defineInlineObject, defineSchema, defineSpan, defineTextBlock, defaultKeyGenerator as keyGenerator, resolveContainerAt, useEditor, useEditorSelector, usePortableTextEditor, usePortableTextEditorSelection };
|
|
17437
17629
|
|
|
17438
17630
|
//# sourceMappingURL=index.js.map
|