@incremark/vue 0.2.5 → 0.2.7
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/components/Incremark.vue.d.ts +24 -4
- package/dist/components/IncremarkCode.vue.d.ts +7 -0
- package/dist/components/IncremarkContent.vue.d.ts +3 -0
- package/dist/components/IncremarkRenderer.vue.d.ts +3 -0
- package/dist/components/index.d.ts +3 -1
- package/dist/composables/useIncremark.d.ts +3 -3
- package/dist/composables/useShiki.d.ts +62 -0
- package/dist/composables/useStreamRenderer.d.ts +7 -11
- package/dist/composables/useTypewriter.d.ts +3 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.js +463 -304
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +25 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/composables/useIncremark.ts
|
|
2
|
-
import { ref as ref3, shallowRef as shallowRef2, computed as computed2, markRaw } from "vue";
|
|
2
|
+
import { ref as ref3, shallowRef as shallowRef2, computed as computed2, markRaw, watch as watch2, toValue as toValue2 } from "vue";
|
|
3
3
|
import {
|
|
4
4
|
createIncremarkParser
|
|
5
5
|
} from "@incremark/core";
|
|
@@ -51,7 +51,7 @@ function useProvideDefinations() {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// src/composables/useTypewriter.ts
|
|
54
|
-
import { ref as ref2, shallowRef, computed, watch, onUnmounted } from "vue";
|
|
54
|
+
import { ref as ref2, shallowRef, computed, watch, toValue, onUnmounted } from "vue";
|
|
55
55
|
import {
|
|
56
56
|
createBlockTransformer,
|
|
57
57
|
defaultPlugins
|
|
@@ -86,23 +86,23 @@ function addCursorToNode(node, cursor) {
|
|
|
86
86
|
|
|
87
87
|
// src/composables/useTypewriter.ts
|
|
88
88
|
function useTypewriter(options) {
|
|
89
|
-
const { typewriter:
|
|
90
|
-
const
|
|
89
|
+
const { typewriter: typewriterInput, completedBlocks, pendingBlocks } = options;
|
|
90
|
+
const initialConfig = toValue(typewriterInput);
|
|
91
|
+
const typewriterEnabled = ref2(initialConfig?.enabled ?? !!initialConfig);
|
|
91
92
|
const displayBlocksRef = shallowRef([]);
|
|
92
93
|
const isTypewriterProcessing = ref2(false);
|
|
93
94
|
const isTypewriterPaused = ref2(false);
|
|
94
|
-
const typewriterEffect = ref2(
|
|
95
|
-
const typewriterCursor = ref2(
|
|
95
|
+
const typewriterEffect = ref2(initialConfig?.effect ?? "none");
|
|
96
|
+
const typewriterCursor = ref2(initialConfig?.cursor ?? "|");
|
|
96
97
|
const isAnimationComplete = ref2(true);
|
|
97
98
|
let transformer = null;
|
|
98
|
-
if (
|
|
99
|
-
const twOptions = typewriterConfig;
|
|
99
|
+
if (initialConfig) {
|
|
100
100
|
transformer = createBlockTransformer({
|
|
101
|
-
charsPerTick:
|
|
102
|
-
tickInterval:
|
|
103
|
-
effect:
|
|
104
|
-
pauseOnHidden:
|
|
105
|
-
plugins:
|
|
101
|
+
charsPerTick: initialConfig.charsPerTick ?? [1, 3],
|
|
102
|
+
tickInterval: initialConfig.tickInterval ?? 30,
|
|
103
|
+
effect: initialConfig.effect ?? "none",
|
|
104
|
+
pauseOnHidden: initialConfig.pauseOnHidden ?? true,
|
|
105
|
+
plugins: initialConfig.plugins ?? defaultPlugins,
|
|
106
106
|
onChange: (blocks2) => {
|
|
107
107
|
displayBlocksRef.value = blocks2;
|
|
108
108
|
isTypewriterProcessing.value = transformer?.isProcessing() ?? false;
|
|
@@ -116,6 +116,28 @@ function useTypewriter(options) {
|
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
+
watch(
|
|
120
|
+
() => toValue(typewriterInput),
|
|
121
|
+
(newConfig) => {
|
|
122
|
+
if (!newConfig) return;
|
|
123
|
+
if (newConfig.enabled !== void 0) {
|
|
124
|
+
typewriterEnabled.value = newConfig.enabled;
|
|
125
|
+
}
|
|
126
|
+
if (newConfig.effect !== void 0) {
|
|
127
|
+
typewriterEffect.value = newConfig.effect;
|
|
128
|
+
}
|
|
129
|
+
if (newConfig.cursor !== void 0) {
|
|
130
|
+
typewriterCursor.value = newConfig.cursor;
|
|
131
|
+
}
|
|
132
|
+
transformer?.setOptions({
|
|
133
|
+
charsPerTick: newConfig.charsPerTick,
|
|
134
|
+
tickInterval: newConfig.tickInterval,
|
|
135
|
+
effect: newConfig.effect,
|
|
136
|
+
pauseOnHidden: newConfig.pauseOnHidden
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
{ deep: true }
|
|
140
|
+
);
|
|
119
141
|
const sourceBlocks = computed(() => {
|
|
120
142
|
return completedBlocks.value.map((block) => ({
|
|
121
143
|
id: block.id,
|
|
@@ -140,17 +162,7 @@ function useTypewriter(options) {
|
|
|
140
162
|
);
|
|
141
163
|
}
|
|
142
164
|
const rawBlocks = computed(() => {
|
|
143
|
-
|
|
144
|
-
for (const block of completedBlocks.value) {
|
|
145
|
-
result.push({ ...block, stableId: block.id });
|
|
146
|
-
}
|
|
147
|
-
for (let i = 0; i < pendingBlocks.value.length; i++) {
|
|
148
|
-
result.push({
|
|
149
|
-
...pendingBlocks.value[i],
|
|
150
|
-
stableId: `pending-${i}`
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
return result;
|
|
165
|
+
return [...completedBlocks.value, ...pendingBlocks.value];
|
|
154
166
|
});
|
|
155
167
|
const blocks = computed(() => {
|
|
156
168
|
if (!typewriterEnabled.value || !transformer) {
|
|
@@ -165,7 +177,6 @@ function useTypewriter(options) {
|
|
|
165
177
|
}
|
|
166
178
|
return {
|
|
167
179
|
id: db.id,
|
|
168
|
-
stableId: db.id,
|
|
169
180
|
status: db.isDisplayComplete ? "completed" : "pending",
|
|
170
181
|
isLastPending,
|
|
171
182
|
node,
|
|
@@ -224,16 +235,19 @@ function useTypewriter(options) {
|
|
|
224
235
|
}
|
|
225
236
|
|
|
226
237
|
// src/composables/useIncremark.ts
|
|
227
|
-
function useIncremark(
|
|
238
|
+
function useIncremark(optionsInput = {}) {
|
|
228
239
|
const { setDefinations, setFootnoteDefinitions, setFootnoteReferenceOrder } = useProvideDefinations();
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
240
|
+
function createParser(options) {
|
|
241
|
+
return createIncremarkParser({
|
|
242
|
+
...options,
|
|
243
|
+
onChange: (state) => {
|
|
244
|
+
setDefinations(state.definitions);
|
|
245
|
+
setFootnoteDefinitions(state.footnoteDefinitions);
|
|
246
|
+
options.onChange?.(state);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
let parser = createParser(toValue2(optionsInput));
|
|
237
251
|
const completedBlocks = shallowRef2([]);
|
|
238
252
|
const pendingBlocks = shallowRef2([]);
|
|
239
253
|
const isLoading = ref3(false);
|
|
@@ -241,11 +255,18 @@ function useIncremark(options = {}) {
|
|
|
241
255
|
const isFinalized = ref3(false);
|
|
242
256
|
const footnoteReferenceOrder = ref3([]);
|
|
243
257
|
const { blocks, typewriter, transformer, isAnimationComplete } = useTypewriter({
|
|
244
|
-
typewriter:
|
|
258
|
+
typewriter: () => toValue2(optionsInput).typewriter,
|
|
245
259
|
completedBlocks,
|
|
246
260
|
pendingBlocks
|
|
247
261
|
});
|
|
248
|
-
const isDisplayComplete = computed2(() =>
|
|
262
|
+
const isDisplayComplete = computed2(() => {
|
|
263
|
+
console.log("\u8BA1\u7B97\u5C5E\u6027\u53D8\u66F4");
|
|
264
|
+
if (!toValue2(optionsInput).typewriter || !typewriter.enabled.value) {
|
|
265
|
+
console.log("isDisplayComplete", isFinalized.value);
|
|
266
|
+
return isFinalized.value;
|
|
267
|
+
}
|
|
268
|
+
return isFinalized.value && isAnimationComplete.value;
|
|
269
|
+
});
|
|
249
270
|
const ast = computed2(() => ({
|
|
250
271
|
type: "root",
|
|
251
272
|
children: [
|
|
@@ -253,9 +274,7 @@ function useIncremark(options = {}) {
|
|
|
253
274
|
...pendingBlocks.value.map((b) => b.node)
|
|
254
275
|
]
|
|
255
276
|
}));
|
|
256
|
-
function
|
|
257
|
-
isLoading.value = true;
|
|
258
|
-
const update = parser.append(chunk);
|
|
277
|
+
function handleUpdate(update, isFinalize = false) {
|
|
259
278
|
markdown.value = parser.getBuffer();
|
|
260
279
|
if (update.completed.length > 0) {
|
|
261
280
|
completedBlocks.value = [
|
|
@@ -264,24 +283,23 @@ function useIncremark(options = {}) {
|
|
|
264
283
|
];
|
|
265
284
|
}
|
|
266
285
|
pendingBlocks.value = update.pending.map((b) => markRaw(b));
|
|
286
|
+
if (isFinalize) {
|
|
287
|
+
isLoading.value = false;
|
|
288
|
+
isFinalized.value = true;
|
|
289
|
+
} else {
|
|
290
|
+
isLoading.value = true;
|
|
291
|
+
}
|
|
267
292
|
footnoteReferenceOrder.value = update.footnoteReferenceOrder;
|
|
268
293
|
setFootnoteReferenceOrder(update.footnoteReferenceOrder);
|
|
294
|
+
}
|
|
295
|
+
function append(chunk) {
|
|
296
|
+
const update = parser.append(chunk);
|
|
297
|
+
handleUpdate(update, false);
|
|
269
298
|
return update;
|
|
270
299
|
}
|
|
271
300
|
function finalize() {
|
|
272
301
|
const update = parser.finalize();
|
|
273
|
-
|
|
274
|
-
if (update.completed.length > 0) {
|
|
275
|
-
completedBlocks.value = [
|
|
276
|
-
...completedBlocks.value,
|
|
277
|
-
...update.completed.map((b) => markRaw(b))
|
|
278
|
-
];
|
|
279
|
-
}
|
|
280
|
-
pendingBlocks.value = [];
|
|
281
|
-
isLoading.value = false;
|
|
282
|
-
isFinalized.value = true;
|
|
283
|
-
footnoteReferenceOrder.value = update.footnoteReferenceOrder;
|
|
284
|
-
setFootnoteReferenceOrder(update.footnoteReferenceOrder);
|
|
302
|
+
handleUpdate(update, true);
|
|
285
303
|
return update;
|
|
286
304
|
}
|
|
287
305
|
function abort() {
|
|
@@ -297,7 +315,18 @@ function useIncremark(options = {}) {
|
|
|
297
315
|
footnoteReferenceOrder.value = [];
|
|
298
316
|
transformer?.reset();
|
|
299
317
|
}
|
|
300
|
-
|
|
318
|
+
watch2(
|
|
319
|
+
() => {
|
|
320
|
+
const { typewriter: _, ...parserOptions } = toValue2(optionsInput);
|
|
321
|
+
return JSON.stringify(parserOptions);
|
|
322
|
+
},
|
|
323
|
+
() => {
|
|
324
|
+
const { typewriter: _, ...parserOptions } = toValue2(optionsInput);
|
|
325
|
+
parser = createParser(parserOptions);
|
|
326
|
+
reset();
|
|
327
|
+
}
|
|
328
|
+
);
|
|
329
|
+
function render19(content) {
|
|
301
330
|
const update = parser.render(content);
|
|
302
331
|
markdown.value = parser.getBuffer();
|
|
303
332
|
completedBlocks.value = parser.getCompletedBlocks().map((b) => markRaw(b));
|
|
@@ -341,7 +370,7 @@ function useIncremark(options = {}) {
|
|
|
341
370
|
/** 重置解析器和打字机 */
|
|
342
371
|
reset,
|
|
343
372
|
/** 一次性渲染(reset + append + finalize) */
|
|
344
|
-
render:
|
|
373
|
+
render: render19,
|
|
345
374
|
/** 解析器实例 */
|
|
346
375
|
parser,
|
|
347
376
|
/** 打字机控制 */
|
|
@@ -353,23 +382,13 @@ function useIncremark(options = {}) {
|
|
|
353
382
|
import { computed as computed3 } from "vue";
|
|
354
383
|
function useStreamRenderer(options) {
|
|
355
384
|
const { completedBlocks, pendingBlocks } = options;
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
stableId: block.id
|
|
360
|
-
}))
|
|
361
|
-
);
|
|
362
|
-
const stablePendingBlocks = computed3(
|
|
363
|
-
() => pendingBlocks.value.map((block, index) => ({
|
|
364
|
-
...block,
|
|
365
|
-
stableId: `pending-${index}`
|
|
366
|
-
}))
|
|
367
|
-
);
|
|
368
|
-
const allStableBlocks = computed3(() => [...stableCompletedBlocks.value, ...stablePendingBlocks.value]);
|
|
385
|
+
const completedBlocksComputed = computed3(() => completedBlocks.value);
|
|
386
|
+
const pendingBlocksComputed = computed3(() => pendingBlocks.value);
|
|
387
|
+
const allBlocks = computed3(() => [...completedBlocksComputed.value, ...pendingBlocksComputed.value]);
|
|
369
388
|
return {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
389
|
+
completedBlocks: completedBlocksComputed,
|
|
390
|
+
pendingBlocks: pendingBlocksComputed,
|
|
391
|
+
allBlocks
|
|
373
392
|
};
|
|
374
393
|
}
|
|
375
394
|
|
|
@@ -380,8 +399,8 @@ function useDevTools(incremark, options = {}) {
|
|
|
380
399
|
const devtools = createDevTools(options);
|
|
381
400
|
incremark.parser.setOnChange((state) => {
|
|
382
401
|
const blocks = [
|
|
383
|
-
...state.completedBlocks
|
|
384
|
-
...state.pendingBlocks
|
|
402
|
+
...state.completedBlocks,
|
|
403
|
+
...state.pendingBlocks
|
|
385
404
|
];
|
|
386
405
|
devtools.update({
|
|
387
406
|
blocks,
|
|
@@ -403,15 +422,15 @@ function useDevTools(incremark, options = {}) {
|
|
|
403
422
|
}
|
|
404
423
|
|
|
405
424
|
// src/composables/useBlockTransformer.ts
|
|
406
|
-
import { ref as
|
|
425
|
+
import { ref as ref4, watch as watch3, computed as computed4, onUnmounted as onUnmounted3 } from "vue";
|
|
407
426
|
import {
|
|
408
427
|
createBlockTransformer as createBlockTransformer2
|
|
409
428
|
} from "@incremark/core";
|
|
410
429
|
function useBlockTransformer(sourceBlocks, options = {}) {
|
|
411
|
-
const displayBlocksRef =
|
|
412
|
-
const isProcessingRef =
|
|
413
|
-
const isPausedRef =
|
|
414
|
-
const effectRef =
|
|
430
|
+
const displayBlocksRef = ref4([]);
|
|
431
|
+
const isProcessingRef = ref4(false);
|
|
432
|
+
const isPausedRef = ref4(false);
|
|
433
|
+
const effectRef = ref4(options.effect ?? "none");
|
|
415
434
|
const transformer = createBlockTransformer2({
|
|
416
435
|
...options,
|
|
417
436
|
onChange: (blocks) => {
|
|
@@ -420,7 +439,7 @@ function useBlockTransformer(sourceBlocks, options = {}) {
|
|
|
420
439
|
isPausedRef.value = transformer.isPausedState();
|
|
421
440
|
}
|
|
422
441
|
});
|
|
423
|
-
|
|
442
|
+
watch3(
|
|
424
443
|
sourceBlocks,
|
|
425
444
|
(blocks) => {
|
|
426
445
|
transformer.push(blocks);
|
|
@@ -474,7 +493,11 @@ function useDefinationsContext() {
|
|
|
474
493
|
|
|
475
494
|
// sfc-script:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/Incremark.vue?type=script
|
|
476
495
|
import { defineComponent as _defineComponent15 } from "vue";
|
|
477
|
-
import { computed as
|
|
496
|
+
import { computed as computed11 } from "vue";
|
|
497
|
+
|
|
498
|
+
// sfc-script:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkRenderer.vue?type=script
|
|
499
|
+
import { defineComponent as _defineComponent13 } from "vue";
|
|
500
|
+
import { computed as computed9 } from "vue";
|
|
478
501
|
|
|
479
502
|
// sfc-script:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkHeading.vue?type=script
|
|
480
503
|
import { defineComponent as _defineComponent4 } from "vue";
|
|
@@ -490,7 +513,7 @@ import {
|
|
|
490
513
|
|
|
491
514
|
// sfc-script:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkMath.vue?type=script
|
|
492
515
|
import { defineComponent as _defineComponent } from "vue";
|
|
493
|
-
import { computed as computed5, ref as
|
|
516
|
+
import { computed as computed5, ref as ref5, watch as watch4, shallowRef as shallowRef3, onUnmounted as onUnmounted4 } from "vue";
|
|
494
517
|
var IncremarkMath_default = /* @__PURE__ */ _defineComponent({
|
|
495
518
|
__name: "IncremarkMath",
|
|
496
519
|
props: {
|
|
@@ -500,9 +523,9 @@ var IncremarkMath_default = /* @__PURE__ */ _defineComponent({
|
|
|
500
523
|
setup(__props, { expose: __expose }) {
|
|
501
524
|
__expose();
|
|
502
525
|
const props = __props;
|
|
503
|
-
const renderedHtml =
|
|
504
|
-
const renderError =
|
|
505
|
-
const isLoading =
|
|
526
|
+
const renderedHtml = ref5("");
|
|
527
|
+
const renderError = ref5("");
|
|
528
|
+
const isLoading = ref5(false);
|
|
506
529
|
const katexRef = shallowRef3(null);
|
|
507
530
|
let renderTimer = null;
|
|
508
531
|
const isInline = computed5(() => props.node.type === "inlineMath");
|
|
@@ -546,7 +569,7 @@ var IncremarkMath_default = /* @__PURE__ */ _defineComponent({
|
|
|
546
569
|
clearTimeout(renderTimer);
|
|
547
570
|
}
|
|
548
571
|
});
|
|
549
|
-
|
|
572
|
+
watch4(formula, scheduleRender, { immediate: true });
|
|
550
573
|
const __returned__ = { props, renderedHtml, renderError, isLoading, katexRef, get renderTimer() {
|
|
551
574
|
return renderTimer;
|
|
552
575
|
}, set renderTimer(v) {
|
|
@@ -1247,30 +1270,159 @@ var IncremarkParagraph_default2 = IncremarkParagraph_default;
|
|
|
1247
1270
|
|
|
1248
1271
|
// sfc-script:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkCode.vue?type=script
|
|
1249
1272
|
import { defineComponent as _defineComponent6 } from "vue";
|
|
1250
|
-
import { computed as computed7, ref as
|
|
1273
|
+
import { computed as computed7, ref as ref6, watch as watch5, onUnmounted as onUnmounted5, shallowRef as shallowRef5 } from "vue";
|
|
1274
|
+
|
|
1275
|
+
// src/composables/useShiki.ts
|
|
1276
|
+
import { shallowRef as shallowRef4 } from "vue";
|
|
1277
|
+
var ShikiManager = class _ShikiManager {
|
|
1278
|
+
static instance = null;
|
|
1279
|
+
/** 存储 highlighter 实例,key 为主题名称 */
|
|
1280
|
+
highlighters = /* @__PURE__ */ new Map();
|
|
1281
|
+
constructor() {
|
|
1282
|
+
}
|
|
1283
|
+
static getInstance() {
|
|
1284
|
+
if (!_ShikiManager.instance) {
|
|
1285
|
+
_ShikiManager.instance = new _ShikiManager();
|
|
1286
|
+
}
|
|
1287
|
+
return _ShikiManager.instance;
|
|
1288
|
+
}
|
|
1289
|
+
/**
|
|
1290
|
+
* 获取或创建 highlighter
|
|
1291
|
+
* @param theme 主题名称
|
|
1292
|
+
* @returns highlighter 实例
|
|
1293
|
+
*/
|
|
1294
|
+
async getHighlighter(theme) {
|
|
1295
|
+
if (this.highlighters.has(theme)) {
|
|
1296
|
+
return this.highlighters.get(theme);
|
|
1297
|
+
}
|
|
1298
|
+
const { createHighlighter } = await import("shiki");
|
|
1299
|
+
const highlighter = await createHighlighter({
|
|
1300
|
+
themes: [theme],
|
|
1301
|
+
langs: []
|
|
1302
|
+
});
|
|
1303
|
+
const info = {
|
|
1304
|
+
highlighter,
|
|
1305
|
+
loadedLanguages: /* @__PURE__ */ new Set(),
|
|
1306
|
+
loadedThemes: /* @__PURE__ */ new Set([theme])
|
|
1307
|
+
};
|
|
1308
|
+
this.highlighters.set(theme, info);
|
|
1309
|
+
return info;
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* 加载语言(按需)
|
|
1313
|
+
* @param theme 主题名称
|
|
1314
|
+
* @param lang 语言名称
|
|
1315
|
+
*/
|
|
1316
|
+
async loadLanguage(theme, lang) {
|
|
1317
|
+
const info = this.highlighters.get(theme);
|
|
1318
|
+
if (!info || info.loadedLanguages.has(lang)) return;
|
|
1319
|
+
try {
|
|
1320
|
+
await info.highlighter.loadLanguage(lang);
|
|
1321
|
+
info.loadedLanguages.add(lang);
|
|
1322
|
+
} catch {
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* 加载主题(按需)
|
|
1327
|
+
* @param theme 主题名称
|
|
1328
|
+
*/
|
|
1329
|
+
async loadTheme(theme) {
|
|
1330
|
+
const info = this.highlighters.get(theme);
|
|
1331
|
+
if (!info || info.loadedThemes.has(theme)) return;
|
|
1332
|
+
try {
|
|
1333
|
+
await info.highlighter.loadTheme(theme);
|
|
1334
|
+
info.loadedThemes.add(theme);
|
|
1335
|
+
} catch {
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* 高亮代码
|
|
1340
|
+
* @param theme 主题名称
|
|
1341
|
+
* @param code 代码内容
|
|
1342
|
+
* @param lang 语言名称
|
|
1343
|
+
* @param fallbackTheme 回退主题
|
|
1344
|
+
* @returns 高亮后的 HTML
|
|
1345
|
+
*/
|
|
1346
|
+
async codeToHtml(theme, code, lang, fallbackTheme) {
|
|
1347
|
+
const info = this.highlighters.get(theme);
|
|
1348
|
+
if (!info) throw new Error("Highlighter not found");
|
|
1349
|
+
const actualLang = info.loadedLanguages.has(lang) ? lang : "text";
|
|
1350
|
+
const actualTheme = info.loadedThemes.has(theme) ? theme : fallbackTheme;
|
|
1351
|
+
return info.highlighter.codeToHtml(code, {
|
|
1352
|
+
lang: actualLang,
|
|
1353
|
+
theme: actualTheme
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* 清理所有 highlighter(应用退出或需要重置时调用)
|
|
1358
|
+
*/
|
|
1359
|
+
disposeAll() {
|
|
1360
|
+
for (const [, info] of this.highlighters) {
|
|
1361
|
+
if (info.highlighter?.dispose) {
|
|
1362
|
+
info.highlighter.dispose();
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
this.highlighters.clear();
|
|
1366
|
+
}
|
|
1367
|
+
};
|
|
1368
|
+
var shikiManager = ShikiManager.getInstance();
|
|
1369
|
+
function useShiki(theme) {
|
|
1370
|
+
const highlighterInfo = shallowRef4(null);
|
|
1371
|
+
const isHighlighting = shallowRef4(false);
|
|
1372
|
+
async function getHighlighter() {
|
|
1373
|
+
if (!highlighterInfo.value) {
|
|
1374
|
+
highlighterInfo.value = await shikiManager.getHighlighter(theme);
|
|
1375
|
+
}
|
|
1376
|
+
return highlighterInfo.value;
|
|
1377
|
+
}
|
|
1378
|
+
async function highlight(code, lang, fallbackTheme) {
|
|
1379
|
+
isHighlighting.value = true;
|
|
1380
|
+
try {
|
|
1381
|
+
const info = await getHighlighter();
|
|
1382
|
+
if (!info.loadedLanguages.has(lang) && lang !== "text") {
|
|
1383
|
+
await shikiManager.loadLanguage(theme, lang);
|
|
1384
|
+
}
|
|
1385
|
+
if (!info.loadedThemes.has(theme)) {
|
|
1386
|
+
await shikiManager.loadTheme(theme);
|
|
1387
|
+
}
|
|
1388
|
+
return await shikiManager.codeToHtml(theme, code, lang, fallbackTheme);
|
|
1389
|
+
} catch (e) {
|
|
1390
|
+
throw e;
|
|
1391
|
+
} finally {
|
|
1392
|
+
isHighlighting.value = false;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
return {
|
|
1396
|
+
highlighterInfo,
|
|
1397
|
+
isHighlighting,
|
|
1398
|
+
highlight
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
// sfc-script:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkCode.vue?type=script
|
|
1251
1403
|
var IncremarkCode_default = /* @__PURE__ */ _defineComponent6({
|
|
1252
1404
|
__name: "IncremarkCode",
|
|
1253
1405
|
props: {
|
|
1254
1406
|
node: { type: null, required: true },
|
|
1255
1407
|
theme: { type: String, required: false, default: "github-dark" },
|
|
1408
|
+
fallbackTheme: { type: String, required: false, default: "github-dark" },
|
|
1256
1409
|
disableHighlight: { type: Boolean, required: false, default: false },
|
|
1257
1410
|
mermaidDelay: { type: Number, required: false, default: 500 },
|
|
1258
1411
|
customCodeBlocks: { type: Object, required: false, default: () => ({}) },
|
|
1412
|
+
codeBlockConfigs: { type: Object, required: false, default: () => ({}) },
|
|
1259
1413
|
blockStatus: { type: String, required: false, default: "completed" }
|
|
1260
1414
|
},
|
|
1261
1415
|
setup(__props, { expose: __expose }) {
|
|
1262
1416
|
__expose();
|
|
1263
1417
|
const props = __props;
|
|
1264
|
-
const copied =
|
|
1265
|
-
const highlightedHtml =
|
|
1266
|
-
const
|
|
1267
|
-
const
|
|
1268
|
-
const
|
|
1269
|
-
const
|
|
1270
|
-
const mermaidLoading = ref7(false);
|
|
1271
|
-
const mermaidRef = shallowRef4(null);
|
|
1418
|
+
const copied = ref6(false);
|
|
1419
|
+
const highlightedHtml = ref6("");
|
|
1420
|
+
const mermaidSvg = ref6("");
|
|
1421
|
+
const mermaidError = ref6("");
|
|
1422
|
+
const mermaidLoading = ref6(false);
|
|
1423
|
+
const mermaidRef = shallowRef5(null);
|
|
1272
1424
|
let mermaidTimer = null;
|
|
1273
|
-
const mermaidViewMode =
|
|
1425
|
+
const mermaidViewMode = ref6("preview");
|
|
1274
1426
|
function toggleMermaidView() {
|
|
1275
1427
|
mermaidViewMode.value = mermaidViewMode.value === "preview" ? "source" : "preview";
|
|
1276
1428
|
}
|
|
@@ -1278,15 +1430,18 @@ var IncremarkCode_default = /* @__PURE__ */ _defineComponent6({
|
|
|
1278
1430
|
const code = computed7(() => props.node.value);
|
|
1279
1431
|
const isMermaid = computed7(() => language.value === "mermaid");
|
|
1280
1432
|
const CustomCodeBlock = computed7(() => {
|
|
1281
|
-
|
|
1433
|
+
const component = props.customCodeBlocks?.[language.value];
|
|
1434
|
+
if (!component) return null;
|
|
1435
|
+
const config = props.codeBlockConfigs?.[language.value];
|
|
1436
|
+
if (config?.takeOver) {
|
|
1437
|
+
return component;
|
|
1438
|
+
}
|
|
1439
|
+
if (props.blockStatus !== "completed") {
|
|
1282
1440
|
return null;
|
|
1283
1441
|
}
|
|
1284
|
-
return
|
|
1442
|
+
return component;
|
|
1285
1443
|
});
|
|
1286
|
-
const
|
|
1287
|
-
const highlighterRef = shallowRef4(null);
|
|
1288
|
-
const loadedLanguages = /* @__PURE__ */ new Set();
|
|
1289
|
-
const loadedThemes = /* @__PURE__ */ new Set();
|
|
1444
|
+
const { isHighlighting, highlight } = useShiki(props.theme);
|
|
1290
1445
|
function scheduleRenderMermaid() {
|
|
1291
1446
|
if (!isMermaid.value || !code.value) return;
|
|
1292
1447
|
if (mermaidTimer) {
|
|
@@ -1307,7 +1462,8 @@ var IncremarkCode_default = /* @__PURE__ */ _defineComponent6({
|
|
|
1307
1462
|
mermaidRef.value.initialize({
|
|
1308
1463
|
startOnLoad: false,
|
|
1309
1464
|
theme: "dark",
|
|
1310
|
-
securityLevel: "loose"
|
|
1465
|
+
securityLevel: "loose",
|
|
1466
|
+
suppressErrorRendering: true
|
|
1311
1467
|
});
|
|
1312
1468
|
}
|
|
1313
1469
|
const mermaid = mermaidRef.value;
|
|
@@ -1321,12 +1477,7 @@ var IncremarkCode_default = /* @__PURE__ */ _defineComponent6({
|
|
|
1321
1477
|
mermaidLoading.value = false;
|
|
1322
1478
|
}
|
|
1323
1479
|
}
|
|
1324
|
-
|
|
1325
|
-
if (mermaidTimer) {
|
|
1326
|
-
clearTimeout(mermaidTimer);
|
|
1327
|
-
}
|
|
1328
|
-
});
|
|
1329
|
-
async function highlight() {
|
|
1480
|
+
async function doHighlight() {
|
|
1330
1481
|
if (isMermaid.value) {
|
|
1331
1482
|
scheduleRenderMermaid();
|
|
1332
1483
|
return;
|
|
@@ -1335,46 +1486,19 @@ var IncremarkCode_default = /* @__PURE__ */ _defineComponent6({
|
|
|
1335
1486
|
highlightedHtml.value = "";
|
|
1336
1487
|
return;
|
|
1337
1488
|
}
|
|
1338
|
-
isHighlighting.value = true;
|
|
1339
|
-
highlightError.value = false;
|
|
1340
1489
|
try {
|
|
1341
|
-
|
|
1342
|
-
const { createHighlighter } = await import("shiki");
|
|
1343
|
-
highlighterRef.value = await createHighlighter({
|
|
1344
|
-
themes: [props.theme],
|
|
1345
|
-
langs: []
|
|
1346
|
-
});
|
|
1347
|
-
loadedThemes.add(props.theme);
|
|
1348
|
-
}
|
|
1349
|
-
const highlighter = highlighterRef.value;
|
|
1350
|
-
const lang = language.value;
|
|
1351
|
-
if (!loadedLanguages.has(lang) && lang !== "text") {
|
|
1352
|
-
try {
|
|
1353
|
-
await highlighter.loadLanguage(lang);
|
|
1354
|
-
loadedLanguages.add(lang);
|
|
1355
|
-
} catch {
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
if (!loadedThemes.has(props.theme)) {
|
|
1359
|
-
try {
|
|
1360
|
-
await highlighter.loadTheme(props.theme);
|
|
1361
|
-
loadedThemes.add(props.theme);
|
|
1362
|
-
} catch {
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
const html = highlighter.codeToHtml(code.value, {
|
|
1366
|
-
lang: loadedLanguages.has(lang) ? lang : "text",
|
|
1367
|
-
theme: loadedThemes.has(props.theme) ? props.theme : "github-dark"
|
|
1368
|
-
});
|
|
1490
|
+
const html = await highlight(code.value, language.value, props.fallbackTheme);
|
|
1369
1491
|
highlightedHtml.value = html;
|
|
1370
1492
|
} catch (e) {
|
|
1371
|
-
highlightError.value = true;
|
|
1372
1493
|
highlightedHtml.value = "";
|
|
1373
|
-
} finally {
|
|
1374
|
-
isHighlighting.value = false;
|
|
1375
1494
|
}
|
|
1376
1495
|
}
|
|
1377
|
-
|
|
1496
|
+
watch5([code, () => props.theme, isMermaid], doHighlight, { immediate: true });
|
|
1497
|
+
onUnmounted5(() => {
|
|
1498
|
+
if (mermaidTimer) {
|
|
1499
|
+
clearTimeout(mermaidTimer);
|
|
1500
|
+
}
|
|
1501
|
+
});
|
|
1378
1502
|
async function copyCode() {
|
|
1379
1503
|
try {
|
|
1380
1504
|
await navigator.clipboard.writeText(code.value);
|
|
@@ -1385,11 +1509,11 @@ var IncremarkCode_default = /* @__PURE__ */ _defineComponent6({
|
|
|
1385
1509
|
} catch {
|
|
1386
1510
|
}
|
|
1387
1511
|
}
|
|
1388
|
-
const __returned__ = { props, copied, highlightedHtml,
|
|
1512
|
+
const __returned__ = { props, copied, highlightedHtml, mermaidSvg, mermaidError, mermaidLoading, mermaidRef, get mermaidTimer() {
|
|
1389
1513
|
return mermaidTimer;
|
|
1390
1514
|
}, set mermaidTimer(v) {
|
|
1391
1515
|
mermaidTimer = v;
|
|
1392
|
-
}, mermaidViewMode, toggleMermaidView, language, code, isMermaid, CustomCodeBlock,
|
|
1516
|
+
}, mermaidViewMode, toggleMermaidView, language, code, isMermaid, CustomCodeBlock, isHighlighting, highlight, scheduleRenderMermaid, doRenderMermaid, doHighlight, copyCode };
|
|
1393
1517
|
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
1394
1518
|
return __returned__;
|
|
1395
1519
|
}
|
|
@@ -1426,11 +1550,13 @@ function render6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1426
1550
|
null,
|
|
1427
1551
|
[
|
|
1428
1552
|
_createCommentVNode4(" \u81EA\u5B9A\u4E49\u4EE3\u7801\u5757\u7EC4\u4EF6 "),
|
|
1429
|
-
$setup.
|
|
1553
|
+
$setup.CustomCodeBlock ? (_openBlock6(), _createBlock3(_resolveDynamicComponent3($setup.CustomCodeBlock), {
|
|
1430
1554
|
key: 0,
|
|
1431
1555
|
"code-str": $setup.code,
|
|
1432
|
-
lang: $setup.language
|
|
1433
|
-
|
|
1556
|
+
lang: $setup.language,
|
|
1557
|
+
completed: $props.blockStatus === "completed",
|
|
1558
|
+
takeOver: $props.codeBlockConfigs?.[$setup.language]?.takeOver
|
|
1559
|
+
}, null, 8, ["code-str", "lang", "completed", "takeOver"])) : $setup.isMermaid ? (_openBlock6(), _createElementBlock5(
|
|
1434
1560
|
_Fragment4,
|
|
1435
1561
|
{ key: 1 },
|
|
1436
1562
|
[
|
|
@@ -1640,14 +1766,14 @@ var IncremarkList_default = /* @__PURE__ */ _defineComponent7({
|
|
|
1640
1766
|
function hasBlockChildren(item) {
|
|
1641
1767
|
return getItemBlockChildren(item).length > 0;
|
|
1642
1768
|
}
|
|
1643
|
-
const __returned__ = { props, tag, getItemInlineContent, getItemBlockChildren, hasBlockChildren, IncremarkInline: IncremarkInline_default };
|
|
1769
|
+
const __returned__ = { props, tag, getItemInlineContent, getItemBlockChildren, hasBlockChildren, IncremarkInline: IncremarkInline_default, IncremarkRenderer: IncremarkRenderer_default };
|
|
1644
1770
|
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
1645
1771
|
return __returned__;
|
|
1646
1772
|
}
|
|
1647
1773
|
});
|
|
1648
1774
|
|
|
1649
1775
|
// sfc-template:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkList.vue?type=template
|
|
1650
|
-
import { renderList as _renderList3, Fragment as _Fragment5, openBlock as _openBlock7, createElementBlock as _createElementBlock6, createElementVNode as _createElementVNode5, createVNode as _createVNode5, createCommentVNode as _createCommentVNode5,
|
|
1776
|
+
import { renderList as _renderList3, Fragment as _Fragment5, openBlock as _openBlock7, createElementBlock as _createElementBlock6, createElementVNode as _createElementVNode5, createVNode as _createVNode5, createCommentVNode as _createCommentVNode5, createBlock as _createBlock4, normalizeClass as _normalizeClass2, resolveDynamicComponent as _resolveDynamicComponent4, withCtx as _withCtx3 } from "vue";
|
|
1651
1777
|
var _hoisted_18 = {
|
|
1652
1778
|
key: 0,
|
|
1653
1779
|
class: "task-label"
|
|
@@ -1655,9 +1781,9 @@ var _hoisted_18 = {
|
|
|
1655
1781
|
var _hoisted_24 = ["checked"];
|
|
1656
1782
|
var _hoisted_34 = { class: "task-content" };
|
|
1657
1783
|
function render7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1658
|
-
const _component_IncremarkList = _resolveComponent3("IncremarkList", true);
|
|
1659
1784
|
return _openBlock7(), _createBlock4(_resolveDynamicComponent4($setup.tag), {
|
|
1660
|
-
class: _normalizeClass2(["incremark-list", { "task-list": $props.node.children.some((item) => item.checked !== null && item.checked !== void 0) }])
|
|
1785
|
+
class: _normalizeClass2(["incremark-list", { "task-list": $props.node.children.some((item) => item.checked !== null && item.checked !== void 0) }]),
|
|
1786
|
+
start: $props.node.start || void 0
|
|
1661
1787
|
}, {
|
|
1662
1788
|
default: _withCtx3(() => [
|
|
1663
1789
|
(_openBlock7(true), _createElementBlock6(
|
|
@@ -1690,25 +1816,15 @@ function render7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1690
1816
|
_createVNode5($setup["IncremarkInline"], {
|
|
1691
1817
|
nodes: $setup.getItemInlineContent(item)
|
|
1692
1818
|
}, null, 8, ["nodes"]),
|
|
1693
|
-
_createCommentVNode5(" \u9012\u5F52\u6E32\u67D3\u5D4C\u5957\u5217\u8868\
|
|
1819
|
+
_createCommentVNode5(" \u9012\u5F52\u6E32\u67D3\u6240\u6709\u5757\u7EA7\u5185\u5BB9\uFF08\u5D4C\u5957\u5217\u8868\u3001heading\u3001blockquote\u3001code\u3001table \u7B49\uFF09 "),
|
|
1694
1820
|
$setup.hasBlockChildren(item) ? (_openBlock7(true), _createElementBlock6(
|
|
1695
1821
|
_Fragment5,
|
|
1696
1822
|
{ key: 0 },
|
|
1697
1823
|
_renderList3($setup.getItemBlockChildren(item), (child, childIndex) => {
|
|
1698
|
-
return _openBlock7(),
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
_createCommentVNode5(" \u5D4C\u5957\u5217\u8868 "),
|
|
1703
|
-
child.type === "list" ? (_openBlock7(), _createBlock4(_component_IncremarkList, {
|
|
1704
|
-
key: 0,
|
|
1705
|
-
node: child
|
|
1706
|
-
}, null, 8, ["node"])) : _createCommentVNode5("v-if", true),
|
|
1707
|
-
_createCommentVNode5(" \u5176\u4ED6\u5757\u7EA7\u5185\u5BB9\u53EF\u4EE5\u5728\u8FD9\u91CC\u6269\u5C55 ")
|
|
1708
|
-
],
|
|
1709
|
-
64
|
|
1710
|
-
/* STABLE_FRAGMENT */
|
|
1711
|
-
);
|
|
1824
|
+
return _openBlock7(), _createBlock4($setup["IncremarkRenderer"], {
|
|
1825
|
+
key: childIndex,
|
|
1826
|
+
node: child
|
|
1827
|
+
}, null, 8, ["node"]);
|
|
1712
1828
|
}),
|
|
1713
1829
|
128
|
|
1714
1830
|
/* KEYED_FRAGMENT */
|
|
@@ -1728,7 +1844,7 @@ function render7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1728
1844
|
]),
|
|
1729
1845
|
_: 1
|
|
1730
1846
|
/* STABLE */
|
|
1731
|
-
}, 8, ["class"]);
|
|
1847
|
+
}, 8, ["class", "start"]);
|
|
1732
1848
|
}
|
|
1733
1849
|
|
|
1734
1850
|
// src/components/IncremarkList.vue
|
|
@@ -1840,43 +1956,25 @@ var IncremarkBlockquote_default = /* @__PURE__ */ _defineComponent9({
|
|
|
1840
1956
|
},
|
|
1841
1957
|
setup(__props, { expose: __expose }) {
|
|
1842
1958
|
__expose();
|
|
1843
|
-
const __returned__ = {
|
|
1959
|
+
const __returned__ = { IncremarkRenderer: IncremarkRenderer_default };
|
|
1844
1960
|
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
1845
1961
|
return __returned__;
|
|
1846
1962
|
}
|
|
1847
1963
|
});
|
|
1848
1964
|
|
|
1849
1965
|
// sfc-template:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkBlockquote.vue?type=template
|
|
1850
|
-
import { renderList as _renderList5, Fragment as _Fragment7, openBlock as _openBlock9, createElementBlock as _createElementBlock8, createBlock as _createBlock5
|
|
1966
|
+
import { renderList as _renderList5, Fragment as _Fragment7, openBlock as _openBlock9, createElementBlock as _createElementBlock8, createBlock as _createBlock5 } from "vue";
|
|
1851
1967
|
var _hoisted_110 = { class: "incremark-blockquote" };
|
|
1852
|
-
var _hoisted_26 = {
|
|
1853
|
-
key: 1,
|
|
1854
|
-
class: "unknown-child"
|
|
1855
|
-
};
|
|
1856
1968
|
function render9(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1857
1969
|
return _openBlock9(), _createElementBlock8("blockquote", _hoisted_110, [
|
|
1858
1970
|
(_openBlock9(true), _createElementBlock8(
|
|
1859
1971
|
_Fragment7,
|
|
1860
1972
|
null,
|
|
1861
1973
|
_renderList5($props.node.children, (child, index) => {
|
|
1862
|
-
return _openBlock9(),
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
child.type === "paragraph" ? (_openBlock9(), _createBlock5($setup["IncremarkParagraph"], {
|
|
1867
|
-
key: 0,
|
|
1868
|
-
node: child
|
|
1869
|
-
}, null, 8, ["node"])) : (_openBlock9(), _createElementBlock8(
|
|
1870
|
-
"div",
|
|
1871
|
-
_hoisted_26,
|
|
1872
|
-
_toDisplayString5(child.type),
|
|
1873
|
-
1
|
|
1874
|
-
/* TEXT */
|
|
1875
|
-
))
|
|
1876
|
-
],
|
|
1877
|
-
64
|
|
1878
|
-
/* STABLE_FRAGMENT */
|
|
1879
|
-
);
|
|
1974
|
+
return _openBlock9(), _createBlock5($setup["IncremarkRenderer"], {
|
|
1975
|
+
key: index,
|
|
1976
|
+
node: child
|
|
1977
|
+
}, null, 8, ["node"]);
|
|
1880
1978
|
}),
|
|
1881
1979
|
128
|
|
1882
1980
|
/* KEYED_FRAGMENT */
|
|
@@ -1913,13 +2011,6 @@ IncremarkThematicBreak_default.render = render10;
|
|
|
1913
2011
|
IncremarkThematicBreak_default.__file = "src/components/IncremarkThematicBreak.vue";
|
|
1914
2012
|
var IncremarkThematicBreak_default2 = IncremarkThematicBreak_default;
|
|
1915
2013
|
|
|
1916
|
-
// sfc-script:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkFootnotes.vue?type=script
|
|
1917
|
-
import { defineComponent as _defineComponent14 } from "vue";
|
|
1918
|
-
import { computed as computed9 } from "vue";
|
|
1919
|
-
|
|
1920
|
-
// sfc-script:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkRenderer.vue?type=script
|
|
1921
|
-
import { defineComponent as _defineComponent13 } from "vue";
|
|
1922
|
-
|
|
1923
2014
|
// sfc-script:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkContainer.vue?type=script
|
|
1924
2015
|
import { defineComponent as _defineComponent11 } from "vue";
|
|
1925
2016
|
var IncremarkContainer_default = /* @__PURE__ */ _defineComponent11({
|
|
@@ -1954,7 +2045,7 @@ var IncremarkContainer_default = /* @__PURE__ */ _defineComponent11({
|
|
|
1954
2045
|
});
|
|
1955
2046
|
|
|
1956
2047
|
// sfc-template:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkContainer.vue?type=template
|
|
1957
|
-
import { createCommentVNode as
|
|
2048
|
+
import { createCommentVNode as _createCommentVNode7, renderList as _renderList6, Fragment as _Fragment8, openBlock as _openBlock11, createElementBlock as _createElementBlock10, createBlock as _createBlock6, resolveDynamicComponent as _resolveDynamicComponent5, withCtx as _withCtx4, normalizeClass as _normalizeClass3, createElementVNode as _createElementVNode7 } from "vue";
|
|
1958
2049
|
var _hoisted_112 = {
|
|
1959
2050
|
key: 0,
|
|
1960
2051
|
class: "incremark-container-content"
|
|
@@ -1964,14 +2055,14 @@ function render11(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1964
2055
|
_Fragment8,
|
|
1965
2056
|
null,
|
|
1966
2057
|
[
|
|
1967
|
-
|
|
2058
|
+
_createCommentVNode7(" \u5982\u679C\u6709\u81EA\u5B9A\u4E49\u5BB9\u5668\u7EC4\u4EF6\uFF0C\u4F7F\u7528\u81EA\u5B9A\u4E49\u7EC4\u4EF6 "),
|
|
1968
2059
|
$setup.hasCustomContainer ? (_openBlock11(), _createBlock6(_resolveDynamicComponent5($setup.CustomContainer), {
|
|
1969
2060
|
key: 0,
|
|
1970
2061
|
name: $setup.containerName,
|
|
1971
2062
|
options: $setup.options
|
|
1972
2063
|
}, {
|
|
1973
2064
|
default: _withCtx4(() => [
|
|
1974
|
-
|
|
2065
|
+
_createCommentVNode7(" \u5C06\u5BB9\u5668\u5185\u5BB9\u4F5C\u4E3A\u9ED8\u8BA4 slot \u4F20\u9012 "),
|
|
1975
2066
|
$props.node.children && $props.node.children.length > 0 ? (_openBlock11(true), _createElementBlock10(
|
|
1976
2067
|
_Fragment8,
|
|
1977
2068
|
{ key: 0 },
|
|
@@ -1983,7 +2074,7 @@ function render11(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1983
2074
|
}),
|
|
1984
2075
|
128
|
|
1985
2076
|
/* KEYED_FRAGMENT */
|
|
1986
|
-
)) :
|
|
2077
|
+
)) : _createCommentVNode7("v-if", true)
|
|
1987
2078
|
]),
|
|
1988
2079
|
_: 1
|
|
1989
2080
|
/* STABLE */
|
|
@@ -1991,7 +2082,7 @@ function render11(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
1991
2082
|
_Fragment8,
|
|
1992
2083
|
{ key: 1 },
|
|
1993
2084
|
[
|
|
1994
|
-
|
|
2085
|
+
_createCommentVNode7(" \u5982\u679C\u6CA1\u6709\u81EA\u5B9A\u4E49\u5BB9\u5668\u7EC4\u4EF6\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u6E32\u67D3 "),
|
|
1995
2086
|
_createElementVNode7(
|
|
1996
2087
|
"div",
|
|
1997
2088
|
{
|
|
@@ -2011,7 +2102,7 @@ function render11(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2011
2102
|
128
|
|
2012
2103
|
/* KEYED_FRAGMENT */
|
|
2013
2104
|
))
|
|
2014
|
-
])) :
|
|
2105
|
+
])) : _createCommentVNode7("v-if", true)
|
|
2015
2106
|
],
|
|
2016
2107
|
2
|
|
2017
2108
|
/* CLASS */
|
|
@@ -2047,22 +2138,22 @@ var IncremarkDefault_default = /* @__PURE__ */ _defineComponent12({
|
|
|
2047
2138
|
});
|
|
2048
2139
|
|
|
2049
2140
|
// sfc-template:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkDefault.vue?type=template
|
|
2050
|
-
import { toDisplayString as
|
|
2141
|
+
import { toDisplayString as _toDisplayString5, createElementVNode as _createElementVNode8, openBlock as _openBlock12, createElementBlock as _createElementBlock11 } from "vue";
|
|
2051
2142
|
var _hoisted_113 = { class: "incremark-default" };
|
|
2052
|
-
var
|
|
2143
|
+
var _hoisted_26 = { class: "type-badge" };
|
|
2053
2144
|
function render12(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2054
2145
|
return _openBlock12(), _createElementBlock11("div", _hoisted_113, [
|
|
2055
2146
|
_createElementVNode8(
|
|
2056
2147
|
"span",
|
|
2057
|
-
|
|
2058
|
-
|
|
2148
|
+
_hoisted_26,
|
|
2149
|
+
_toDisplayString5($props.node.type),
|
|
2059
2150
|
1
|
|
2060
2151
|
/* TEXT */
|
|
2061
2152
|
),
|
|
2062
2153
|
_createElementVNode8(
|
|
2063
2154
|
"pre",
|
|
2064
2155
|
null,
|
|
2065
|
-
|
|
2156
|
+
_toDisplayString5(JSON.stringify($props.node, null, 2)),
|
|
2066
2157
|
1
|
|
2067
2158
|
/* TEXT */
|
|
2068
2159
|
)
|
|
@@ -2081,12 +2172,14 @@ var IncremarkRenderer_default2 = /* @__PURE__ */ _defineComponent13({
|
|
|
2081
2172
|
node: { type: null, required: true },
|
|
2082
2173
|
customContainers: { type: Object, required: false },
|
|
2083
2174
|
customCodeBlocks: { type: Object, required: false },
|
|
2084
|
-
|
|
2175
|
+
codeBlockConfigs: { type: Object, required: false },
|
|
2176
|
+
blockStatus: { type: String, required: false },
|
|
2177
|
+
components: { type: Object, required: false }
|
|
2085
2178
|
},
|
|
2086
2179
|
setup(__props, { expose: __expose }) {
|
|
2087
2180
|
__expose();
|
|
2088
2181
|
const props = __props;
|
|
2089
|
-
const
|
|
2182
|
+
const defaultComponentMap = {
|
|
2090
2183
|
heading: IncremarkHeading_default2,
|
|
2091
2184
|
paragraph: IncremarkParagraph_default2,
|
|
2092
2185
|
code: IncremarkCode_default2,
|
|
@@ -2101,8 +2194,12 @@ var IncremarkRenderer_default2 = /* @__PURE__ */ _defineComponent13({
|
|
|
2101
2194
|
leafDirective: IncremarkContainer_default2,
|
|
2102
2195
|
textDirective: IncremarkContainer_default2
|
|
2103
2196
|
};
|
|
2197
|
+
const componentMap = computed9(() => ({
|
|
2198
|
+
...defaultComponentMap,
|
|
2199
|
+
...props.components
|
|
2200
|
+
}));
|
|
2104
2201
|
function getComponent(type) {
|
|
2105
|
-
return componentMap[type] || IncremarkDefault_default2;
|
|
2202
|
+
return componentMap.value[type] || IncremarkDefault_default2;
|
|
2106
2203
|
}
|
|
2107
2204
|
function isContainerNode(node) {
|
|
2108
2205
|
return node.type === "containerDirective" || node.type === "leafDirective" || node.type === "textDirective";
|
|
@@ -2110,14 +2207,14 @@ var IncremarkRenderer_default2 = /* @__PURE__ */ _defineComponent13({
|
|
|
2110
2207
|
function isHtmlNode2(node) {
|
|
2111
2208
|
return node.type === "html";
|
|
2112
2209
|
}
|
|
2113
|
-
const __returned__ = { props, componentMap, getComponent, isContainerNode, isHtmlNode: isHtmlNode2, IncremarkCode: IncremarkCode_default2, IncremarkContainer: IncremarkContainer_default2 };
|
|
2210
|
+
const __returned__ = { props, defaultComponentMap, componentMap, getComponent, isContainerNode, isHtmlNode: isHtmlNode2, IncremarkCode: IncremarkCode_default2, IncremarkContainer: IncremarkContainer_default2 };
|
|
2114
2211
|
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
2115
2212
|
return __returned__;
|
|
2116
2213
|
}
|
|
2117
2214
|
});
|
|
2118
2215
|
|
|
2119
2216
|
// sfc-template:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkRenderer.vue?type=template
|
|
2120
|
-
import { createCommentVNode as
|
|
2217
|
+
import { createCommentVNode as _createCommentVNode8, toDisplayString as _toDisplayString6, createElementVNode as _createElementVNode9, openBlock as _openBlock13, createElementBlock as _createElementBlock12, createVNode as _createVNode7, Fragment as _Fragment9, resolveDynamicComponent as _resolveDynamicComponent6, createBlock as _createBlock7 } from "vue";
|
|
2121
2218
|
var _hoisted_114 = {
|
|
2122
2219
|
key: 0,
|
|
2123
2220
|
class: "incremark-html-code"
|
|
@@ -2127,12 +2224,12 @@ function render13(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2127
2224
|
_Fragment9,
|
|
2128
2225
|
null,
|
|
2129
2226
|
[
|
|
2130
|
-
|
|
2227
|
+
_createCommentVNode8(" HTML \u8282\u70B9\uFF1A\u6E32\u67D3\u4E3A\u4EE3\u7801\u5757\u663E\u793A\u6E90\u4EE3\u7801 "),
|
|
2131
2228
|
$setup.isHtmlNode($props.node) ? (_openBlock13(), _createElementBlock12("pre", _hoisted_114, [
|
|
2132
2229
|
_createElementVNode9(
|
|
2133
2230
|
"code",
|
|
2134
2231
|
null,
|
|
2135
|
-
|
|
2232
|
+
_toDisplayString6($props.node.value),
|
|
2136
2233
|
1
|
|
2137
2234
|
/* TEXT */
|
|
2138
2235
|
)
|
|
@@ -2140,7 +2237,7 @@ function render13(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2140
2237
|
_Fragment9,
|
|
2141
2238
|
{ key: 1 },
|
|
2142
2239
|
[
|
|
2143
|
-
|
|
2240
|
+
_createCommentVNode8(" \u5BB9\u5668\u8282\u70B9\uFF1A\u4F7F\u7528\u5BB9\u5668\u7EC4\u4EF6\uFF0C\u4F20\u9012 customContainers "),
|
|
2144
2241
|
_createVNode7($setup["IncremarkContainer"], {
|
|
2145
2242
|
node: $props.node,
|
|
2146
2243
|
"custom-containers": $props.customContainers
|
|
@@ -2152,12 +2249,13 @@ function render13(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2152
2249
|
_Fragment9,
|
|
2153
2250
|
{ key: 2 },
|
|
2154
2251
|
[
|
|
2155
|
-
|
|
2252
|
+
_createCommentVNode8(" \u4EE3\u7801\u8282\u70B9\uFF1A\u7279\u6B8A\u5904\u7406\uFF0C\u4F20\u9012 customCodeBlocks\u3001codeBlockConfigs \u548C blockStatus "),
|
|
2156
2253
|
_createVNode7($setup["IncremarkCode"], {
|
|
2157
2254
|
node: $props.node,
|
|
2158
2255
|
"custom-code-blocks": $props.customCodeBlocks,
|
|
2256
|
+
"code-block-configs": $props.codeBlockConfigs,
|
|
2159
2257
|
"block-status": $props.blockStatus
|
|
2160
|
-
}, null, 8, ["node", "custom-code-blocks", "block-status"])
|
|
2258
|
+
}, null, 8, ["node", "custom-code-blocks", "code-block-configs", "block-status"])
|
|
2161
2259
|
],
|
|
2162
2260
|
2112
|
|
2163
2261
|
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
@@ -2165,7 +2263,7 @@ function render13(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2165
2263
|
_Fragment9,
|
|
2166
2264
|
{ key: 3 },
|
|
2167
2265
|
[
|
|
2168
|
-
|
|
2266
|
+
_createCommentVNode8(" \u5176\u4ED6\u8282\u70B9\uFF1A\u4F7F\u7528\u5BF9\u5E94\u7EC4\u4EF6 "),
|
|
2169
2267
|
(_openBlock13(), _createBlock7(_resolveDynamicComponent6($setup.getComponent($props.node.type)), {
|
|
2170
2268
|
node: $props.node
|
|
2171
2269
|
}, null, 8, ["node"]))
|
|
@@ -2185,18 +2283,20 @@ IncremarkRenderer_default2.__file = "src/components/IncremarkRenderer.vue";
|
|
|
2185
2283
|
var IncremarkRenderer_default = IncremarkRenderer_default2;
|
|
2186
2284
|
|
|
2187
2285
|
// sfc-script:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkFootnotes.vue?type=script
|
|
2286
|
+
import { defineComponent as _defineComponent14 } from "vue";
|
|
2287
|
+
import { computed as computed10 } from "vue";
|
|
2188
2288
|
var IncremarkFootnotes_default = /* @__PURE__ */ _defineComponent14({
|
|
2189
2289
|
__name: "IncremarkFootnotes",
|
|
2190
2290
|
setup(__props, { expose: __expose }) {
|
|
2191
2291
|
__expose();
|
|
2192
2292
|
const { footnoteDefinitions, footnoteReferenceOrder } = useDefinationsContext();
|
|
2193
|
-
const orderedFootnotes =
|
|
2293
|
+
const orderedFootnotes = computed10(() => {
|
|
2194
2294
|
return footnoteReferenceOrder.value.map((identifier) => ({
|
|
2195
2295
|
identifier,
|
|
2196
2296
|
definition: footnoteDefinitions.value[identifier]
|
|
2197
2297
|
})).filter((item) => item.definition !== void 0);
|
|
2198
2298
|
});
|
|
2199
|
-
const hasFootnotes =
|
|
2299
|
+
const hasFootnotes = computed10(() => orderedFootnotes.value.length > 0);
|
|
2200
2300
|
const __returned__ = { footnoteDefinitions, footnoteReferenceOrder, orderedFootnotes, hasFootnotes, IncremarkRenderer: IncremarkRenderer_default };
|
|
2201
2301
|
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
2202
2302
|
return __returned__;
|
|
@@ -2204,12 +2304,12 @@ var IncremarkFootnotes_default = /* @__PURE__ */ _defineComponent14({
|
|
|
2204
2304
|
});
|
|
2205
2305
|
|
|
2206
2306
|
// sfc-template:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkFootnotes.vue?type=template
|
|
2207
|
-
import { createElementVNode as _createElementVNode10, renderList as _renderList7, Fragment as _Fragment10, openBlock as _openBlock14, createElementBlock as _createElementBlock13, createCommentVNode as
|
|
2307
|
+
import { createElementVNode as _createElementVNode10, renderList as _renderList7, Fragment as _Fragment10, openBlock as _openBlock14, createElementBlock as _createElementBlock13, createCommentVNode as _createCommentVNode9, toDisplayString as _toDisplayString7, createBlock as _createBlock8 } from "vue";
|
|
2208
2308
|
var _hoisted_115 = {
|
|
2209
2309
|
key: 0,
|
|
2210
2310
|
class: "incremark-footnotes"
|
|
2211
2311
|
};
|
|
2212
|
-
var
|
|
2312
|
+
var _hoisted_27 = { class: "incremark-footnotes-list" };
|
|
2213
2313
|
var _hoisted_36 = ["id"];
|
|
2214
2314
|
var _hoisted_44 = { class: "incremark-footnote-content" };
|
|
2215
2315
|
var _hoisted_54 = { class: "incremark-footnote-number" };
|
|
@@ -2224,7 +2324,7 @@ function render14(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2224
2324
|
-1
|
|
2225
2325
|
/* CACHED */
|
|
2226
2326
|
)),
|
|
2227
|
-
_createElementVNode10("ol",
|
|
2327
|
+
_createElementVNode10("ol", _hoisted_27, [
|
|
2228
2328
|
(_openBlock14(true), _createElementBlock13(
|
|
2229
2329
|
_Fragment10,
|
|
2230
2330
|
null,
|
|
@@ -2235,15 +2335,15 @@ function render14(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2235
2335
|
class: "incremark-footnote-item"
|
|
2236
2336
|
}, [
|
|
2237
2337
|
_createElementVNode10("div", _hoisted_44, [
|
|
2238
|
-
|
|
2338
|
+
_createCommentVNode9(" \u811A\u6CE8\u5E8F\u53F7 "),
|
|
2239
2339
|
_createElementVNode10(
|
|
2240
2340
|
"span",
|
|
2241
2341
|
_hoisted_54,
|
|
2242
|
-
|
|
2342
|
+
_toDisplayString7(index + 1) + ".",
|
|
2243
2343
|
1
|
|
2244
2344
|
/* TEXT */
|
|
2245
2345
|
),
|
|
2246
|
-
|
|
2346
|
+
_createCommentVNode9(" \u811A\u6CE8\u5185\u5BB9 "),
|
|
2247
2347
|
_createElementVNode10("div", _hoisted_64, [
|
|
2248
2348
|
(_openBlock14(true), _createElementBlock13(
|
|
2249
2349
|
_Fragment10,
|
|
@@ -2259,7 +2359,7 @@ function render14(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2259
2359
|
))
|
|
2260
2360
|
])
|
|
2261
2361
|
]),
|
|
2262
|
-
|
|
2362
|
+
_createCommentVNode9(" \u8FD4\u56DE\u94FE\u63A5 "),
|
|
2263
2363
|
_createElementVNode10("a", {
|
|
2264
2364
|
href: `#fnref-${item.identifier}`,
|
|
2265
2365
|
class: "incremark-footnote-backref",
|
|
@@ -2271,7 +2371,7 @@ function render14(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2271
2371
|
/* KEYED_FRAGMENT */
|
|
2272
2372
|
))
|
|
2273
2373
|
])
|
|
2274
|
-
])) :
|
|
2374
|
+
])) : _createCommentVNode9("v-if", true);
|
|
2275
2375
|
}
|
|
2276
2376
|
|
|
2277
2377
|
// src/components/IncremarkFootnotes.vue
|
|
@@ -2284,9 +2384,11 @@ var Incremark_default = /* @__PURE__ */ _defineComponent15({
|
|
|
2284
2384
|
__name: "Incremark",
|
|
2285
2385
|
props: {
|
|
2286
2386
|
blocks: { type: Array, required: false, default: () => [] },
|
|
2387
|
+
isDisplayComplete: { type: Boolean, required: false, default: false },
|
|
2287
2388
|
components: { type: Object, required: false, default: () => ({}) },
|
|
2288
2389
|
customContainers: { type: Object, required: false, default: () => ({}) },
|
|
2289
2390
|
customCodeBlocks: { type: Object, required: false, default: () => ({}) },
|
|
2391
|
+
codeBlockConfigs: { type: Object, required: false, default: () => ({}) },
|
|
2290
2392
|
pendingClass: { type: String, required: false, default: "incremark-pending" },
|
|
2291
2393
|
completedClass: { type: String, required: false, default: "incremark-completed" },
|
|
2292
2394
|
showBlockStatus: { type: Boolean, required: false, default: false },
|
|
@@ -2294,53 +2396,29 @@ var Incremark_default = /* @__PURE__ */ _defineComponent15({
|
|
|
2294
2396
|
},
|
|
2295
2397
|
setup(__props, { expose: __expose }) {
|
|
2296
2398
|
__expose();
|
|
2297
|
-
function isHtmlNode2(node) {
|
|
2298
|
-
return node.type === "html";
|
|
2299
|
-
}
|
|
2300
2399
|
const props = __props;
|
|
2301
2400
|
const {
|
|
2302
2401
|
footnoteReferenceOrder
|
|
2303
2402
|
} = useDefinationsContext();
|
|
2304
|
-
const actualBlocks =
|
|
2305
|
-
const actualIsDisplayComplete =
|
|
2403
|
+
const actualBlocks = computed11(() => props.incremark?.blocks.value || props.blocks || []);
|
|
2404
|
+
const actualIsDisplayComplete = computed11(() => {
|
|
2306
2405
|
if (props.incremark) {
|
|
2307
2406
|
return props.incremark.isDisplayComplete.value;
|
|
2308
2407
|
}
|
|
2309
|
-
|
|
2310
|
-
return blocks.length > 0 && blocks.every((b) => b.status === "completed");
|
|
2408
|
+
return props.isDisplayComplete;
|
|
2311
2409
|
});
|
|
2312
|
-
const
|
|
2313
|
-
heading: IncremarkHeading_default2,
|
|
2314
|
-
paragraph: IncremarkParagraph_default2,
|
|
2315
|
-
code: IncremarkCode_default2,
|
|
2316
|
-
list: IncremarkList_default2,
|
|
2317
|
-
table: IncremarkTable_default2,
|
|
2318
|
-
blockquote: IncremarkBlockquote_default2,
|
|
2319
|
-
thematicBreak: IncremarkThematicBreak_default2,
|
|
2320
|
-
math: IncremarkMath_default2,
|
|
2321
|
-
inlineMath: IncremarkMath_default2,
|
|
2322
|
-
htmlElement: IncremarkHtmlElement_default2
|
|
2323
|
-
};
|
|
2324
|
-
const mergedComponents = computed10(() => ({
|
|
2325
|
-
...defaultComponents,
|
|
2326
|
-
...props.components
|
|
2327
|
-
}));
|
|
2328
|
-
const __returned__ = { isHtmlNode: isHtmlNode2, props, footnoteReferenceOrder, actualBlocks, actualIsDisplayComplete, defaultComponents, mergedComponents, IncremarkFootnotes: IncremarkFootnotes_default2, IncremarkRenderer: IncremarkRenderer_default };
|
|
2410
|
+
const __returned__ = { props, footnoteReferenceOrder, actualBlocks, actualIsDisplayComplete, IncremarkRenderer: IncremarkRenderer_default, IncremarkFootnotes: IncremarkFootnotes_default2 };
|
|
2329
2411
|
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
2330
2412
|
return __returned__;
|
|
2331
2413
|
}
|
|
2332
2414
|
});
|
|
2333
2415
|
|
|
2334
2416
|
// sfc-template:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/Incremark.vue?type=template
|
|
2335
|
-
import { createCommentVNode as
|
|
2417
|
+
import { createCommentVNode as _createCommentVNode10, renderList as _renderList8, Fragment as _Fragment11, openBlock as _openBlock15, createElementBlock as _createElementBlock14, createVNode as _createVNode8, normalizeClass as _normalizeClass4, createBlock as _createBlock9 } from "vue";
|
|
2336
2418
|
var _hoisted_116 = { class: "incremark" };
|
|
2337
|
-
var _hoisted_29 = {
|
|
2338
|
-
key: 0,
|
|
2339
|
-
class: "incremark-html-code"
|
|
2340
|
-
};
|
|
2341
2419
|
function render15(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2342
2420
|
return _openBlock15(), _createElementBlock14("div", _hoisted_116, [
|
|
2343
|
-
|
|
2421
|
+
_createCommentVNode10(" \u4E3B\u8981\u5185\u5BB9\u5757 "),
|
|
2344
2422
|
(_openBlock15(true), _createElementBlock14(
|
|
2345
2423
|
_Fragment11,
|
|
2346
2424
|
null,
|
|
@@ -2352,7 +2430,7 @@ function render15(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2352
2430
|
block.node.type !== "definition" && block.node.type !== "footnoteDefinition" ? (_openBlock15(), _createElementBlock14(
|
|
2353
2431
|
"div",
|
|
2354
2432
|
{
|
|
2355
|
-
key: block.
|
|
2433
|
+
key: block.id,
|
|
2356
2434
|
class: _normalizeClass4([
|
|
2357
2435
|
"incremark-block",
|
|
2358
2436
|
block.status === "completed" ? $props.completedClass : $props.pendingClass,
|
|
@@ -2361,34 +2439,19 @@ function render15(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2361
2439
|
])
|
|
2362
2440
|
},
|
|
2363
2441
|
[
|
|
2364
|
-
|
|
2365
|
-
$setup
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
])) : (_openBlock15(), _createElementBlock14(
|
|
2374
|
-
_Fragment11,
|
|
2375
|
-
{ key: 1 },
|
|
2376
|
-
[
|
|
2377
|
-
_createCommentVNode11(" \u5176\u4ED6\u8282\u70B9\uFF1A\u4F7F\u7528\u5BF9\u5E94\u7EC4\u4EF6\uFF0C\u4F20\u9012 customContainers \u548C customCodeBlocks "),
|
|
2378
|
-
_createVNode8($setup["IncremarkRenderer"], {
|
|
2379
|
-
node: block.node,
|
|
2380
|
-
"block-status": block.status,
|
|
2381
|
-
"custom-containers": $props.customContainers,
|
|
2382
|
-
"custom-code-blocks": $props.customCodeBlocks
|
|
2383
|
-
}, null, 8, ["node", "block-status", "custom-containers", "custom-code-blocks"])
|
|
2384
|
-
],
|
|
2385
|
-
2112
|
|
2386
|
-
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
2387
|
-
))
|
|
2442
|
+
_createCommentVNode10(" \u4F7F\u7528 IncremarkRenderer \u7EDF\u4E00\u5904\u7406\u6240\u6709\u8282\u70B9\u7C7B\u578B "),
|
|
2443
|
+
_createVNode8($setup["IncremarkRenderer"], {
|
|
2444
|
+
node: block.node,
|
|
2445
|
+
"block-status": block.status,
|
|
2446
|
+
"custom-containers": $props.customContainers,
|
|
2447
|
+
"custom-code-blocks": $props.customCodeBlocks,
|
|
2448
|
+
"code-block-configs": $props.codeBlockConfigs,
|
|
2449
|
+
components: $props.components
|
|
2450
|
+
}, null, 8, ["node", "block-status", "custom-containers", "custom-code-blocks", "code-block-configs", "components"])
|
|
2388
2451
|
],
|
|
2389
2452
|
2
|
|
2390
2453
|
/* CLASS */
|
|
2391
|
-
)) :
|
|
2454
|
+
)) : _createCommentVNode10("v-if", true)
|
|
2392
2455
|
],
|
|
2393
2456
|
64
|
|
2394
2457
|
/* STABLE_FRAGMENT */
|
|
@@ -2397,8 +2460,8 @@ function render15(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2397
2460
|
256
|
|
2398
2461
|
/* UNKEYED_FRAGMENT */
|
|
2399
2462
|
)),
|
|
2400
|
-
|
|
2401
|
-
$setup.actualIsDisplayComplete && $setup.footnoteReferenceOrder.length > 0 ? (_openBlock15(), _createBlock9($setup["IncremarkFootnotes"], { key: 0 })) :
|
|
2463
|
+
_createCommentVNode10(" \u811A\u6CE8\u5217\u8868\uFF08\u4EC5\u5728\u5185\u5BB9\u5B8C\u5168\u663E\u793A\u540E\u663E\u793A\uFF09 "),
|
|
2464
|
+
$setup.actualIsDisplayComplete && $setup.footnoteReferenceOrder.length > 0 ? (_openBlock15(), _createBlock9($setup["IncremarkFootnotes"], { key: 0 })) : _createCommentVNode10("v-if", true)
|
|
2402
2465
|
]);
|
|
2403
2466
|
}
|
|
2404
2467
|
|
|
@@ -2407,10 +2470,105 @@ Incremark_default.render = render15;
|
|
|
2407
2470
|
Incremark_default.__file = "src/components/Incremark.vue";
|
|
2408
2471
|
var Incremark_default2 = Incremark_default;
|
|
2409
2472
|
|
|
2410
|
-
// sfc-script:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/
|
|
2473
|
+
// sfc-script:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkContent.vue?type=script
|
|
2411
2474
|
import { defineComponent as _defineComponent16 } from "vue";
|
|
2412
|
-
import {
|
|
2413
|
-
var
|
|
2475
|
+
import { computed as computed12, watch as watch6 } from "vue";
|
|
2476
|
+
var IncremarkContent_default = /* @__PURE__ */ _defineComponent16({
|
|
2477
|
+
__name: "IncremarkContent",
|
|
2478
|
+
props: {
|
|
2479
|
+
stream: { type: Function, required: false },
|
|
2480
|
+
content: { type: String, required: false },
|
|
2481
|
+
components: { type: Object, required: false },
|
|
2482
|
+
customContainers: { type: Object, required: false },
|
|
2483
|
+
customCodeBlocks: { type: Object, required: false },
|
|
2484
|
+
codeBlockConfigs: { type: Object, required: false },
|
|
2485
|
+
isFinished: { type: Boolean, required: false },
|
|
2486
|
+
incremarkOptions: { type: Object, required: false },
|
|
2487
|
+
pendingClass: { type: String, required: false },
|
|
2488
|
+
showBlockStatus: { type: Boolean, required: false }
|
|
2489
|
+
},
|
|
2490
|
+
setup(__props, { expose: __expose }) {
|
|
2491
|
+
__expose();
|
|
2492
|
+
const props = __props;
|
|
2493
|
+
const incremarkOptions = computed12(() => ({
|
|
2494
|
+
gfm: true,
|
|
2495
|
+
htmlTree: true,
|
|
2496
|
+
containers: true,
|
|
2497
|
+
math: true,
|
|
2498
|
+
...props.incremarkOptions
|
|
2499
|
+
}));
|
|
2500
|
+
const { blocks, append, finalize, render: render19, reset, isDisplayComplete, markdown } = useIncremark(incremarkOptions);
|
|
2501
|
+
const isStreamMode = computed12(() => typeof props.stream === "function");
|
|
2502
|
+
async function handleStreamInput() {
|
|
2503
|
+
if (!props.stream) return;
|
|
2504
|
+
try {
|
|
2505
|
+
const stream = props.stream();
|
|
2506
|
+
for await (const chunk of stream) {
|
|
2507
|
+
append(chunk);
|
|
2508
|
+
}
|
|
2509
|
+
finalize();
|
|
2510
|
+
} catch (error) {
|
|
2511
|
+
console.error("Stream error: ", error);
|
|
2512
|
+
finalize();
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
function handleContentInput(newContent, oldContent) {
|
|
2516
|
+
if (!newContent) {
|
|
2517
|
+
if (oldContent) {
|
|
2518
|
+
reset();
|
|
2519
|
+
}
|
|
2520
|
+
return;
|
|
2521
|
+
}
|
|
2522
|
+
if (newContent?.startsWith(oldContent ?? "")) {
|
|
2523
|
+
const delta = newContent.slice((oldContent || "").length);
|
|
2524
|
+
append(delta);
|
|
2525
|
+
} else {
|
|
2526
|
+
render19(newContent);
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
watch6(() => props.content, async (newContent, oldContent) => {
|
|
2530
|
+
if (isStreamMode.value) {
|
|
2531
|
+
await handleStreamInput();
|
|
2532
|
+
return;
|
|
2533
|
+
} else {
|
|
2534
|
+
handleContentInput(newContent, oldContent);
|
|
2535
|
+
}
|
|
2536
|
+
}, { immediate: true });
|
|
2537
|
+
watch6(() => props.isFinished, (newIsFinished) => {
|
|
2538
|
+
if (newIsFinished && props.content === markdown.value) {
|
|
2539
|
+
finalize();
|
|
2540
|
+
}
|
|
2541
|
+
}, { immediate: true });
|
|
2542
|
+
const __returned__ = { props, incremarkOptions, blocks, append, finalize, render: render19, reset, isDisplayComplete, markdown, isStreamMode, handleStreamInput, handleContentInput, Incremark: Incremark_default2 };
|
|
2543
|
+
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
2544
|
+
return __returned__;
|
|
2545
|
+
}
|
|
2546
|
+
});
|
|
2547
|
+
|
|
2548
|
+
// sfc-template:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/IncremarkContent.vue?type=template
|
|
2549
|
+
import { openBlock as _openBlock16, createBlock as _createBlock10 } from "vue";
|
|
2550
|
+
function render16(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2551
|
+
return _openBlock16(), _createBlock10($setup["Incremark"], {
|
|
2552
|
+
blocks: $setup.blocks,
|
|
2553
|
+
"pending-class": $props.pendingClass,
|
|
2554
|
+
"is-display-complete": $setup.isDisplayComplete,
|
|
2555
|
+
"show-block-status": $props.showBlockStatus,
|
|
2556
|
+
components: $props.components,
|
|
2557
|
+
"custom-containers": $props.customContainers,
|
|
2558
|
+
"custom-code-blocks": $props.customCodeBlocks,
|
|
2559
|
+
"code-block-configs": $props.codeBlockConfigs
|
|
2560
|
+
}, null, 8, ["blocks", "pending-class", "is-display-complete", "show-block-status", "components", "custom-containers", "custom-code-blocks", "code-block-configs"]);
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
// src/components/IncremarkContent.vue
|
|
2564
|
+
IncremarkContent_default.render = render16;
|
|
2565
|
+
IncremarkContent_default.__file = "src/components/IncremarkContent.vue";
|
|
2566
|
+
var IncremarkContent_default2 = IncremarkContent_default;
|
|
2567
|
+
|
|
2568
|
+
// sfc-script:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/AutoScrollContainer.vue?type=script
|
|
2569
|
+
import { defineComponent as _defineComponent17 } from "vue";
|
|
2570
|
+
import { ref as ref7, onMounted as onMounted2, onUnmounted as onUnmounted6, nextTick } from "vue";
|
|
2571
|
+
var AutoScrollContainer_default = /* @__PURE__ */ _defineComponent17({
|
|
2414
2572
|
__name: "AutoScrollContainer",
|
|
2415
2573
|
props: {
|
|
2416
2574
|
enabled: { type: Boolean, required: false, default: true },
|
|
@@ -2419,8 +2577,8 @@ var AutoScrollContainer_default = /* @__PURE__ */ _defineComponent16({
|
|
|
2419
2577
|
},
|
|
2420
2578
|
setup(__props, { expose: __expose }) {
|
|
2421
2579
|
const props = __props;
|
|
2422
|
-
const containerRef =
|
|
2423
|
-
const isUserScrolledUp =
|
|
2580
|
+
const containerRef = ref7(null);
|
|
2581
|
+
const isUserScrolledUp = ref7(false);
|
|
2424
2582
|
let lastScrollTop = 0;
|
|
2425
2583
|
let lastScrollHeight = 0;
|
|
2426
2584
|
function isNearBottom() {
|
|
@@ -2518,9 +2676,9 @@ var AutoScrollContainer_default = /* @__PURE__ */ _defineComponent16({
|
|
|
2518
2676
|
});
|
|
2519
2677
|
|
|
2520
2678
|
// sfc-template:/Users/yishuai/develop/ai/markdown/packages/vue/src/components/AutoScrollContainer.vue?type=template
|
|
2521
|
-
import { renderSlot as _renderSlot, openBlock as
|
|
2522
|
-
function
|
|
2523
|
-
return
|
|
2679
|
+
import { renderSlot as _renderSlot, openBlock as _openBlock17, createElementBlock as _createElementBlock15 } from "vue";
|
|
2680
|
+
function render17(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2681
|
+
return _openBlock17(), _createElementBlock15(
|
|
2524
2682
|
"div",
|
|
2525
2683
|
{
|
|
2526
2684
|
ref: "containerRef",
|
|
@@ -2536,15 +2694,15 @@ function render16(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2536
2694
|
}
|
|
2537
2695
|
|
|
2538
2696
|
// src/components/AutoScrollContainer.vue
|
|
2539
|
-
AutoScrollContainer_default.render =
|
|
2697
|
+
AutoScrollContainer_default.render = render17;
|
|
2540
2698
|
AutoScrollContainer_default.__file = "src/components/AutoScrollContainer.vue";
|
|
2541
2699
|
var AutoScrollContainer_default2 = AutoScrollContainer_default;
|
|
2542
2700
|
|
|
2543
2701
|
// sfc-script:/Users/yishuai/develop/ai/markdown/packages/vue/src/ThemeProvider.vue?type=script
|
|
2544
|
-
import { defineComponent as
|
|
2545
|
-
import { ref as
|
|
2702
|
+
import { defineComponent as _defineComponent18 } from "vue";
|
|
2703
|
+
import { ref as ref8, watch as watch8 } from "vue";
|
|
2546
2704
|
import { applyTheme } from "@incremark/theme";
|
|
2547
|
-
var ThemeProvider_default = /* @__PURE__ */
|
|
2705
|
+
var ThemeProvider_default = /* @__PURE__ */ _defineComponent18({
|
|
2548
2706
|
__name: "ThemeProvider",
|
|
2549
2707
|
props: {
|
|
2550
2708
|
theme: { type: null, required: true },
|
|
@@ -2553,8 +2711,8 @@ var ThemeProvider_default = /* @__PURE__ */ _defineComponent17({
|
|
|
2553
2711
|
setup(__props, { expose: __expose }) {
|
|
2554
2712
|
__expose();
|
|
2555
2713
|
const props = __props;
|
|
2556
|
-
const containerRef =
|
|
2557
|
-
|
|
2714
|
+
const containerRef = ref8();
|
|
2715
|
+
watch8(
|
|
2558
2716
|
() => props.theme,
|
|
2559
2717
|
(theme) => {
|
|
2560
2718
|
if (containerRef.value) {
|
|
@@ -2570,9 +2728,9 @@ var ThemeProvider_default = /* @__PURE__ */ _defineComponent17({
|
|
|
2570
2728
|
});
|
|
2571
2729
|
|
|
2572
2730
|
// sfc-template:/Users/yishuai/develop/ai/markdown/packages/vue/src/ThemeProvider.vue?type=template
|
|
2573
|
-
import { renderSlot as _renderSlot2, normalizeClass as _normalizeClass5, openBlock as
|
|
2574
|
-
function
|
|
2575
|
-
return
|
|
2731
|
+
import { renderSlot as _renderSlot2, normalizeClass as _normalizeClass5, openBlock as _openBlock18, createElementBlock as _createElementBlock16 } from "vue";
|
|
2732
|
+
function render18(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2733
|
+
return _openBlock18(), _createElementBlock16(
|
|
2576
2734
|
"div",
|
|
2577
2735
|
{
|
|
2578
2736
|
ref: "containerRef",
|
|
@@ -2587,7 +2745,7 @@ function render17(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2587
2745
|
}
|
|
2588
2746
|
|
|
2589
2747
|
// src/ThemeProvider.vue
|
|
2590
|
-
ThemeProvider_default.render =
|
|
2748
|
+
ThemeProvider_default.render = render18;
|
|
2591
2749
|
ThemeProvider_default.__file = "src/ThemeProvider.vue";
|
|
2592
2750
|
var ThemeProvider_default2 = ThemeProvider_default;
|
|
2593
2751
|
|
|
@@ -2620,6 +2778,7 @@ export {
|
|
|
2620
2778
|
Incremark_default2 as Incremark,
|
|
2621
2779
|
IncremarkBlockquote_default2 as IncremarkBlockquote,
|
|
2622
2780
|
IncremarkCode_default2 as IncremarkCode,
|
|
2781
|
+
IncremarkContent_default2 as IncremarkContent,
|
|
2623
2782
|
IncremarkDefault_default2 as IncremarkDefault,
|
|
2624
2783
|
IncremarkFootnotes_default2 as IncremarkFootnotes,
|
|
2625
2784
|
IncremarkHeading_default2 as IncremarkHeading,
|