Files
CrazyJasonwell fb40c9b109 add all
2025-10-25 20:35:10 +08:00

136 lines
4.7 KiB
JavaScript
Executable File

/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// main.ts
var main_exports = {};
__export(main_exports, {
default: () => TextWrap
});
module.exports = __toCommonJS(main_exports);
var import_obsidian = require("obsidian");
var DEFAULT_SETTINGS = {
quickTagOne: "",
quickTagTwo: "",
quickTagThree: ""
};
var TextWrap = class extends import_obsidian.Plugin {
async onload() {
await this.loadSettings();
this.addCommand({
id: "wrap-text",
name: "Enter new tags",
editorCallback: (editor, view) => {
const selection = editor.getSelection();
const tagAndText = (tag, text) => {
editor.replaceSelection(`<${tag}>${text}</${tag}>`);
};
new TextWrapModal(this.app, selection, tagAndText).open();
}
});
this.addCommand({
id: "quick-tag-one",
name: "Quick Tag One",
editorCallback: (editor, view) => {
const selection = editor.getSelection();
const tag = this.settings.quickTagOne;
editor.replaceSelection(`<${tag}>${selection}</${tag}>`);
}
});
this.addCommand({
id: "quick-tag-two",
name: "Quick Tag Two",
editorCallback: (editor, view) => {
const selection = editor.getSelection();
const tag = this.settings.quickTagTwo;
editor.replaceSelection(`<${tag}>${selection}</${tag}>`);
}
});
this.addCommand({
id: "quick-tag-three",
name: "Quick Tag Three",
editorCallback: (editor, view) => {
const selection = editor.getSelection();
const tag = this.settings.quickTagThree;
editor.replaceSelection(`<${tag}>${selection}</${tag}>`);
}
});
this.addSettingTab(new SettingTab(this.app, this));
}
onunload() {
}
async loadSettings() {
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
}
async saveSettings() {
await this.saveData(this.settings);
}
};
var TextWrapModal = class extends import_obsidian.Modal {
constructor(app, defaultText, tagAndText) {
super(app);
this.modalText = defaultText;
this.tagAndText = tagAndText;
}
onOpen() {
const { contentEl } = this;
contentEl.createEl("h3", { text: "Enter tags" });
new import_obsidian.Setting(contentEl).setName("Press submit button to send tags").addText((text) => text.onChange((value) => {
this.modalTag = value;
}));
new import_obsidian.Setting(contentEl).addButton((btn) => btn.setButtonText("Submit").setCta().onClick(() => {
this.tagAndText(this.modalTag, this.modalText);
this.close();
}));
}
onClose() {
const { contentEl } = this;
contentEl.empty();
}
};
var SettingTab = class extends import_obsidian.PluginSettingTab {
constructor(app, plugin) {
super(app, plugin);
this.plugin = plugin;
}
display() {
const { containerEl } = this;
containerEl.empty();
containerEl.createEl("h2", { text: "Customize Quick Tags" });
containerEl.createEl("p", { text: "Tags will be applied to selected text as: <tagName>selectedText</tagName>" });
new import_obsidian.Setting(containerEl).setName("Quick Tag One").setDesc("Customize").addText((text) => text.setValue(this.plugin.settings.quickTagOne).onChange(async (value) => {
this.plugin.settings.quickTagOne = value;
await this.plugin.saveSettings();
}));
new import_obsidian.Setting(containerEl).setName("Quick Tag Two").setDesc("Customize").addText((text) => text.setValue(this.plugin.settings.quickTagTwo).onChange(async (value) => {
this.plugin.settings.quickTagTwo = value;
await this.plugin.saveSettings();
}));
new import_obsidian.Setting(containerEl).setName("Quick Tag Three").setDesc("Customize").addText((text) => text.setValue(this.plugin.settings.quickTagThree).onChange(async (value) => {
this.plugin.settings.quickTagThree = value;
await this.plugin.saveSettings();
}));
}
};
/* nosourcemap */