mirror of
https://github.com/alberti42/obsidian-plugins-annotations.git
synced 2026-07-22 10:10:24 +00:00
New settings
This commit is contained in:
parent
5a93cef1bf
commit
0675fe3b7d
10 changed files with 203 additions and 63 deletions
|
|
@ -2,5 +2,45 @@
|
|||
"dataview-recent-files": "markdown:\nMy own plugin to show the recently modified files.\n[[2024-06-13 Survey group culture]]\n\n![[00 Meta/Misc/Test.jpg]]\n\n[[2024-08-05 Review Cs-based Rydberg quantum computers]]",
|
||||
"dataview": "Super-useful plugin that allows querying the notes to provide database functionality. 🔥🔥🔥",
|
||||
"highlightr-plugin": "Allows highlighting the markdown text.",
|
||||
"obsidian-completr": "Allows auto-completion of commands. Very useful."
|
||||
"obsidian-completr": "Allows auto-completion of commands. Very useful.",
|
||||
"find-unlinked-files": "Very useful to find orphaned files and broken links.",
|
||||
"homepage": "Useful to show a customized homepage.",
|
||||
"obsidian-icon-folder": "Useful to customize icons.",
|
||||
"import-attachments-plus": "My own plugin to import attachments by moving them into the vault.",
|
||||
"obsidian-languagetool-plugin": "Very useful as spell checker.",
|
||||
"languagetool": "It is claimed to be better but it does not work. It is still in beta function.",
|
||||
"number-headings-obsidian": "Very useful to add numbers to the headings.",
|
||||
"pdf-plus": "Very useful to comment PDF documents in Obsidian.",
|
||||
"templater-obsidian": "Very useful to define templates.",
|
||||
"obsidian-tasks-plugin": "Not really useful. Never used so far.",
|
||||
"obsidian-style-settings": "Super useful to customize the style with CCS and be able to modify the settings from Obsidian.",
|
||||
"obsidian-smart-typography": "Semi useful to improve typography of symbols.",
|
||||
"wikilinks-to-mdlinks-obsidian": "Not really needed. It converts Wikilinks to MD links.",
|
||||
"webpage-html-export": "Super useful to export in HTML. It is a bit clunky to load. It is per default disabled, unless I need it.",
|
||||
"frontmatter-modified-date": "Very useful to update the property `modified date`.",
|
||||
"supercharged-links-obsidian": "The idea is very nice but then the MD notes are not really readable outside of Obsidian. Disabled for now.",
|
||||
"tag-wrangler": "Very useful to rename tags across all notes.",
|
||||
"sheets": "Useful to extend tables and merge cells.",
|
||||
"obsidian-html-plugin": "It allows opening HTML files in Obsidian.",
|
||||
"obsidian-advanced-uri": "Very useful to copy URI.",
|
||||
"callout-manager": "Offers a GUI to customize callouts.",
|
||||
"obsidian-file-path-to-uri": "Not really needed. It converts a file path to a URI.",
|
||||
"obsidian-text-expander-js": "Quite powerful to run inline scripts, and replace predefined macros. However, not really used.",
|
||||
"omnisearch": "Powerful tool to search through the vault.",
|
||||
"obsidian-outliner": "Very handy to operate on outlines.",
|
||||
"url-into-selection": "Not really needed. It causes more confusion when pasting on existing selected text.",
|
||||
"periodic-notes": "Manages daily notes. Just used for daily notes.",
|
||||
"settings-search": "Adds a search field with a fuzzy search functionality to search through Obsidian settings.",
|
||||
"text-extractor": "I did not really test it how good it works.",
|
||||
"file-explorer-note-count": "Very useful to display the number of notes in the various folders.",
|
||||
"plugins-annotations": "My own plugin to take notes about installed plugins.",
|
||||
"editing-toolbar": "Nice toolbar shown above the notes. Quite handy.",
|
||||
"obsidian-spaced-repetition": "Super effective plugin to learn flashcards.",
|
||||
"table-editor-obsidian": "A must to operate on tables in Obsidian. 🚀🚀🚀",
|
||||
"settings-management": "Enhanced settings with multiple configurations.",
|
||||
"obsidian-admonition": "Improve callouts 🖋️. They can be entered as `codeblocks`.",
|
||||
"obsidian-divide-and-conquer": "Plugin useful to debug problems with plugins. Generally, it can be left disabled.",
|
||||
"js-engine": "Allows executing Javascript dynamically in the note.",
|
||||
"plugin-reloader": "Allows reloading a specific plugin without restarting Obsidian. Hotkeys configurable.",
|
||||
"obsidian-kanban": "Plugin for the Kanban 🗓️ organization."
|
||||
}
|
||||
|
|
@ -4,7 +4,47 @@
|
|||
"dataview-recent-files": "markdown:\nMy own plugin to show the recently modified files.\n[[2024-06-13 Survey group culture]]\n\n![[00 Meta/Misc/Test.jpg]]\n\n[[2024-08-05 Review Cs-based Rydberg quantum computers]]",
|
||||
"dataview": "Super-useful plugin that allows querying the notes to provide database functionality. 🔥🔥🔥",
|
||||
"highlightr-plugin": "Allows highlighting the markdown text.",
|
||||
"obsidian-completr": "Allows auto-completion of commands. Very useful."
|
||||
"obsidian-completr": "Allows auto-completion of commands. Very useful.",
|
||||
"find-unlinked-files": "Very useful to find orphaned files and broken links.",
|
||||
"homepage": "Useful to show a customized homepage.",
|
||||
"obsidian-icon-folder": "Useful to customize icons.",
|
||||
"import-attachments-plus": "My own plugin to import attachments by moving them into the vault.",
|
||||
"obsidian-languagetool-plugin": "Very useful as spell checker.",
|
||||
"languagetool": "It is claimed to be better but it does not work. It is still in beta function.",
|
||||
"number-headings-obsidian": "Very useful to add numbers to the headings.",
|
||||
"pdf-plus": "Very useful to comment PDF documents in Obsidian.",
|
||||
"templater-obsidian": "Very useful to define templates.",
|
||||
"obsidian-tasks-plugin": "Not really useful. Never used so far.",
|
||||
"obsidian-style-settings": "Super useful to customize the style with CCS and be able to modify the settings from Obsidian.",
|
||||
"obsidian-smart-typography": "Semi useful to improve typography of symbols.",
|
||||
"wikilinks-to-mdlinks-obsidian": "Not really needed. It converts Wikilinks to MD links.",
|
||||
"webpage-html-export": "Super useful to export in HTML. It is a bit clunky to load. It is per default disabled, unless I need it.",
|
||||
"frontmatter-modified-date": "Very useful to update the property `modified date`.",
|
||||
"supercharged-links-obsidian": "The idea is very nice but then the MD notes are not really readable outside of Obsidian. Disabled for now.",
|
||||
"tag-wrangler": "Very useful to rename tags across all notes.",
|
||||
"sheets": "Useful to extend tables and merge cells.",
|
||||
"obsidian-html-plugin": "It allows opening HTML files in Obsidian.",
|
||||
"obsidian-advanced-uri": "Very useful to copy URI.",
|
||||
"callout-manager": "Offers a GUI to customize callouts.",
|
||||
"obsidian-file-path-to-uri": "Not really needed. It converts a file path to a URI.",
|
||||
"obsidian-text-expander-js": "Quite powerful to run inline scripts, and replace predefined macros. However, not really used.",
|
||||
"omnisearch": "Powerful tool to search through the vault.",
|
||||
"obsidian-outliner": "Very handy to operate on outlines.",
|
||||
"url-into-selection": "Not really needed. It causes more confusion when pasting on existing selected text.",
|
||||
"periodic-notes": "Manages daily notes. Just used for daily notes.",
|
||||
"settings-search": "Adds a search field with a fuzzy search functionality to search through Obsidian settings.",
|
||||
"text-extractor": "I did not really test it how good it works.",
|
||||
"file-explorer-note-count": "Very useful to display the number of notes in the various folders.",
|
||||
"plugins-annotations": "My own plugin to take notes about installed plugins.",
|
||||
"editing-toolbar": "Nice toolbar shown above the notes. Quite handy.",
|
||||
"obsidian-spaced-repetition": "Super effective plugin to learn flashcards.",
|
||||
"table-editor-obsidian": "A must to operate on tables in Obsidian. 🚀🚀🚀",
|
||||
"settings-management": "Enhanced settings with multiple configurations.",
|
||||
"obsidian-admonition": "Improve callouts 🖋️. They can be entered as `codeblocks`.",
|
||||
"obsidian-divide-and-conquer": "Plugin useful to debug problems with plugins. Generally, it can be left disabled.",
|
||||
"js-engine": "Allows executing Javascript dynamically in the note.",
|
||||
"plugin-reloader": "Allows reloading a specific plugin without restarting Obsidian. Hotkeys configurable.",
|
||||
"obsidian-kanban": "Plugin for the Kanban 🗓️ organization."
|
||||
},
|
||||
"plugins_annotations_uuid": "FAA70013-38E9-4FDF-B06A-F899F6487C19",
|
||||
"hide_placeholders": true,
|
||||
|
|
@ -13,7 +53,5 @@
|
|||
"label_desktop": "<b>Personal annotation: </b>",
|
||||
"label_placeholder": "<em>Add your personal comment about <strong>${plugin_name}</strong> here...</em>",
|
||||
"editable": true,
|
||||
"automatic_remove": false,
|
||||
"markdown_file_path": "00 Meta/Misc/Plugins annotations.md",
|
||||
"markdown_notes": false
|
||||
"automatic_remove": false
|
||||
}
|
||||
|
|
@ -229,7 +229,5 @@
|
|||
"label_desktop": "<b>Personal annotation: </b>",
|
||||
"label_placeholder": "<em>Add your personal comment about <strong>${plugin_name}</strong> here...</em>",
|
||||
"editable": true,
|
||||
"automatic_remove": false,
|
||||
"markdown_file_path": "00 Meta/Misc/Plugins annotations.md",
|
||||
"markdown_notes": false
|
||||
"automatic_remove": false
|
||||
}
|
||||
|
|
@ -1,5 +1,17 @@
|
|||
// defaults.ts
|
||||
|
||||
// import { PluginsAnnotationsSettings_1_4_0 } from './types_legacy';
|
||||
import { PluginsAnnotationsSettings } from './types';
|
||||
|
||||
export const a = 1;
|
||||
export const DEFAULT_SETTINGS: PluginsAnnotationsSettings = {
|
||||
annotations: {},
|
||||
plugins_annotations_uuid: 'BC56AB7B-A46F-4ACF-9BA1-3A4461F74C79',
|
||||
hide_placeholders: false,
|
||||
delete_placeholder_string_on_insertion: false,
|
||||
label_mobile: '<b>Annotation: </b>',
|
||||
label_desktop: '<b>Personal annotation: </b>',
|
||||
label_placeholder : "<em>Add your personal comment about <strong>${plugin_name}</strong> here...</em>",
|
||||
editable: true,
|
||||
automatic_remove: false,
|
||||
markdown_file_path: '',
|
||||
compatibility: '1.5.0',
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ export const DEFAULT_SETTINGS_1_4_0: PluginsAnnotationsSettings_1_4_0 = {
|
|||
label_placeholder : "<em>Add your personal comment about <strong>${plugin_name}</strong> here...</em>",
|
||||
editable: true,
|
||||
automatic_remove: false,
|
||||
markdown_file_path: '',
|
||||
}
|
||||
|
||||
export const DEFAULT_SETTINGS_1_3_0: PluginsAnnotationsSettings_1_3_0 = {
|
||||
|
|
|
|||
74
src/main.ts
74
src/main.ts
|
|
@ -14,15 +14,16 @@ import {
|
|||
// App,
|
||||
} from 'obsidian';
|
||||
import { around } from 'monkey-around';
|
||||
import { AnnotationType } from './types';
|
||||
import { PluginAnnotationDict_1_4_0, isPluginsAnnotationsSettings_1_4_0, PluginsAnnotationsSettings_1_4_0, PluginsAnnotationsSettings_1_3_0, isPluginAnnotationDictFormat_1_3_0, isSettingsFormat_1_3_0} from 'types_legacy'
|
||||
import { AnnotationType, isPluginsAnnotationsSettings, PluginAnnotationDict, PluginsAnnotationsSettings } from './types';
|
||||
import { PluginAnnotationDict_1_4_0, PluginsAnnotationsSettings_1_4_0, PluginsAnnotationsSettings_1_3_0, isPluginAnnotationDictFormat_1_3_0, isSettingsFormat_1_3_0, isSettingsFormat_1_4_0, parse_annotation_1_4_0, } from 'types_legacy'
|
||||
import { DEFAULT_SETTINGS_1_3_0, DEFAULT_SETTINGS_1_4_0 } from './defaults_legacy';
|
||||
import { DEFAULT_SETTINGS } from 'defaults';
|
||||
import { PluginsAnnotationsSettingTab } from 'settings_tab'
|
||||
import * as path from 'path';
|
||||
import { readAnnotationsFromFile, writeAnnotationsToFile } from 'manageAnnotations';
|
||||
|
||||
export default class PluginsAnnotations extends Plugin {
|
||||
settings: PluginsAnnotationsSettings_1_4_0 = {...DEFAULT_SETTINGS_1_4_0};
|
||||
settings: PluginsAnnotationsSettings = {...DEFAULT_SETTINGS};
|
||||
pluginNameToIdMap: Record<string,string> = {};
|
||||
pluginIdToNameMap: Record<string,string> = {};
|
||||
|
||||
|
|
@ -71,9 +72,35 @@ export default class PluginsAnnotations extends Plugin {
|
|||
|
||||
// type: AnnotationType.markdown,
|
||||
|
||||
if (isPluginsAnnotationsSettings_1_4_0(data)) {
|
||||
const settings: PluginsAnnotationsSettings_1_4_0 = data;
|
||||
if (isPluginsAnnotationsSettings(data)) {
|
||||
const settings: PluginsAnnotationsSettings = data;
|
||||
return settings;
|
||||
} else if (isSettingsFormat_1_4_0(data)) { // previous versions where the name of the plugins was not stored
|
||||
// Upgrade annotations format
|
||||
const upgradedAnnotations: PluginAnnotationDict = {};
|
||||
for (const pluginId in data.annotations) {
|
||||
const annotation = data.annotations[pluginId];
|
||||
const {type,content} = parse_annotation_1_4_0(annotation.anno);
|
||||
upgradedAnnotations[pluginId] = {
|
||||
name: annotation.name,
|
||||
desc: content,
|
||||
type: type,
|
||||
};
|
||||
}
|
||||
|
||||
const oldSettings: PluginsAnnotationsSettings_1_4_0 = data;
|
||||
|
||||
// Update the data with the new format
|
||||
const newSettings: PluginsAnnotationsSettings = {
|
||||
...oldSettings,
|
||||
annotations: upgradedAnnotations,
|
||||
plugins_annotations_uuid: DEFAULT_SETTINGS.plugins_annotations_uuid,
|
||||
compatibility: DEFAULT_SETTINGS.compatibility,
|
||||
markdown_file_path: DEFAULT_SETTINGS.markdown_file_path
|
||||
};
|
||||
wasUpdated = true;
|
||||
return getSettingsFromData(newSettings);
|
||||
|
||||
} else if (isSettingsFormat_1_3_0(data)) { // previous versions where the name of the plugins was not stored
|
||||
// Upgrade annotations format
|
||||
const upgradedAnnotations: PluginAnnotationDict_1_4_0 = {};
|
||||
|
|
@ -105,10 +132,9 @@ export default class PluginsAnnotations extends Plugin {
|
|||
};
|
||||
|
||||
// Merge loaded settings with default settings
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS_1_4_0, getSettingsFromData(await this.loadData()));
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, getSettingsFromData(await this.loadData()));
|
||||
|
||||
if(wasUpdated) {
|
||||
console.log("SAVED");
|
||||
this.debouncedSaveAnnotations();
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +160,7 @@ export default class PluginsAnnotations extends Plugin {
|
|||
} else return "";
|
||||
}
|
||||
|
||||
async saveSettings(settings:PluginsAnnotationsSettings_1_4_0) {
|
||||
async saveSettings(settings:PluginsAnnotationsSettings) {
|
||||
try {
|
||||
await this.saveData(settings);
|
||||
} catch (error) {
|
||||
|
|
@ -277,24 +303,6 @@ export default class PluginsAnnotations extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
// Function to render the annotation based on preamble
|
||||
parse_annotation(annotation_div: HTMLDivElement, text: string): {type:AnnotationType,content:string} {
|
||||
const lines = text.split('\n');
|
||||
const preamble = lines[0].toLowerCase();
|
||||
const sliced = lines.slice(1).join('\n');
|
||||
|
||||
annotation_div.innerHTML = '';
|
||||
if (preamble.startsWith('html:')) {
|
||||
return {type: AnnotationType.html, content: sliced};
|
||||
} else if (preamble.startsWith('markdown:')) {
|
||||
return {type: AnnotationType.markdown, content: sliced};
|
||||
} else if (preamble.startsWith('text:')) {
|
||||
return {type: AnnotationType.text, content: sliced};
|
||||
} else {
|
||||
return {type: AnnotationType.text, content: text};
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to parse links and add click listeners
|
||||
parse_links(element: HTMLElement) {
|
||||
const links = element.querySelectorAll('a');
|
||||
|
|
@ -372,7 +380,7 @@ export default class PluginsAnnotations extends Plugin {
|
|||
const placeholder = (this.settings.label_placeholder).replace(/\$\{plugin_name\}/g, pluginName);
|
||||
|
||||
let isPlaceholder = this.settings.annotations[pluginId] ? false : true;
|
||||
let annotation_text = ((this.settings.annotations[pluginId] && this.settings.annotations[pluginId].anno) || placeholder).trim();
|
||||
let annotation_text = ((this.settings.annotations[pluginId] && this.settings.annotations[pluginId].desc) || placeholder).trim();
|
||||
|
||||
if (isPlaceholder) {
|
||||
annotation_div.classList.add('plugin-comment-placeholder');
|
||||
|
|
@ -384,7 +392,7 @@ export default class PluginsAnnotations extends Plugin {
|
|||
// Parsing the stored annotation
|
||||
let type:AnnotationType;
|
||||
let content:string;
|
||||
({type,content} = this.parse_annotation(annotation_div,annotation_text));
|
||||
({type,content} = parse_annotation_1_4_0(annotation_text));
|
||||
|
||||
// Initial render
|
||||
if(isPlaceholder) {
|
||||
|
|
@ -443,7 +451,7 @@ export default class PluginsAnnotations extends Plugin {
|
|||
}
|
||||
isPlaceholder = true;
|
||||
} else {
|
||||
({type,content} = this.parse_annotation(annotation_div,annotation_text));
|
||||
({type,content} = parse_annotation_1_4_0(annotation_text));
|
||||
this.render_annotation(annotation_div,type,content);
|
||||
}
|
||||
}
|
||||
|
|
@ -470,9 +478,9 @@ export default class PluginsAnnotations extends Plugin {
|
|||
} else {
|
||||
isPlaceholder = false;
|
||||
this.settings.annotations[pluginId] = {
|
||||
anno: annotation_text,
|
||||
desc: annotation_text,
|
||||
name: pluginName,
|
||||
// type: AnnotationType.markdown,
|
||||
type: AnnotationType.markdown, // FIXME
|
||||
};
|
||||
annotation_div.classList.remove('plugin-comment-placeholder');
|
||||
isPlaceholder = false;
|
||||
|
|
@ -644,9 +652,9 @@ export default class PluginsAnnotations extends Plugin {
|
|||
this.disconnectObservers();
|
||||
}
|
||||
|
||||
getUninstalledPlugins(): PluginAnnotationDict_1_4_0 {
|
||||
getUninstalledPlugins(): PluginAnnotationDict {
|
||||
const installedPluginIds = new Set(Object.keys(this.app.plugins.manifests));
|
||||
const uninstalledPlugins: PluginAnnotationDict_1_4_0 = {};
|
||||
const uninstalledPlugins: PluginAnnotationDict = {};
|
||||
|
||||
for (const pluginId in this.settings.annotations) {
|
||||
if (!installedPluginIds.has(pluginId)) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { Platform, TFile } from "obsidian";
|
|||
import { createFolderIfNotExists, joinPaths, makePosixPathOScompatible, parseFilePath, showConfirmationDialog } from "utils";
|
||||
import { parse, SyntaxError } from "./peggy.mjs";
|
||||
import { PluginAnnotationDict_1_4_0 } from "types_legacy";
|
||||
import { PluginAnnotationDict } from "types";
|
||||
|
||||
export async function handleMarkdownFilePathChange(plugin: PluginsAnnotations, filepath: string): Promise<boolean> {
|
||||
const file = plugin.app.vault.getAbstractFileByPath(filepath);
|
||||
|
|
@ -74,7 +75,7 @@ export async function readAnnotationsFromFile(plugin: PluginsAnnotations): Promi
|
|||
const md_content = await plugin.app.vault.read(file);
|
||||
|
||||
try {
|
||||
const md_content_parsed = parse(md_content) as PluginAnnotationDict_1_4_0;
|
||||
const md_content_parsed = parse(md_content) as PluginAnnotationDict;
|
||||
plugin.settings.annotations = md_content_parsed;
|
||||
} catch(error) {
|
||||
if (error instanceof SyntaxError) {
|
||||
|
|
@ -100,7 +101,7 @@ export async function writeAnnotationsToFile(plugin: PluginsAnnotations) {
|
|||
|
||||
const content: string[] = [header];
|
||||
for (const pluginId in annotations) {
|
||||
content.push(`# ${annotations[pluginId].name}\n\n<!-- id: ${pluginId} -->\n<!-- BEGIN ANNOTATION -->\n${annotations[pluginId].anno}\n<!-- END ANNOTATION -->\n`);
|
||||
content.push(`# ${annotations[pluginId].name}\n\n<!-- id: ${pluginId} -->\n<!-- BEGIN ANNOTATION -->\n${annotations[pluginId].desc}\n<!-- END ANNOTATION -->\n`);
|
||||
}
|
||||
|
||||
console.log(content.join('\n'));
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import PluginsAnnotations from "main";
|
||||
import { handleMarkdownFilePathChange } from "manageAnnotations";
|
||||
import { AbstractInputSuggest, App, Platform, PluginSettingTab, prepareFuzzySearch, SearchResult, Setting, TFile } from "obsidian";
|
||||
import { PluginAnnotationDict } from "types";
|
||||
import { PluginAnnotationDict_1_4_0 } from "types_legacy";
|
||||
import { parseFilePath } from "utils";
|
||||
|
||||
|
|
@ -56,7 +57,7 @@ export class PluginsAnnotationsSettingTab extends PluginSettingTab {
|
|||
}
|
||||
|
||||
createUninstalledPluginSettings(containerEl: HTMLElement) {
|
||||
const uninstalledPlugins:PluginAnnotationDict_1_4_0 = this.plugin.getUninstalledPlugins();
|
||||
const uninstalledPlugins:PluginAnnotationDict = this.plugin.getUninstalledPlugins();
|
||||
|
||||
const heading = new Setting(containerEl).setName('Personal annotations of no longer installed community plugins').setHeading();
|
||||
const headingEl = heading.settingEl;
|
||||
|
|
@ -86,7 +87,7 @@ export class PluginsAnnotationsSettingTab extends PluginSettingTab {
|
|||
Object.keys({...uninstalledPlugins}).forEach(pluginId => {
|
||||
const pluginSetting = new Setting(containerEl)
|
||||
.setName(`Plugin ${uninstalledPlugins[pluginId].name}`)
|
||||
.setDesc("Annotation: " + uninstalledPlugins[pluginId].anno)
|
||||
.setDesc("Annotation: " + uninstalledPlugins[pluginId].desc)
|
||||
.addButton(button => button
|
||||
.setButtonText('Delete')
|
||||
.setCta()
|
||||
|
|
|
|||
36
src/types.ts
36
src/types.ts
|
|
@ -1,6 +1,40 @@
|
|||
// types.ts
|
||||
|
||||
import { DEFAULT_SETTINGS_1_4_0 } from './defaults_legacy';
|
||||
import { DEFAULT_SETTINGS } from "defaults";
|
||||
|
||||
export interface PluginAnnotation {
|
||||
name: string; // extended name of the plugin
|
||||
desc: string; // personal annontation
|
||||
type: AnnotationType; // annotation type
|
||||
}
|
||||
|
||||
export interface PluginAnnotationDict {
|
||||
[pluginId: string]: PluginAnnotation;
|
||||
}
|
||||
|
||||
export interface PluginsAnnotationsSettings {
|
||||
annotations: PluginAnnotationDict;
|
||||
plugins_annotations_uuid: string;
|
||||
hide_placeholders: boolean;
|
||||
delete_placeholder_string_on_insertion: boolean;
|
||||
label_mobile: string;
|
||||
label_desktop: string;
|
||||
label_placeholder: string;
|
||||
editable: boolean;
|
||||
automatic_remove: boolean;
|
||||
markdown_file_path: string;
|
||||
compatibility: string;
|
||||
}
|
||||
|
||||
export function isPluginsAnnotationsSettings(s:unknown): s is PluginsAnnotationsSettings {
|
||||
if (typeof s !== 'object' || s === null) {
|
||||
return false;
|
||||
}
|
||||
return 'annotations' in s
|
||||
&& 'compatibility' in s && (s as PluginsAnnotationsSettings).compatibility === '1.5.0'
|
||||
&& 'plugins_annotations_uuid' in s
|
||||
&& (s as PluginsAnnotationsSettings).plugins_annotations_uuid === DEFAULT_SETTINGS.plugins_annotations_uuid;
|
||||
}
|
||||
|
||||
// type: AnnotationType; // type of annotation
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +1,24 @@
|
|||
// types_legacy.ts
|
||||
|
||||
import { DEFAULT_SETTINGS_1_3_0, DEFAULT_SETTINGS_1_4_0 } from "defaults_legacy";
|
||||
import { AnnotationType, PluginAnnotation, PluginsAnnotationsSettings } from "types";
|
||||
|
||||
/* VERSION 1.4 */
|
||||
|
||||
export interface PluginAnnotation_1_4_0 {
|
||||
name: string; // extended name of the plugin
|
||||
export interface PluginAnnotation_1_4_0 extends Omit<PluginAnnotation, 'type' | 'desc'> {
|
||||
anno: string; // personal annontation
|
||||
}
|
||||
|
||||
export interface PluginAnnotationDict_1_4_0 {
|
||||
export type PluginAnnotationDict_1_4_0 = {
|
||||
[pluginId: string]: PluginAnnotation_1_4_0;
|
||||
}
|
||||
|
||||
export interface PluginsAnnotationsSettings_1_4_0 {
|
||||
// Extend the original interface and override the annotations property
|
||||
export interface PluginsAnnotationsSettings_1_4_0 extends Omit<PluginsAnnotationsSettings, 'annotations' | 'markdown_file_path' | 'compatibility'> {
|
||||
annotations: PluginAnnotationDict_1_4_0;
|
||||
plugins_annotations_uuid: string;
|
||||
hide_placeholders: boolean;
|
||||
delete_placeholder_string_on_insertion: boolean;
|
||||
label_mobile: string;
|
||||
label_desktop: string;
|
||||
label_placeholder: string;
|
||||
editable: boolean;
|
||||
automatic_remove: boolean;
|
||||
markdown_file_path: string;
|
||||
}
|
||||
|
||||
export function isPluginsAnnotationsSettings_1_4_0(s:unknown): s is PluginsAnnotationsSettings_1_4_0 {
|
||||
export function isSettingsFormat_1_4_0(s:unknown): s is PluginsAnnotationsSettings_1_4_0 {
|
||||
if (typeof s !== 'object' || s === null) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -35,6 +27,23 @@ export function isPluginsAnnotationsSettings_1_4_0(s:unknown): s is PluginsAnnot
|
|||
&& (s as PluginsAnnotationsSettings_1_4_0).plugins_annotations_uuid === DEFAULT_SETTINGS_1_4_0.plugins_annotations_uuid;
|
||||
}
|
||||
|
||||
// Function to render the annotation based on preamble
|
||||
export function parse_annotation_1_4_0(text: string): {type:AnnotationType,content:string} {
|
||||
const lines = text.split('\n');
|
||||
const preamble = lines[0].toLowerCase();
|
||||
const sliced = lines.slice(1).join('\n');
|
||||
|
||||
// annotation_div.innerHTML = '';
|
||||
if (preamble.startsWith('html:')) {
|
||||
return {type: AnnotationType.html, content: sliced};
|
||||
} else if (preamble.startsWith('markdown:')) {
|
||||
return {type: AnnotationType.markdown, content: sliced};
|
||||
} else if (preamble.startsWith('text:')) {
|
||||
return {type: AnnotationType.text, content: sliced};
|
||||
} else {
|
||||
return {type: AnnotationType.text, content: text};
|
||||
}
|
||||
}
|
||||
|
||||
/* VERSION 1.3 */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue