This commit is contained in:
2025-05-12 05:38:44 +09:00
parent dced21c3f8
commit 6d78bfa46e
8120 changed files with 1161564 additions and 0 deletions

View File

@ -0,0 +1,11 @@
/**
Edit the ref of an article
@param {Summary} summary
@param {string} level
@param {string} newRef
@return {Summary}
*/
declare function editArticleRef(summary: any, level: any, newRef: any): any;
export default editArticleRef;
//# sourceMappingURL=editArticleRef.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"editArticleRef.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/editArticleRef.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,iBAAS,cAAc,CAAC,OAAO,KAAA,EAAE,KAAK,KAAA,EAAE,MAAM,KAAA,OAI7C;AAED,eAAe,cAAc,CAAC"}

View File

@ -0,0 +1,20 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const mergeAtLevel_1 = __importDefault(require("./mergeAtLevel"));
/**
Edit the ref of an article
@param {Summary} summary
@param {string} level
@param {string} newRef
@return {Summary}
*/
function editArticleRef(summary, level, newRef) {
return (0, mergeAtLevel_1.default)(summary, level, {
ref: newRef
});
}
exports.default = editArticleRef;

View File

@ -0,0 +1,11 @@
/**
Edit title of an article
@param {Summary} summary
@param {string} level
@param {string} newTitle
@return {Summary}
*/
declare function editArticleTitle(summary: any, level: any, newTitle: any): any;
export default editArticleTitle;
//# sourceMappingURL=editArticleTitle.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"editArticleTitle.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/editArticleTitle.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,iBAAS,gBAAgB,CAAC,OAAO,KAAA,EAAE,KAAK,KAAA,EAAE,QAAQ,KAAA,OAIjD;AAED,eAAe,gBAAgB,CAAC"}

View File

@ -0,0 +1,20 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const mergeAtLevel_1 = __importDefault(require("./mergeAtLevel"));
/**
Edit title of an article
@param {Summary} summary
@param {string} level
@param {string} newTitle
@return {Summary}
*/
function editArticleTitle(summary, level, newTitle) {
return (0, mergeAtLevel_1.default)(summary, level, {
title: newTitle
});
}
exports.default = editArticleTitle;

View File

@ -0,0 +1,11 @@
/**
Edit title of a part in the summary
@param {Summary} summary
@param {number} index
@param {string} newTitle
@return {Summary}
*/
declare function editPartTitle(summary: any, index: any, newTitle: any): any;
export default editPartTitle;
//# sourceMappingURL=editPartTitle.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"editPartTitle.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/editPartTitle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,iBAAS,aAAa,CAAC,OAAO,KAAA,EAAE,KAAK,KAAA,EAAE,QAAQ,KAAA,OAY9C;AAED,eAAe,aAAa,CAAC"}

View File

@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
Edit title of a part in the summary
@param {Summary} summary
@param {number} index
@param {string} newTitle
@return {Summary}
*/
function editPartTitle(summary, index, newTitle) {
let parts = summary.getParts();
let part = parts.get(index);
if (!part) {
return summary;
}
part = part.set("title", newTitle);
parts = parts.set(index, part);
return summary.set("parts", parts);
}
exports.default = editPartTitle;

View File

@ -0,0 +1,24 @@
import moveArticleAfter0 from "./moveArticleAfter";
import moveArticle0 from "./moveArticle";
import insertArticle0 from "./insertArticle";
import removeArticle0 from "./removeArticle";
import unshiftArticle0 from "./unshiftArticle";
import editArticleTitle0 from "./editArticleTitle";
import editArticleRef0 from "./editArticleRef";
import insertPart0 from "./insertPart";
import removePart0 from "./removePart";
import editPartTitle0 from "./editPartTitle";
declare const _default: {
insertArticle: typeof insertArticle0;
moveArticle: typeof moveArticle0;
moveArticleAfter: typeof moveArticleAfter0;
removeArticle: typeof removeArticle0;
unshiftArticle: typeof unshiftArticle0;
editArticleTitle: typeof editArticleTitle0;
editArticleRef: typeof editArticleRef0;
insertPart: typeof insertPart0;
removePart: typeof removePart0;
editPartTitle: typeof editPartTitle0;
};
export default _default;
//# sourceMappingURL=index.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/index.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,cAAc,MAAM,iBAAiB,CAAC;AAC7C,OAAO,cAAc,MAAM,iBAAiB,CAAC;AAC7C,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,cAAc,MAAM,iBAAiB,CAAC;;;;;;;;;;;;;AAE7C,wBAWE"}

