1- import { App , Editor , MarkdownView , Modal , Notice , Plugin } from 'obsidian' ;
1+ import { Editor , MarkdownView , Notice , Plugin } from 'obsidian' ;
22import { DEFAULT_SETTINGS , MyPluginSettings , SampleSettingTab } from "./settings" ;
33import { copyTextToClipboard } from './utils/clipboard' ;
44import { Formatter } from './formatter' ;
@@ -13,31 +13,9 @@ export default class Format4LinkedIn extends Plugin {
1313 // This creates an icon in the left ribbon. Clicking it will trigger the copy action.
1414 this . addRibbonIcon ( 'clipboard' , 'Format4LinkedIn: Copy to Clipboard' , ( evt : MouseEvent ) => {
1515 // Trigger the copy action using the active editor
16- // (avoid using this.app.commands since App type may not expose it)
1716 this . copyEditorContentToClipboard ( ) ;
1817 } ) ;
1918
20- // This adds a status bar item to the bottom of the app. Does not work on mobile apps.
21- const statusBarItemEl = this . addStatusBarItem ( ) ;
22- statusBarItemEl . setText ( 'Status bar text' ) ;
23-
24- // This adds a simple command that can be triggered anywhere
25- this . addCommand ( {
26- id : 'open-modal-simple' ,
27- name : 'Open modal (simple)' ,
28- callback : ( ) => {
29- new SampleModal ( this . app ) . open ( ) ;
30- }
31- } ) ;
32- // This adds an editor command that can perform some operation on the current editor instance
33- this . addCommand ( {
34- id : 'replace-selected' ,
35- name : 'Replace selected content' ,
36- editorCallback : ( editor : Editor , view : MarkdownView ) => {
37- editor . replaceSelection ( 'Sample editor command' ) ;
38- }
39- } ) ;
40-
4119 // Command to copy current editor markdown to clipboard
4220 this . addCommand ( {
4321 id : 'format4linkedin:copy-markdown' ,
@@ -46,39 +24,10 @@ export default class Format4LinkedIn extends Plugin {
4624 this . copyEditorContentToClipboard ( editor ) ;
4725 }
4826 } ) ;
49- // This adds a complex command that can check whether the current state of the app allows execution of the command
50- this . addCommand ( {
51- id : 'open-modal-complex' ,
52- name : 'Open modal (complex)' ,
53- checkCallback : ( checking : boolean ) => {
54- // Conditions to check
55- const markdownView = this . app . workspace . getActiveViewOfType ( MarkdownView ) ;
56- if ( markdownView ) {
57- // If checking is true, we're simply "checking" if the command can be run.
58- // If checking is false, then we want to actually perform the operation.
59- if ( ! checking ) {
60- new SampleModal ( this . app ) . open ( ) ;
61- }
62-
63- // This command will only show up in Command Palette when the check function returns true
64- return true ;
65- }
66- return false ;
67- }
68- } ) ;
6927
7028 // This adds a settings tab so the user can configure various aspects of the plugin
7129 this . addSettingTab ( new SampleSettingTab ( this . app , this ) ) ;
7230
73- // If the plugin hooks up any global DOM events (on parts of the app that doesn't belong to this plugin)
74- // Using this function will automatically remove the event listener when this plugin is disabled.
75- // this.registerDomEvent(document, 'click', (evt: MouseEvent) => {
76- // new Notice("Click");
77- // });
78-
79- // When registering intervals, this function will automatically clear the interval when the plugin is disabled.
80- this . registerInterval ( window . setInterval ( ( ) => console . log ( 'setInterval' ) , 5 * 60 * 1000 ) ) ;
81-
8231
8332 }
8433
@@ -123,19 +72,3 @@ export default class Format4LinkedIn extends Plugin {
12372 await this . saveData ( this . settings ) ;
12473 }
12574}
126-
127- class SampleModal extends Modal {
128- constructor ( app : App ) {
129- super ( app ) ;
130- }
131-
132- onOpen ( ) {
133- let { contentEl } = this ;
134- contentEl . setText ( 'Woah!' ) ;
135- }
136-
137- onClose ( ) {
138- const { contentEl } = this ;
139- contentEl . empty ( ) ;
140- }
141- }
0 commit comments