@danxbot/ui 7.7.1 → 7.7.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/index.js +3503 -3501
- package/dist/index.js.map +1 -1
- package/dist/types/lib/markdown/commands.d.ts +8 -0
- package/dist/types/lib/markdown/images.d.ts +53 -0
- package/package.json +1 -1
|
@@ -87,6 +87,14 @@ export declare function insertLink(href?: string, title?: string): Command;
|
|
|
87
87
|
* to do nothing at all. Choosing a picture is the editor's job (its file
|
|
88
88
|
* picker), so a command is only ever asked to write one that exists. The caret
|
|
89
89
|
* lands after the image, where the next keystroke belongs.
|
|
90
|
+
*
|
|
91
|
+
* NEVER LANDS INSIDE CODE (DX-3140). This is public API (`src/index.ts`), a
|
|
92
|
+
* separate path from `ImagePipeline.insert` that a consumer can call directly
|
|
93
|
+
* against a selection with no idea what it currently contains — so it is
|
|
94
|
+
* exactly as able to write a dead `` into a fence or a span as a paste
|
|
95
|
+
* ever was. `enclosingCode` + `reshapeForCodeBoundary` (`images.ts`) are the
|
|
96
|
+
* SAME functions the pipeline uses for the same reason there, redirecting
|
|
97
|
+
* the insertion to land just past the code instead of inside it.
|
|
90
98
|
*/
|
|
91
99
|
export declare function insertImage(src: string, alt?: string): Command;
|
|
92
100
|
export interface TableSpan {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Projection } from "./project";
|
|
1
2
|
/** An image whose picture exists only in this page's memory. */
|
|
2
3
|
export interface UnstoredImage {
|
|
3
4
|
/** The `blob:` URL exactly as the source spells it. */
|
|
@@ -66,3 +67,55 @@ export interface Substitution {
|
|
|
66
67
|
* INSIDE a replaced URL lands at the end of its replacement.
|
|
67
68
|
*/
|
|
68
69
|
export declare function substituteAll(source: string, from: string, to: string): Substitution | null;
|
|
70
|
+
/** The innermost code construct containing an offset — see `enclosingCode`. */
|
|
71
|
+
export interface CodeConstruct {
|
|
72
|
+
end: number;
|
|
73
|
+
block: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The innermost code construct — fenced block, indented block, or inline span
|
|
77
|
+
* — containing `offset`, or null when `offset` sits in ordinary prose.
|
|
78
|
+
*
|
|
79
|
+
* DX-3140: read from the PROJECTION, the same source `marksAt`/`constructAt`
|
|
80
|
+
* in `convert.ts` use, rather than re-deriving fence syntax with a second
|
|
81
|
+
* regex — `blockAt`'s own `fenceAround` regex only ever recognises a FENCED
|
|
82
|
+
* block, so it would miss an indented one entirely, and every code kind here
|
|
83
|
+
* (fenced, indented, span) shares exactly one frame shape either way: the
|
|
84
|
+
* parser has already decided the boundary in every case a hand-rolled pattern
|
|
85
|
+
* gets wrong. Boundaries are inclusive on both ends, matching `marksAt` — a
|
|
86
|
+
* caret at either edge still reads as inside. When several code frames
|
|
87
|
+
* contain `offset` (a nested case the grammar does not produce today), the
|
|
88
|
+
* outermost one wins, so the image lands past all of them, not between two.
|
|
89
|
+
*
|
|
90
|
+
* SHARED, not private to the image pipeline: `insertImage` below is public
|
|
91
|
+
* API (`src/index.ts`), so a consumer calling it directly with a selection
|
|
92
|
+
* inside a code construct is exactly as able to write dead `` text into
|
|
93
|
+
* code as a paste ever was — the ONE check has to live somewhere both paths
|
|
94
|
+
* reach, not be re-derived per caller.
|
|
95
|
+
*/
|
|
96
|
+
export declare function enclosingCode(projection: Projection, offset: number): CodeConstruct | null;
|
|
97
|
+
/**
|
|
98
|
+
* The text to actually write at `at` when it sits at the boundary of a code
|
|
99
|
+
* BLOCK (fenced or indented) — reshaped so it lands cleanly outside it.
|
|
100
|
+
*
|
|
101
|
+
* CALLERS MUST PASS THE SAME `at` THEY ACTUALLY SPLICE AT, and nothing else —
|
|
102
|
+
* this was a real bug (DX-3140 code review, round 1): reading the boundary
|
|
103
|
+
* characters from `enclosingCode`'s raw `end` while splicing at a DIFFERENT,
|
|
104
|
+
* caret-map-snapped offset meant the two could disagree, most detectably when
|
|
105
|
+
* `nearestStop` ever moved the insertion point off `end`. There being exactly
|
|
106
|
+
* ONE offset in this function's signature makes that class of drift
|
|
107
|
+
* impossible to reintroduce by construction, rather than by convention.
|
|
108
|
+
*
|
|
109
|
+
* A BLOCK FRAME ALREADY OWNS ITS OWN TRAILING NEWLINE, when one exists (`at`
|
|
110
|
+
* sits at the START of the next line, not at the fence's last backtick) — so
|
|
111
|
+
* blindly prefixing "\n\n" would stack a THIRD newline on top of the one
|
|
112
|
+
* already there, splitting the image from the code by a full extra blank
|
|
113
|
+
* line no author asked for. Reading what is already on each side of `at` and
|
|
114
|
+
* adding only what is missing keeps it to exactly one blank line before the
|
|
115
|
+
* image, and puts it on its own line after, whatever originally followed the
|
|
116
|
+
* block (nothing, a line right away, or an existing blank line of its own).
|
|
117
|
+
*
|
|
118
|
+
* A SPAN NEEDS NO RESHAPING — it just continues the line it was on — so this
|
|
119
|
+
* is only ever called for `enclosingCode(...).block === true`.
|
|
120
|
+
*/
|
|
121
|
+
export declare function reshapeForCodeBoundary(source: string, at: number, text: string): string;
|