diff --git a/manifest.json b/manifest.json index 2460715..469700f 100644 --- a/manifest.json +++ b/manifest.json @@ -3,6 +3,6 @@ "name": "Advanced Tables", "description": "Improved table navigation, formatting, manipulation, and formulas", "isDesktopOnly": false, - "version": "0.6.1", + "version": "0.6.2", "js": "main.js" } diff --git a/src/disabled-formulas.ts b/src/disabled-formulas.ts new file mode 100644 index 0000000..f3d9269 --- /dev/null +++ b/src/disabled-formulas.ts @@ -0,0 +1,34 @@ +import { App, Modal } from 'obsidian'; + +export class DisabledFormulasModal extends Modal { + constructor(app: App) { + super(app); + } + + onOpen() { + let { contentEl } = this; + const header = document.createElement('h2'); + header.appendText('Table formulas temporarily disabled'); + contentEl.appendChild(header); + + const body = document.createElement('p'); + body.appendText( + 'I have discovered changes which will dramatically simplify how formulas ' + + 'function, but implementing them will take some time. In the mean time, ' + + 'I am disabling functions to prevent people from writing the old format. ' + + 'Sorry for the inconvenience!', + ); + contentEl.appendChild(body); + + const end = document.createElement('p'); + end.appendText( + 'I look forward to showing you the new, simplified format 🙂', + ); + contentEl.appendChild(end); + } + + onClose() { + let { contentEl } = this; + contentEl.empty(); + } +} diff --git a/src/main.ts b/src/main.ts index e0e1986..2e6b541 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,11 +6,13 @@ import { addIcon, App, MarkdownView, + Modal, Notice, Plugin, PluginSettingTab, Setting, } from 'obsidian'; +import { DisabledFormulasModal } from './disabled-formulas'; export default class TableEditorPlugin extends Plugin { public settings: TableEditorPluginSettings; @@ -201,7 +203,8 @@ export default class TableEditorPlugin extends Plugin { id: 'evaluate-formulas', name: 'Evaluate table formulas', callback: this.newPerformTableAction((te: TableEditor) => { - te.evaluateFormulas(); + // te.evaluateFormulas(); + new DisabledFormulasModal(this.app).open(); }), }); @@ -215,7 +218,7 @@ export default class TableEditorPlugin extends Plugin { }, ], callback: this.newPerformTableAction((te: TableEditor) => { - this.tableControls = te.openTableControls(); + this.tableControls = te.openTableControls(this.app); }), }); @@ -390,7 +393,7 @@ export default class TableEditorPlugin extends Plugin { addIcon('spreadsheet', tableControlsIcon); this.addRibbonIcon('spreadsheet', 'Advanced Tables Toolbar', () => { this.newPerformTableAction((te: TableEditor) => { - this.tableControls = te.openTableControls(); + this.tableControls = te.openTableControls(this.app); })(); }); } diff --git a/src/table-controls.ts b/src/table-controls.ts index e9cb678..d16c329 100644 --- a/src/table-controls.ts +++ b/src/table-controls.ts @@ -1,3 +1,5 @@ +import { App } from 'obsidian'; +import { DisabledFormulasModal } from './disabled-formulas'; import { TableEditor } from './table-editor'; /** @@ -7,6 +9,7 @@ import { TableEditor } from './table-editor'; export class TableControls { private readonly cm: CodeMirror.Editor; private readonly te: TableEditor; + private readonly app: App; /** * Stores the position of the cursor when this widget was created. @@ -19,9 +22,10 @@ export class TableControls { */ private widget: CodeMirror.LineWidget; - constructor(cm: CodeMirror.Editor, te: TableEditor) { + constructor(cm: CodeMirror.Editor, te: TableEditor, app: App) { this.cm = cm; this.te = te; + this.app = app; this.cursorPos = cm.getCursor(); } @@ -155,7 +159,8 @@ export class TableControls { node.appendChild( this.createButtonSvg(formula, 'Evaluate formulas', () => { this.cm.setCursor(this.cursorPos); - this.te.evaluateFormulas(); + new DisabledFormulasModal(this.app).open(); + //this.te.evaluateFormulas(); }), ); diff --git a/src/table-editor.ts b/src/table-editor.ts index cdb7f68..68f5c20 100644 --- a/src/table-editor.ts +++ b/src/table-editor.ts @@ -6,7 +6,7 @@ import { SortOrder, TableEditor as MTEEditor, } from '@tgrosinger/md-advanced-tables'; -import { Notice } from 'obsidian'; +import { App, Notice } from 'obsidian'; export class TableEditor { private readonly settings: TableEditorPluginSettings; @@ -103,8 +103,8 @@ export class TableEditor { } }; - public readonly openTableControls = (): TableControls => { - const controls = new TableControls(this.editor, this); + public readonly openTableControls = (app: App): TableControls => { + const controls = new TableControls(this.editor, this, app); controls.display(); return controls; };