@interactive-inc/docs-client 1.0.15 → 1.0.16
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/build/index.d.ts +2 -10
- package/build/index.js +15 -43
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -219,10 +219,6 @@ declare class DocFileMdContentValue<T extends DocCustomSchema> {
|
|
|
219
219
|
* Generate from Markdown text
|
|
220
220
|
*/
|
|
221
221
|
static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T): DocFileMdContentValue<T>;
|
|
222
|
-
/**
|
|
223
|
-
* Generate complete Markdown text
|
|
224
|
-
*/
|
|
225
|
-
toMarkdownText(): string;
|
|
226
222
|
/**
|
|
227
223
|
* Generate complete text combining FrontMatter and body
|
|
228
224
|
*/
|
|
@@ -1331,10 +1327,6 @@ declare class DocFileIndexContentValue<T extends DocCustomSchema> {
|
|
|
1331
1327
|
* Generate from Markdown text
|
|
1332
1328
|
*/
|
|
1333
1329
|
static fromMarkdown<T extends DocCustomSchema>(markdown: string, customSchema: T, config: DocClientConfig): DocFileIndexContentValue<T>;
|
|
1334
|
-
/**
|
|
1335
|
-
* Generate complete Markdown text
|
|
1336
|
-
*/
|
|
1337
|
-
toMarkdownText(): string;
|
|
1338
1330
|
/**
|
|
1339
1331
|
* Update content
|
|
1340
1332
|
*/
|
|
@@ -1668,11 +1660,11 @@ declare class DocMarkdownSystem {
|
|
|
1668
1660
|
*/
|
|
1669
1661
|
extractDescription(text: string): string | null;
|
|
1670
1662
|
/**
|
|
1671
|
-
* Update title in body
|
|
1663
|
+
* Update title in body (returns body only, without FrontMatter)
|
|
1672
1664
|
*/
|
|
1673
1665
|
updateTitle(text: string, newTitle: string): string;
|
|
1674
1666
|
/**
|
|
1675
|
-
* Update description in body
|
|
1667
|
+
* Update description in body (returns body only, without FrontMatter)
|
|
1676
1668
|
*/
|
|
1677
1669
|
updateDescription(text: string, newDescription: string, defaultTitle: string): string;
|
|
1678
1670
|
/**
|
package/build/index.js
CHANGED
|
@@ -398,40 +398,30 @@ ${separator}`, separator.length);
|
|
|
398
398
|
return null;
|
|
399
399
|
}
|
|
400
400
|
/**
|
|
401
|
-
* Update title in body
|
|
401
|
+
* Update title in body (returns body only, without FrontMatter)
|
|
402
402
|
*/
|
|
403
403
|
updateTitle(text, newTitle) {
|
|
404
|
-
const
|
|
405
|
-
const lines = body.split("\n");
|
|
404
|
+
const lines = text.split("\n");
|
|
406
405
|
const titleIndex = lines.findIndex((line) => line.match(/^#\s+/));
|
|
407
406
|
if (titleIndex !== -1) {
|
|
408
407
|
lines[titleIndex] = `# ${newTitle}`;
|
|
409
408
|
} else {
|
|
410
409
|
lines.unshift(`# ${newTitle}`, "");
|
|
411
410
|
}
|
|
412
|
-
|
|
413
|
-
const frontMatter = this.extractFrontMatter(text);
|
|
414
|
-
const separator = this.detectFrontMatterSeparator(text);
|
|
415
|
-
return frontMatter ? `${separator}
|
|
416
|
-
${frontMatter}
|
|
417
|
-
${separator}
|
|
418
|
-
|
|
419
|
-
${updatedBody}` : updatedBody;
|
|
411
|
+
return lines.join("\n");
|
|
420
412
|
}
|
|
421
413
|
/**
|
|
422
|
-
* Update description in body
|
|
414
|
+
* Update description in body (returns body only, without FrontMatter)
|
|
423
415
|
*/
|
|
424
416
|
updateDescription(text, newDescription, defaultTitle) {
|
|
425
|
-
const
|
|
426
|
-
const lines = body.split("\n");
|
|
417
|
+
const lines = text.split("\n");
|
|
427
418
|
const titleIndex = lines.findIndex((line) => line.match(/^#\s+/));
|
|
428
|
-
let updatedBody;
|
|
429
419
|
if (titleIndex === -1) {
|
|
430
|
-
|
|
420
|
+
return `# ${defaultTitle}
|
|
431
421
|
|
|
432
422
|
${newDescription}
|
|
433
423
|
|
|
434
|
-
${
|
|
424
|
+
${text}`.trim();
|
|
435
425
|
} else {
|
|
436
426
|
const descIndex = this.skipEmptyLines(lines, titleIndex + 1);
|
|
437
427
|
if (descIndex < lines.length && lines[descIndex] && !lines[descIndex].startsWith("#")) {
|
|
@@ -439,15 +429,8 @@ ${body}`.trim();
|
|
|
439
429
|
} else {
|
|
440
430
|
lines.splice(titleIndex + 1, 0, "", newDescription);
|
|
441
431
|
}
|
|
442
|
-
|
|
432
|
+
return lines.join("\n");
|
|
443
433
|
}
|
|
444
|
-
const frontMatter = this.extractFrontMatter(text);
|
|
445
|
-
const separator = this.detectFrontMatterSeparator(text);
|
|
446
|
-
return frontMatter ? `${separator}
|
|
447
|
-
${frontMatter}
|
|
448
|
-
${separator}
|
|
449
|
-
|
|
450
|
-
${updatedBody}` : updatedBody;
|
|
451
434
|
}
|
|
452
435
|
/**
|
|
453
436
|
* Skip empty lines
|
|
@@ -1524,12 +1507,6 @@ var DocFileMdContentValue = class _DocFileMdContentValue {
|
|
|
1524
1507
|
customSchema
|
|
1525
1508
|
);
|
|
1526
1509
|
}
|
|
1527
|
-
/**
|
|
1528
|
-
* Generate complete Markdown text
|
|
1529
|
-
*/
|
|
1530
|
-
toMarkdownText() {
|
|
1531
|
-
return DocMarkdownSystem.from(this.title, this.description, this.body);
|
|
1532
|
-
}
|
|
1533
1510
|
/**
|
|
1534
1511
|
* Generate complete text combining FrontMatter and body
|
|
1535
1512
|
*/
|
|
@@ -3072,17 +3049,16 @@ var DocFileIndexContentValue = class _DocFileIndexContentValue {
|
|
|
3072
3049
|
* Update description
|
|
3073
3050
|
*/
|
|
3074
3051
|
withDescription(description, defaultTitle) {
|
|
3075
|
-
const fullText = this.toText();
|
|
3076
3052
|
const engine = new DocMarkdownSystem();
|
|
3077
|
-
const
|
|
3078
|
-
|
|
3053
|
+
const updatedBody = engine.updateDescription(
|
|
3054
|
+
this.body,
|
|
3079
3055
|
description,
|
|
3080
3056
|
defaultTitle || this.title
|
|
3081
3057
|
);
|
|
3082
3058
|
return new _DocFileIndexContentValue(
|
|
3083
3059
|
{
|
|
3084
3060
|
...this.value,
|
|
3085
|
-
body:
|
|
3061
|
+
body: updatedBody,
|
|
3086
3062
|
description
|
|
3087
3063
|
},
|
|
3088
3064
|
this.customSchema,
|
|
@@ -3111,12 +3087,6 @@ var DocFileIndexContentValue = class _DocFileIndexContentValue {
|
|
|
3111
3087
|
config
|
|
3112
3088
|
);
|
|
3113
3089
|
}
|
|
3114
|
-
/**
|
|
3115
|
-
* Generate complete Markdown text
|
|
3116
|
-
*/
|
|
3117
|
-
toMarkdownText() {
|
|
3118
|
-
return DocMarkdownSystem.from(this.title, this.description, this.body);
|
|
3119
|
-
}
|
|
3120
3090
|
/**
|
|
3121
3091
|
* Update content
|
|
3122
3092
|
*/
|
|
@@ -3178,11 +3148,13 @@ schema: {}
|
|
|
3178
3148
|
schema: this.meta().schema().toJson()
|
|
3179
3149
|
};
|
|
3180
3150
|
const yamlStr = stringify3(yamlData).trim();
|
|
3181
|
-
|
|
3151
|
+
const text = `---
|
|
3182
3152
|
${yamlStr}
|
|
3183
3153
|
---
|
|
3184
3154
|
|
|
3185
|
-
${this.
|
|
3155
|
+
${this.body.trim()}`;
|
|
3156
|
+
return `${text.trim()}
|
|
3157
|
+
`;
|
|
3186
3158
|
}
|
|
3187
3159
|
/**
|
|
3188
3160
|
* Output in JSON format
|