Large diffs are not rendered by default.

@@ -1,7 +1,7 @@
{
"id": "templater-obsidian",
"name": "Templater",
"version": "1.9.11",
"version": "1.10.0",
"description": "Create and use templates",
"minAppVersion": "0.11.13",
"author": "SilentVoid",
@@ -1,14 +1,14 @@
{
"name": "templater-obsidian",
"version": "1.9.11",
"version": "1.10.0",
"description": "Create and use templates",
"main": "main.js",
"scripts": {
"dev": "rollup --config rollup.config.js -w",
"build": "rollup --config rollup.config.js",
"dev": "node esbuild.config.mjs",
"build": "node esbuild.config.mjs production",
"pretest": "eslint --ignore-path .gitignore src/",
"test": "rollup --config rollup.config.js --testBuild",
"test-dev": "rollup --config rollup.config.js -w --testBuild",
"test-build": "node esbuild.config.mjs production test",
"test-dev": "node esbuild.config.mjs test",
"release": "standard-version -t ''"
},
"keywords": [
@@ -20,34 +20,31 @@
"author": "SilentVoid13",
"license": "AGPL-3.0-only",
"devDependencies": {
"@rollup/plugin-commonjs": "^18.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"@rollup/plugin-typescript": "^8.3.0",
"@types/chai": "^4.3.0",
"@types/chai-as-promised": "^7.1.4",
"@types/node": "^14.18.5",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"builtin-modules": "^3.2.0",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"cz-conventional-changelog": "^3.3.0",
"detect-indent": "6.1.0",
"detect-newline": "3.1.0",
"esbuild-plugin-toml": "^0.0.1",
"esbuild": "^0.13.15",
"eslint": "^7.32.0",
"obsidian": "^0.12.17",
"rollup": "2.53.0",
"rollup-plugin-toml": "^1.0.0",
"standard-version": "^9.3.2",
"stringify-package": "^1.0.1",
"ts-node": "^9.1.1",
"tslib": "^2.3.1",
"typescript": "^4.5.4"
},
"dependencies": {
"@popperjs/core": "^2.11.2",
"child_process": "^1.0.2",
"eta": "github:SilentVoid13/eta#custom-eta",
"stringify-package": "^1.0.1"
"eta": "github:SilentVoid13/eta#custom-eta"
},
"config": {
"commitizen": {

Large diffs are not rendered by default.

This file was deleted.

@@ -8,17 +8,15 @@ import {
TFolder,
} from "obsidian";

import { generate_dynamic_command_regex, resolve_tfile, delay } from "Utils";
import { generate_dynamic_command_regex, resolve_tfile, delay } from "utils/Utils";
import TemplaterPlugin from "main";
import {
FunctionsMode,
FunctionsGenerator,
} from "functions/FunctionsGenerator";
import { errorWrapper, errorWrapperSync, TemplaterError } from "Error";
import { Editor } from "editor/Editor";
import { Parser } from "parser/Parser";
import { log_error } from "Log";
import { Documentation } from "functions/TpDocumentation";
} from "./functions/FunctionsGenerator";
import { errorWrapper, errorWrapperSync, TemplaterError } from "utils/Error";
import { Parser } from "./parser/Parser";
import { log_error } from "utils/Log";

export enum RunMode {
CreateNewFromTemplate,
@@ -39,22 +37,17 @@ export type RunningConfig = {
export class Templater {
public parser: Parser;
public functions_generator: FunctionsGenerator;
public editor: Editor;
public current_functions_object: Record<string, unknown>;
public documentation: Documentation;

constructor(private app: App, private plugin: TemplaterPlugin) {
this.functions_generator = new FunctionsGenerator(
this.app,
this.plugin
);
this.editor = new Editor(this.app, this.plugin);
this.parser = new Parser();
this.documentation = new Documentation(this.app);
}

async setup(): Promise<void> {
await this.editor.setup();
await this.functions_generator.init();
this.plugin.registerMarkdownPostProcessor((el, ctx) =>
this.process_dynamic_templates(el, ctx)
@@ -99,15 +92,6 @@ export class Templater {
return content;
}

async jump_to_next_cursor_location(file: TFile): Promise<void> {
if (
this.plugin.settings.auto_jump_to_cursor &&
this.app.workspace.getActiveFile() === file
) {
await this.editor.jump_to_next_cursor_location();
}
}

async create_new_note_from_template(
template: TFile | string,
folder?: TFolder,
@@ -118,8 +102,7 @@ export class Templater {
if (!folder) {
// TODO: Fix that
// @ts-ignore
const new_file_location =
this.app.vault.getConfig("newFileLocation");
const new_file_location = this.app.vault.getConfig("newFileLocation");
switch (new_file_location) {
case "current": {
const active_file = this.app.workspace.getActiveFile();
@@ -187,7 +170,7 @@ export class Templater {
state: { mode: "source" },
eState: { rename: "all" },
});
await this.jump_to_next_cursor_location(created_note);
await this.plugin.editor_handler.jump_to_next_cursor_location(created_note, true);
}

return created_note;
@@ -220,7 +203,7 @@ export class Templater {
const doc = editor.getDoc();
doc.replaceSelection(output_content);

await this.jump_to_next_cursor_location(active_view.file);
await this.plugin.editor_handler.jump_to_next_cursor_location(active_view.file, true);
}

async write_template_to_file(
@@ -241,7 +224,7 @@ export class Templater {
return;
}
await this.app.vault.modify(file, output_content);
await this.jump_to_next_cursor_location(file);
await this.plugin.editor_handler.jump_to_next_cursor_location(file, true);
}

overwrite_active_file_commands(): void {
@@ -276,7 +259,7 @@ export class Templater {
return;
}
await this.app.vault.modify(file, output_content);
await this.jump_to_next_cursor_location(file);
await this.plugin.editor_handler.jump_to_next_cursor_location(file, true);
}

async process_dynamic_templates(
@@ -1,10 +1,10 @@
import { App } from "obsidian";

import { InternalFunctions } from "functions/internal_functions/InternalFunctions";
import { UserFunctions } from "functions/user_functions/UserFunctions";
import { InternalFunctions } from "./internal_functions/InternalFunctions";
import { UserFunctions } from "./user_functions/UserFunctions";
import TemplaterPlugin from "main";
import { IGenerateObject } from "functions/IGenerateObject";
import { RunningConfig } from "Templater";
import { IGenerateObject } from "./IGenerateObject";
import { RunningConfig } from "core/Templater";
import * as obsidian_module from "obsidian";

export enum FunctionsMode {
@@ -1,4 +1,4 @@
import { RunningConfig } from "Templater";
import { RunningConfig } from "core/Templater";

export interface IGenerateObject {
generate_object(config: RunningConfig): Promise<Record<string, unknown>>;
@@ -1,14 +1,14 @@
import { App } from "obsidian";

import TemplaterPlugin from "main";
import { IGenerateObject } from "functions/IGenerateObject";
import { IGenerateObject } from "core/functions/IGenerateObject";
import { InternalModule } from "./InternalModule";
import { InternalModuleDate } from "./date/InternalModuleDate";
import { InternalModuleFile } from "./file/InternalModuleFile";
import { InternalModuleWeb } from "./web/InternalModuleWeb";
import { InternalModuleFrontmatter } from "./frontmatter/InternalModuleFrontmatter";
import { InternalModuleSystem } from "./system/InternalModuleSystem";
import { RunningConfig } from "Templater";
import { RunningConfig } from "core/Templater";
import { InternalModuleConfig } from "./config/InternalModuleConfig";

export class InternalFunctions implements IGenerateObject {
File renamed without changes.
@@ -1,6 +1,6 @@
import { InternalModule } from "functions/internal_functions/InternalModule";
import { RunningConfig } from "Templater";
import { ModuleName } from "functions/TpDocumentation";
import { InternalModule } from "../InternalModule";
import { RunningConfig } from "core/Templater";
import { ModuleName } from "editor/TpDocumentation";

export class InternalModuleConfig extends InternalModule {
public name: ModuleName = "config";
@@ -1,6 +1,6 @@
import { TemplaterError } from "Error";
import { TemplaterError } from "utils/Error";
import { InternalModule } from "../InternalModule";
import { ModuleName } from "functions/TpDocumentation";
import { ModuleName } from "editor/TpDocumentation";

export class InternalModuleDate extends InternalModule {
public name: ModuleName = "date";
@@ -1,5 +1,5 @@
import { InternalModule } from "../InternalModule";
import { log_error } from "Log";
import { log_error } from "utils/Log";

import {
FileSystemAdapter,
@@ -12,9 +12,9 @@ import {
TFile,
TFolder,
} from "obsidian";
import { UNSUPPORTED_MOBILE_TEMPLATE } from "Constants";
import { TemplaterError } from "Error";
import { ModuleName } from "functions/TpDocumentation";
import { UNSUPPORTED_MOBILE_TEMPLATE } from "utils/Constants";
import { TemplaterError } from "utils/Error";
import { ModuleName } from "editor/TpDocumentation";

export const DEPTH_LIMIT = 10;

@@ -1,5 +1,5 @@
import { InternalModule } from "../InternalModule";
import { ModuleName } from "functions/TpDocumentation";
import { ModuleName } from "editor/TpDocumentation";

export class InternalModuleFrontmatter extends InternalModule {
public name: ModuleName = "frontmatter";
@@ -1,10 +1,10 @@
import { UNSUPPORTED_MOBILE_TEMPLATE } from "Constants";
import { UNSUPPORTED_MOBILE_TEMPLATE } from "utils/Constants";
import { InternalModule } from "../InternalModule";
import { Platform } from "obsidian";
import { PromptModal } from "./PromptModal";
import { SuggesterModal } from "./SuggesterModal";
import { TemplaterError } from "Error";
import { ModuleName } from "functions/TpDocumentation";
import { TemplaterError } from "utils/Error";
import { ModuleName } from "editor/TpDocumentation";

export class InternalModuleSystem extends InternalModule {
public name: ModuleName = "system";
@@ -1,4 +1,4 @@
import { TemplaterError } from "Error";
import { TemplaterError } from "utils/Error";
import { App, Modal } from "obsidian";

export class PromptModal extends Modal {
@@ -1,4 +1,4 @@
import { TemplaterError } from "Error";
import { TemplaterError } from "utils/Error";
import { App, FuzzyMatch, FuzzySuggestModal } from "obsidian";

export class SuggesterModal<T> extends FuzzySuggestModal<T> {
@@ -1,6 +1,6 @@
import { TemplaterError } from "Error";
import { TemplaterError } from "utils/Error";
import { InternalModule } from "../InternalModule";
import { ModuleName } from "functions/TpDocumentation";
import { ModuleName } from "editor/TpDocumentation";

export class InternalModuleWeb extends InternalModule {
name: ModuleName = "web";
@@ -1,10 +1,10 @@
import { App, Platform } from "obsidian";

import TemplaterPlugin from "main";
import { RunningConfig } from "Templater";
import { IGenerateObject } from "functions/IGenerateObject";
import { UserSystemFunctions } from "functions/user_functions/UserSystemFunctions";
import { UserScriptFunctions } from "functions/user_functions/UserScriptFunctions";
import { RunningConfig } from "core/Templater";
import { IGenerateObject } from "../IGenerateObject";
import { UserSystemFunctions } from "./UserSystemFunctions";
import { UserScriptFunctions } from "./UserScriptFunctions";

export class UserFunctions implements IGenerateObject {
private user_system_functions: UserSystemFunctions;
@@ -1,16 +1,15 @@
import { App, FileSystemAdapter, TFile } from "obsidian";
import { App, TFile } from "obsidian";

import TemplaterPlugin from "main";
import { IGenerateObject } from "functions/IGenerateObject";
import { RunningConfig } from "Templater";
import { get_tfiles_from_folder } from "Utils";
import { errorWrapperSync, TemplaterError } from "Error";
import { IGenerateObject } from "../IGenerateObject";
import { RunningConfig } from "core/Templater";
import { get_tfiles_from_folder } from "utils/Utils";
import { errorWrapperSync, TemplaterError } from "utils/Error";

export class UserScriptFunctions implements IGenerateObject {
constructor(private app: App, private plugin: TemplaterPlugin) {}

async generate_user_script_functions(
config: RunningConfig
): Promise<Map<string, Function>> {
const user_script_functions: Map<string, Function> = new Map();
const files = errorWrapperSync(
@@ -28,7 +27,6 @@ export class UserScriptFunctions implements IGenerateObject {
for (const file of files) {
if (file.extension.toLowerCase() === "js") {
await this.load_user_script_function(
config,
file,
user_script_functions
);
@@ -38,44 +36,37 @@ export class UserScriptFunctions implements IGenerateObject {
}

async load_user_script_function(
config: RunningConfig,
file: TFile,
user_script_functions: Map<string, Function>
): Promise<void> {
if (!(this.app.vault.adapter instanceof FileSystemAdapter)) {
throw new TemplaterError(
"app.vault is not a FileSystemAdapter instance"
);
}
const vault_path = this.app.vault.adapter.getBasePath();
const file_path = `${vault_path}/${file.path}`;
let req = (s: string) => {
return window.require && window.require(s);
};
let exp: Record<string, unknown> = {};
let mod = {
exports: exp
};

// https://stackoverflow.com/questions/26633901/reload-module-at-runtime
// https://stackoverflow.com/questions/1972242/how-to-auto-reload-files-in-node-js
if (Object.keys(window.require.cache).contains(file_path)) {
delete window.require.cache[window.require.resolve(file_path)];
}
const file_content = await this.app.vault.read(file);
const wrapping_fn = window.eval("(function anonymous(require, module, exports){" + file_content + "\n})");
wrapping_fn(req, mod, exp);
const user_function = exp['default'] || mod.exports;

const user_function = await import(file_path);
if (!user_function.default) {
if (!user_function) {
throw new TemplaterError(
`Failed to load user script ${file_path}. No exports detected.`
`Failed to load user script ${file.path}. No exports detected.`
);
}
if (!(user_function.default instanceof Function)) {
if (!(user_function instanceof Function)) {
throw new TemplaterError(
`Failed to load user script ${file_path}. Default export is not a function.`
`Failed to load user script ${file.path}. Default export is not a function.`
);
}
user_script_functions.set(`${file.basename}`, user_function.default);
user_script_functions.set(`${file.basename}`, user_function);
}

async generate_object(
config: RunningConfig
): Promise<Record<string, unknown>> {
const user_script_functions = await this.generate_user_script_functions(
config
);
async generate_object(): Promise<Record<string, unknown>> {
const user_script_functions = await this.generate_user_script_functions();
return Object.fromEntries(user_script_functions);
}
}
@@ -3,11 +3,11 @@ import { promisify } from "util";
import { App, Platform, FileSystemAdapter } from "obsidian";

import TemplaterPlugin from "main";
import { IGenerateObject } from "functions/IGenerateObject";
import { RunningConfig } from "Templater";
import { UNSUPPORTED_MOBILE_TEMPLATE } from "Constants";
import { TemplaterError } from "Error";
import { FunctionsMode } from "functions/FunctionsGenerator";
import { IGenerateObject } from "../IGenerateObject";
import { RunningConfig } from "core/Templater";
import { UNSUPPORTED_MOBILE_TEMPLATE } from "utils/Constants";
import { TemplaterError } from "utils/Error";
import { FunctionsMode } from "../FunctionsGenerator";

export class UserSystemFunctions implements IGenerateObject {
private cwd: string;
@@ -1,11 +1,11 @@
import * as Eta from "eta";
import { renderAsync } from "eta";

export class Parser {
async parse_commands(
content: string,
object: Record<string, unknown>
): Promise<string> {
content = (await Eta.renderAsync(content, object, {
content = (await renderAsync(content, object, {
varName: "tp",
parse: {
exec: "*",
@@ -15,20 +15,23 @@ import {
is_module_name,
ModuleName,
TpSuggestDocumentation,
} from "functions/TpDocumentation";
Documentation
} from "./TpDocumentation";

export class Autocomplete extends EditorSuggest<TpSuggestDocumentation> {
//private in_command = false;
// https://regex101.com/r/ocmHzR/1
private tp_keyword_regex =
/tp\.(?<module>[a-z]*)?(?<fn_trigger>\.(?<fn>[a-z_]*)?)?$/;
private documentation: Documentation;
private latest_trigger_info: EditorSuggestTriggerInfo;
private module_name: ModuleName | string;
private function_trigger: boolean;
private function_name: string;

constructor(private app: App, private plugin: TemplaterPlugin) {
super(app);
this.documentation = new Documentation(this.app);
}

onTrigger(
@@ -76,12 +79,12 @@ export class Autocomplete extends EditorSuggest<TpSuggestDocumentation> {
let suggestions: Array<TpSuggestDocumentation>;
if (this.module_name && this.function_trigger) {
suggestions =
this.plugin.templater.documentation.get_all_functions_documentation(
this.documentation.get_all_functions_documentation(
this.module_name as ModuleName
);
} else {
suggestions =
this.plugin.templater.documentation.get_all_modules_documentation();
this.documentation.get_all_modules_documentation();
}
if (!suggestions) {
return [];
@@ -5,7 +5,7 @@ import {
EditorTransaction,
MarkdownView,
} from "obsidian";
import { escape_RegExp } from "Utils";
import { escape_RegExp } from "utils/Utils";

export class CursorJumper {
constructor(private app: App) {}
@@ -33,15 +33,15 @@ export class CursorJumper {
content: string,
index: number
): EditorPosition {
const substr = content.substr(0, index);
const substr = content.slice(0, index);

let l = 0;
let offset = -1;
let r = -1;
for (; (r = substr.indexOf("\n", r + 1)) !== -1; l++, offset = r);
offset += 1;

const ch = content.substr(offset, index - offset).length;
const ch = content.slice(offset, index).length;

return { line: l, ch: ch };
}
@@ -1,8 +1,8 @@
import { App, Platform } from "obsidian";
import { App, Platform, TFile } from "obsidian";
import TemplaterPlugin from "main";
import { TemplaterError } from "Error";
import { TemplaterError } from "utils/Error";
import { CursorJumper } from "editor/CursorJumper";
import { log_error } from "Log";
import { log_error } from "utils/Log";
import { Autocomplete } from "editor/Autocomplete";

import "editor/mode/javascript";
@@ -28,11 +28,16 @@ export class Editor {

async setup(): Promise<void> {
await this.registerCodeMirrorMode();
//await this.registerHinter();
this.plugin.registerEditorSuggest(new Autocomplete(this.app, this.plugin));
}

async jump_to_next_cursor_location(): Promise<void> {
async jump_to_next_cursor_location(file: TFile = null, auto_jump = false): Promise<void> {
if (auto_jump && !this.plugin.settings.auto_jump_to_cursor) {
return;
}
if (file && this.app.workspace.getActiveFile() !== file) {
return;
}
this.cursor_jumper.jump_to_next_cursor_location();
}

@@ -159,56 +164,4 @@ export class Editor {
);
});
}

async registerHinter(): Promise<void> {
// TODO
/*
await delay(1000);
var comp = [
["here", "hither"],
["asynchronous", "nonsynchronous"],
["completion", "achievement", "conclusion", "culmination", "expirations"],
["hinting", "advise", "broach", "imply"],
["function","action"],
["provide", "add", "bring", "give"],
["synonyms", "equivalents"],
["words", "token"],
["each", "every"],
];
function synonyms(cm: any, option: any) {
return new Promise(function(accept) {
setTimeout(function() {
var cursor = cm.getCursor(), line = cm.getLine(cursor.line)
var start = cursor.ch, end = cursor.ch
while (start && /\w/.test(line.charAt(start - 1))) --start
while (end < line.length && /\w/.test(line.charAt(end))) ++end
var word = line.slice(start, end).toLowerCase()
for (var i = 0; i < comp.length; i++) {
if (comp[i].indexOf(word) != -1) {
return accept({
list: comp[i],
from: window.CodeMirror.Pos(cursor.line, start),
to: window.CodeMirror.Pos(cursor.line, end)
});
}
}
return accept(null);
}, 100)
});
}
this.app.workspace.on("codemirror", cm => {
cm.setOption("extraKeys", {"Ctrl-Space": "autocomplete"});
cm.setOption("hintOptions", {hint: synonyms});
});
this.app.workspace.iterateCodeMirrors(cm => {
console.log("CM:", cm);
cm.setOption("extraKeys", {"Space": "autocomplete"});
cm.setOption("hintOptions", {hint: synonyms});
});
*/
}
}
File renamed without changes.
@@ -1,8 +1,8 @@
import { App } from "obsidian";

import TemplaterPlugin from "main";
import { resolve_tfile } from "Utils";
import { errorWrapperSync } from "Error";
import { resolve_tfile } from "utils/Utils";
import { errorWrapperSync } from "utils/Error";

export class CommandHandler {
constructor(private app: App, private plugin: TemplaterPlugin) {}
@@ -46,7 +46,7 @@ export class CommandHandler {
},
],
callback: () => {
this.plugin.templater.editor.jump_to_next_cursor_location();
this.plugin.editor_handler.jump_to_next_cursor_location();
},
});

@@ -1,6 +1,6 @@
import TemplaterPlugin from "main";
import { Templater } from "Templater";
import { Settings } from "Settings";
import { Templater } from "core/Templater";
import { Settings } from "settings/Settings";
import {
App,
EventRef,
@@ -1,8 +1,8 @@
import { App, FuzzySuggestModal, TFile, TFolder } from "obsidian";
import { get_tfiles_from_folder } from "Utils";
import { get_tfiles_from_folder } from "utils/Utils";
import TemplaterPlugin from "./main";
import { errorWrapperSync } from "Error";
import { log_error } from "Log";
import { errorWrapperSync } from "utils/Error";
import { log_error } from "utils/Log";

export enum OpenMode {
InsertTemplate,
@@ -1,26 +1,30 @@
import { addIcon, Plugin } from "obsidian";
import { addIcon, Plugin } from 'obsidian';

import { DEFAULT_SETTINGS, Settings, TemplaterSettingTab } from "Settings";
import { FuzzySuggester } from "FuzzySuggester";
import { ICON_DATA } from "Constants";
import { Templater } from "Templater";
import EventHandler from "EventHandler";
import { CommandHandler } from "CommandHandler";
import { TpDocumentation } from "functions/TpDocumentation";
import { DEFAULT_SETTINGS, Settings, TemplaterSettingTab } from "settings/Settings";
import { FuzzySuggester } from "handlers/FuzzySuggester";
import { ICON_DATA } from "utils/Constants";
import { Templater } from "core/Templater";
import EventHandler from "handlers/EventHandler";
import { CommandHandler } from "handlers/CommandHandler";
import { Editor } from "editor/Editor";

export default class TemplaterPlugin extends Plugin {
public settings: Settings;
public templater: Templater;
public event_handler: EventHandler;
public command_handler: CommandHandler;
public fuzzy_suggester: FuzzySuggester;
public editor_handler: Editor;

async onload(): Promise<void> {
await this.load_settings();

this.templater = new Templater(this.app, this);
await this.templater.setup();

this.editor_handler = new Editor(this.app, this);
await this.editor_handler.setup();

this.fuzzy_suggester = new FuzzySuggester(this.app, this);

this.event_handler = new EventHandler(
@@ -1,10 +1,10 @@
import { App, ButtonComponent, PluginSettingTab, Setting } from "obsidian";
import { errorWrapperSync, TemplaterError } from "Error";
import { FolderSuggest } from "suggesters/FolderSuggester";
import { FileSuggest, FileSuggestMode } from "suggesters/FileSuggester";
import TemplaterPlugin from "./main";
import { arraymove, get_tfiles_from_folder } from "Utils";
import { log_error } from "Log";
import { errorWrapperSync, TemplaterError } from "utils/Error";
import { FolderSuggest } from "./suggesters/FolderSuggester";
import { FileSuggest, FileSuggestMode } from "./suggesters/FileSuggester";
import TemplaterPlugin from "main";
import { arraymove, get_tfiles_from_folder } from "utils/Utils";
import { log_error } from "utils/Log";

export interface FolderTemplate {
folder: string;
@@ -1,10 +1,10 @@
// Credits go to Liam's Periodic Notes Plugin: https://github.com/liamcain/obsidian-periodic-notes

import { App, TAbstractFile, TFile } from "obsidian";
import { TextInputSuggest } from "suggesters/suggest";
import { get_tfiles_from_folder } from "Utils";
import { TextInputSuggest } from "./suggest";
import { get_tfiles_from_folder } from "utils/Utils";
import TemplaterPlugin from "main";
import { errorWrapperSync } from "Error";
import { errorWrapperSync } from "utils/Error";

export enum FileSuggestMode {
TemplateFiles,
@@ -1,7 +1,7 @@
// Credits go to Liam's Periodic Notes Plugin: https://github.com/liamcain/obsidian-periodic-notes

import { TAbstractFile, TFolder } from "obsidian";
import { TextInputSuggest } from "suggesters/suggest";
import { TextInputSuggest } from "./suggest";

export class FolderSuggest extends TextInputSuggest<TFolder> {
getSuggestions(inputStr: string): TFolder[] {
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,4 @@
import { log_error } from "Log";
import { log_error } from "./Log";

export class TemplaterError extends Error {
constructor(msg: string, public console_msg?: string) {
@@ -1,5 +1,5 @@
import { Notice } from "obsidian";
import { TemplaterError } from "Error";
import { TemplaterError } from "./Error";

export function log_update(msg: string): void {
const notice = new Notice("", 15000);
@@ -1,4 +1,4 @@
import { TemplaterError } from "Error";
import { TemplaterError } from "./Error";
import {
App,
normalizePath,
@@ -1,4 +1,4 @@
import { TFile, TFolder } from "obsidian";
import { TFile } from "obsidian";
import TestTemplaterPlugin from "./main.test";

export const PLUGIN_NAME = "templater-obsidian";
@@ -2,7 +2,7 @@ import { Plugin, TAbstractFile, TFile, TFolder } from "obsidian";
import chai from "chai";
import chaiAsPromised from "chai-as-promised";

import { RunMode, RunningConfig } from "Templater";
import { RunMode, RunningConfig } from "core/Templater";
import TemplaterPlugin from "main";
import {
cache_update,
@@ -9,8 +9,8 @@
"noImplicitAny": true,
"moduleResolution": "node",
"importHelpers": true,
"esModuleInterop": true,
"lib": ["dom", "es6", "scripthost", "es2015", "es2019"]
"lib": ["dom", "es5", "es6", "es7", "es2019"],
"allowSyntheticDefaultImports": true
},
"include": ["src/**/*.ts", "tests/**/*.ts"]
}
@@ -9,7 +9,7 @@ module.exports.readVersion = function (contents) {
return Object.keys(JSON.parse(contents))[0];
};

module.exports.writeVersion = async function (contents, version) {
module.exports.writeVersion = function (contents, version) {
let json = JSON.parse(contents);
let indent = detectIndent(contents).indent;
let newline = detectNewline(contents);
@@ -1,4 +1,6 @@
{
"1.10.0": "0.13.19",
"1.9.11": "0.13.19",
"1.9.10": "0.12.2",
"1.9.9": "0.12.2",
"1.9.8": "0.12.2",