@vectojs/markdown 0.9.0 → 0.10.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/Markdown.d.ts +2 -2
- package/dist/index.js +19 -10
- package/dist/index.mjs +20 -10
- package/package.json +1 -1
package/dist/Markdown.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Entity, type DevtoolsDescriptor, GlyphRasterAtlas, type GlyphRasterAtlasStats, IRenderer, type ContentProjection } from '@vectojs/core';
|
|
1
|
+
import { type ContentProjectionHint, Entity, type DevtoolsDescriptor, GlyphRasterAtlas, type GlyphRasterAtlasStats, IRenderer, type ContentProjection } from '@vectojs/core';
|
|
2
2
|
import { type Token } from 'marked';
|
|
3
3
|
import { type StreamController, type StreamControllerOptions } from './StreamController';
|
|
4
4
|
import { Stack, UIComponent } from '@vectojs/ui';
|
|
@@ -69,7 +69,7 @@ export declare class CodeBlock extends UIComponent {
|
|
|
69
69
|
* @returns `this` for chaining.
|
|
70
70
|
*/
|
|
71
71
|
setWidth(width: number): this;
|
|
72
|
-
getContentProjection(): ContentProjection | null;
|
|
72
|
+
getContentProjection(hint?: ContentProjectionHint): ContentProjection | null;
|
|
73
73
|
/**
|
|
74
74
|
* Re-highlight the code, reusing the highlight of any unchanged line prefix.
|
|
75
75
|
*
|
package/dist/index.js
CHANGED
|
@@ -1177,9 +1177,25 @@ var CodeBlock = class extends import_ui.UIComponent {
|
|
|
1177
1177
|
this.scene?.markDirty();
|
|
1178
1178
|
return this;
|
|
1179
1179
|
}
|
|
1180
|
-
getContentProjection() {
|
|
1180
|
+
getContentProjection(hint) {
|
|
1181
1181
|
if (!this.source) return null;
|
|
1182
1182
|
const grid = this.ensureGrid();
|
|
1183
|
+
const rows = [];
|
|
1184
|
+
rows.length = grid.lines.length;
|
|
1185
|
+
for (let row = 0; row < grid.lines.length; row++) {
|
|
1186
|
+
const line = grid.lines[row];
|
|
1187
|
+
const y = this.pad + row * this.lineH;
|
|
1188
|
+
if (!(0, import_core.contentLineInHint)(hint, y, this.lineH)) continue;
|
|
1189
|
+
rows[row] = {
|
|
1190
|
+
text: this.source.slice(line.sourceStart, line.sourceEnd),
|
|
1191
|
+
separatorAfter: this.source.slice(line.sourceEnd, line.nextSourceStart) || void 0,
|
|
1192
|
+
x: this.pad,
|
|
1193
|
+
y,
|
|
1194
|
+
baseline: this.lineH * 0.75,
|
|
1195
|
+
font: this.codeFont,
|
|
1196
|
+
lineHeight: this.lineH
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1183
1199
|
return {
|
|
1184
1200
|
text: this.source,
|
|
1185
1201
|
font: this.codeFont,
|
|
@@ -1187,15 +1203,8 @@ var CodeBlock = class extends import_ui.UIComponent {
|
|
|
1187
1203
|
// Every row is absolutely positioned from the same local coordinates as
|
|
1188
1204
|
// render(). A single pre-wrap DOM text node would introduce browser
|
|
1189
1205
|
// wrapping for long source lines that canvas intentionally keeps intact.
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
separatorAfter: this.source.slice(line.sourceEnd, line.nextSourceStart) || void 0,
|
|
1193
|
-
x: this.pad,
|
|
1194
|
-
y: this.pad + row * this.lineH,
|
|
1195
|
-
baseline: this.lineH * 0.75,
|
|
1196
|
-
font: this.codeFont,
|
|
1197
|
-
lineHeight: this.lineH
|
|
1198
|
-
})),
|
|
1206
|
+
//
|
|
1207
|
+
lines: rows,
|
|
1199
1208
|
selectable: this.selectable,
|
|
1200
1209
|
// render() draws cell-by-cell (no ligatures can form); the DOM copy
|
|
1201
1210
|
// must not ligate either or Firefox selection geometry drifts.
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/Markdown.ts
|
|
2
2
|
import {
|
|
3
|
+
contentLineInHint,
|
|
3
4
|
BidiResolver,
|
|
4
5
|
Entity,
|
|
5
6
|
GlyphRasterAtlas,
|
|
@@ -1144,9 +1145,25 @@ var CodeBlock = class extends UIComponent {
|
|
|
1144
1145
|
this.scene?.markDirty();
|
|
1145
1146
|
return this;
|
|
1146
1147
|
}
|
|
1147
|
-
getContentProjection() {
|
|
1148
|
+
getContentProjection(hint) {
|
|
1148
1149
|
if (!this.source) return null;
|
|
1149
1150
|
const grid = this.ensureGrid();
|
|
1151
|
+
const rows = [];
|
|
1152
|
+
rows.length = grid.lines.length;
|
|
1153
|
+
for (let row = 0; row < grid.lines.length; row++) {
|
|
1154
|
+
const line = grid.lines[row];
|
|
1155
|
+
const y = this.pad + row * this.lineH;
|
|
1156
|
+
if (!contentLineInHint(hint, y, this.lineH)) continue;
|
|
1157
|
+
rows[row] = {
|
|
1158
|
+
text: this.source.slice(line.sourceStart, line.sourceEnd),
|
|
1159
|
+
separatorAfter: this.source.slice(line.sourceEnd, line.nextSourceStart) || void 0,
|
|
1160
|
+
x: this.pad,
|
|
1161
|
+
y,
|
|
1162
|
+
baseline: this.lineH * 0.75,
|
|
1163
|
+
font: this.codeFont,
|
|
1164
|
+
lineHeight: this.lineH
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1150
1167
|
return {
|
|
1151
1168
|
text: this.source,
|
|
1152
1169
|
font: this.codeFont,
|
|
@@ -1154,15 +1171,8 @@ var CodeBlock = class extends UIComponent {
|
|
|
1154
1171
|
// Every row is absolutely positioned from the same local coordinates as
|
|
1155
1172
|
// render(). A single pre-wrap DOM text node would introduce browser
|
|
1156
1173
|
// wrapping for long source lines that canvas intentionally keeps intact.
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
separatorAfter: this.source.slice(line.sourceEnd, line.nextSourceStart) || void 0,
|
|
1160
|
-
x: this.pad,
|
|
1161
|
-
y: this.pad + row * this.lineH,
|
|
1162
|
-
baseline: this.lineH * 0.75,
|
|
1163
|
-
font: this.codeFont,
|
|
1164
|
-
lineHeight: this.lineH
|
|
1165
|
-
})),
|
|
1174
|
+
//
|
|
1175
|
+
lines: rows,
|
|
1166
1176
|
selectable: this.selectable,
|
|
1167
1177
|
// render() draws cell-by-cell (no ligatures can form); the DOM copy
|
|
1168
1178
|
// must not ligate either or Firefox selection geometry drifts.
|