From 17c66fe95fb49cceb3dc31f3e3db9ad3184a60e2 Mon Sep 17 00:00:00 2001 From: iLiftALot Date: Sat, 7 Dec 2024 09:07:14 -0500 Subject: [PATCH 1/7] - Enhanced merging logic with `mergician` package for more reliable updates to local and global settings - Added a static method to main.ts in order to add more usage by extracting global settings prior to initialization - Fixed global settings merging issue (see above) where excluded characters would not update and duplicate within data.json --- package-lock.json | 20 ++++++++++---------- package.json | 2 +- src/constants.ts | 44 +++++++++++++++++++++++++++++--------------- src/main.ts | 15 +++++++++++---- 4 files changed, 51 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5630b87..71d68f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "6.2.0", "license": "MIT", "dependencies": { - "deepmerge-ts": "7.1.3", + "mergician": "^2.0.2", "turndown": "^7.2.0" }, "devDependencies": { @@ -4888,15 +4888,6 @@ "node": ">=0.10.0" } }, - "node_modules/deepmerge-ts": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/deepmerge-ts/-/deepmerge-ts-7.1.3.tgz", - "integrity": "sha512-qCSH6I0INPxd9Y1VtAiLpnYvz5O//6rCfJXKk0z66Up9/VOSr+1yS8XSKA5IWRxjocFGlzPyaZYe+jxq7OOLtQ==", - "license": "BSD-3-Clause", - "engines": { - "node": ">=16.0.0" - } - }, "node_modules/defer-to-connect": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", @@ -8429,6 +8420,15 @@ "node": ">= 8" } }, + "node_modules/mergician": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/mergician/-/mergician-2.0.2.tgz", + "integrity": "sha512-1GDF4LuMcc7UpE7XitfSm822yDtTxLoOVB+9QFnb3o/+zoMAVKxM67UjvmEXOA7FQnz9209K0ZyHAoD+5Ibe4A==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/micromatch": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", diff --git a/package.json b/package.json index 4ed7749..9ace9ca 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "vitest": "^2.1.5" }, "dependencies": { - "deepmerge-ts": "7.1.3", + "mergician": "^2.0.2", "turndown": "^7.2.0" } } \ No newline at end of file diff --git a/src/constants.ts b/src/constants.ts index b12dd72..3213ee5 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,4 +1,6 @@ +import InstaTocPlugin from "./main"; import { LocalTocSettings } from "./types"; +import { MergicianOptions } from "mergician"; export const instaTocCodeBlockId = 'insta-toc'; @@ -30,18 +32,30 @@ export const BulletTypes = { } export const DefaultExcludedChars: string[] = ['*', '_', '`', '==', '~~', '{', '}', '#', '\\']; -export const defaultLocalSettings: LocalTocSettings = { - title: { - name: "Table of Contents", - level: 1 - }, - exclude: "", - style: { - listType: "dash", - }, - omit: [], - levels: { - min: 1, - max: 6 - } -}; +export const mergicianSettings: MergicianOptions = { + onlyCommonKeys: false, + onlyUniversalKeys: false, + skipCommonKeys: false, + skipUniversalKeys: false, + dedupArrays: true, + sortArrays: true +} + +export function getDefaultLocalSettings(): LocalTocSettings { + return { + title: { + name: InstaTocPlugin.getGlobalSetting<'tocTitle'>('tocTitle') ?? 'Table of Contents', + level: 1, + center: false + }, + exclude: "", + style: { + listType: InstaTocPlugin.getGlobalSetting<'bulletType'>('bulletType') ?? BulletTypes.dash + }, + omit: [], + levels: { + min: 1, + max: 6 + } + }; +} diff --git a/src/main.ts b/src/main.ts index 23cba4e..cc9f0f3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,10 +8,10 @@ import { Plugin, PluginManifest, TFile, - debounce, - stringifyYaml + debounce } from 'obsidian'; -import { deepmerge } from 'deepmerge-ts'; +import { mergicianSettings } from './constants'; +import { mergician } from 'mergician'; import { InstaTocSettings, DEFAULT_SETTINGS } from './Settings'; import { SettingTab } from './SettingsTab'; import { ManageToc } from './ManageToc'; @@ -104,7 +104,7 @@ export default class InstaTocPlugin extends Plugin { const settingsData: InstaTocSettings = await this.loadData(); if (settingsData) { - mergedSettings = deepmerge(DEFAULT_SETTINGS, settingsData); + mergedSettings = mergician(mergicianSettings)(DEFAULT_SETTINGS, settingsData); } this.settings = mergedSettings; @@ -166,4 +166,11 @@ export default class InstaTocPlugin extends Plugin { }, this.settings.updateDelay, false ); } + + public static getGlobalSetting(key: K): InstaTocSettings[K] { + const plugin = (window as any).app.plugins.getPlugin('insta-toc') as InstaTocPlugin; + const settings = plugin?.settings as InstaTocSettings; + + return settings[key]; + } } \ No newline at end of file From b838dedc347103e10c883c2fb1c70ba22a596a85 Mon Sep 17 00:00:00 2001 From: iLiftALot Date: Sat, 7 Dec 2024 09:20:42 -0500 Subject: [PATCH 2/7] - Added `excludedHeadingLevels` to present an option to globally exclude specific heading levels - Added `excludedHeadingText` to present an option to globally exclude specific headings entirely --- src/Settings.ts | 8 +++-- src/SettingsTab.ts | 80 +++++++++++++++++++++++++++++++++++++++------- src/validator.ts | 41 +++++++++++++++++------- 3 files changed, 104 insertions(+), 25 deletions(-) diff --git a/src/Settings.ts b/src/Settings.ts index 913eea7..f864952 100644 --- a/src/Settings.ts +++ b/src/Settings.ts @@ -1,18 +1,22 @@ import { DefaultExcludedChars } from "./constants"; -import { BulletType, IndentLevel, UpdateDelay } from "./types"; +import { BulletType, HeadingLevel, IndentLevel, UpdateDelay } from "./types"; export interface InstaTocSettings { bulletType: BulletType; indentSize: IndentLevel; updateDelay: UpdateDelay; tocTitle: string; + excludedHeadingLevels: HeadingLevel[]; + excludedHeadingText: string[]; excludedChars: string[]; } export const DEFAULT_SETTINGS: InstaTocSettings = { bulletType: 'dash', - indentSize: 4, + indentSize: 2, updateDelay: 2000, tocTitle: 'Table of Contents', + excludedHeadingLevels: [], + excludedHeadingText: [], excludedChars: DefaultExcludedChars } diff --git a/src/SettingsTab.ts b/src/SettingsTab.ts index 66cddad..4755b68 100644 --- a/src/SettingsTab.ts +++ b/src/SettingsTab.ts @@ -8,8 +8,8 @@ import { TextComponent } from 'obsidian'; import InstaToc from './main'; -import { BulletTypes } from './constants'; -import { BulletType, IndentLevel, UpdateDelay } from "./types"; +import { BulletTypes, DefaultExcludedChars } from './constants'; +import { BulletType, HeadingLevel, IndentLevel, UpdateDelay } from "./types"; export class SettingTab extends PluginSettingTab { @@ -31,6 +31,7 @@ export class SettingTab extends PluginSettingTab { tabTitle.nameEl.classList.add('setting-title'); tabTitle.controlEl.remove(); + // Global list bullet style new Setting(containerEl) .setName('List bullet style') .setDesc('Select the global list bullet type.') @@ -44,6 +45,7 @@ export class SettingTab extends PluginSettingTab { }) ); + // Global indentation width new Setting(containerEl) .setName('Indentation width') .setDesc('Select the global indentation size.') @@ -59,9 +61,10 @@ export class SettingTab extends PluginSettingTab { }) ); + // Update delay new Setting(containerEl) .setName('Update delay') - .setDesc('The delay for each TOC update.') + .setDesc('The delay for each ToC update.') .addSlider((component: SliderComponent) => { component .setLimits(500, 10000, 500) @@ -72,12 +75,13 @@ export class SettingTab extends PluginSettingTab { this.plugin.settings.updateDelay = value; await this.plugin.saveSettings(); this.plugin.updateModifyEventListener(); - }) + }); }); + // Global ToC title new Setting(containerEl) .setName('ToC Title') - .setDesc('The global title of the generated Table of Contents.') + .setDesc('The global title for the Table of Contents.') .addText((component: TextComponent) => { component .setValue(this.plugin.settings.tocTitle) @@ -85,22 +89,75 @@ export class SettingTab extends PluginSettingTab { this.plugin.settings.tocTitle = value; await this.plugin.saveSettings(); }); - }); + + component.inputEl.placeholder = 'Table of Contents'; + }).infoEl.classList.add('insta-toc-text-info'); + + // Global excluded heading text + new Setting(containerEl) + .setName('Excluded heading text') + .setDesc('Comma-separated list of headings to exclude globally within the Table of Contents.') + .addTextArea((component: TextAreaComponent) => { + component + .setValue(this.plugin.settings.excludedHeadingText.join(',')) + .onChange(async (value: string) => { + const textValue = component.getValue(); + const excludedHeadingText = [ + ...this.plugin.settings.excludedHeadingText + ].concat( + textValue + .replace(/^,/, '').replace(/,$/, '') + .split(',') + .map((value: string) => value.trim()) + ); + + this.plugin.settings.excludedHeadingText = [...excludedHeadingText]; + await this.plugin.saveSettings(); + }); + + component.inputEl.placeholder = 'Table of Contents,Introduction,Side Note'; + component.inputEl.classList.add('insta-toc-text-area'); + }).infoEl.classList.add('insta-toc-text-info'); + + // Global excluded heading levels + new Setting(containerEl) + .setName('Excluded heading levels') + .setDesc('Comma-separated list of heading levels to exclude globally within the Table of Contents.') + .setTooltip('Valid values are 1-6.') + .addTextArea((component: TextAreaComponent) => { + component + .setValue(this.plugin.settings.excludedHeadingLevels.join(',')) + .onChange(async (value: string) => { + const textValue = component.getValue(); + const excludedHeadingLevels: HeadingLevel[] = textValue + .replace(/^,/, '').replace(/,$/, '') + .split(',') + .map((value: string) => parseInt(value.trim()) as HeadingLevel) + .filter((value: HeadingLevel) => value > 0 && value < 7); + + this.plugin.settings.excludedHeadingLevels = [...excludedHeadingLevels]; + await this.plugin.saveSettings(); + }); + component.inputEl.classList.add('insta-toc-text-area'); + component.inputEl.placeholder = '1,2,3,4,5,6'; + }).infoEl.classList.add('insta-toc-text-info'); + + // Global excluded characters new Setting(containerEl) .setName('Excluded characters') - .setDesc('Characters to exclude in headings.') + .setDesc('Globally excluded heading characters.') .addTextArea((component: TextAreaComponent) => { component .setValue([...new Set(this.plugin.settings.excludedChars)].join(',')) - .onChange(async (value: string) => { + .onChange(async (value: string) => { const textValue = component.getValue(); const excludedChars = new Set([ - ...this.plugin.settings.excludedChars, - ...textValue + ...textValue.trim() .replace(/^,/, '').replace(/,$/, '') .split(',') .map((value: string) => value.trim()) + .filter((value: string) => value.length > 0) ]); this.plugin.settings.excludedChars = [...excludedChars]; @@ -108,6 +165,7 @@ export class SettingTab extends PluginSettingTab { }); component.inputEl.classList.add('exclude-chars'); - }); + component.inputEl.placeholder = DefaultExcludedChars.join(','); + }).infoEl.classList.add('insta-toc-text-info'); } } \ No newline at end of file diff --git a/src/validator.ts b/src/validator.ts index 31a2cd1..ded22dc 100644 --- a/src/validator.ts +++ b/src/validator.ts @@ -7,10 +7,10 @@ import { parseYaml, EditorRange } from "obsidian"; -import { defaultLocalSettings, instaTocCodeBlockId, localTocSettingsRegex } from "./constants"; -import { LocalTocSettings, ValidatedInstaToc, ValidCacheType } from "./types"; -import InstaTocPlugin from "./main"; +import { getDefaultLocalSettings, instaTocCodeBlockId, localTocSettingsRegex } from "./constants"; +import { HeadingLevel, LocalTocSettings, ValidatedInstaToc, ValidCacheType } from "./types"; import { deepMerge, escapeRegExp, isHeadingLevel, isRegexPattern } from "./Utils"; +import InstaTocPlugin from "./main"; export class Validator { private plugin: InstaTocPlugin; @@ -36,7 +36,7 @@ export class Validator { this.metadata = metadata; this.editor = editor; this.cursorPos = cursorPos; - this.localTocSettings = defaultLocalSettings; + this.localTocSettings = getDefaultLocalSettings(); } // Method to update the validator properties while maintaining the previous state @@ -166,6 +166,7 @@ export class Validator { if (name !== undefined && typeof name !== 'string') { validationErrors.push("'title.name' must be a string indicating the title to be displayed on the ToC."); } + if (level !== undefined && !isHeadingLevel(level)) { validationErrors.push("'title.level' must be an integer between 1 and 6 indicating the heading level of the ToC title."); } @@ -241,9 +242,17 @@ export class Validator { } else { // All validations passed; merge if (!this.updatedLocalSettings) { - this.updatedLocalSettings = deepMerge(this.localTocSettings, parsedYml, true); + this.updatedLocalSettings = deepMerge( + this.localTocSettings, + parsedYml, + true + ); } else { - this.updatedLocalSettings = deepMerge(this.updatedLocalSettings, parsedYml, false); + this.updatedLocalSettings = deepMerge( + this.updatedLocalSettings, + parsedYml, + false + ); } } @@ -260,16 +269,23 @@ export class Validator { // Store the file headings to reference in later code this.fileHeadings = this.metadata.headings .filter((heading: HeadingCache) => { + const headingText: string = heading.heading.trim(); + const headingLevel = heading.level as HeadingLevel; + return ( // Omit headings with "" - !heading.heading.match(//) && + !headingText.match(//) && // Omit headings included within local "omit" setting - !this.localTocSettings.omit.includes(heading.heading) && + !this.localTocSettings.omit.includes(headingText) && // Omit headings with levels outside of the specified local min/max setting - heading.level >= this.localTocSettings.levels.min && - heading.level <= this.localTocSettings.levels.max && - // Exlcude empty headings - heading.heading.trim().length > 0 + headingLevel >= this.localTocSettings.levels.min && + headingLevel <= this.localTocSettings.levels.max && + // Omit empty headings + headingText.trim().length > 0 && + // Omit heading text specified in the global exclude setting + !this.plugin.settings.excludedHeadingText.includes(headingText) && + // Omit heading levels specified in the global exclude setting + !this.plugin.settings.excludedHeadingLevels.includes(headingLevel) ); }) .map((heading: HeadingCache) => { @@ -343,6 +359,7 @@ export class Validator { // If the headings have not changed, skip processing if (!headingsChanged) return false; + // Process and store data for later use this.setTocInsertPos(); this.configureLocalSettings(); this.setFileHeadings(); From 073996b50fb04a648485107f762f10c6cfd27f4d Mon Sep 17 00:00:00 2001 From: iLiftALot Date: Sat, 7 Dec 2024 09:24:53 -0500 Subject: [PATCH 3/7] - Added boolean value `center` within the `title` object configurator to present an option to center the heading/name of the ToC --- README.md | 62 +++++++++++++++++++++++++++++++++++++++++------- src/ManageToc.ts | 8 +++++-- src/types.ts | 3 ++- src/validator.ts | 6 ++++- 4 files changed, 66 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 02afc2f..948f97b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,9 @@ There are various other ToC plugins for Obsidian, however, they come with certain limitations which this plugin aims to mitigate and improve upon which includes: **Seamless Integration & Dynamic Generation** -- Just insert the code block and start typing. There's nothing more to it. Other ToC plugins generate the ToC via command activation. This plugin is designed for performance and simplicity for maximum convenience and organization with no hassle. +- Just insert the code block and start typing. There's nothing more to it. +- Other ToC plugins generate the ToC via command activation. +- This plugin is designed for performance and simplicity for maximum convenience and organization. **Omit Specific Headings** - Exclude any heading you want from the ToC by simply adding `` to the end of the heading. @@ -33,10 +35,11 @@ There are various other ToC plugins for Obsidian, however, they come with certai **HTML & Special Symbols** - Feel free to include HTML or any kind of special symbols within headings. This plugin will handle these cases elegantly. -- Alternatively, specify which characters should be escaped within the local settings. +- You can additionally specify which characters should be escaped within the local settings. **Heading Hierarchy Handling** -- Include any type of heading hierarchy you want. Your heading structure doesn't have to be any certain way. Other plugins will prohibit the ToC insertion if the heading hierachy. +- Include any type of heading hierarchy you want. Your heading structure doesn't have to be any certain way. +- Other plugins will prohibit the ToC insertion if the heading hierachy is not in a particular optimal format. **Markdown Links & Wiki-Links** - This plugin will handle multiple of both markdown links (`[Title]\(https://link)`) and wiki-links (`[[file-name.md]]`) within headings. @@ -44,10 +47,14 @@ There are various other ToC plugins for Obsidian, however, they come with certai **Settings**
  • Bullet Style - Select your preferred list-bullet style within the settings tab.
  • +
  • Update Delay - Configure the delay between ToC updates.
  • -
  • Excluded Characters - Specify which characters should be escaped within headings.
  • + +
  • Exclusions - You will have multiple custimization choices pertaining to exlcuding specific heading text, individual characters, and heading levels.
  • +
  • Indentation Width - Determine your preferred amount of indentation spacing.
  • -
  • Local Settings
  • + +
  • Local File Settings