View File

@ -0,0 +1,27 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const moveArticleAfter_1 = __importDefault(require("./moveArticleAfter"));
const moveArticle_1 = __importDefault(require("./moveArticle"));
const insertArticle_1 = __importDefault(require("./insertArticle"));
const removeArticle_1 = __importDefault(require("./removeArticle"));
const unshiftArticle_1 = __importDefault(require("./unshiftArticle"));
const editArticleTitle_1 = __importDefault(require("./editArticleTitle"));
const editArticleRef_1 = __importDefault(require("./editArticleRef"));
const insertPart_1 = __importDefault(require("./insertPart"));
const removePart_1 = __importDefault(require("./removePart"));
const editPartTitle_1 = __importDefault(require("./editPartTitle"));
exports.default = {
insertArticle: insertArticle_1.default,
moveArticle: moveArticle_1.default,
moveArticleAfter: moveArticleAfter_1.default,
removeArticle: removeArticle_1.default,
unshiftArticle: unshiftArticle_1.default,
editArticleTitle: editArticleTitle_1.default,
editArticleRef: editArticleRef_1.default,
insertPart: insertPart_1.default,
removePart: removePart_1.default,
editPartTitle: editPartTitle_1.default
};

View File

@ -0,0 +1,10 @@
/**
Index levels in an article tree
@param {Article}
@param {string} baseLevel
@return {Article}
*/
declare function indexArticleLevels(article: any, baseLevel: any): any;
export default indexArticleLevels;
//# sourceMappingURL=indexArticleLevels.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"indexArticleLevels.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/indexArticleLevels.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iBAAS,kBAAkB,CAAC,OAAO,KAAA,EAAE,SAAS,KAAA,OAY7C;AAED,eAAe,kBAAkB,CAAC"}

View File

@ -0,0 +1,21 @@
"use strict";
/**
Index levels in an article tree
@param {Article}
@param {string} baseLevel
@return {Article}
*/
Object.defineProperty(exports, "__esModule", { value: true });
function indexArticleLevels(article, baseLevel) {
baseLevel = baseLevel || article.getLevel();
let articles = article.getArticles();
articles = articles.map((inner, i) => {
return indexArticleLevels(inner, `${baseLevel}.${i + 1}`);
});
return article.merge({
level: baseLevel,
articles: articles
});
}
exports.default = indexArticleLevels;

View File

@ -0,0 +1,9 @@
/**
Index all levels in the summary
@param {Summary}
@return {Summary}
*/
declare function indexLevels(summary: any): any;
export default indexLevels;
//# sourceMappingURL=indexLevels.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"indexLevels.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/indexLevels.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,iBAAS,WAAW,CAAC,OAAO,KAAA,OAK3B;AAED,eAAe,WAAW,CAAC"}

View File

@ -0,0 +1,18 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const indexPartLevels_1 = __importDefault(require("./indexPartLevels"));
/**
Index all levels in the summary
@param {Summary}
@return {Summary}
*/
function indexLevels(summary) {
let parts = summary.getParts();
parts = parts.map(indexPartLevels_1.default);
return summary.set("parts", parts);
}
exports.default = indexLevels;

View File

@ -0,0 +1,10 @@
/**
Index levels in a part
@param {Part}
@param {number} index
@return {Part}
*/
declare function indexPartLevels(part: any, index: any): any;
export default indexPartLevels;
//# sourceMappingURL=indexPartLevels.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"indexPartLevels.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/indexPartLevels.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,iBAAS,eAAe,CAAC,IAAI,KAAA,EAAE,KAAK,KAAA,OAYnC;AAED,eAAe,eAAe,CAAC"}

View File

@ -0,0 +1,25 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const indexArticleLevels_1 = __importDefault(require("./indexArticleLevels"));
/**
Index levels in a part
@param {Part}
@param {number} index
@return {Part}
*/
function indexPartLevels(part, index) {
const baseLevel = String(index + 1);
let articles = part.getArticles();
articles = articles.map((inner, i) => {
return (0, indexArticleLevels_1.default)(inner, `${baseLevel}.${i + 1}`);
});
return part.merge({
level: baseLevel,
articles: articles
});
}
exports.default = indexPartLevels;

View File

