From 160ac19058ffdebb5f38e28f1567c8956834b473 Mon Sep 17 00:00:00 2001 From: kasahala <4k.kasahara@gmail.com> Date: Thu, 19 Dec 2024 17:16:27 +0900 Subject: [PATCH 1/6] feat: Tentative generic implementation of remove style --- src/constant/regExp.ts | 6 +++ src/features/applyHeading/module.ts | 36 +++++++++-------- src/settings.ts | 21 +++++++++- src/utils/markdown.ts | 17 ++++++++ test/features.test.ts | 9 +++++ test/utils.test.ts | 63 ++++++++++++++++++++++++++++- 6 files changed, 133 insertions(+), 19 deletions(-) create mode 100644 src/constant/regExp.ts diff --git a/src/constant/regExp.ts b/src/constant/regExp.ts new file mode 100644 index 0000000..40b3d1d --- /dev/null +++ b/src/constant/regExp.ts @@ -0,0 +1,6 @@ +export const RegExpExample = { + ol: String.raw`^\d+\. (.*)`, + ul: String.raw`^(?:\-|\*) (.*)`, + bold: String.raw`(?:\*\*|__)(.*?)(?:\*\*|__)`, + italic: String.raw`(?:\*|_)(.*?)(?:\*|_)`, +}; diff --git a/src/features/applyHeading/module.ts b/src/features/applyHeading/module.ts index 97da500..6b6107b 100644 --- a/src/features/applyHeading/module.ts +++ b/src/features/applyHeading/module.ts @@ -1,7 +1,10 @@ import { HeadingShifterSettings } from "settings"; +import { removeFromRegExpStrings } from "utils/markdown"; -const regExp: Record = - { ol: new RegExp("\\d+\\."), ul: new RegExp("\\-|\\*") }; +const regExp: Record = { + ol: new RegExp("\\d+\\. (.*)"), + ul: new RegExp("\\-|\\* (.*)"), +}; /**Return heading applied string from chunk * @return heading applied string @@ -11,25 +14,24 @@ const regExp: Record = export const applyHeading = ( chunk: string, headingSize: number, - settings?: HeadingShifterSettings + settings?: Partial ): string => { - const replacer = Object.entries(settings?.styleToRemove ?? {}).flatMap( - ([k, v]: [ - keyof HeadingShifterSettings["styleToRemove"], - boolean - ]) => { - return v ? regExp[k].source : []; - } - ); - - const replaceStyleRegExp = new RegExp(`^(${replacer.join("|")}) `, ""); - - const remove = chunk.replace(replaceStyleRegExp, "").replace(/^#+ /, ""); + const removed = removeFromRegExpStrings(chunk, [ + ...Object.entries(settings?.styleToRemove ?? {}).flatMap( + ([k, v]: [ + keyof HeadingShifterSettings["styleToRemove"], + boolean + ]) => { + return v ? regExp[k].source : []; + } + ), + ...(settings?.stylesToRemove ?? []), + ]); - if (headingSize <= 0) return remove; + if (headingSize <= 0) return removed; return ( new Array(headingSize).fill("#").reduce((prev, cur) => { return cur + prev; - }, " ") + remove + }, " ") + removed ); }; diff --git a/src/settings.ts b/src/settings.ts index 33e3289..871de90 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -6,12 +6,14 @@ export interface HeadingShifterSettings { limitHeadingFrom: number; overrideTab: boolean; styleToRemove: { ul: boolean; ol: boolean }; + stylesToRemove: string[]; } export const DEFAULT_SETTINGS: HeadingShifterSettings = { limitHeadingFrom: 1, overrideTab: false, styleToRemove: { ul: true, ol: true }, + stylesToRemove: [], }; export class HeadingShifterSettingTab extends PluginSettingTab { @@ -64,7 +66,9 @@ export class HeadingShifterSettingTab extends PluginSettingTab { ); containerEl.createEl("h3", { text: "Style to remove" }); - containerEl.createEl('p', { text: "If this style is at the beginning of a line, replace it by a Heading:" }); + containerEl.createEl("p", { + text: "If this style is at the beginning of a line, replace it by a Heading:", + }); new Setting(containerEl) .setName("Unordered list") @@ -88,5 +92,20 @@ export class HeadingShifterSettingTab extends PluginSettingTab { await this.plugin.saveSettings(); }) ); + + containerEl.createEl("h3", { text: "Styles to remove" }); + containerEl.createEl("p", { + text: "If this style is at the beginning of a line, replace it by a Heading:", + }); + + new Setting(containerEl).setName("RegExp list").addTextArea((str) => { + str.setValue( + this.plugin.settings.stylesToRemove.join("\n") + ).onChange(async (str) => { + this.plugin.settings.stylesToRemove = str.split("\n"); + console.log(this.plugin.settings.stylesToRemove); + await this.plugin.saveSettings(); + }); + }); } } diff --git a/src/utils/markdown.ts b/src/utils/markdown.ts index a9f63fd..7c57466 100644 --- a/src/utils/markdown.ts +++ b/src/utils/markdown.ts @@ -88,3 +88,20 @@ export const getPreviousHeading = ( // no heading found return undefined; }; + +export const removeFromRegExpStrings = ( + str: string, + regExpStrings: string[] +): string => { + const remove = regExpStrings + .reduce((acc, cur) => { + try { + return acc.replace(new RegExp(cur), "$1"); + } catch (error) { + return acc; + } + }, str) + .replace(/^#+ /, ""); + + return remove; +}; diff --git a/test/features.test.ts b/test/features.test.ts index 2d11a3a..1129d08 100644 --- a/test/features.test.ts +++ b/test/features.test.ts @@ -1,3 +1,4 @@ +import { RegExpExample } from "constant/regExp"; import { applyHeading } from "features/applyHeading"; import { decreaseHeading, increaseHeading } from "features/shiftHeading/module"; @@ -23,6 +24,14 @@ describe("apply heading", () => { test("Heading 10", () => { expect(applyHeading(content, 10)).toBe(`########## ${content}`); }); + + test("With Replace", () => { + expect( + applyHeading(`# **${content}**`, 0, { + stylesToRemove: [RegExpExample.ul, RegExpExample.bold], + }) + ).toBe(`${content}`); + }); }); describe("increase heading", () => { diff --git a/test/utils.test.ts b/test/utils.test.ts index 5a86598..51aba7a 100644 --- a/test/utils.test.ts +++ b/test/utils.test.ts @@ -1,3 +1,4 @@ +import { RegExpExample } from "constant/regExp"; import { composeLineChanges } from "utils/editorChange"; import { checkFence, @@ -5,7 +6,8 @@ import { FenceType, getFenceStatus, getHeadingLines, - getPreviousHeading + getPreviousHeading, + removeFromRegExpStrings, } from "utils/markdown"; import { createRange } from "utils/range"; @@ -216,3 +218,62 @@ describe("range", () => { expect(createRange(0, 3)).toStrictEqual([0, 1, 2]); }); }); + +describe("regExp Example", () => { + const content = "EXAMPLE"; + + test("bold(**)", () => { + expect( + removeFromRegExpStrings(`**${content}**`, [RegExpExample.bold]) + ).toBe(content); + }); + test("bold(__)", () => { + expect( + removeFromRegExpStrings(`__${content}__`, [RegExpExample.bold]) + ).toBe(content); + }); + + test("italic(*)", () => { + expect( + removeFromRegExpStrings(`*${content}*`, [RegExpExample.italic]) + ).toBe(content); + }); + test("italic(__)", () => { + expect( + removeFromRegExpStrings(`_${content}_`, [RegExpExample.italic]) + ).toBe(content); + }); + + test("ol(1)", () => { + expect( + removeFromRegExpStrings(`1. ${content}`, [RegExpExample.ol]) + ).toBe(content); + }); + test("ol(1234567890)", () => { + expect( + removeFromRegExpStrings(`1234567890. ${content}`, [ + RegExpExample.ol, + ]) + ).toBe(content); + }); + + test("ul(-)", () => { + expect( + removeFromRegExpStrings(`- ${content}`, [RegExpExample.ul]) + ).toBe(content); + }); + test("ul(*)", () => { + expect( + removeFromRegExpStrings(`* ${content}`, [RegExpExample.ul]) + ).toBe(content); + }); + + test("all", () => { + expect( + removeFromRegExpStrings(`- 1. ${content}`, [ + RegExpExample.ul, + RegExpExample.ol, + ]) + ).toBe(content); + }); +}); From 9c8567d62f30a4a67e95e1b41fba09786de5c7c3 Mon Sep 17 00:00:00 2001 From: kasahala <4k.kasahara@gmail.com> Date: Thu, 19 Dec 2024 18:51:08 +0900 Subject: [PATCH 2/6] feat: Implementing REMOVE by splitting into BEGGING and SURROUND --- src/constant/regExp.ts | 15 +++-- src/features/applyHeading/module.ts | 53 +++++++++++----- src/main.ts | 3 + src/settings.ts | 96 ++++++++++++++++++++++------- src/utils/markdown.ts | 51 +++++++++++---- src/utils/object.ts | 45 ++++++++++++++ test/features.test.ts | 44 ++++++++++--- test/utils.test.ts | 69 +++++++++++++++------ 8 files changed, 294 insertions(+), 82 deletions(-) create mode 100644 src/utils/object.ts diff --git a/src/constant/regExp.ts b/src/constant/regExp.ts index 40b3d1d..8c2f3d9 100644 --- a/src/constant/regExp.ts +++ b/src/constant/regExp.ts @@ -1,6 +1,13 @@ export const RegExpExample = { - ol: String.raw`^\d+\. (.*)`, - ul: String.raw`^(?:\-|\*) (.*)`, - bold: String.raw`(?:\*\*|__)(.*?)(?:\*\*|__)`, - italic: String.raw`(?:\*|_)(.*?)(?:\*|_)`, + head: { + ol: String.raw`\d+\.`, + ul: String.raw`(?:\-|\*)`, + }, + surround: { + // Only one match + italic: String.raw`(?:(? = { - ol: new RegExp("\\d+\\. (.*)"), - ul: new RegExp("\\-|\\* (.*)"), -}; +import { checkHeading, removeUsingRegexpStrings } from "utils/markdown"; /**Return heading applied string from chunk * @return heading applied string @@ -16,17 +13,41 @@ export const applyHeading = ( headingSize: number, settings?: Partial ): string => { - const removed = removeFromRegExpStrings(chunk, [ - ...Object.entries(settings?.styleToRemove ?? {}).flatMap( - ([k, v]: [ - keyof HeadingShifterSettings["styleToRemove"], - boolean - ]) => { - return v ? regExp[k].source : []; + const extractRegExp = ( + settingObj: Record, + regExpObj: Record + ): string[] => { + return Object.entries(settingObj ?? {}).flatMap(([k, v]) => { + if (Array.isArray(v)) { + return v; + } + if (k in regExpObj && v == true) { + return regExpObj[k as keyof typeof regExpObj]; } - ), - ...(settings?.stylesToRemove ?? []), - ]); + return []; + }); + }; + + let removed = chunk; + + // Remove any style only when it is not HEADING (because it may be daring to put it on when HEADING) + if (!checkHeading(chunk)) { + removed = settings?.styleToRemove + ? removeUsingRegexpStrings(chunk, { + beginning: extractRegExp( + settings.styleToRemove.beginning, + RegExpExample.head + ), + surround: extractRegExp( + settings.styleToRemove.surround, + RegExpExample.surround + ), + }) + : chunk; + } + + // Once all headings are set to 0 + removed = removed.replace(/^#+ /, ""); if (headingSize <= 0) return removed; return ( diff --git a/src/main.ts b/src/main.ts index aaa2576..45a887b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,6 +8,7 @@ import { import { ObsidianService } from "services/obsidianService"; import { InterfaceService } from "services/interfaceService"; import { RegisterService } from "services/registerService"; +import { assingUnknownObjectFromDefaultObject } from "utils/object"; export default class HeadingShifter extends Plugin { settings: HeadingShifterSettings; @@ -28,6 +29,8 @@ export default class HeadingShifter extends Plugin { this.interfaceService.exec(); // Setting + // There is a possibility of undefined access when the structure of setting is changed (should be done more carefully, but it is handled by corrective default override). + assingUnknownObjectFromDefaultObject(DEFAULT_SETTINGS, this.settings); this.addSettingTab(new HeadingShifterSettingTab(this.app, this)); } diff --git a/src/settings.ts b/src/settings.ts index 871de90..ecbabc9 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -2,18 +2,22 @@ import HeadingShifter from "main"; import { PluginSettingTab, App, Setting } from "obsidian"; import { HEADINGS } from "types/type"; -export interface HeadingShifterSettings { +export type HeadingShifterSettings = { limitHeadingFrom: number; overrideTab: boolean; - styleToRemove: { ul: boolean; ol: boolean }; - stylesToRemove: string[]; -} + styleToRemove: { + beginning: { ul: boolean; ol: boolean; others: string[] }; + surround: { bold: boolean; italic: boolean; others: string[] }; + }; +}; export const DEFAULT_SETTINGS: HeadingShifterSettings = { limitHeadingFrom: 1, overrideTab: false, - styleToRemove: { ul: true, ol: true }, - stylesToRemove: [], + styleToRemove: { + beginning: { ul: true, ol: true, others: [] }, + surround: { bold: false, italic: false, others: [] }, + }, }; export class HeadingShifterSettingTab extends PluginSettingTab { @@ -67,17 +71,18 @@ export class HeadingShifterSettingTab extends PluginSettingTab { containerEl.createEl("h3", { text: "Style to remove" }); containerEl.createEl("p", { - text: "If this style is at the beginning of a line, replace it by a Heading:", + text: "If this style is at the of a line, remove it", }); + containerEl.createEl("b", { text: "Beggining" }); new Setting(containerEl) .setName("Unordered list") .setDesc("-") .addToggle((toggle) => toggle - .setValue(this.plugin.settings.styleToRemove.ul) + .setValue(this.plugin.settings.styleToRemove?.beginning?.ul) .onChange(async (value) => { - this.plugin.settings.styleToRemove.ul = value; + this.plugin.settings.styleToRemove.beginning.ul = value; await this.plugin.saveSettings(); }) ); @@ -86,26 +91,71 @@ export class HeadingShifterSettingTab extends PluginSettingTab { .setDesc("1., 2. ,3. ,...") .addToggle((toggle) => toggle - .setValue(this.plugin.settings.styleToRemove.ol) + .setValue(this.plugin.settings.styleToRemove?.beginning?.ol) .onChange(async (value) => { - this.plugin.settings.styleToRemove.ol = value; + this.plugin.settings.styleToRemove.beginning.ol = value; await this.plugin.saveSettings(); }) ); + new Setting(containerEl) + .setName("Others") + .setDesc("Arbitrary string (regular expression)") + .addTextArea((str) => { + str.setValue( + this.plugin.settings.styleToRemove.beginning?.others?.join( + "\n" + ) + ).onChange(async (str) => { + this.plugin.settings.styleToRemove.beginning.others = + str.split("\n"); + await this.plugin.saveSettings(); + }); + }); - containerEl.createEl("h3", { text: "Styles to remove" }); - containerEl.createEl("p", { - text: "If this style is at the beginning of a line, replace it by a Heading:", + containerEl.createEl("b", { + text: "Surround", }); - - new Setting(containerEl).setName("RegExp list").addTextArea((str) => { - str.setValue( - this.plugin.settings.stylesToRemove.join("\n") - ).onChange(async (str) => { - this.plugin.settings.stylesToRemove = str.split("\n"); - console.log(this.plugin.settings.stylesToRemove); - await this.plugin.saveSettings(); + new Setting(containerEl) + .setName("Bold") + .setDesc("**|__") + .addToggle((toggle) => + toggle + .setValue( + this.plugin.settings.styleToRemove?.surround?.bold + ) + .onChange(async (value) => { + this.plugin.settings.styleToRemove.surround.bold = + value; + await this.plugin.saveSettings(); + }) + ); + new Setting(containerEl) + .setName("Italic") + .setDesc("*|_") + .addToggle((toggle) => + toggle + .setValue( + this.plugin.settings.styleToRemove?.surround?.italic + ) + .onChange(async (value) => { + this.plugin.settings.styleToRemove.surround.italic = + value; + await this.plugin.saveSettings(); + }) + ); + new Setting(containerEl) + .setName("Others") + .setDesc("Arbitrary string (regular expression)") + .addTextArea((str) => { + str.setValue( + this.plugin.settings.styleToRemove?.surround?.others?.join( + "\n" + ) + ).onChange(async (str) => { + this.plugin.settings.styleToRemove.surround.others = + str.split("\n"); + await this.plugin.saveSettings(); + }); }); - }); } } diff --git a/src/utils/markdown.ts b/src/utils/markdown.ts index 7c57466..d7b5765 100644 --- a/src/utils/markdown.ts +++ b/src/utils/markdown.ts @@ -89,19 +89,44 @@ export const getPreviousHeading = ( return undefined; }; -export const removeFromRegExpStrings = ( +/** Returns the result of the substitution only when the substitution is performed, otherwise undefined */ +const replaceFunc = (str: string, regExp: RegExp): string | undefined => { + try { + const replaced = str.replace(regExp, "$1"); + if (replaced !== str) { + return replaced; + } + } catch (error) { + console.error(error); + } + return undefined; +}; + +export const removeUsingRegexpStrings = ( str: string, - regExpStrings: string[] + regExpStrings: { beginning?: string[]; surround?: string[] } ): string => { - const remove = regExpStrings - .reduce((acc, cur) => { - try { - return acc.replace(new RegExp(cur), "$1"); - } catch (error) { - return acc; - } - }, str) - .replace(/^#+ /, ""); - - return remove; + let removed = str; + + // beginning + for (const regExpStr of regExpStrings.beginning ?? []) { + const regExp = new RegExp(`^${regExpStr} (.*)`); + const result = replaceFunc(removed, regExp); + if (result !== undefined) { + removed = result; + break; + } + } + + // surround + for (const regExpStr of regExpStrings.surround ?? []) { + const regExp = new RegExp(`${regExpStr}(.*)${regExpStr}`); + const result = replaceFunc(removed, regExp); + if (result !== undefined) { + removed = result; + break; + } + } + + return removed; }; diff --git a/src/utils/object.ts b/src/utils/object.ts new file mode 100644 index 0000000..f5b4795 --- /dev/null +++ b/src/utils/object.ts @@ -0,0 +1,45 @@ +export const assingUnknownObjectFromDefaultObject = ( + defaultObject: Record, + targetObject: Record +) => { + Object.entries(defaultObject).map(([k, v]) => { + if (v === null) { + return; + } + + if (isPlainRecord(v)) { + const newTargetObject = targetObject[k]; + if (isPlainRecord(newTargetObject)) { + assingUnknownObjectFromDefaultObject(v, newTargetObject); + } else { + targetObject[k] = v; + } + return; + } + + if (targetObject[k] === null || targetObject[k] === undefined) { + targetObject[k] = v; + return; + } + }); +}; +function isPlainRecord(value: unknown): value is Record { + // まず、valueがオブジェクトであり、nullではないかを確認 + if (typeof value !== "object" || value === null) { + return false; + } + + // valueが配列、Map、Setなどの特殊なオブジェクトでないことを確認 + if (Array.isArray(value) || value instanceof Map || value instanceof Set) { + return false; + } + + // すべてのキーが文字列であることを確認 + for (const key in value) { + if (typeof key !== "string") { + return false; + } + } + + return true; +} diff --git a/test/features.test.ts b/test/features.test.ts index 1129d08..378efb5 100644 --- a/test/features.test.ts +++ b/test/features.test.ts @@ -1,4 +1,3 @@ -import { RegExpExample } from "constant/regExp"; import { applyHeading } from "features/applyHeading"; import { decreaseHeading, increaseHeading } from "features/shiftHeading/module"; @@ -25,12 +24,43 @@ describe("apply heading", () => { expect(applyHeading(content, 10)).toBe(`########## ${content}`); }); - test("With Replace", () => { - expect( - applyHeading(`# **${content}**`, 0, { - stylesToRemove: [RegExpExample.ul, RegExpExample.bold], - }) - ).toBe(`${content}`); + describe("With Replace", () => { + test("default regexp", () => { + expect( + applyHeading(`**${content}**`, 0, { + styleToRemove: { + beginning: { ol: true, ul: false, others: [] }, + surround: { bold: true, italic: false, others: [] }, + }, + }) + ).toBe(`${content}`); + }); + + test("input regexp", () => { + expect( + applyHeading(`+ &&${content}&&`, 0, { + styleToRemove: { + beginning: { + ol: true, + ul: true, + others: [String.raw`\+`], + }, + surround: { bold: true, italic: true, others: ["&&"] }, + }, + }) + ).toBe(`${content}`); + }); + + test("Not applicable when there is heading", () => { + expect( + applyHeading(`# **${content}**`, 0, { + styleToRemove: { + beginning: { ol: true, ul: false, others: [] }, + surround: { bold: true, italic: false, others: [] }, + }, + }) + ).toBe(`**${content}**`); + }); }); }); diff --git a/test/utils.test.ts b/test/utils.test.ts index 51aba7a..5b9b9a4 100644 --- a/test/utils.test.ts +++ b/test/utils.test.ts @@ -7,8 +7,9 @@ import { getFenceStatus, getHeadingLines, getPreviousHeading, - removeFromRegExpStrings, + removeUsingRegexpStrings, } from "utils/markdown"; +import { assingUnknownObjectFromDefaultObject } from "utils/object"; import { createRange } from "utils/range"; @@ -57,7 +58,7 @@ describe("checkFence", () => { describe("fenceStatus", () => { const fences: ("`" | "~")[] = ["`", `~`]; - for (let fenceType of fences) { + for (const fenceType of fences) { test(`start fence(${fenceType})`, () => { const result: FenceType = { fenceType, fenceNum: 3 }; expect(getFenceStatus(null, result)).toEqual(result); @@ -224,56 +225,86 @@ describe("regExp Example", () => { test("bold(**)", () => { expect( - removeFromRegExpStrings(`**${content}**`, [RegExpExample.bold]) + removeUsingRegexpStrings(`**${content}**`, { + surround: [RegExpExample.surround.bold], + }) ).toBe(content); }); test("bold(__)", () => { expect( - removeFromRegExpStrings(`__${content}__`, [RegExpExample.bold]) + removeUsingRegexpStrings(`__${content}__`, { + surround: [RegExpExample.surround.bold], + }) ).toBe(content); }); test("italic(*)", () => { expect( - removeFromRegExpStrings(`*${content}*`, [RegExpExample.italic]) + removeUsingRegexpStrings(`*${content}*`, { + surround: [RegExpExample.surround.italic], + }) ).toBe(content); }); test("italic(__)", () => { expect( - removeFromRegExpStrings(`_${content}_`, [RegExpExample.italic]) + removeUsingRegexpStrings(`_${content}_`, { + surround: [RegExpExample.surround.italic], + }) ).toBe(content); }); test("ol(1)", () => { expect( - removeFromRegExpStrings(`1. ${content}`, [RegExpExample.ol]) + removeUsingRegexpStrings(`1. ${content}`, { + beginning: [RegExpExample.head.ol], + }) ).toBe(content); }); test("ol(1234567890)", () => { expect( - removeFromRegExpStrings(`1234567890. ${content}`, [ - RegExpExample.ol, - ]) + removeUsingRegexpStrings(`1234567890. ${content}`, { + beginning: [RegExpExample.head.ol], + }) ).toBe(content); }); test("ul(-)", () => { expect( - removeFromRegExpStrings(`- ${content}`, [RegExpExample.ul]) + removeUsingRegexpStrings(`- ${content}`, { + beginning: [RegExpExample.head.ul], + }) ).toBe(content); }); test("ul(*)", () => { expect( - removeFromRegExpStrings(`* ${content}`, [RegExpExample.ul]) + removeUsingRegexpStrings(`* ${content}`, { + beginning: [RegExpExample.head.ul], + }) ).toBe(content); }); +}); - test("all", () => { - expect( - removeFromRegExpStrings(`- 1. ${content}`, [ - RegExpExample.ul, - RegExpExample.ol, - ]) - ).toBe(content); +describe("assingUnknownObjectFromDefaultObject", () => { + const defaultObj = { + str: "string", + num: 1, + obj: { str: "string", num: 1 }, + arr: [1, 2, 3], + }; + test("all properties are null", () => { + const UnknownObj = {}; + assingUnknownObjectFromDefaultObject(defaultObj, UnknownObj); + expect(UnknownObj).toStrictEqual(defaultObj); + }); + + test("some properties are null", () => { + const UnknownObj = { str: "other string", obj: { num: 2 } }; + assingUnknownObjectFromDefaultObject(defaultObj, UnknownObj); + expect(UnknownObj).toStrictEqual({ + str: UnknownObj.str, + num: defaultObj.num, + obj: { str: defaultObj.obj.str, num: UnknownObj.obj.num }, + arr: defaultObj.arr, + }); }); }); From e6bac440c30825f8cbfb8bbe92b82bbebd70f337 Mon Sep 17 00:00:00 2001 From: kasahala <4k.kasahara@gmail.com> Date: Thu, 19 Dec 2024 18:52:59 +0900 Subject: [PATCH 3/6] doc: update style to remove doc --- README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8753d97..6b725eb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ - ![github release](https://img.shields.io/github/v/release/k4a-dev/obsidian-heading-shifter?style=for-the-badge) [![PayPal](https://github.com/user-attachments/assets/022d3ada-7995-4a27-b680-5ab6cfc117e1)](https://paypal.me/k4al) @@ -88,31 +87,35 @@ Download directory(includes `main.js, manifest.json, styles.css`) from the lates ## Common Settings -| Setting | Description | Value(Default) | -| --------------- | ------------------------------------------------------------------------- | ----------------- | -| Style to remove | If this style is at the beginning of a line, remove it and make it Heading | boolean(All true) | +| Setting | Description | Value(Default) | +| ------------------------------------------------------------- | ------------------------------------------------------- | ----------------- | +| Style to remove(default) | If this style is at the of a line, remove it | boolean(All true) | +| Style to remove(Other arbitrary group of regular expressions) | If this style is at the of a line, remove it | string[]([]) | ### Detailed Description + #### Style to remove This is the toggle between removing or retaining the leading `-` or `1.`,`2.`,... when applying Heading in a "single" row. before + ``` - line ``` after (`True`) + ``` ## line ``` after (`False`) + ``` ## - line ``` - #### Use Case Operate headings like an outliner like the following, From 40589dcca350724eadc605fb134de9243efb1122 Mon Sep 17 00:00:00 2001 From: kasahala <4k.kasahara@gmail.com> Date: Thu, 19 Dec 2024 19:11:58 +0900 Subject: [PATCH 4/6] version 1.7.0 --- manifest.json | 2 +- package.json | 2 +- versions.json | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index 068b34a..71d8ad2 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-heading-shifter", "name": "Heading Shifter", - "version": "1.6.1", + "version": "1.7.0", "minAppVersion": "0.12.0", "description": "Easily Shift and Change markdown headings.", "author": "kasahala", diff --git a/package.json b/package.json index c33da25..c456881 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-heading-shifter", - "version": "1.6.1", + "version": "1.7.0", "description": "Easily shift multiple heading of markdown", "main": "main.js", "type": "module", diff --git a/versions.json b/versions.json index 6dc7677..eadba1f 100644 --- a/versions.json +++ b/versions.json @@ -8,5 +8,6 @@ "1.5.0": "0.12.0", "1.5.1": "0.12.0", "1.6.0": "0.12.0", - "1.6.1": "0.12.0" + "1.6.1": "0.12.0", + "1.7.0": "0.12.0" } \ No newline at end of file From f9e8e9651d7f4401f1406d696f12b59899e6e077 Mon Sep 17 00:00:00 2001 From: kasahala <4k.kasahara@gmail.com> Date: Fri, 20 Dec 2024 01:20:57 +0900 Subject: [PATCH 5/6] fix: typo --- src/settings.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/settings.ts b/src/settings.ts index ecbabc9..c88e322 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -74,7 +74,7 @@ export class HeadingShifterSettingTab extends PluginSettingTab { text: "If this style is at the of a line, remove it", }); - containerEl.createEl("b", { text: "Beggining" }); + containerEl.createEl("b", { text: "Beginning" }); new Setting(containerEl) .setName("Unordered list") .setDesc("-") @@ -98,7 +98,7 @@ export class HeadingShifterSettingTab extends PluginSettingTab { }) ); new Setting(containerEl) - .setName("Others") + .setName("User defined") .setDesc("Arbitrary string (regular expression)") .addTextArea((str) => { str.setValue( @@ -113,7 +113,7 @@ export class HeadingShifterSettingTab extends PluginSettingTab { }); containerEl.createEl("b", { - text: "Surround", + text: "Surrounding", }); new Setting(containerEl) .setName("Bold") @@ -144,7 +144,7 @@ export class HeadingShifterSettingTab extends PluginSettingTab { }) ); new Setting(containerEl) - .setName("Others") + .setName("User defined") .setDesc("Arbitrary string (regular expression)") .addTextArea((str) => { str.setValue( From 4738acf8580fcf0a7449700fccc28100f753ccff Mon Sep 17 00:00:00 2001 From: kasahala <4k.kasahara@gmail.com> Date: Fri, 20 Dec 2024 01:26:34 +0900 Subject: [PATCH 6/6] refactor: fix type and add cspell --- .eslintrc | 48 +- .gitignore | 3 - .vscode/settings.json | 1 + config/jest.config.ts | 2 +- package-lock.json | 957 ++++++++++++++++++++++++- package.json | 4 +- src/constant/regExp.ts | 4 +- src/features/applyHeading/module.ts | 8 +- src/features/applyHeading/operation.ts | 6 +- src/features/shiftHeading/operation.ts | 8 +- src/main.ts | 4 +- src/services/obsidianService.ts | 2 +- src/services/registerService.ts | 8 +- src/settings.ts | 24 +- src/utils/markdown.ts | 6 +- src/utils/object.ts | 4 +- test/features.test.ts | 24 +- test/utils.test.ts | 30 +- 18 files changed, 1062 insertions(+), 81 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.eslintrc b/.eslintrc index 0807290..f5e9b2d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,23 +1,45 @@ { "root": true, "parser": "@typescript-eslint/parser", - "env": { "node": true }, + "env": { + "node": true + }, "plugins": [ - "@typescript-eslint" + "@typescript-eslint" ], "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended" - ], + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@cspell/recommended" + ], "parserOptions": { "sourceType": "module" }, "rules": { - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], - "@typescript-eslint/ban-ts-comment": "off", - "no-prototype-builtins": "off", - "@typescript-eslint/no-empty-function": "off" - } - } \ No newline at end of file + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": [ + "error", + { + "args": "none" + } + ], + "@typescript-eslint/ban-ts-comment": "off", + "no-prototype-builtins": "off", + "@typescript-eslint/no-empty-function": "off", + "@cspell/spellchecker": [ + "warn", + { + "cspell": { + "language": "en", + "ignoreRegExpList": [ + // 日本語を無視 + "[0-9A-Za-zぁ-んァ-ヶ亜-熙纊-黑]+", + "keymap", + "Prec" + ] + } + } + ] + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index a05d58d..0a6ea79 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ -# vscode -.vscode - # Intellij *.iml .idea diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/config/jest.config.ts b/config/jest.config.ts index 79f6e08..d88d79e 100644 --- a/config/jest.config.ts +++ b/config/jest.config.ts @@ -18,7 +18,7 @@ const config: Config.InitialOptions = { }, globals: { "ts-jest": { - tsonfig: "tsconfig.json", + tsconfig: "tsconfig.json", isolatedModules: true, }, }, diff --git a/package-lock.json b/package-lock.json index 7ddbc9a..25fdb97 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-heading-shifter", - "version": "1.5.1", + "version": "1.7.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-heading-shifter", - "version": "1.5.1", + "version": "1.7.0", "license": "MIT", "dependencies": { "@codemirror/state": "^6.1.1", @@ -15,6 +15,7 @@ "ts-node": "^10.9.1" }, "devDependencies": { + "@cspell/eslint-plugin": "^8.17.1", "@types/jest": "^28.1.6", "@types/node": "^16.11.6", "@typescript-eslint/eslint-plugin": "5.29.0", @@ -626,6 +627,580 @@ "w3c-keyname": "^2.2.4" } }, + "node_modules/@cspell/cspell-bundled-dicts": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-8.17.1.tgz", + "integrity": "sha512-HmkXS5uX4bk/XxsRS4Q+zRvhgRa81ddGiR2/Xfag9MIi5L5UnEJ4g21EpmIlXkMxYrTu2fp69SZFss5NfcFF9Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspell/dict-ada": "^4.0.5", + "@cspell/dict-al": "^1.0.3", + "@cspell/dict-aws": "^4.0.7", + "@cspell/dict-bash": "^4.1.8", + "@cspell/dict-companies": "^3.1.8", + "@cspell/dict-cpp": "^6.0.2", + "@cspell/dict-cryptocurrencies": "^5.0.3", + "@cspell/dict-csharp": "^4.0.5", + "@cspell/dict-css": "^4.0.16", + "@cspell/dict-dart": "^2.2.4", + "@cspell/dict-django": "^4.1.3", + "@cspell/dict-docker": "^1.1.11", + "@cspell/dict-dotnet": "^5.0.8", + "@cspell/dict-elixir": "^4.0.6", + "@cspell/dict-en_us": "^4.3.28", + "@cspell/dict-en-common-misspellings": "^2.0.7", + "@cspell/dict-en-gb": "1.1.33", + "@cspell/dict-filetypes": "^3.0.9", + "@cspell/dict-flutter": "^1.0.3", + "@cspell/dict-fonts": "^4.0.3", + "@cspell/dict-fsharp": "^1.0.4", + "@cspell/dict-fullstack": "^3.2.3", + "@cspell/dict-gaming-terms": "^1.0.9", + "@cspell/dict-git": "^3.0.3", + "@cspell/dict-golang": "^6.0.17", + "@cspell/dict-google": "^1.0.4", + "@cspell/dict-haskell": "^4.0.4", + "@cspell/dict-html": "^4.0.10", + "@cspell/dict-html-symbol-entities": "^4.0.3", + "@cspell/dict-java": "^5.0.10", + "@cspell/dict-julia": "^1.0.4", + "@cspell/dict-k8s": "^1.0.9", + "@cspell/dict-latex": "^4.0.3", + "@cspell/dict-lorem-ipsum": "^4.0.3", + "@cspell/dict-lua": "^4.0.6", + "@cspell/dict-makefile": "^1.0.3", + "@cspell/dict-markdown": "^2.0.7", + "@cspell/dict-monkeyc": "^1.0.9", + "@cspell/dict-node": "^5.0.5", + "@cspell/dict-npm": "^5.1.17", + "@cspell/dict-php": "^4.0.13", + "@cspell/dict-powershell": "^5.0.13", + "@cspell/dict-public-licenses": "^2.0.11", + "@cspell/dict-python": "^4.2.13", + "@cspell/dict-r": "^2.0.4", + "@cspell/dict-ruby": "^5.0.7", + "@cspell/dict-rust": "^4.0.10", + "@cspell/dict-scala": "^5.0.6", + "@cspell/dict-software-terms": "^4.1.19", + "@cspell/dict-sql": "^2.1.8", + "@cspell/dict-svelte": "^1.0.5", + "@cspell/dict-swift": "^2.0.4", + "@cspell/dict-terraform": "^1.0.6", + "@cspell/dict-typescript": "^3.1.11", + "@cspell/dict-vue": "^3.0.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@cspell/cspell-pipe": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/@cspell/cspell-pipe/-/cspell-pipe-8.17.1.tgz", + "integrity": "sha512-uhC99Ox+OH3COSgShv4fpVHiotR70dNvAOSkzRvKVRzV6IGyFnxHjmyVVPEV0dsqzVLxltwYTqFhwI+UOwm45A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@cspell/cspell-resolver": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/@cspell/cspell-resolver/-/cspell-resolver-8.17.1.tgz", + "integrity": "sha512-XEK2ymTdQNgsV3ny60VkKzWskbICl4zNXh/DbxsoRXHqIRg43MXFpTNkEJ7j873EqdX7BU4opQQ+5D4stWWuhQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "global-directory": "^4.0.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@cspell/cspell-service-bus": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/@cspell/cspell-service-bus/-/cspell-service-bus-8.17.1.tgz", + "integrity": "sha512-2sFWQtMEWZ4tdz7bw0bAx4NaV1t0ynGfjpuKWdQppsJFKNb+ZPZZ6Ah1dC13AdRRMZaG194kDRFwzNvRaCgWkQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@cspell/cspell-types": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-8.17.1.tgz", + "integrity": "sha512-NJbov7Jp57fh8addoxesjb8atg/APQfssCH5Q9uZuHBN06wEJDgs7fhfE48bU+RBViC9gltblsYZzZZQKzHYKg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@cspell/dict-ada": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@cspell/dict-ada/-/dict-ada-4.0.5.tgz", + "integrity": "sha512-6/RtZ/a+lhFVmrx/B7bfP7rzC4yjEYe8o74EybXcvu4Oue6J4Ey2WSYj96iuodloj1LWrkNCQyX5h4Pmcj0Iag==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-al": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@cspell/dict-al/-/dict-al-1.0.3.tgz", + "integrity": "sha512-V1HClwlfU/qwSq2Kt+MkqRAsonNu3mxjSCDyGRecdLGIHmh7yeEeaxqRiO/VZ4KP+eVSiSIlbwrb5YNFfxYZbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-aws": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/@cspell/dict-aws/-/dict-aws-4.0.7.tgz", + "integrity": "sha512-PoaPpa2NXtSkhGIMIKhsJUXB6UbtTt6Ao3x9JdU9kn7fRZkwD4RjHDGqulucIOz7KeEX/dNRafap6oK9xHe4RA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-bash": { + "version": "4.1.8", + "resolved": "https://registry.npmjs.org/@cspell/dict-bash/-/dict-bash-4.1.8.tgz", + "integrity": "sha512-I2CM2pTNthQwW069lKcrVxchJGMVQBzru2ygsHCwgidXRnJL/NTjAPOFTxN58Jc1bf7THWghfEDyKX/oyfc0yg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-companies": { + "version": "3.1.9", + "resolved": "https://registry.npmjs.org/@cspell/dict-companies/-/dict-companies-3.1.9.tgz", + "integrity": "sha512-w7XEJ2B6x2jq9ws5XNyYgpYj2MxdZ3jW3PETLxjK7nc8pulCFmaGVgZ0JTnDWfJ3QMOczoagn5f9LM2PZ/CuJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-cpp": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@cspell/dict-cpp/-/dict-cpp-6.0.2.tgz", + "integrity": "sha512-yw5eejWvY4bAnc6LUA44m4WsFwlmgPt2uMSnO7QViGMBDuoeopMma4z9XYvs4lSjTi8fIJs/A1YDfM9AVzb8eg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-cryptocurrencies": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@cspell/dict-cryptocurrencies/-/dict-cryptocurrencies-5.0.3.tgz", + "integrity": "sha512-bl5q+Mk+T3xOZ12+FG37dB30GDxStza49Rmoax95n37MTLksk9wBo1ICOlPJ6PnDUSyeuv4SIVKgRKMKkJJglA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-csharp": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@cspell/dict-csharp/-/dict-csharp-4.0.5.tgz", + "integrity": "sha512-c/sFnNgtRwRJxtC3JHKkyOm+U3/sUrltFeNwml9VsxKBHVmvlg4tk4ar58PdpW9/zTlGUkWi2i85//DN1EsUCA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-css": { + "version": "4.0.16", + "resolved": "https://registry.npmjs.org/@cspell/dict-css/-/dict-css-4.0.16.tgz", + "integrity": "sha512-70qu7L9z/JR6QLyJPk38fNTKitlIHnfunx0wjpWQUQ8/jGADIhMCrz6hInBjqPNdtGpYm8d1dNFyF8taEkOgrQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-dart": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-dart/-/dict-dart-2.2.4.tgz", + "integrity": "sha512-of/cVuUIZZK/+iqefGln8G3bVpfyN6ZtH+LyLkHMoR5tEj+2vtilGNk9ngwyR8L4lEqbKuzSkOxgfVjsXf5PsQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-data-science": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@cspell/dict-data-science/-/dict-data-science-2.0.5.tgz", + "integrity": "sha512-nNSILXmhSJox9/QoXICPQgm8q5PbiSQP4afpbkBqPi/u/b3K9MbNH5HvOOa6230gxcGdbZ9Argl2hY/U8siBlg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-django": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/@cspell/dict-django/-/dict-django-4.1.3.tgz", + "integrity": "sha512-yBspeL3roJlO0a1vKKNaWABURuHdHZ9b1L8d3AukX0AsBy9snSggc8xCavPmSzNfeMDXbH+1lgQiYBd3IW03fg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-docker": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/@cspell/dict-docker/-/dict-docker-1.1.11.tgz", + "integrity": "sha512-s0Yhb16/R+UT1y727ekbR/itWQF3Qz275DR1ahOa66wYtPjHUXmhM3B/LT3aPaX+hD6AWmK23v57SuyfYHUjsw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-dotnet": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/@cspell/dict-dotnet/-/dict-dotnet-5.0.8.tgz", + "integrity": "sha512-MD8CmMgMEdJAIPl2Py3iqrx3B708MbCIXAuOeZ0Mzzb8YmLmiisY7QEYSZPg08D7xuwARycP0Ki+bb0GAkFSqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-elixir": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@cspell/dict-elixir/-/dict-elixir-4.0.6.tgz", + "integrity": "sha512-TfqSTxMHZ2jhiqnXlVKM0bUADtCvwKQv2XZL/DI0rx3doG8mEMS8SGPOmiyyGkHpR/pGOq18AFH3BEm4lViHIw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-en_us": { + "version": "4.3.28", + "resolved": "https://registry.npmjs.org/@cspell/dict-en_us/-/dict-en_us-4.3.28.tgz", + "integrity": "sha512-BN1PME7cOl7DXRQJ92pEd1f0Xk5sqjcDfThDGkKcsgwbSOY7KnTc/czBW6Pr3WXIchIm6cT12KEfjNqx7U7Rrw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-en-common-misspellings": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@cspell/dict-en-common-misspellings/-/dict-en-common-misspellings-2.0.7.tgz", + "integrity": "sha512-qNFo3G4wyabcwnM+hDrMYKN9vNVg/k9QkhqSlSst6pULjdvPyPs1mqz1689xO/v9t8e6sR4IKc3CgUXDMTYOpA==", + "dev": true, + "license": "CC BY-SA 4.0" + }, + "node_modules/@cspell/dict-en-gb": { + "version": "1.1.33", + "resolved": "https://registry.npmjs.org/@cspell/dict-en-gb/-/dict-en-gb-1.1.33.tgz", + "integrity": "sha512-tKSSUf9BJEV+GJQAYGw5e+ouhEe2ZXE620S7BLKe3ZmpnjlNG9JqlnaBhkIMxKnNFkLY2BP/EARzw31AZnOv4g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-filetypes": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/@cspell/dict-filetypes/-/dict-filetypes-3.0.9.tgz", + "integrity": "sha512-U7ycC1cE32A5aEgwzp/iE0TVabonUFnVt+Ygbf6NsIWqEuFWZgZChC7gfztA4T1fpuj602nFdp7eOnTWKORsnQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-flutter": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@cspell/dict-flutter/-/dict-flutter-1.0.3.tgz", + "integrity": "sha512-52C9aUEU22ptpgYh6gQyIdA4MP6NPwzbEqndfgPh3Sra191/kgs7CVqXiO1qbtZa9gnYHUoVApkoxRE7mrXHfg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-fonts": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@cspell/dict-fonts/-/dict-fonts-4.0.3.tgz", + "integrity": "sha512-sPd17kV5qgYXLteuHFPn5mbp/oCHKgitNfsZLFC3W2fWEgZlhg4hK+UGig3KzrYhhvQ8wBnmZrAQm0TFKCKzsA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-fsharp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-fsharp/-/dict-fsharp-1.0.4.tgz", + "integrity": "sha512-G5wk0o1qyHUNi9nVgdE1h5wl5ylq7pcBjX8vhjHcO4XBq20D5eMoXjwqMo/+szKAqzJ+WV3BgAL50akLKrT9Rw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-fullstack": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/@cspell/dict-fullstack/-/dict-fullstack-3.2.3.tgz", + "integrity": "sha512-62PbndIyQPH11mAv0PyiyT0vbwD0AXEocPpHlCHzfb5v9SspzCCbzQ/LIBiFmyRa+q5LMW35CnSVu6OXdT+LKg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-gaming-terms": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@cspell/dict-gaming-terms/-/dict-gaming-terms-1.0.9.tgz", + "integrity": "sha512-AVIrZt3YiUnxsUzzGYTZ1XqgtkgwGEO0LWIlEf+SiDUEVLtv4CYmmyXFQ+WXDN0pyJ0wOwDazWrP0Cu7avYQmQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-git": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@cspell/dict-git/-/dict-git-3.0.3.tgz", + "integrity": "sha512-LSxB+psZ0qoj83GkyjeEH/ZViyVsGEF/A6BAo8Nqc0w0HjD2qX/QR4sfA6JHUgQ3Yi/ccxdK7xNIo67L2ScW5A==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-golang": { + "version": "6.0.17", + "resolved": "https://registry.npmjs.org/@cspell/dict-golang/-/dict-golang-6.0.17.tgz", + "integrity": "sha512-uDDLEJ/cHdLiqPw4+5BnmIo2i/TSR+uDvYd6JlBjTmjBKpOCyvUgYRztH7nv5e7virsN5WDiUWah4/ATQGz4Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-google": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-google/-/dict-google-1.0.4.tgz", + "integrity": "sha512-JThUT9eiguCja1mHHLwYESgxkhk17Gv7P3b1S7ZJzXw86QyVHPrbpVoMpozHk0C9o+Ym764B7gZGKmw9uMGduQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-haskell": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-haskell/-/dict-haskell-4.0.4.tgz", + "integrity": "sha512-EwQsedEEnND/vY6tqRfg9y7tsnZdxNqOxLXSXTsFA6JRhUlr8Qs88iUUAfsUzWc4nNmmzQH2UbtT25ooG9x4nA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-html": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/@cspell/dict-html/-/dict-html-4.0.10.tgz", + "integrity": "sha512-I9uRAcdtHbh0wEtYZlgF0TTcgH0xaw1B54G2CW+tx4vHUwlde/+JBOfIzird4+WcMv4smZOfw+qHf7puFUbI5g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-html-symbol-entities": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@cspell/dict-html-symbol-entities/-/dict-html-symbol-entities-4.0.3.tgz", + "integrity": "sha512-aABXX7dMLNFdSE8aY844X4+hvfK7977sOWgZXo4MTGAmOzR8524fjbJPswIBK7GaD3+SgFZ2yP2o0CFvXDGF+A==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-java": { + "version": "5.0.10", + "resolved": "https://registry.npmjs.org/@cspell/dict-java/-/dict-java-5.0.10.tgz", + "integrity": "sha512-pVNcOnmoGiNL8GSVq4WbX/Vs2FGS0Nej+1aEeGuUY9CU14X8yAVCG+oih5ZoLt1jaR8YfR8byUF8wdp4qG4XIw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-julia": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-julia/-/dict-julia-1.0.4.tgz", + "integrity": "sha512-bFVgNX35MD3kZRbXbJVzdnN7OuEqmQXGpdOi9jzB40TSgBTlJWA4nxeAKV4CPCZxNRUGnLH0p05T/AD7Aom9/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-k8s": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@cspell/dict-k8s/-/dict-k8s-1.0.9.tgz", + "integrity": "sha512-Q7GELSQIzo+BERl2ya/nBEnZeQC+zJP19SN1pI6gqDYraM51uYJacbbcWLYYO2Y+5joDjNt/sd/lJtLaQwoSlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-latex": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@cspell/dict-latex/-/dict-latex-4.0.3.tgz", + "integrity": "sha512-2KXBt9fSpymYHxHfvhUpjUFyzrmN4c4P8mwIzweLyvqntBT3k0YGZJSriOdjfUjwSygrfEwiuPI1EMrvgrOMJw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-lorem-ipsum": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/@cspell/dict-lorem-ipsum/-/dict-lorem-ipsum-4.0.3.tgz", + "integrity": "sha512-WFpDi/PDYHXft6p0eCXuYnn7mzMEQLVeqpO+wHSUd+kz5ADusZ4cpslAA4wUZJstF1/1kMCQCZM6HLZic9bT8A==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-lua": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@cspell/dict-lua/-/dict-lua-4.0.6.tgz", + "integrity": "sha512-Jwvh1jmAd9b+SP9e1GkS2ACbqKKRo9E1f9GdjF/ijmooZuHU0hPyqvnhZzUAxO1egbnNjxS/J2T6iUtjAUK2KQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-makefile": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@cspell/dict-makefile/-/dict-makefile-1.0.3.tgz", + "integrity": "sha512-R3U0DSpvTs6qdqfyBATnePj9Q/pypkje0Nj26mQJ8TOBQutCRAJbr2ZFAeDjgRx5EAJU/+8txiyVF97fbVRViw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-markdown": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@cspell/dict-markdown/-/dict-markdown-2.0.7.tgz", + "integrity": "sha512-F9SGsSOokFn976DV4u/1eL4FtKQDSgJHSZ3+haPRU5ki6OEqojxKa8hhj4AUrtNFpmBaJx/WJ4YaEzWqG7hgqg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@cspell/dict-css": "^4.0.16", + "@cspell/dict-html": "^4.0.10", + "@cspell/dict-html-symbol-entities": "^4.0.3", + "@cspell/dict-typescript": "^3.1.11" + } + }, + "node_modules/@cspell/dict-monkeyc": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@cspell/dict-monkeyc/-/dict-monkeyc-1.0.9.tgz", + "integrity": "sha512-Jvf6g5xlB4+za3ThvenYKREXTEgzx5gMUSzrAxIiPleVG4hmRb/GBSoSjtkGaibN3XxGx5x809gSTYCA/IHCpA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-node": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@cspell/dict-node/-/dict-node-5.0.5.tgz", + "integrity": "sha512-7NbCS2E8ZZRZwlLrh2sA0vAk9n1kcTUiRp/Nia8YvKaItGXLfxYqD2rMQ3HpB1kEutal6hQLVic3N2Yi1X7AaA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-npm": { + "version": "5.1.18", + "resolved": "https://registry.npmjs.org/@cspell/dict-npm/-/dict-npm-5.1.18.tgz", + "integrity": "sha512-/Nukl+DSxtEWSlb8svWFSpJVctAsM9SP+f5Q1n+qdDcXNKMb1bUCo/d3QZPwyOhuMjDawnsGBUAfp+iq7Mw83Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-php": { + "version": "4.0.13", + "resolved": "https://registry.npmjs.org/@cspell/dict-php/-/dict-php-4.0.13.tgz", + "integrity": "sha512-P6sREMZkhElzz/HhXAjahnICYIqB/HSGp1EhZh+Y6IhvC15AzgtDP8B8VYCIsQof6rPF1SQrFwunxOv8H1e2eg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-powershell": { + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/@cspell/dict-powershell/-/dict-powershell-5.0.13.tgz", + "integrity": "sha512-0qdj0XZIPmb77nRTynKidRJKTU0Fl+10jyLbAhFTuBWKMypVY06EaYFnwhsgsws/7nNX8MTEQuewbl9bWFAbsg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-public-licenses": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/@cspell/dict-public-licenses/-/dict-public-licenses-2.0.11.tgz", + "integrity": "sha512-rR5KjRUSnVKdfs5G+gJ4oIvQvm8+NJ6cHWY2N+GE69/FSGWDOPHxulCzeGnQU/c6WWZMSimG9o49i9r//lUQyA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-python": { + "version": "4.2.13", + "resolved": "https://registry.npmjs.org/@cspell/dict-python/-/dict-python-4.2.13.tgz", + "integrity": "sha512-mZIcmo9qif8LkJ6N/lqTZawcOk2kVTcuWIUOSbMcjyomO0XZ7iWz15TfONyr03Ea/l7o5ULV+MZ4vx76bAUb7w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspell/dict-data-science": "^2.0.5" + } + }, + "node_modules/@cspell/dict-r": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-r/-/dict-r-2.0.4.tgz", + "integrity": "sha512-cBpRsE/U0d9BRhiNRMLMH1PpWgw+N+1A2jumgt1if9nBGmQw4MUpg2u9I0xlFVhstTIdzXiLXMxP45cABuiUeQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-ruby": { + "version": "5.0.7", + "resolved": "https://registry.npmjs.org/@cspell/dict-ruby/-/dict-ruby-5.0.7.tgz", + "integrity": "sha512-4/d0hcoPzi5Alk0FmcyqlzFW9lQnZh9j07MJzPcyVO62nYJJAGKaPZL2o4qHeCS/od/ctJC5AHRdoUm0ktsw6Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-rust": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/@cspell/dict-rust/-/dict-rust-4.0.10.tgz", + "integrity": "sha512-6o5C8566VGTTctgcwfF3Iy7314W0oMlFFSQOadQ0OEdJ9Z9ERX/PDimrzP3LGuOrvhtEFoK8pj+BLnunNwRNrw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-scala": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/@cspell/dict-scala/-/dict-scala-5.0.6.tgz", + "integrity": "sha512-tl0YWAfjUVb4LyyE4JIMVE8DlLzb1ecHRmIWc4eT6nkyDqQgHKzdHsnusxFEFMVLIQomgSg0Zz6hJ5S1E4W4ww==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-software-terms": { + "version": "4.1.20", + "resolved": "https://registry.npmjs.org/@cspell/dict-software-terms/-/dict-software-terms-4.1.20.tgz", + "integrity": "sha512-ma51njqbk9ZKzZF9NpCZpZ+c50EwR5JTJ2LEXlX0tX+ExVbKpthhlDLhT2+mkUh5Zvj+CLf5F9z0qB4+X3re/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-sql": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@cspell/dict-sql/-/dict-sql-2.1.8.tgz", + "integrity": "sha512-dJRE4JV1qmXTbbGm6WIcg1knmR6K5RXnQxF4XHs5HA3LAjc/zf77F95i5LC+guOGppVF6Hdl66S2UyxT+SAF3A==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-svelte": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@cspell/dict-svelte/-/dict-svelte-1.0.5.tgz", + "integrity": "sha512-sseHlcXOqWE4Ner9sg8KsjxwSJ2yssoJNqFHR9liWVbDV+m7kBiUtn2EB690TihzVsEmDr/0Yxrbb5Bniz70mA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-swift": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@cspell/dict-swift/-/dict-swift-2.0.4.tgz", + "integrity": "sha512-CsFF0IFAbRtYNg0yZcdaYbADF5F3DsM8C4wHnZefQy8YcHP/qjAF/GdGfBFBLx+XSthYuBlo2b2XQVdz3cJZBw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-terraform": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@cspell/dict-terraform/-/dict-terraform-1.0.6.tgz", + "integrity": "sha512-Sqm5vGbXuI9hCFcr4w6xWf4Y25J9SdleE/IqfM6RySPnk8lISEmVdax4k6+Kinv9qaxyvnIbUUN4WFLWcBPQAg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-typescript": { + "version": "3.1.11", + "resolved": "https://registry.npmjs.org/@cspell/dict-typescript/-/dict-typescript-3.1.11.tgz", + "integrity": "sha512-FwvK5sKbwrVpdw0e9+1lVTl8FPoHYvfHRuQRQz2Ql5XkC0gwPPkpoyD1zYImjIyZRoYXk3yp9j8ss4iz7A7zoQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dict-vue": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@cspell/dict-vue/-/dict-vue-3.0.3.tgz", + "integrity": "sha512-akmYbrgAGumqk1xXALtDJcEcOMYBYMnkjpmGzH13Ozhq1mkPF4VgllFQlm1xYde+BUKNnzMgPEzxrL2qZllgYA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspell/dynamic-import": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/@cspell/dynamic-import/-/dynamic-import-8.17.1.tgz", + "integrity": "sha512-XQtr2olYOtqbg49E+8SISd6I5DzfxmsKINDn0ZgaTFeLalnNdF3ewDU4gOEbApIzGffRa1mW9t19MsiVrznSDw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspell/url": "8.17.1", + "import-meta-resolve": "^4.1.0" + }, + "engines": { + "node": ">=18.0" + } + }, + "node_modules/@cspell/eslint-plugin": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/@cspell/eslint-plugin/-/eslint-plugin-8.17.1.tgz", + "integrity": "sha512-S3+NKHqba0gsrWHPcQkFNs+yCGhyPbFyO5aY8l2sETKJJutL02Qy/qTVJdmA0TYnYUeu1SvDyLL9BJbWuzJ9tA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspell/cspell-types": "8.17.1", + "@cspell/url": "8.17.1", + "cspell-lib": "8.17.1", + "synckit": "^0.9.2" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "eslint": "^7 || ^8 || ^9" + } + }, + "node_modules/@cspell/filetypes": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/@cspell/filetypes/-/filetypes-8.17.1.tgz", + "integrity": "sha512-AxYw6j7EPYtDFAFjwybjFpMc9waXQzurfBXmEVfQ5RQRlbylujLZWwR6GnMqofeNg4oGDUpEjcAZFrgdkvMQlA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@cspell/strong-weak-map": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/@cspell/strong-weak-map/-/strong-weak-map-8.17.1.tgz", + "integrity": "sha512-8cY3vLAKdt5gQEMM3Gr57BuQ8sun2NjYNh9qTdrctC1S9gNC7XzFghTYAfHSWR4VrOUcMFLO/izMdsc1KFvFOA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@cspell/url": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/@cspell/url/-/url-8.17.1.tgz", + "integrity": "sha512-LMvReIndW1ckvemElfDgTt282fb2C3C/ZXfsm0pJsTV5ZmtdelCHwzmgSBmY5fDr7D66XDp8EurotSE0K6BTvw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.0" + } + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -1226,6 +1801,19 @@ "node": ">= 8" } }, + "node_modules/@pkgr/core": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", + "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/@sinclair/typebox": { "version": "0.24.51", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.51.tgz", @@ -1757,6 +2345,13 @@ "license": "Python-2.0", "peer": true }, + "node_modules/array-timsort": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-timsort/-/array-timsort-1.0.3.tgz", + "integrity": "sha512-/+3GRL7dDAGEfM6TseQk/U+mi18TU2Ms9I3UlLdUMhz2hbvGNTKdj9xniwXfUqgYhHxRx0+8UnKkvlNwVU+cWQ==", + "dev": true, + "license": "MIT" + }, "node_modules/array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", @@ -2045,6 +2640,46 @@ "integrity": "sha512-N1NGmowPlGBLsOZLPvm48StN04V4YvQRL0i6b7ctrVY3epjP/ct7hFLOItz6pDIvRjwpfPxi52a2UWV2ziir8g==", "license": "MIT" }, + "node_modules/clear-module": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/clear-module/-/clear-module-4.1.2.tgz", + "integrity": "sha512-LWAxzHqdHsAZlPlEyJ2Poz6AIs384mPeqLVCru2p0BrP9G/kVGuhNyZYClLO6cXlnuJjzC8xtsJIuMjKqLXoAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "parent-module": "^2.0.0", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/clear-module/node_modules/parent-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-2.0.0.tgz", + "integrity": "sha512-uo0Z9JJeWzv8BG+tRcapBKNJ0dro9cLyczGzulS6EfeyAdeC9sbojtW6XwvYxJkEne9En+J2XEl4zyglVeIwFg==", + "dev": true, + "license": "MIT", + "dependencies": { + "callsites": "^3.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/clear-module/node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", @@ -2093,6 +2728,23 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "license": "MIT" }, + "node_modules/comment-json": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/comment-json/-/comment-json-4.2.5.tgz", + "integrity": "sha512-bKw/r35jR3HGt5PEPm1ljsQQGyCrR8sFGNiN5L+ykDHdpO8Smxkrkla9Yi6NkQyUrb8V54PGhfMs6NrIwtxtdw==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-timsort": "^1.0.3", + "core-util-is": "^1.0.3", + "esprima": "^4.0.1", + "has-own-prop": "^2.0.0", + "repeat-string": "^1.6.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -2105,6 +2757,13 @@ "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", "license": "MIT" }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true, + "license": "MIT" + }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -2125,6 +2784,143 @@ "node": ">= 8" } }, + "node_modules/cspell-config-lib": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/cspell-config-lib/-/cspell-config-lib-8.17.1.tgz", + "integrity": "sha512-x1S7QWprgUcwuwiJB1Ng0ZTBC4G50qP9qQyg/aroMkcdMsHfk26E8jUGRPNt4ftHFzS4YMhwtXuJQ9IgRUuNPA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspell/cspell-types": "8.17.1", + "comment-json": "^4.2.5", + "yaml": "^2.6.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/cspell-dictionary": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/cspell-dictionary/-/cspell-dictionary-8.17.1.tgz", + "integrity": "sha512-zSl9l3wii+x16yc2NVZl/+CMLeLBAiuEd5YoFkOYPcbTJnfPwdjMNcj71u7wBvNJ+qwbF+kGbutEt15yHW3NBw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspell/cspell-pipe": "8.17.1", + "@cspell/cspell-types": "8.17.1", + "cspell-trie-lib": "8.17.1", + "fast-equals": "^5.0.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/cspell-glob": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/cspell-glob/-/cspell-glob-8.17.1.tgz", + "integrity": "sha512-cUwM5auSt0RvLX7UkP2GEArJRWc85l51B1voArl+3ZIKeMZwcJpJgN3qvImtF8yRTZwYeYCs1sgsihb179q+mg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspell/url": "8.17.1", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/cspell-grammar": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/cspell-grammar/-/cspell-grammar-8.17.1.tgz", + "integrity": "sha512-H5tLcBuW7aUj9L0rR+FSbnWPEsWb8lWppHVidtqw9Ll1CUHWOZC9HTB2RdrhJZrsz/8DJbM2yNbok0Xt0VAfdw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspell/cspell-pipe": "8.17.1", + "@cspell/cspell-types": "8.17.1" + }, + "bin": { + "cspell-grammar": "bin.mjs" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/cspell-io": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/cspell-io/-/cspell-io-8.17.1.tgz", + "integrity": "sha512-liIOsblt7oVItifzRAbuxiYrwlgw1VOqKppMxVKtYoAn2VUuuEpjCj6jLWpoTqSszR/38o7ChsHY1LHakhJZmw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspell/cspell-service-bus": "8.17.1", + "@cspell/url": "8.17.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/cspell-lib": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/cspell-lib/-/cspell-lib-8.17.1.tgz", + "integrity": "sha512-66n83Q7bK5tnvkDH7869/pBY/65AKmZVfCOAlsbhJn3YMDbNHFCHR0d1oNMlqG+n65Aco89VGwYfXxImZY+/mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspell/cspell-bundled-dicts": "8.17.1", + "@cspell/cspell-pipe": "8.17.1", + "@cspell/cspell-resolver": "8.17.1", + "@cspell/cspell-types": "8.17.1", + "@cspell/dynamic-import": "8.17.1", + "@cspell/filetypes": "8.17.1", + "@cspell/strong-weak-map": "8.17.1", + "@cspell/url": "8.17.1", + "clear-module": "^4.1.2", + "comment-json": "^4.2.5", + "cspell-config-lib": "8.17.1", + "cspell-dictionary": "8.17.1", + "cspell-glob": "8.17.1", + "cspell-grammar": "8.17.1", + "cspell-io": "8.17.1", + "cspell-trie-lib": "8.17.1", + "env-paths": "^3.0.0", + "fast-equals": "^5.0.1", + "gensequence": "^7.0.0", + "import-fresh": "^3.3.0", + "resolve-from": "^5.0.0", + "vscode-languageserver-textdocument": "^1.0.12", + "vscode-uri": "^3.0.8", + "xdg-basedir": "^5.1.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/cspell-lib/node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/cspell-trie-lib": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-8.17.1.tgz", + "integrity": "sha512-13WNa5s75VwOjlGzWprmfNbBFIfXyA7tYYrbV+LugKkznyNZJeJPojHouEudcLq3SYb2Q6tJ7qyWcuT5bR9qPA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspell/cspell-pipe": "8.17.1", + "@cspell/cspell-types": "8.17.1", + "gensequence": "^7.0.0" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/debug": { "version": "4.3.6", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", @@ -2243,6 +3039,19 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "license": "MIT" }, + "node_modules/env-paths": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-3.0.0.tgz", + "integrity": "sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -2949,6 +3758,16 @@ "license": "MIT", "peer": true }, + "node_modules/fast-equals": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-5.0.1.tgz", + "integrity": "sha512-WF1Wi8PwwSY7/6Kx0vKXtw8RwuSGoM1bvDaJbu7MxDlR1vovZjIAKrnzyrThgAjm6JDTu0fVgWXDlMGspodfoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/fast-glob": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", @@ -3116,6 +3935,16 @@ "dev": true, "license": "MIT" }, + "node_modules/gensequence": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/gensequence/-/gensequence-7.0.0.tgz", + "integrity": "sha512-47Frx13aZh01afHJTB3zTtKIlFI6vWY+MYCN9Qpew6i52rfKjnhCF/l1YlC8UmEMvvntZZ6z4PiCcmyuedR2aQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -3190,6 +4019,22 @@ "node": ">=10.13.0" } }, + "node_modules/global-directory": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/global-directory/-/global-directory-4.0.1.tgz", + "integrity": "sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ini": "4.1.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/globals": { "version": "13.24.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", @@ -3251,6 +4096,16 @@ "node": ">=8" } }, + "node_modules/has-own-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-own-prop/-/has-own-prop-2.0.0.tgz", + "integrity": "sha512-Pq0h+hvsVm6dDEa8x82GnLSYHOzNDt7f0ddFa3FqcQlgzEiptPqL+XrOJNavjOzSYiYWIrgeVYYgGlLmnxwilQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/hasown": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", @@ -3294,7 +4149,6 @@ "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "parent-module": "^1.0.0", "resolve-from": "^4.0.0" @@ -3325,6 +4179,17 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/import-meta-resolve": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-4.1.0.tgz", + "integrity": "sha512-I6fiaX09Xivtk+THaMfAwnA3MVA5Big1WHF1Dfx9hFuvNIWpXnorlkzhcQf6ehrqQiiZECRt1poOAkPmer3ruw==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -3351,6 +4216,16 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "license": "ISC" }, + "node_modules/ini": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ini/-/ini-4.1.1.tgz", + "integrity": "sha512-QQnnxNyfvmHFIsj7gkPcYymR8Jdw/o7mp5ZFihxn6h8Ci6fh3Dx4E1gPjpQEpIuPo9XVNY/ZUwh4BPMjGyL01g==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", @@ -4485,7 +5360,6 @@ "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "callsites": "^3.0.0" }, @@ -4747,6 +5621,16 @@ "url": "https://github.com/sponsors/mysticatea" } }, + "node_modules/repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -4800,7 +5684,6 @@ "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=4" } @@ -5077,6 +5960,30 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/synckit": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.2.tgz", + "integrity": "sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@pkgr/core": "^0.1.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, + "node_modules/synckit/node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD" + }, "node_modules/terminal-link": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/terminal-link/-/terminal-link-2.1.1.tgz", @@ -5375,6 +6282,20 @@ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "license": "MIT" }, + "node_modules/vscode-languageserver-textdocument": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.12.tgz", + "integrity": "sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==", + "dev": true, + "license": "MIT" + }, + "node_modules/vscode-uri": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.8.tgz", + "integrity": "sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==", + "dev": true, + "license": "MIT" + }, "node_modules/w3c-keyname": { "version": "2.2.8", "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", @@ -5452,6 +6373,19 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, + "node_modules/xdg-basedir": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-5.1.0.tgz", + "integrity": "sha512-GCPAHLvrIH13+c0SuacwvRYj2SxJXQ4kaVTT5xgL3kPrz56XxkF21IGhjSE1+W0aw7gpBWRGXLCPnPby6lSpmQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -5467,6 +6401,19 @@ "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "license": "ISC" }, + "node_modules/yaml": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.1.tgz", + "integrity": "sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/yargs": { "version": "17.7.2", "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", diff --git a/package.json b/package.json index c456881..ce42664 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,15 @@ "version": "node version-bump.mjs && git add manifest.json versions.json package.json", "test": "jest --config config/jest.config.ts", "test-action": "jest --config config/jest.action.config.ts", - "test-watch": "jest --watchAll --config config/jest.config.ts" + "test-watch": "jest --watchAll --config config/jest.config.ts", + "lint": "eslint . --ext .ts" }, "keywords": [], "author": "kasahala", "url": "https://github.com/k4a-l/obsidian-heading-shifter", "license": "MIT", "devDependencies": { + "@cspell/eslint-plugin": "^8.17.1", "@types/jest": "^28.1.6", "@types/node": "^16.11.6", "@typescript-eslint/eslint-plugin": "5.29.0", diff --git a/src/constant/regExp.ts b/src/constant/regExp.ts index 8c2f3d9..2a1d1e5 100644 --- a/src/constant/regExp.ts +++ b/src/constant/regExp.ts @@ -1,9 +1,9 @@ export const RegExpExample = { - head: { + beginning: { ol: String.raw`\d+\.`, ul: String.raw`(?:\-|\*)`, }, - surround: { + surrounding: { // Only one match italic: String.raw`(?:(? { @@ -25,7 +25,7 @@ export class ApplyHeading implements EditorOperation { editor.getCursor("to").line - editor.getCursor("from").line + 1 ); - const isOneline = + const isOneLine = editor.getCursor("from").line === editor.getCursor("to").line; // Dispatch Transaction @@ -36,7 +36,7 @@ export class ApplyHeading implements EditorOperation { }); // If only one line is targeted, move the cursor to the end of the line. - if (isOneline) { + if (isOneLine) { editor.setCursor(editor.getCursor("anchor").line); } return true; diff --git a/src/features/shiftHeading/operation.ts b/src/features/shiftHeading/operation.ts index 5d271f5..9d69499 100644 --- a/src/features/shiftHeading/operation.ts +++ b/src/features/shiftHeading/operation.ts @@ -34,7 +34,7 @@ export class IncreaseHeading implements EditorOperation { return true; } - const isOneline = + const isOneLine = editor.getCursor("from").line === editor.getCursor("to").line; // Dispatch Transaction @@ -49,7 +49,7 @@ export class IncreaseHeading implements EditorOperation { }); // If only one line is targeted, move the cursor to the end of the line. - if (isOneline) { + if (isOneLine) { editor.setCursor(editor.getCursor("anchor").line); } return editorChange.length ? true : false; @@ -99,7 +99,7 @@ export class DecreaseHeading implements EditorOperation { return true; } - const isOneline = + const isOneLine = editor.getCursor("from").line === editor.getCursor("to").line; // Dispatch Transaction @@ -114,7 +114,7 @@ export class DecreaseHeading implements EditorOperation { }); // If only one line is targeted, move the cursor to the end of the line. - if (isOneline) { + if (isOneLine) { editor.setCursor(editor.getCursor("anchor").line); } return editorChange.length ? true : false; diff --git a/src/main.ts b/src/main.ts index 45a887b..d371b9e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,7 +8,7 @@ import { import { ObsidianService } from "services/obsidianService"; import { InterfaceService } from "services/interfaceService"; import { RegisterService } from "services/registerService"; -import { assingUnknownObjectFromDefaultObject } from "utils/object"; +import { assignUnknownObjectFromDefaultObject } from "utils/object"; export default class HeadingShifter extends Plugin { settings: HeadingShifterSettings; @@ -30,7 +30,7 @@ export default class HeadingShifter extends Plugin { // Setting // There is a possibility of undefined access when the structure of setting is changed (should be done more carefully, but it is handled by corrective default override). - assingUnknownObjectFromDefaultObject(DEFAULT_SETTINGS, this.settings); + assignUnknownObjectFromDefaultObject(DEFAULT_SETTINGS, this.settings); this.addSettingTab(new HeadingShifterSettingTab(this.app, this)); } diff --git a/src/services/obsidianService.ts b/src/services/obsidianService.ts index 2f4b3e7..aa95817 100644 --- a/src/services/obsidianService.ts +++ b/src/services/obsidianService.ts @@ -10,7 +10,7 @@ export class ObsidianService { return state.field(editorInfoField).editor; } - createKeymapRunCallback(config: { + createKeyMapRunCallback(config: { check?: (editor: Editor) => boolean; run: (editor: Editor) => StopPropagation; }) { diff --git a/src/services/registerService.ts b/src/services/registerService.ts index 9fc5188..7a53f29 100644 --- a/src/services/registerService.ts +++ b/src/services/registerService.ts @@ -32,7 +32,7 @@ export class RegisterService { true ); const decreaseHeading = new DecreaseHeading(this.plugin.settings); - const insertHeadingAtCurrentLebel = new InsertHeadingAtCurrentLevel( + const insertHeadingAtCurrentLabel = new InsertHeadingAtCurrentLevel( this.plugin.settings ); const insertHeadingAtDeeperLevel = new InsertHeadingAtDeeperLevel( @@ -52,7 +52,7 @@ export class RegisterService { this.plugin.addCommand(increaseHeading.createCommand()); this.plugin.addCommand(increaseHeadingForced.createCommand()); this.plugin.addCommand(decreaseHeading.createCommand()); - this.plugin.addCommand(insertHeadingAtCurrentLebel.createCommand()); + this.plugin.addCommand(insertHeadingAtCurrentLabel.createCommand()); this.plugin.addCommand(insertHeadingAtDeeperLevel.createCommand()); this.plugin.addCommand(insertHeadingAtHigherLevel.createCommand()); @@ -61,7 +61,7 @@ export class RegisterService { keymap.of([ { key: "Tab", - run: this.plugin.obsidianService.createKeymapRunCallback( + run: this.plugin.obsidianService.createKeyMapRunCallback( { check: increaseHeading.check, run: increaseHeading.editorCallback, @@ -77,7 +77,7 @@ export class RegisterService { keymap.of([ { key: "s-Tab", - run: this.plugin.obsidianService.createKeymapRunCallback( + run: this.plugin.obsidianService.createKeyMapRunCallback( { check: decreaseHeading.check, run: decreaseHeading.editorCallback, diff --git a/src/settings.ts b/src/settings.ts index c88e322..c04e9d1 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -6,8 +6,8 @@ export type HeadingShifterSettings = { limitHeadingFrom: number; overrideTab: boolean; styleToRemove: { - beginning: { ul: boolean; ol: boolean; others: string[] }; - surround: { bold: boolean; italic: boolean; others: string[] }; + beginning: { ul: boolean; ol: boolean; userDefined: string[] }; + surrounding: { bold: boolean; italic: boolean; userDefined: string[] }; }; }; @@ -15,8 +15,8 @@ export const DEFAULT_SETTINGS: HeadingShifterSettings = { limitHeadingFrom: 1, overrideTab: false, styleToRemove: { - beginning: { ul: true, ol: true, others: [] }, - surround: { bold: false, italic: false, others: [] }, + beginning: { ul: true, ol: true, userDefined: [] }, + surrounding: { bold: false, italic: false, userDefined: [] }, }, }; @@ -102,11 +102,11 @@ export class HeadingShifterSettingTab extends PluginSettingTab { .setDesc("Arbitrary string (regular expression)") .addTextArea((str) => { str.setValue( - this.plugin.settings.styleToRemove.beginning?.others?.join( + this.plugin.settings.styleToRemove.beginning?.userDefined?.join( "\n" ) ).onChange(async (str) => { - this.plugin.settings.styleToRemove.beginning.others = + this.plugin.settings.styleToRemove.beginning.userDefined = str.split("\n"); await this.plugin.saveSettings(); }); @@ -121,10 +121,10 @@ export class HeadingShifterSettingTab extends PluginSettingTab { .addToggle((toggle) => toggle .setValue( - this.plugin.settings.styleToRemove?.surround?.bold + this.plugin.settings.styleToRemove?.surrounding?.bold ) .onChange(async (value) => { - this.plugin.settings.styleToRemove.surround.bold = + this.plugin.settings.styleToRemove.surrounding.bold = value; await this.plugin.saveSettings(); }) @@ -135,10 +135,10 @@ export class HeadingShifterSettingTab extends PluginSettingTab { .addToggle((toggle) => toggle .setValue( - this.plugin.settings.styleToRemove?.surround?.italic + this.plugin.settings.styleToRemove?.surrounding?.italic ) .onChange(async (value) => { - this.plugin.settings.styleToRemove.surround.italic = + this.plugin.settings.styleToRemove.surrounding.italic = value; await this.plugin.saveSettings(); }) @@ -148,11 +148,11 @@ export class HeadingShifterSettingTab extends PluginSettingTab { .setDesc("Arbitrary string (regular expression)") .addTextArea((str) => { str.setValue( - this.plugin.settings.styleToRemove?.surround?.others?.join( + this.plugin.settings.styleToRemove?.surrounding?.userDefined?.join( "\n" ) ).onChange(async (str) => { - this.plugin.settings.styleToRemove.surround.others = + this.plugin.settings.styleToRemove.surrounding.userDefined = str.split("\n"); await this.plugin.saveSettings(); }); diff --git a/src/utils/markdown.ts b/src/utils/markdown.ts index d7b5765..cd18744 100644 --- a/src/utils/markdown.ts +++ b/src/utils/markdown.ts @@ -104,7 +104,7 @@ const replaceFunc = (str: string, regExp: RegExp): string | undefined => { export const removeUsingRegexpStrings = ( str: string, - regExpStrings: { beginning?: string[]; surround?: string[] } + regExpStrings: { beginning?: string[]; surrounding?: string[] } ): string => { let removed = str; @@ -118,8 +118,8 @@ export const removeUsingRegexpStrings = ( } } - // surround - for (const regExpStr of regExpStrings.surround ?? []) { + // surrounding + for (const regExpStr of regExpStrings.surrounding ?? []) { const regExp = new RegExp(`${regExpStr}(.*)${regExpStr}`); const result = replaceFunc(removed, regExp); if (result !== undefined) { diff --git a/src/utils/object.ts b/src/utils/object.ts index f5b4795..35393e3 100644 --- a/src/utils/object.ts +++ b/src/utils/object.ts @@ -1,4 +1,4 @@ -export const assingUnknownObjectFromDefaultObject = ( +export const assignUnknownObjectFromDefaultObject = ( defaultObject: Record, targetObject: Record ) => { @@ -10,7 +10,7 @@ export const assingUnknownObjectFromDefaultObject = ( if (isPlainRecord(v)) { const newTargetObject = targetObject[k]; if (isPlainRecord(newTargetObject)) { - assingUnknownObjectFromDefaultObject(v, newTargetObject); + assignUnknownObjectFromDefaultObject(v, newTargetObject); } else { targetObject[k] = v; } diff --git a/test/features.test.ts b/test/features.test.ts index 378efb5..88809d2 100644 --- a/test/features.test.ts +++ b/test/features.test.ts @@ -29,8 +29,12 @@ describe("apply heading", () => { expect( applyHeading(`**${content}**`, 0, { styleToRemove: { - beginning: { ol: true, ul: false, others: [] }, - surround: { bold: true, italic: false, others: [] }, + beginning: { ol: true, ul: false, userDefined: [] }, + surrounding: { + bold: true, + italic: false, + userDefined: [], + }, }, }) ).toBe(`${content}`); @@ -43,9 +47,13 @@ describe("apply heading", () => { beginning: { ol: true, ul: true, - others: [String.raw`\+`], + userDefined: [String.raw`\+`], + }, + surrounding: { + bold: true, + italic: true, + userDefined: ["&&"], }, - surround: { bold: true, italic: true, others: ["&&"] }, }, }) ).toBe(`${content}`); @@ -55,8 +63,12 @@ describe("apply heading", () => { expect( applyHeading(`# **${content}**`, 0, { styleToRemove: { - beginning: { ol: true, ul: false, others: [] }, - surround: { bold: true, italic: false, others: [] }, + beginning: { ol: true, ul: false, userDefined: [] }, + surrounding: { + bold: true, + italic: false, + userDefined: [], + }, }, }) ).toBe(`**${content}**`); diff --git a/test/utils.test.ts b/test/utils.test.ts index 5b9b9a4..4a11aa3 100644 --- a/test/utils.test.ts +++ b/test/utils.test.ts @@ -9,7 +9,7 @@ import { getPreviousHeading, removeUsingRegexpStrings, } from "utils/markdown"; -import { assingUnknownObjectFromDefaultObject } from "utils/object"; +import { assignUnknownObjectFromDefaultObject as assignUnknownObjectFromDefaultObject } from "utils/object"; import { createRange } from "utils/range"; @@ -20,7 +20,7 @@ describe("checkHeading", () => { expect(checkHeading("########## content")).toBe(10); }); - test("unmatch", () => { + test("unMatch", () => { expect(checkHeading("content")).toBe(0); expect(checkHeading("#content")).toBe(0); expect(checkHeading(" # content")).toBe(0); @@ -48,7 +48,7 @@ describe("checkFence", () => { expect(checkFence("~~~~~~~~~~")).toEqual(result); }); - test("unmatch", () => { + test("unMatch", () => { expect(checkFence("``")).toBeNull(); expect(checkFence("~~")).toBeNull(); expect(checkFence(" ```")).toBeNull(); @@ -115,7 +115,7 @@ Normal ~~~~ -### Heaging3`; +### Heading3`; const editor = new Editor(input); @@ -226,14 +226,14 @@ describe("regExp Example", () => { test("bold(**)", () => { expect( removeUsingRegexpStrings(`**${content}**`, { - surround: [RegExpExample.surround.bold], + surrounding: [RegExpExample.surrounding.bold], }) ).toBe(content); }); test("bold(__)", () => { expect( removeUsingRegexpStrings(`__${content}__`, { - surround: [RegExpExample.surround.bold], + surrounding: [RegExpExample.surrounding.bold], }) ).toBe(content); }); @@ -241,14 +241,14 @@ describe("regExp Example", () => { test("italic(*)", () => { expect( removeUsingRegexpStrings(`*${content}*`, { - surround: [RegExpExample.surround.italic], + surrounding: [RegExpExample.surrounding.italic], }) ).toBe(content); }); test("italic(__)", () => { expect( removeUsingRegexpStrings(`_${content}_`, { - surround: [RegExpExample.surround.italic], + surrounding: [RegExpExample.surrounding.italic], }) ).toBe(content); }); @@ -256,14 +256,14 @@ describe("regExp Example", () => { test("ol(1)", () => { expect( removeUsingRegexpStrings(`1. ${content}`, { - beginning: [RegExpExample.head.ol], + beginning: [RegExpExample.beginning.ol], }) ).toBe(content); }); test("ol(1234567890)", () => { expect( removeUsingRegexpStrings(`1234567890. ${content}`, { - beginning: [RegExpExample.head.ol], + beginning: [RegExpExample.beginning.ol], }) ).toBe(content); }); @@ -271,20 +271,20 @@ describe("regExp Example", () => { test("ul(-)", () => { expect( removeUsingRegexpStrings(`- ${content}`, { - beginning: [RegExpExample.head.ul], + beginning: [RegExpExample.beginning.ul], }) ).toBe(content); }); test("ul(*)", () => { expect( removeUsingRegexpStrings(`* ${content}`, { - beginning: [RegExpExample.head.ul], + beginning: [RegExpExample.beginning.ul], }) ).toBe(content); }); }); -describe("assingUnknownObjectFromDefaultObject", () => { +describe("assignUnknownObjectFromDefaultObject", () => { const defaultObj = { str: "string", num: 1, @@ -293,13 +293,13 @@ describe("assingUnknownObjectFromDefaultObject", () => { }; test("all properties are null", () => { const UnknownObj = {}; - assingUnknownObjectFromDefaultObject(defaultObj, UnknownObj); + assignUnknownObjectFromDefaultObject(defaultObj, UnknownObj); expect(UnknownObj).toStrictEqual(defaultObj); }); test("some properties are null", () => { const UnknownObj = { str: "other string", obj: { num: 2 } }; - assingUnknownObjectFromDefaultObject(defaultObj, UnknownObj); + assignUnknownObjectFromDefaultObject(defaultObj, UnknownObj); expect(UnknownObj).toStrictEqual({ str: UnknownObj.str, num: defaultObj.num,