@blankdotpage/cake 0.1.0 → 0.1.2
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/cake/clipboard.d.ts +1 -1
- package/dist/cake/core/runtime.d.ts +21 -2
- package/dist/cake/dom/render.d.ts +1 -1
- package/dist/cake/engine/selection/selection-geometry.d.ts +1 -3
- package/dist/cake/extensions/index.d.ts +1 -1
- package/dist/cake/extensions/scrollbar/index.d.ts +2 -2
- package/dist/cake/index.d.ts +1 -0
- package/dist/cake/react/CakeEditor.d.ts +41 -7
- package/dist/index.cjs +11397 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +11382 -77
- package/package.json +8 -4
- package/dist/cake/extensions/overlay-types.d.ts +0 -31
- package/dist/editor.d.ts +0 -83
package/dist/cake/clipboard.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function htmlToMarkdownForPaste(
|
|
1
|
+
export declare function htmlToMarkdownForPaste(htmlContent: string): string | null;
|
|
@@ -2,7 +2,23 @@ import type { Block, Doc, Inline, Selection } from "./types";
|
|
|
2
2
|
import type { ReactElement } from "react";
|
|
3
3
|
import { type CursorSourceMap } from "./mapping/cursor-source-map";
|
|
4
4
|
import type { DomRenderContext } from "../dom/types";
|
|
5
|
-
|
|
5
|
+
export type OverlayExtensionContext = {
|
|
6
|
+
container: HTMLElement;
|
|
7
|
+
insertText: (text: string) => void;
|
|
8
|
+
replaceText: (oldText: string, newText: string) => void;
|
|
9
|
+
getSelection: () => {
|
|
10
|
+
start: number;
|
|
11
|
+
end: number;
|
|
12
|
+
} | null;
|
|
13
|
+
contentRoot?: HTMLElement;
|
|
14
|
+
overlayRoot?: HTMLElement;
|
|
15
|
+
toOverlayRect?: (rect: DOMRectReadOnly) => {
|
|
16
|
+
top: number;
|
|
17
|
+
left: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
6
22
|
type BlockParseResult = {
|
|
7
23
|
block: Block;
|
|
8
24
|
nextPos: number;
|
|
@@ -26,6 +42,8 @@ export type EditCommand = {
|
|
|
26
42
|
text: string;
|
|
27
43
|
} | {
|
|
28
44
|
type: "insert-line-break";
|
|
45
|
+
} | {
|
|
46
|
+
type: "exit-block-wrapper";
|
|
29
47
|
} | {
|
|
30
48
|
type: "delete-backward";
|
|
31
49
|
} | {
|
|
@@ -89,7 +107,7 @@ export type CakeExtension = {
|
|
|
89
107
|
serializeInline?: (inline: Inline, context: ExtensionContext) => SerializeInlineResult | null;
|
|
90
108
|
normalizeBlock?: (block: Block) => Block | null;
|
|
91
109
|
normalizeInline?: (inline: Inline) => Inline | null;
|
|
92
|
-
onEdit?: (command: EditCommand, state: RuntimeState) => EditResult | null;
|
|
110
|
+
onEdit?: (command: EditCommand, state: RuntimeState) => EditResult | EditCommand | null;
|
|
93
111
|
onPasteText?: (text: string, state: RuntimeState) => EditCommand | null;
|
|
94
112
|
keybindings?: KeyBinding[];
|
|
95
113
|
renderInline?: (inline: Inline, context: DomRenderContext) => Node | Node[] | null;
|
|
@@ -115,6 +133,7 @@ export type Runtime = {
|
|
|
115
133
|
kind?: "dom" | "keyboard" | "programmatic";
|
|
116
134
|
}): RuntimeState;
|
|
117
135
|
serializeSelection(state: RuntimeState, selection: Selection): string;
|
|
136
|
+
serializeSelectionToHtml(state: RuntimeState, selection: Selection): string;
|
|
118
137
|
applyEdit(command: EditCommand, state: RuntimeState): RuntimeState;
|
|
119
138
|
};
|
|
120
139
|
export declare function createRuntime(extensions: CakeExtension[]): Runtime;
|
|
@@ -9,6 +9,6 @@ export type RenderContentResult = {
|
|
|
9
9
|
content: Node[];
|
|
10
10
|
map: ReturnType<typeof createDomMap>;
|
|
11
11
|
};
|
|
12
|
-
export declare function renderDocContent(doc: Doc, extensions: CakeExtension[],
|
|
12
|
+
export declare function renderDocContent(doc: Doc, extensions: CakeExtension[], root?: HTMLElement): RenderContentResult;
|
|
13
13
|
export declare function renderDoc(doc: Doc, extensions: CakeExtension[]): RenderResult;
|
|
14
14
|
export declare function mergeInlineForRender(inlines: Inline[]): Inline[];
|
|
@@ -10,13 +10,11 @@ export type SelectionCaretMeasurement = {
|
|
|
10
10
|
lineRect: LayoutRect;
|
|
11
11
|
caretRect: LayoutRect;
|
|
12
12
|
lineLength: number;
|
|
13
|
-
|
|
14
|
-
fontSize: number | null;
|
|
13
|
+
fontSize: number;
|
|
15
14
|
padding: {
|
|
16
15
|
top: number;
|
|
17
16
|
bottom: number;
|
|
18
17
|
};
|
|
19
|
-
nearestTextCaretHeight: number | null;
|
|
20
18
|
};
|
|
21
19
|
export type OffsetToXMeasurer = (lineIndex: number, offsetInLine: number) => number | null;
|
|
22
20
|
export declare function computeSelectionRects(layout: LayoutModel, selection: Selection, measurer?: OffsetToXMeasurer): SelectionRect[];
|
|
@@ -10,4 +10,4 @@ import { listExtension } from "./list/list";
|
|
|
10
10
|
import { scrollbarExtension } from "./scrollbar";
|
|
11
11
|
import { strikethroughExtension } from "./strikethrough/strikethrough";
|
|
12
12
|
export { boldExtension, combinedEmphasisExtension, linkExtension, pipeLinkExtension, blockquoteExtension, italicExtension, headingExtension, imageExtension, listExtension, scrollbarExtension, strikethroughExtension, };
|
|
13
|
-
export declare const bundledExtensions: import("
|
|
13
|
+
export declare const bundledExtensions: import("../..").CakeExtension[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const scrollbarExtension:
|
|
1
|
+
import type { CakeExtension } from "../../core/runtime";
|
|
2
|
+
export declare const scrollbarExtension: CakeExtension;
|
package/dist/cake/index.d.ts
CHANGED
|
@@ -1,8 +1,42 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export type
|
|
4
|
-
|
|
1
|
+
import type { StateCommand } from "@codemirror/state";
|
|
2
|
+
import type { CakeExtension } from "../core/runtime";
|
|
3
|
+
export type CakeEditorSelection = {
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
affinity?: "backward" | "forward";
|
|
5
7
|
};
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
export interface CakeEditorUpdate {
|
|
9
|
+
value?: string;
|
|
10
|
+
selection?: CakeEditorSelection;
|
|
11
|
+
focus?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface CakeEditorProps {
|
|
14
|
+
value: string;
|
|
15
|
+
onChange: (value: string) => void;
|
|
16
|
+
selection?: CakeEditorSelection;
|
|
17
|
+
onSelectionChange?: (start: number, end: number, affinity?: "backward" | "forward") => void;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
spellCheck?: boolean;
|
|
21
|
+
className?: string;
|
|
22
|
+
style?: React.CSSProperties;
|
|
23
|
+
extensions?: CakeExtension[];
|
|
24
|
+
onBlur?: (event?: FocusEvent) => void;
|
|
25
|
+
}
|
|
26
|
+
export interface CakeEditorRef {
|
|
27
|
+
element: HTMLElement | null;
|
|
28
|
+
focus: (selection?: CakeEditorSelection) => void;
|
|
29
|
+
blur: () => void;
|
|
30
|
+
hasFocus: () => boolean;
|
|
31
|
+
selectAll: () => void;
|
|
32
|
+
executeCommand: (command: StateCommand) => boolean;
|
|
33
|
+
applyUpdate: (update: CakeEditorUpdate) => void;
|
|
34
|
+
getValue: () => string;
|
|
35
|
+
getSelection: () => {
|
|
36
|
+
start: number;
|
|
37
|
+
end: number;
|
|
38
|
+
} | null;
|
|
39
|
+
insertText: (text: string) => void;
|
|
40
|
+
replaceText: (oldText: string, newText: string) => void;
|
|
41
|
+
}
|
|
42
|
+
export declare const CakeEditor: import("react").ForwardRefExoticComponent<CakeEditorProps & import("react").RefAttributes<CakeEditorRef | null>>;
|