@ -0,0 +1,12 @@
/**
Returns a new Summary with the article at the given level, with
subsequent article shifted.
@param {Summary} summary
@param {Article} article
@param {String|Article} level: level to insert at
@return {Summary}
*/
declare function insertArticle(summary: any, article: any, level: any): any;
export default insertArticle;
//# sourceMappingURL=insertArticle.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"insertArticle.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/insertArticle.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AAEH,iBAAS,aAAa,CAAC,OAAO,KAAA,EAAE,OAAO,KAAA,EAAE,KAAK,KAAA,OAuB7C;AAaD,eAAe,aAAa,CAAC"}

View File

@ -0,0 +1,47 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const is_1 = __importDefault(require("is"));
const summaryArticle_1 = __importDefault(require("../../models/summaryArticle"));
const mergeAtLevel_1 = __importDefault(require("./mergeAtLevel"));
const indexArticleLevels_1 = __importDefault(require("./indexArticleLevels"));
/**
Returns a new Summary with the article at the given level, with
subsequent article shifted.
@param {Summary} summary
@param {Article} article
@param {String|Article} level: level to insert at
@return {Summary}
*/
function insertArticle(summary, article, level) {
article = new summaryArticle_1.default(article);
level = is_1.default.string(level) ? level : level.getLevel();
let parent = summary.getParent(level);
if (!parent) {
return summary;
}
// Find the index to insert at
let articles = parent.getArticles();
const index = getLeafIndex(level);
// Insert the article at the right index
articles = articles.insert(index, article);
// Reindex the level from here
parent = parent.set("articles", articles);
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
parent = (0, indexArticleLevels_1.default)(parent);
return (0, mergeAtLevel_1.default)(summary, parent.getLevel(), parent);
}
/**
@param {string}
@return {number} The index of this level within its parent's children
*/
function getLeafIndex(level) {
const arr = level.split(".").map((char) => {
return parseInt(char, 10);
});
return arr[arr.length - 1] - 1;
}
exports.default = insertArticle;

View File

@ -0,0 +1,13 @@
import SummaryPart from "../../models/summaryPart";
import Summary from "../../models/summary";
/**
Returns a new Summary with a part inserted at given index
@param {Summary} summary
@param {Part} part
@param {number} index
@return {Summary}
*/
declare function insertPart(summary: Summary, part: SummaryPart, index: number): any;
export default insertPart;
//# sourceMappingURL=insertPart.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"insertPart.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/insertPart.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAE3C;;;;;;;GAOG;AACH,iBAAS,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,OAKrE;AAED,eAAe,UAAU,CAAC"}

View File

@ -0,0 +1,21 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const summaryPart_1 = __importDefault(require("../../models/summaryPart"));
const indexLevels_1 = __importDefault(require("./indexLevels"));
/**
Returns a new Summary with a part inserted at given index
@param {Summary} summary
@param {Part} part
@param {number} index
@return {Summary}
*/
function insertPart(summary, part, index) {
part = new summaryPart_1.default(part);
const parts = summary.getParts().insert(index, part);
return (0, indexLevels_1.default)(summary.set("parts", parts));
}
exports.default = insertPart;

View File

@ -0,0 +1,11 @@
/**
Edit an article, or a part, in a summary. Does a shallow merge.
@param {Summary} summary
@param {string} level
@param {Article|Part} newValue
@return {Summary}
*/
declare function mergeAtLevel(summary: any, level: any, newValue: any): any;
export default mergeAtLevel;
//# sourceMappingURL=mergeAtLevel.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"mergeAtLevel.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/mergeAtLevel.ts"],"names":[],"mappings":"AAyCA;;;;;;;GAOG;AAEH,iBAAS,YAAY,CAAC,OAAO,KAAA,EAAE,KAAK,KAAA,EAAE,QAAQ,KAAA,OAmB7C;AAED,eAAe,YAAY,CAAC"}

View File

