@morfira-dev/wysiwyg-core 1.6.0 → 1.7.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/dist/document/budget.d.ts +6 -0
- package/dist/document/index.d.ts +1 -1
- package/dist/document/internal-types.d.ts +4 -0
- package/dist/editor/internal-types.d.ts +2 -0
- package/dist/editor/types.d.ts +3 -3
- package/dist/events/index.d.ts +1 -1
- package/dist/events/types.d.ts +8 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/input/index.d.ts +3 -0
- package/dist/input/inline-fragment.d.ts +2 -0
- package/dist/input/internal-types.d.ts +14 -0
- package/dist/input/paste-replacement.d.ts +4 -0
- package/dist/input/replace-selection.d.ts +9 -0
- package/dist/lists/first-body-backspace.d.ts +4 -0
- package/dist/lists/first-body-backspace.types.d.ts +14 -0
- package/dist/lists/forward-delete.d.ts +4 -0
- package/dist/lists/index.d.ts +5 -1
- package/dist/lists/internal-types.d.ts +65 -0
- package/dist/lists/paste-payload.d.ts +6 -0
- package/dist/lists/quote-crossing.d.ts +5 -0
- package/dist/lists/quote-selection.d.ts +9 -0
- package/dist/lists/replace-selection.d.ts +8 -0
- package/dist/lists/selection-boundaries.d.ts +11 -0
- package/dist/lists/wrapped-input.d.ts +5 -0
- package/dist/lists/wrapped-input.types.d.ts +1 -0
- package/dist/schema/index.d.ts +3 -3
- package/dist/schema/types.d.ts +14 -0
- package/dist/selection/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/input/index.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
1
|
export { editBlockInput, handlesBlockInput } from './block-boundaries.js';
|
|
2
|
+
export { handlesSelectionReplacement, replaceSelection, cutSelectionReplacement, ensureReplacementPlaceholder, finishSelectionReplacement } from './replace-selection.js';
|
|
3
|
+
export { prepareSelectionPaste, replaceSelectionWithFragment } from './paste-replacement.js';
|
|
4
|
+
export { insertInlineFragment } from './inline-fragment.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface SelectionReplacement {
|
|
2
|
+
range: Range;
|
|
3
|
+
leaves: HTMLElement[];
|
|
4
|
+
contentRoots?: {
|
|
5
|
+
left: HTMLElement;
|
|
6
|
+
right: HTMLElement;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface CutSelectionReplacement {
|
|
10
|
+
left: HTMLElement;
|
|
11
|
+
right: HTMLElement;
|
|
12
|
+
tail: DocumentFragment;
|
|
13
|
+
caret: Range;
|
|
14
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Validate/normalize a detached payload only when the new sibling-range path owns it. */
|
|
2
|
+
export declare const prepareSelectionPaste: (root: HTMLElement, fragment: DocumentFragment, range?: Range) => void;
|
|
3
|
+
/** A validated fragment replaces only the accepted ordinary sibling range. */
|
|
4
|
+
export declare const replaceSelectionWithFragment: (root: HTMLElement, fragment: DocumentFragment) => boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SelectionReplacement, CutSelectionReplacement } from './internal-types.js';
|
|
2
|
+
export declare const handlesSelectionReplacement: (root: HTMLElement, inputType: string, data: string | null) => boolean;
|
|
3
|
+
export declare const selectionReplacement: (root: HTMLElement, range?: Range | undefined) => SelectionReplacement | undefined;
|
|
4
|
+
/** Shared live cut, called only after eligibility and detached import validation. */
|
|
5
|
+
export declare const cutSelectionReplacement: ({ range, leaves, contentRoots }: SelectionReplacement) => CutSelectionReplacement;
|
|
6
|
+
export declare const ensureReplacementPlaceholder: (leaf: HTMLElement, caret: Range) => void;
|
|
7
|
+
export declare const finishSelectionReplacement: (leaf: HTMLElement, caret: Range) => void;
|
|
8
|
+
/** Replace only ordinary sibling leaves inside the editor's validated transaction. */
|
|
9
|
+
export declare const replaceSelection: (root: HTMLElement, text: string) => void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ListItemBoundary } from './internal-types.js';
|
|
2
|
+
export declare const canEditFirstBodyBackspace: (root: HTMLElement, boundary: ListItemBoundary) => boolean;
|
|
3
|
+
/** Invoked only inside the cancelable-beforeinput transaction owner. */
|
|
4
|
+
export declare const editFirstBodyBackspace: (root: HTMLElement, boundary: ListItemBoundary, start: Range) => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ListItemBoundary } from './internal-types.js';
|
|
2
|
+
export type FirstBodyBackspacePlan = {
|
|
3
|
+
kind: 'join';
|
|
4
|
+
previous: ListItemBoundary;
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'unwrap';
|
|
7
|
+
list: HTMLElement;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'lift';
|
|
10
|
+
list: HTMLElement;
|
|
11
|
+
owner: HTMLLIElement;
|
|
12
|
+
following: ChildNode[];
|
|
13
|
+
laterBranches: HTMLElement[];
|
|
14
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Only the validated cancelable beforeinput path calls this handler. */
|
|
2
|
+
export declare const handlesListForwardDelete: (root: HTMLElement, inputType: string) => boolean;
|
|
3
|
+
/** Join one sibling pair inside the existing editor transaction; barriers are no-ops. */
|
|
4
|
+
export declare const editListForwardDelete: (root: HTMLElement) => boolean;
|
package/dist/lists/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export { inspectWrappedListInput, editWrappedListInput } from './wrapped-input.js';
|
|
2
|
+
export { handlesListForwardDelete, editListForwardDelete } from './forward-delete.js';
|
|
3
|
+
export { inspectListItem, listSelectionReplacement } from './selection-boundaries.js';
|
|
4
|
+
export { prepareListSelectionPaste, replaceListSelection, replaceListSelectionWithFragment, handlesCollapsedListBlockPaste } from './replace-selection.js';
|
|
1
5
|
export declare const selectedBlocks: (root: HTMLElement, range?: Range | undefined, preferItems?: boolean) => HTMLElement[];
|
|
2
6
|
export declare const listState: (root: HTMLElement) => {
|
|
3
7
|
listDepth: number;
|
|
@@ -7,4 +11,4 @@ export declare const listState: (root: HTMLElement) => {
|
|
|
7
11
|
export declare const indentList: (root: HTMLElement, direction: unknown) => void;
|
|
8
12
|
export declare const applyList: (root: HTMLElement, value: unknown) => void;
|
|
9
13
|
export declare const handlesListInput: (root: HTMLElement, inputType: string) => boolean;
|
|
10
|
-
export declare const editListInput: (root: HTMLElement, inputType: string) => void;
|
|
14
|
+
export declare const editListInput: (root: HTMLElement, inputType: string, prepareSplit?: (item: HTMLLIElement) => void) => void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface ListItemBoundary {
|
|
2
|
+
item: HTMLLIElement;
|
|
3
|
+
body: HTMLElement;
|
|
4
|
+
bodies: HTMLElement[];
|
|
5
|
+
ownNodes: ChildNode[];
|
|
6
|
+
nestedLists: HTMLElement[];
|
|
7
|
+
interleaved: boolean;
|
|
8
|
+
ownStart: Range;
|
|
9
|
+
ownEnd: Range;
|
|
10
|
+
ownEmpty: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ListSelectionPlan {
|
|
13
|
+
status: 'eligible';
|
|
14
|
+
range: Range;
|
|
15
|
+
leaves: HTMLLIElement[];
|
|
16
|
+
gaps: ChildNode[];
|
|
17
|
+
first: ListItemBoundary;
|
|
18
|
+
last: ListItemBoundary;
|
|
19
|
+
startBody: HTMLElement;
|
|
20
|
+
endBody: HTMLElement;
|
|
21
|
+
quote?: QuotePasteContext;
|
|
22
|
+
crossing?: QuoteCrossingContext;
|
|
23
|
+
}
|
|
24
|
+
export interface QuoteCrossingContext {
|
|
25
|
+
startRoot: HTMLElement;
|
|
26
|
+
endRoot: HTMLElement;
|
|
27
|
+
startQuoteBody?: HTMLElement;
|
|
28
|
+
endQuoteBody?: HTMLElement;
|
|
29
|
+
range: Range;
|
|
30
|
+
covered: HTMLElement[];
|
|
31
|
+
siblings?: QuoteSiblingContext;
|
|
32
|
+
ordered?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface QuoteSiblingContext {
|
|
35
|
+
container: HTMLLIElement;
|
|
36
|
+
removedItems: HTMLLIElement[];
|
|
37
|
+
following: HTMLElement[];
|
|
38
|
+
branches: HTMLElement[];
|
|
39
|
+
gaps: ChildNode[];
|
|
40
|
+
directStart: boolean;
|
|
41
|
+
directEnd: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface QuotePasteContext {
|
|
44
|
+
container: HTMLElement;
|
|
45
|
+
bodies: HTMLElement[];
|
|
46
|
+
range: Range;
|
|
47
|
+
startBody: HTMLElement;
|
|
48
|
+
endBody: HTMLElement;
|
|
49
|
+
gaps: ChildNode[];
|
|
50
|
+
}
|
|
51
|
+
export interface QuoteBodyPoint {
|
|
52
|
+
body: HTMLElement;
|
|
53
|
+
range: Range;
|
|
54
|
+
}
|
|
55
|
+
export type ListSelectionResult = {
|
|
56
|
+
status: 'unowned';
|
|
57
|
+
} | {
|
|
58
|
+
status: 'blocked';
|
|
59
|
+
reason: string;
|
|
60
|
+
} | ListSelectionPlan;
|
|
61
|
+
export interface ListSelectionOptions {
|
|
62
|
+
includeSameBody: boolean;
|
|
63
|
+
includeCollapsed: boolean;
|
|
64
|
+
preserveQuotes: boolean;
|
|
65
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const inlinePayloadNode: (node: Node) => boolean;
|
|
2
|
+
export declare const formattingWhitespace: (node: Node) => boolean;
|
|
3
|
+
export declare const ordinaryPayloadBody: (node: Node) => node is HTMLElement;
|
|
4
|
+
export declare const quoteBodyBlocks: (quote: HTMLElement) => HTMLElement[] | undefined;
|
|
5
|
+
/** Read-only validation shared by detached payloads and opaque paste sources. */
|
|
6
|
+
export declare const isOrdinaryQuote: (node: Node) => node is HTMLElement;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ListItemBoundary, QuoteCrossingContext } from './internal-types.js';
|
|
2
|
+
/** Read-only inspection of the selected body interval in consecutive inspected items. */
|
|
3
|
+
export declare const quoteCrossingContext: (boundaries: ListItemBoundary[], range: Range, startRoot: HTMLElement, endRoot: HTMLElement, start: Range, end: Range, gaps?: ChildNode[]) => QuoteCrossingContext | undefined;
|
|
4
|
+
/** Payload/source were fully validated before this transaction-owned mutation. */
|
|
5
|
+
export declare const replaceQuoteCrossing: (context: QuoteCrossingContext, roots: HTMLElement[]) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { QuoteBodyPoint, QuotePasteContext } from './internal-types.js';
|
|
2
|
+
/** A source quote being edited has stricter content than an opaque neighbor. */
|
|
3
|
+
export declare const quoteSourceBodies: (quote: HTMLElement) => HTMLElement[] | undefined;
|
|
4
|
+
/** Only a quote owned directly by this item can form the bounded inner scope. */
|
|
5
|
+
export declare const directQuoteAt: (item: HTMLElement, node: Node) => HTMLElement | undefined;
|
|
6
|
+
/** Resolve one actual quote endpoint using the same child/gap affinity as inner paste. */
|
|
7
|
+
export declare const quoteEndpointPoint: (quote: HTMLElement, range: Range, end: boolean) => QuoteBodyPoint | undefined;
|
|
8
|
+
/** Inspect without normalizing the actual quote or changing the active selection. */
|
|
9
|
+
export declare const quotePasteContext: (quote: HTMLElement, range: Range) => QuotePasteContext | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The transaction owner clears old caret formats only for this validated path. */
|
|
2
|
+
export declare const handlesCollapsedListBlockPaste: (root: HTMLElement, fragment: DocumentFragment, range?: Range | undefined) => boolean;
|
|
3
|
+
/** Detached import preflight: an empty sanitized fragment stays a no-op for any source. */
|
|
4
|
+
export declare const prepareListSelectionPaste: (root: HTMLElement, fragment: DocumentFragment, range?: Range) => void;
|
|
5
|
+
/** Called only inside the editor transaction after native ownership was chosen. */
|
|
6
|
+
export declare const replaceListSelection: (root: HTMLElement, text: string) => boolean;
|
|
7
|
+
/** Recheck the live range; trusted focus callbacks may have changed ownership. */
|
|
8
|
+
export declare const replaceListSelectionWithFragment: (root: HTMLElement, fragment: DocumentFragment) => boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ListItemBoundary, ListSelectionResult } from './internal-types.js';
|
|
2
|
+
/** Native/boundary callers deliberately keep the ordinary inline/p/h profile. */
|
|
3
|
+
export declare const inspectListItem: (root: HTMLElement, item: HTMLElement) => ListItemBoundary | undefined;
|
|
4
|
+
/** Resolve an inline body or an unambiguous edge between direct body blocks. */
|
|
5
|
+
export declare const listBodyAt: (range: Range, boundary: ListItemBoundary, end: boolean) => HTMLElement | undefined;
|
|
6
|
+
/** Translate only unambiguous item-level edges; never mutate the active Range. */
|
|
7
|
+
export declare const normalizeListBodyRange: (range: Range, boundary: ListItemBoundary, end: boolean) => Range | undefined;
|
|
8
|
+
/** Existing callers keep their earlier native and ordinary insertion ownership. */
|
|
9
|
+
export declare const listSelectionReplacement: (root: HTMLElement, range?: Range | undefined, includeSameBody?: boolean, includeCollapsed?: boolean) => ListSelectionResult;
|
|
10
|
+
/** Only block payload candidates may preserve opaque quotes beside their range. */
|
|
11
|
+
export declare const listPasteSelection: (root: HTMLElement, range?: Range | undefined, blockCandidate?: boolean) => ListSelectionResult;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WrappedListInputStatus } from './wrapped-input.types.js';
|
|
2
|
+
/** Own only p/heading-shaped items; ordinary inline-list input stays unchanged. */
|
|
3
|
+
export declare const inspectWrappedListInput: (root: HTMLElement, inputType: string) => WrappedListInputStatus;
|
|
4
|
+
/** Called only by the guarded cancelable-beforeinput transaction owner. */
|
|
5
|
+
export declare const editWrappedListInput: (root: HTMLElement, inputType: string, prepareSplit?: (item: HTMLLIElement) => void) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type WrappedListInputStatus = 'unowned' | 'legacy' | 'blocked' | 'eligible';
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { DocumentSchema,
|
|
2
|
-
export type { DocumentSchema, SchemaAttributeSpec, SchemaNodeSpec } from './types.js';
|
|
3
|
-
export declare const createDocumentSchema: (nodes?: readonly
|
|
1
|
+
import type { DocumentSchema, SchemaContribution } from './types.js';
|
|
2
|
+
export type { DocumentSchema, SchemaAttributeSpec, SchemaNodeSpec, SchemaAttributesSpec, SchemaContribution } from './types.js';
|
|
3
|
+
export declare const createDocumentSchema: (nodes?: readonly SchemaContribution[]) => DocumentSchema;
|
package/dist/schema/types.d.ts
CHANGED
|
@@ -22,11 +22,25 @@ export interface SchemaNodeSpec {
|
|
|
22
22
|
readonly tag: DocumentTag;
|
|
23
23
|
readonly attributes?: Readonly<Record<string, SchemaAttributeSpec>>;
|
|
24
24
|
}
|
|
25
|
+
type OptionalSchemaAttributeSpec = SchemaAttributeSpec & {
|
|
26
|
+
readonly required?: false;
|
|
27
|
+
};
|
|
28
|
+
export interface SchemaAttributesSpec {
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly kind: 'attributes';
|
|
31
|
+
readonly tag: DocumentTag;
|
|
32
|
+
readonly attributes: Readonly<Record<string, OptionalSchemaAttributeSpec>>;
|
|
33
|
+
readonly split?: Readonly<Record<string, string>>;
|
|
34
|
+
}
|
|
35
|
+
export type SchemaContribution = SchemaNodeSpec | SchemaAttributesSpec;
|
|
25
36
|
/** A compiled immutable schema with safe HTML/JSON import and rendering boundaries. */
|
|
26
37
|
export interface DocumentSchema {
|
|
38
|
+
/** Reset patches for present registered attributes on an owned LI split. */
|
|
39
|
+
readonly attributesForSplit: (tag: DocumentTag, attributes: Readonly<Record<string, string>>) => Record<string, string>;
|
|
27
40
|
readonly parseHTML: (html: string) => EditorDocument;
|
|
28
41
|
readonly validateDocument: (input: unknown) => EditorDocument;
|
|
29
42
|
readonly renderDocument: (value: EditorDocument) => DocumentFragment;
|
|
30
43
|
readonly documentHTML: (value: EditorDocument) => string;
|
|
31
44
|
readonly sanitizeHTML: (html: string) => string;
|
|
32
45
|
}
|
|
46
|
+
export {};
|
|
@@ -2,6 +2,8 @@ import type { TextSelection, SelectionBookmark } from './types.js';
|
|
|
2
2
|
export type { TextSelection, SelectionBookmark } from './types.js';
|
|
3
3
|
export declare const activeRange: (root: HTMLElement) => Range | undefined;
|
|
4
4
|
export declare const bookmark: (root: HTMLElement) => SelectionBookmark | undefined;
|
|
5
|
+
/** Resolve a remembered selection without changing focus or the document selection. */
|
|
6
|
+
export declare const rangeFromBookmark: (root: HTMLElement, saved: SelectionBookmark | undefined) => Range | undefined;
|
|
5
7
|
export declare const restoreBookmark: (root: HTMLElement, saved: SelectionBookmark | undefined) => void;
|
|
6
8
|
export declare const readTextSelection: (root: HTMLElement) => TextSelection | undefined;
|
|
7
9
|
export declare const selectText: (root: HTMLElement, index: number, length?: number) => void;
|