@codemerge/kernel 2.4.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/LICENSE +21 -0
- package/dist/commands.d.cts +25 -0
- package/dist/commands.d.ts +25 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/document.d.cts +24 -0
- package/dist/document.d.ts +24 -0
- package/dist/document.d.ts.map +1 -0
- package/dist/history.d.cts +24 -0
- package/dist/history.d.ts +24 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/index.cjs +2034 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +1968 -0
- package/dist/index.mjs.map +1 -0
- package/dist/normalize.d.cts +5 -0
- package/dist/normalize.d.ts +5 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/operations.d.cts +105 -0
- package/dist/operations.d.ts +105 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/schema.d.cts +23 -0
- package/dist/schema.d.ts +23 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/selection.d.cts +14 -0
- package/dist/selection.d.ts +14 -0
- package/dist/selection.d.ts.map +1 -0
- package/dist/structure.d.cts +29 -0
- package/dist/structure.d.ts +29 -0
- package/dist/structure.d.ts.map +1 -0
- package/dist/transaction.d.cts +18 -0
- package/dist/transaction.d.ts +18 -0
- package/dist/transaction.d.ts.map +1 -0
- package/dist/transform.d.cts +15 -0
- package/dist/transform.d.ts +15 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/types.d.cts +27 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { EditorState } from './transaction';
|
|
2
|
+
import { Operation } from './operations';
|
|
3
|
+
import { DocNode, Mark, Selection } from './types';
|
|
4
|
+
export type Command = (state: EditorState) => Operation[] | null;
|
|
5
|
+
/**
|
|
6
|
+
* Ops to delete the current selection — same-path text or cross-block (siblings / root span).
|
|
7
|
+
* Keeps selectAll → deleteBackward/insertText working.
|
|
8
|
+
*/
|
|
9
|
+
export declare function deleteSelectionRangeOps(doc: DocNode, sel: Selection): Operation[] | null;
|
|
10
|
+
export declare function insertText(text: string, marks?: Mark[]): Command;
|
|
11
|
+
/**
|
|
12
|
+
* Track-changes style backspace: mark the previous char as deleted instead of
|
|
13
|
+
* removing it. Hard-deletes own `insertion` marks and already-marked deletions.
|
|
14
|
+
*/
|
|
15
|
+
export declare function softDeleteBackward(deletionMark: Mark): Command;
|
|
16
|
+
export declare const deleteBackward: Command;
|
|
17
|
+
/** Delete one character forward of the caret (range → delete selection, incl. cross-block). */
|
|
18
|
+
export declare const deleteForward: Command;
|
|
19
|
+
export declare const splitBlock: Command;
|
|
20
|
+
export declare function toggleMark(markType: string): Command;
|
|
21
|
+
/** Whether the current selection (or caret) carries `markType`. */
|
|
22
|
+
export declare function selectionHasMark(markType: string): (state: EditorState) => boolean;
|
|
23
|
+
export declare const selectAll: Command;
|
|
24
|
+
export declare function runCommand(state: EditorState, command: Command): import('./transaction').Transaction | null;
|
|
25
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { EditorState } from './transaction';
|
|
2
|
+
import { Operation } from './operations';
|
|
3
|
+
import { DocNode, Mark, Selection } from './types';
|
|
4
|
+
export type Command = (state: EditorState) => Operation[] | null;
|
|
5
|
+
/**
|
|
6
|
+
* Ops to delete the current selection — same-path text or cross-block (siblings / root span).
|
|
7
|
+
* Keeps selectAll → deleteBackward/insertText working.
|
|
8
|
+
*/
|
|
9
|
+
export declare function deleteSelectionRangeOps(doc: DocNode, sel: Selection): Operation[] | null;
|
|
10
|
+
export declare function insertText(text: string, marks?: Mark[]): Command;
|
|
11
|
+
/**
|
|
12
|
+
* Track-changes style backspace: mark the previous char as deleted instead of
|
|
13
|
+
* removing it. Hard-deletes own `insertion` marks and already-marked deletions.
|
|
14
|
+
*/
|
|
15
|
+
export declare function softDeleteBackward(deletionMark: Mark): Command;
|
|
16
|
+
export declare const deleteBackward: Command;
|
|
17
|
+
/** Delete one character forward of the caret (range → delete selection, incl. cross-block). */
|
|
18
|
+
export declare const deleteForward: Command;
|
|
19
|
+
export declare const splitBlock: Command;
|
|
20
|
+
export declare function toggleMark(markType: string): Command;
|
|
21
|
+
/** Whether the current selection (or caret) carries `markType`. */
|
|
22
|
+
export declare function selectionHasMark(markType: string): (state: EditorState) => boolean;
|
|
23
|
+
export declare const selectAll: Command;
|
|
24
|
+
export declare function runCommand(state: EditorState, command: Command): import('./transaction').Transaction | null;
|
|
25
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAI9C,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAS,SAAS,EAAE,MAAM,SAAS,CAAC;AAU/D,MAAM,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,SAAS,EAAE,GAAG,IAAI,CAAC;AAyBjE;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,GAAG,SAAS,EAAE,GAAG,IAAI,CA2BxF;AA2ND,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,CAoChE;AAMD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,IAAI,GAAG,OAAO,CA0B9D;AAmED,eAAO,MAAM,cAAc,EAAE,OAoH5B,CAAC;AAEF,+FAA+F;AAC/F,eAAO,MAAM,aAAa,EAAE,OAoB3B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,OA4DxB,CAAC;AAEF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CA6BpD;AAED,mEAAmE;AACnE,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAalF;AAED,eAAO,MAAM,SAAS,EAAE,OAqBvB,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,8CAM9D"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DocNode, JSONDoc, Mark } from './types';
|
|
2
|
+
export declare function resetIdCounter(n?: number): void;
|
|
3
|
+
export declare function nextId(prefix?: string): string;
|
|
4
|
+
export declare function createText(text: string, marks?: Mark[]): DocNode;
|
|
5
|
+
export declare function createParagraph(content?: DocNode[], attrs?: Record<string, unknown>): DocNode;
|
|
6
|
+
export declare function createDoc(content?: DocNode[]): DocNode;
|
|
7
|
+
/** Null-prototype attrs bag (no __proto__ pollution). */
|
|
8
|
+
export declare function emptyAttrsRecord(): Record<string, unknown>;
|
|
9
|
+
/** Copy own enumerable attrs onto a null-prototype bag (no __proto__ pollution). */
|
|
10
|
+
export declare function copyAttrs(src?: Record<string, unknown> | null): Record<string, unknown> | undefined;
|
|
11
|
+
/** Shallow clone node; children array is new, child refs shared (structural sharing). */
|
|
12
|
+
export declare function cloneNode(node: DocNode): DocNode;
|
|
13
|
+
/** Deep clone node tree (content recursively cloned). */
|
|
14
|
+
export declare function deepCloneNode(node: DocNode): DocNode;
|
|
15
|
+
/** Assign stable ids to every non-text node missing `id`. */
|
|
16
|
+
export declare function ensureNodeIds(node: DocNode): DocNode;
|
|
17
|
+
/** Document JSON format version — bump when the on-disk shape changes. */
|
|
18
|
+
export declare const JSON_DOC_VERSION = 1;
|
|
19
|
+
export declare function docToJSON(doc: DocNode): JSONDoc;
|
|
20
|
+
export declare function docFromJSON(json: JSONDoc | DocNode | object): DocNode;
|
|
21
|
+
export declare function getNodeAt(doc: DocNode, path: number[]): DocNode;
|
|
22
|
+
export declare function replaceAt(doc: DocNode, path: number[], next: DocNode): DocNode;
|
|
23
|
+
export declare function textLength(node: DocNode): number;
|
|
24
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DocNode, JSONDoc, Mark } from './types';
|
|
2
|
+
export declare function resetIdCounter(n?: number): void;
|
|
3
|
+
export declare function nextId(prefix?: string): string;
|
|
4
|
+
export declare function createText(text: string, marks?: Mark[]): DocNode;
|
|
5
|
+
export declare function createParagraph(content?: DocNode[], attrs?: Record<string, unknown>): DocNode;
|
|
6
|
+
export declare function createDoc(content?: DocNode[]): DocNode;
|
|
7
|
+
/** Null-prototype attrs bag (no __proto__ pollution). */
|
|
8
|
+
export declare function emptyAttrsRecord(): Record<string, unknown>;
|
|
9
|
+
/** Copy own enumerable attrs onto a null-prototype bag (no __proto__ pollution). */
|
|
10
|
+
export declare function copyAttrs(src?: Record<string, unknown> | null): Record<string, unknown> | undefined;
|
|
11
|
+
/** Shallow clone node; children array is new, child refs shared (structural sharing). */
|
|
12
|
+
export declare function cloneNode(node: DocNode): DocNode;
|
|
13
|
+
/** Deep clone node tree (content recursively cloned). */
|
|
14
|
+
export declare function deepCloneNode(node: DocNode): DocNode;
|
|
15
|
+
/** Assign stable ids to every non-text node missing `id`. */
|
|
16
|
+
export declare function ensureNodeIds(node: DocNode): DocNode;
|
|
17
|
+
/** Document JSON format version — bump when the on-disk shape changes. */
|
|
18
|
+
export declare const JSON_DOC_VERSION = 1;
|
|
19
|
+
export declare function docToJSON(doc: DocNode): JSONDoc;
|
|
20
|
+
export declare function docFromJSON(json: JSONDoc | DocNode | object): DocNode;
|
|
21
|
+
export declare function getNodeAt(doc: DocNode, path: number[]): DocNode;
|
|
22
|
+
export declare function replaceAt(doc: DocNode, path: number[], next: DocNode): DocNode;
|
|
23
|
+
export declare function textLength(node: DocNode): number;
|
|
24
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAItD,wBAAgB,cAAc,CAAC,CAAC,SAAI,GAAG,IAAI,CAE1C;AAED,wBAAgB,MAAM,CAAC,MAAM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,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAQhD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EditorState, Transaction } from './transaction';
|
|
2
|
+
import { Schema } from './schema';
|
|
3
|
+
export interface HistoryOptions {
|
|
4
|
+
maxDepth?: number;
|
|
5
|
+
/** Merge window in ms for consecutive typing */
|
|
6
|
+
mergeWindowMs?: number;
|
|
7
|
+
/** Cap merged typing entry size (insert+delete char counts); stop merging when exceeded. */
|
|
8
|
+
maxEntryChars?: number;
|
|
9
|
+
/** When set, applyTransaction validates ops against this schema. */
|
|
10
|
+
schema?: Schema;
|
|
11
|
+
}
|
|
12
|
+
export interface HistoryController {
|
|
13
|
+
apply: (state: EditorState, tr: Transaction, now?: number) => EditorState;
|
|
14
|
+
undo: (state: EditorState) => EditorState;
|
|
15
|
+
redo: (state: EditorState) => EditorState;
|
|
16
|
+
canUndo: () => boolean;
|
|
17
|
+
canRedo: () => boolean;
|
|
18
|
+
depth: () => number;
|
|
19
|
+
/** Drop stacks after out-of-band full-document replace (setJSON / replaceDocument). */
|
|
20
|
+
clear: () => void;
|
|
21
|
+
}
|
|
22
|
+
export declare function createHistory(options?: HistoryOptions): HistoryController;
|
|
23
|
+
export declare function emptyState(): EditorState;
|
|
24
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EditorState, Transaction } from './transaction';
|
|
2
|
+
import { Schema } from './schema';
|
|
3
|
+
export interface HistoryOptions {
|
|
4
|
+
maxDepth?: number;
|
|
5
|
+
/** Merge window in ms for consecutive typing */
|
|
6
|
+
mergeWindowMs?: number;
|
|
7
|
+
/** Cap merged typing entry size (insert+delete char counts); stop merging when exceeded. */
|
|
8
|
+
maxEntryChars?: number;
|
|
9
|
+
/** When set, applyTransaction validates ops against this schema. */
|
|
10
|
+
schema?: Schema;
|
|
11
|
+
}
|
|
12
|
+
export interface HistoryController {
|
|
13
|
+
apply: (state: EditorState, tr: Transaction, now?: number) => EditorState;
|
|
14
|
+
undo: (state: EditorState) => EditorState;
|
|
15
|
+
redo: (state: EditorState) => EditorState;
|
|
16
|
+
canUndo: () => boolean;
|
|
17
|
+
canRedo: () => boolean;
|
|
18
|
+
depth: () => number;
|
|
19
|
+
/** Drop stacks after out-of-band full-document replace (setJSON / replaceDocument). */
|
|
20
|
+
clear: () => void;
|
|
21
|
+
}
|
|
22
|
+
export declare function createHistory(options?: HistoryOptions): HistoryController;
|
|
23
|
+
export declare function emptyState(): EditorState;
|
|
24
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4FAA4F;IAC5F,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,WAAW,CAAC;IAC1E,IAAI,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,WAAW,CAAC;IAC1C,IAAI,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,WAAW,CAAC;IAC1C,OAAO,EAAE,MAAM,OAAO,CAAC;IACvB,OAAO,EAAE,MAAM,OAAO,CAAC;IACvB,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,uFAAuF;IACvF,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAWD,wBAAgB,aAAa,CAAC,OAAO,GAAE,cAAmB,GAAG,iBAAiB,CA8E7E;AAkBD,wBAAgB,UAAU,IAAI,WAAW,CAExC"}
|