@ -0,0 +1,68 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
Edit a list of articles
@param {List<Article>} articles
@param {string} level
@param {Article} newArticle
@return {List<Article>}
*/
function editArticleInList(articles, level, newArticle) {
return articles.map((article) => {
const articleLevel = article.getLevel();
if (articleLevel === level) {
// it is the article to edit
return article.merge(newArticle);
}
else if (level.indexOf(articleLevel) === 0) {
// it is a parent
const articles = editArticleInList(article.getArticles(), level, newArticle);
return article.set("articles", articles);
}
else {
// This is not the article you are looking for
return article;
}
});
}
/**
Edit an article in a part
@param {Part} part
@param {string} level
@param {Article} newArticle
@return {Part}
*/
function editArticleInPart(part, level, newArticle) {
let articles = part.getArticles();
articles = editArticleInList(articles, level, newArticle);
return part.set("articles", articles);
}
/**
Edit an article, or a part, in a summary. Does a shallow merge.
@param {Summary} summary
@param {string} level
@param {Article|Part} newValue
@return {Summary}
*/
function mergeAtLevel(summary, level, newValue) {
const levelParts = level.split(".");
const partIndex = Number(levelParts[0]) - 1;
let parts = summary.getParts();
let part = parts.get(partIndex);
if (!part) {
return summary;
}
const isEditingPart = levelParts.length < 2;
if (isEditingPart) {
part = part.merge(newValue);
}
else {
part = editArticleInPart(part, level, newValue);
}
parts = parts.set(partIndex, part);
return summary.set("parts", parts);
}
exports.default = mergeAtLevel;

View File

@ -0,0 +1,12 @@
/**
Returns a new summary, with the given article removed from its
origin level, and placed at the given target level.
@param {Summary} summary
@param {String|SummaryArticle} origin: level to remove
@param {String|SummaryArticle} target: the level where the article will be found
@return {Summary}
*/
declare function moveArticle(summary: any, origin: any, target: any): any;
export default moveArticle;
//# sourceMappingURL=moveArticle.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"moveArticle.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/moveArticle.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,iBAAS,WAAW,CAAC,OAAO,KAAA,EAAE,MAAM,KAAA,EAAE,MAAM,KAAA,OAS3C;AAED,eAAe,WAAW,CAAC"}

View File

@ -0,0 +1,27 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const is_1 = __importDefault(require("is"));
const removeArticle_1 = __importDefault(require("./removeArticle"));
const insertArticle_1 = __importDefault(require("./insertArticle"));
/**
Returns a new summary, with the given article removed from its
origin level, and placed at the given target level.
@param {Summary} summary
@param {String|SummaryArticle} origin: level to remove
@param {String|SummaryArticle} target: the level where the article will be found
@return {Summary}
*/
function moveArticle(summary, origin, target) {
// Coerce to level
const originLevel = is_1.default.string(origin) ? origin : origin.getLevel();
const targetLevel = is_1.default.string(target) ? target : target.getLevel();
const article = summary.getByLevel(originLevel);
// Remove first
const removed = (0, removeArticle_1.default)(summary, originLevel);
return (0, insertArticle_1.default)(removed, article, targetLevel);
}
exports.default = moveArticle;

View File

@ -0,0 +1,13 @@
/**
Returns a new summary, with the an article moved after another
article. Unlike `moveArticle`, does not ensure that the article
will be found at the target's level plus one.
@param {Summary} summary
@param {String|SummaryArticle} origin
@param {String|SummaryArticle} afterTarget
@return {Summary}
*/
declare function moveArticleAfter(summary: any, origin: any, afterTarget: any): any;
export default moveArticleAfter;
//# sourceMappingURL=moveArticleAfter.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"moveArticleAfter.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/moveArticleAfter.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,iBAAS,gBAAgB,CAAC,OAAO,KAAA,EAAE,MAAM,KAAA,EAAE,WAAW,KAAA,OAmBrD;AA0BD,eAAe,gBAAgB,CAAC"}

View File

@ -0,0 +1,59 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const is_1 = __importDefault(require("is"));
const removeArticle_1 = __importDefault(require("./removeArticle"));
const insertArticle_1 = __importDefault(require("./insertArticle"));
/**
Returns a new summary, with the an article moved after another
article. Unlike `moveArticle`, does not ensure that the article
will be found at the target's level plus one.
@param {Summary} summary
@param {String|SummaryArticle} origin
@param {String|SummaryArticle} afterTarget
@return {Summary}
*/
function moveArticleAfter(summary, origin, afterTarget) {
// Coerce to level
const originLevel = is_1.default.string(origin) ? origin : origin.getLevel();
const afterTargetLevel = is_1.default.string(afterTarget) ? afterTarget : afterTarget.getLevel();
const article = summary.getByLevel(originLevel);
const targetLevel = increment(afterTargetLevel);
if (targetLevel < origin) {
// Remove first
const removed = (0, removeArticle_1.default)(summary, originLevel);
// Insert then
return (0, insertArticle_1.default)(removed, article, targetLevel);
}
else {
// Insert right after first
const inserted = (0, insertArticle_1.default)(summary, article, targetLevel);
// Remove old one
return (0, removeArticle_1.default)(inserted, originLevel);
}
}
/**
@param {string}
@return {Array<Number>}
*/
function levelToArray(l) {
return l.split(".").map((char) => {
return parseInt(char, 10);
});
}
/**
@param {Array<Number>}
@return {string}
*/
function arrayToLevel(a) {
return a.join(".");
}
function increment(level) {
level = levelToArray(level);
level[level.length - 1]++;
return arrayToLevel(level);
}
exports.default = moveArticleAfter;