@@ -68,7 +75,6 @@ There are various other ToC plugins for Obsidian, however, they come with certai ``` - Alternatively, utilize the local settings: - ```yml --- omit: [ @@ -78,7 +84,23 @@ There are various other ToC plugins for Obsidian, however, they come with certai --- ``` +
↕️    ↕️    ↕️    ↕️
+ + ```yml + --- + omit: + - Heading 1 + - Heading 2 + --- + ``` +--- + **Local ToC Settings Guide** +>
⚠️ FORMAT CAUTION ⚠️
+> +> The local settings use YAML formatting, which is a format that is very particular about perfect spacing. +> I'll be implementing auto-correction logic soon to account for this, but for the time being ensure that you are only indenting with 2 spaces, otherwise you will get errors. + - Type Guide: ```yml --- @@ -86,7 +108,9 @@ There are various other ToC plugins for Obsidian, however, they come with certai name: [string: any] - The title of the ToC. level: [number: 1 | 2 | 3 | 4 | 5 | 6] - - The heading level of the title + - The heading level of the title. + center: [boolean: true | false] + - Optionally center position of the title. exclude: [string: any | RegExp: /.../] - Exclude specific headings based on a string of characters (e.g., ",._-+=") or a regular expression (e.g., /[^a-zA-Z0-9]/). - NOTE: Currently, this will include global excluded characters as well. @@ -103,12 +127,13 @@ There are various other ToC plugins for Obsidian, however, they come with certai --- ``` -- Example: +- Example 1: ```yml --- title: name: "Table of Contents" level: 2 + center: false exclude: ",._-+" style: listType: "dash" @@ -122,6 +147,25 @@ There are various other ToC plugins for Obsidian, however, they come with certai --- ``` +- Example 2: + ```yml + --- + title: + name: "Table of Contents" + level: 1 + center: true + exclude: /[^a-zA-Z0-9]/ + style: + listType: number + omit: + - Heading 3 + - Heading 4 + levels: + min: 2 + max: 6 + --- + ``` + ## Installation @@ -194,7 +238,7 @@ npm install insta-toc
  • PDF
  • HTML
  • - Markdown +
  • Markdown
  • ...
diff --git a/src/ManageToc.ts b/src/ManageToc.ts index b4ac992..9423d31 100644 --- a/src/ManageToc.ts +++ b/src/ManageToc.ts @@ -80,7 +80,9 @@ export class ManageToc { }---\n\n${ '#'.repeat(this.validator.localTocSettings.title.level) } ${ - this.validator.localTocSettings.title.name + this.validator.localTocSettings.title.center + ? '
' + this.validator.localTocSettings.title.name + '
' + : this.validator.localTocSettings.title.name }\n\n${ tocHeadingRefs.join('\n') }`; @@ -115,7 +117,9 @@ export class ManageToc { }---\n\n${ '#'.repeat(this.validator.localTocSettings.title.level) } ${ - this.validator.localTocSettings.title.name + this.validator.localTocSettings.title.center + ? '
' + this.validator.localTocSettings.title.name + '
' + : this.validator.localTocSettings.title.name }\n\n${ tocHeadingRefs.join('\n') }`; diff --git a/src/types.ts b/src/types.ts index 2c80c1d..f1cb5ca 100644 --- a/src/types.ts +++ b/src/types.ts @@ -51,7 +51,8 @@ export type LocalTocStyle = { } export type LocalTocTitle = { name: string; - level: HeadingLevel + level: HeadingLevel; + center: boolean; } export type LocalTocLevels = { min: HeadingLevel; diff --git a/src/validator.ts b/src/validator.ts index ded22dc..e871cff 100644 --- a/src/validator.ts +++ b/src/validator.ts @@ -161,7 +161,7 @@ export class Validator { if (typeof title !== 'object' || title === null) { validationErrors.push("'title' must be an object."); } else { - const { name, level } = title; + const { name, level, center } = title; if (name !== undefined && typeof name !== 'string') { validationErrors.push("'title.name' must be a string indicating the title to be displayed on the ToC."); @@ -170,6 +170,10 @@ export class Validator { if (level !== undefined && !isHeadingLevel(level)) { validationErrors.push("'title.level' must be an integer between 1 and 6 indicating the heading level of the ToC title."); } + + if (center !== undefined && !(typeof center === 'boolean')) { + validationErrors.push("'title.center' must be a boolean indicating whether the title position should be centered."); + } } } From 858778a36af4c5b87b7405e9cb25c84b831359a3 Mon Sep 17 00:00:00 2001 From: iLiftALot Date: Sat, 7 Dec 2024 09:25:24 -0500 Subject: [PATCH 4/7] Minor formatting and comment improvements. --- src/Utils.ts | 3 ++- src/types.ts | 23 +++++++++++++++-------- styles.css | 9 +++++++++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/Utils.ts b/src/Utils.ts index 159753b..df082e5 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -99,7 +99,7 @@ export function cleanAlias(aliasText: string, plugin?: InstaTocPlugin, exclChars return alias; } -// Configure indentation for the insta-toc codeblock element post-render +// Configure indentation for the insta-toc code block HTML element, post-render export function configureRenderedIndent( el: HTMLElement, headingLevels: number[], @@ -116,6 +116,7 @@ export function configureRenderedIndent( } const subList: HTMLUListElement | HTMLOListElement | null = listItem.querySelector('ul, ol'); + if (subList) { // List item has children const toggleButton: HTMLButtonElement = document.createElement('button'); diff --git a/src/types.ts b/src/types.ts index f1cb5ca..4c9db6b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,10 +1,17 @@ -import { CachedMetadata, Editor, EditorPosition, EditorRange, HeadingCache, SectionCache } from "obsidian"; +import { + CachedMetadata, + Editor, + EditorPosition, + EditorRange, + HeadingCache, + SectionCache +} from "obsidian"; // Interface asserts that HeadingCache[] and SectionCache[] // are not undefined within the CachedMetadata type export interface ValidCacheType extends CachedMetadata { - headings: HeadingCache[], - sections: SectionCache[] + headings: HeadingCache[]; + sections: SectionCache[]; } // Type that represents a fully validated Validator instance @@ -31,13 +38,13 @@ export type UpdateDelay = 500 | 1000 | 7500 | 8000 | 8500 | 9000 | 9500 | 10000 export type TocData = { - fileHeadings: HeadingCache[], - instaTocSection: SectionCache | undefined + fileHeadings: HeadingCache[]; + instaTocSection: SectionCache | undefined; } export type HandledLink = { - contentText: string, - alias: string + contentText: string; + alias: string; } export type ListItemContext = { indent: string; @@ -63,5 +70,5 @@ export interface LocalTocSettings { exclude: string; style: LocalTocStyle; omit: string[]; - levels: LocalTocLevels + levels: LocalTocLevels; }; diff --git a/styles.css b/styles.css index 25b527c..62206e9 100644 --- a/styles.css +++ b/styles.css @@ -16,6 +16,7 @@ .exclude-chars { font-size: larger; font-weight: bolder; + width: 100%; } .setting-title { @@ -23,3 +24,11 @@ justify-content: center; font-size: xx-large; } + +.insta-toc-text-info { + width: 33%; +} + +.insta-toc-text-area { + width: 100%; +} From 19d4988a16816b226a49fadf1f6269ac707c3ffe Mon Sep 17 00:00:00 2001 From: iLiftALot Date: Sat, 7 Dec 2024 10:02:58 -0500 Subject: [PATCH 5/7] Update release workflow to trigger on closed pull requests and modify version upload scripts for direct push to master. Signed-off-by: iLiftALot --- .github/workflows/release_publish.yml | 15 +++++++++++---- package.json | 7 ++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release_publish.yml b/.github/workflows/release_publish.yml index 317ab8a..df7384a 100644 --- a/.github/workflows/release_publish.yml +++ b/.github/workflows/release_publish.yml @@ -1,11 +1,11 @@ name: Release and Publish on: - push: - tags: - - '[0-9]+.[0-9]+.[0-9]+' + pull_request: branches: - - 'master' + - master + types: + - closed workflow_dispatch: inputs: version_type: @@ -23,6 +23,13 @@ permissions: jobs: release: + if: | + github.event_name == 'workflow_dispatch' || ( + github.event_name == 'pull_request' && + github.event.pull_request.merged == true && + github.event.pull_request.base.ref == 'master' + ) + runs-on: ubuntu-latest steps: diff --git a/package.json b/package.json index 9ace9ca..882c799 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,10 @@ "dev": "node esbuild.config.mjs && terser -o dist/dev/main.js dist/dev/main.js", "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production && terser -o dist/build/main.js dist/build/main.js", "bump-version": "node version-bump.mjs", - "upload:patch": "npm version patch --no-git-tag-version && npm run bump-version && npm run build && git add . && VERSION=$(node -p \"require('./package.json').version\") && git commit -m \"Automated update for version $VERSION\" && git tag -a $VERSION -m \"Version $VERSION\" && git push origin --follow-tags", - "upload:minor": "npm version minor --no-git-tag-version && npm run bump-version && npm run build && git add . && VERSION=$(node -p \"require('./package.json').version\") && git commit -m \"Automated update for version $VERSION\" && git tag -a $VERSION -m \"Version $VERSION\" && git push origin --follow-tags", - "upload:major": "npm version major --no-git-tag-version && npm run bump-version && npm run build && git add . && VERSION=$(node -p \"require('./package.json').version\") && git commit -m \"Automated update for version $VERSION\" && git tag -a $VERSION -m \"Version $VERSION\" && git push origin --follow-tags" + + "upload:patch": "npm version patch --no-git-tag-version && npm run bump-version && npm run build && git add . && git commit -m \"Automated update for version $npm_package_version\" && git push origin master", + "upload:minor": "npm version minor --no-git-tag-version && npm run bump-version && npm run build && git add . && git commit -m \"Automated update for version $npm_package_version\" && git push origin master", + "upload:major": "npm version major --no-git-tag-version && npm run bump-version && npm run build && git add . && git commit -m \"Automated update for version $npm_package_version\" && git push origin master" }, "keywords": [ "obsidian", From 89e5f693d4f7635b6d2a7613443b49f2c5794500 Mon Sep 17 00:00:00 2001 From: iLiftALot Date: Sat, 7 Dec 2024 10:13:25 -0500 Subject: [PATCH 6/7] Bump version to 6.3.0 --- package.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 882c799..78b86f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "insta-toc", - "version": "6.2.0", + "version": "6.3.0", "description": "Simultaneously generate, update, and maintain a table of contents for your notes in real time.", "repository": { "directory": ".", @@ -15,7 +15,6 @@ "dev": "node esbuild.config.mjs && terser -o dist/dev/main.js dist/dev/main.js", "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production && terser -o dist/build/main.js dist/build/main.js", "bump-version": "node version-bump.mjs", - "upload:patch": "npm version patch --no-git-tag-version && npm run bump-version && npm run build && git add . && git commit -m \"Automated update for version $npm_package_version\" && git push origin master", "upload:minor": "npm version minor --no-git-tag-version && npm run bump-version && npm run build && git add . && git commit -m \"Automated update for version $npm_package_version\" && git push origin master", "upload:major": "npm version major --no-git-tag-version && npm run bump-version && npm run build && git add . && git commit -m \"Automated update for version $npm_package_version\" && git push origin master" @@ -53,4 +52,4 @@ "mergician": "^2.0.2", "turndown": "^7.2.0" } -} \ No newline at end of file +} From fccebf9adcb4d066b1385c53e518ed594155d074 Mon Sep 17 00:00:00 2001 From: iLiftALot Date: Sat, 7 Dec 2024 10:26:24 -0500 Subject: [PATCH 7/7] Automated update for version 6.3.0 --- manifest.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- versions.json | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/manifest.json b/manifest.json index d688da8..9e55772 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "insta-toc", "name": "Insta TOC", - "version": "6.2.0", + "version": "6.3.0", "minAppVersion": "0.15.0", "description": "Simultaneously generate, update, and maintain a table of contents for your notes.", "author": "Nick C.", diff --git a/package-lock.json b/package-lock.json index 71d68f8..7bfb48b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "insta-toc", - "version": "6.2.0", + "version": "6.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "insta-toc", - "version": "6.2.0", + "version": "6.3.0", "license": "MIT", "dependencies": { "mergician": "^2.0.2", diff --git a/package.json b/package.json index 78b86f1..3816a81 100644 --- a/package.json +++ b/package.json @@ -52,4 +52,4 @@ "mergician": "^2.0.2", "turndown": "^7.2.0" } -} +} \ No newline at end of file diff --git a/versions.json b/versions.json index 4b02655..584dbfc 100644 --- a/versions.json +++ b/versions.json @@ -58,5 +58,6 @@ "6.1.0": "0.15.0", "6.1.1": "0.15.0", "6.1.2": "0.15.0", - "6.2.0": "0.15.0" + "6.2.0": "0.15.0", + "6.3.0": "0.15.0" } \ No newline at end of file