View File

@ -0,0 +1,10 @@
/**
Remove an article from a level.
@param {Summary} summary
@param {String|SummaryArticle} level: level to remove
@return {Summary}
*/
declare function removeArticle(summary: any, level: any): any;
export default removeArticle;
//# sourceMappingURL=removeArticle.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"removeArticle.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/removeArticle.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH,iBAAS,aAAa,CAAC,OAAO,KAAA,EAAE,KAAK,KAAA,OAyBpC;AAED,eAAe,aAAa,CAAC"}

View File

@ -0,0 +1,36 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const is_1 = __importDefault(require("is"));
const mergeAtLevel_1 = __importDefault(require("./mergeAtLevel"));
const indexArticleLevels_1 = __importDefault(require("./indexArticleLevels"));
/**
Remove an article from a level.
@param {Summary} summary
@param {String|SummaryArticle} level: level to remove
@return {Summary}
*/
function removeArticle(summary, level) {
// Coerce to level
level = is_1.default.string(level) ? level : level.getLevel();
let parent = summary.getParent(level);
let articles = parent.getArticles();
// Find the index to remove
const index = articles.findIndex((art) => {
return art.getLevel() === level;
});
if (index === -1) {
return summary;
}
// Remove from children
articles = articles.remove(index);
parent = parent.set("articles", articles);
// Reindex the level from here
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
parent = (0, indexArticleLevels_1.default)(parent);
return (0, mergeAtLevel_1.default)(summary, parent.getLevel(), parent);
}
exports.default = removeArticle;

View File

@ -0,0 +1,10 @@
/**
Remove a part at given index
@param {Summary} summary
@param {Number|} index
@return {Summary}
*/
declare function removePart(summary: any, index: any): any;
export default removePart;
//# sourceMappingURL=removePart.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"removePart.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/removePart.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,iBAAS,UAAU,CAAC,OAAO,KAAA,EAAE,KAAK,KAAA,OAGjC;AAED,eAAe,UAAU,CAAC"}

View File

@ -0,0 +1,18 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const indexLevels_1 = __importDefault(require("./indexLevels"));
/**
Remove a part at given index
@param {Summary} summary
@param {Number|} index
@return {Summary}
*/
function removePart(summary, index) {
const parts = summary.getParts().remove(index);
return (0, indexLevels_1.default)(summary.set("parts", parts));
}
exports.default = removePart;

View File

@ -0,0 +1,10 @@
/**
Insert an article at the beginning of summary
@param {Summary} summary
@param {Article} article
@return {Summary}
*/
declare function unshiftArticle(summary: any, article: any): any;
export default unshiftArticle;
//# sourceMappingURL=unshiftArticle.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"unshiftArticle.d.ts","sourceRoot":"","sources":["../../../src/modifiers/summary/unshiftArticle.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,iBAAS,cAAc,CAAC,OAAO,KAAA,EAAE,OAAO,KAAA,OAcvC;AAED,eAAe,cAAc,CAAC"}

View File

@ -0,0 +1,27 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const summaryArticle_1 = __importDefault(require("../../models/summaryArticle"));
const summaryPart_1 = __importDefault(require("../../models/summaryPart"));
const indexLevels_1 = __importDefault(require("./indexLevels"));
/**
Insert an article at the beginning of summary
@param {Summary} summary
@param {Article} article
@return {Summary}
*/
function unshiftArticle(summary, article) {
article = new summaryArticle_1.default(article);
let parts = summary.getParts();
let part = parts.get(0) || new summaryPart_1.default();
let articles = part.getArticles();
articles = articles.unshift(article);
part = part.set("articles", articles);
parts = parts.set(0, part);
summary = summary.set("parts", parts);
return (0, indexLevels_1.default)(summary);
}
exports.default = unshiftArticle;