2023-02-03 18:11:50 +00:00
/ *
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 ) ;
// src/index.ts
var src _exports = { } ;
_ _export ( src _exports , {
default : ( ) => MyPlugin
} ) ;
module . exports = _ _toCommonJS ( src _exports ) ;
var import _obsidian = require ( "obsidian" ) ;
var DEFAULT _SETTINGS = {
mySetting : "default"
} ;
var MyPlugin = class extends import _obsidian . Plugin {
async onload ( ) {
await this . loadSettings ( ) ;
const ribbonIconEl = this . addRibbonIcon ( "dice" , "Sample Plugin" , ( evt ) => {
new import _obsidian . Notice ( "This is a notice!" ) ;
} ) ;
ribbonIconEl . addClass ( "my-plugin-ribbon-class" ) ;
const statusBarItemEl = this . addStatusBarItem ( ) ;
statusBarItemEl . setText ( "Status Bar Text" ) ;
this . addCommand ( {
id : "run-x86-parser" ,
name : "Parse x86 Codeblocks" ,
callback : ( ) => {
var tmp = document . getElementsByClassName ( "HyperMD-codeblock-begin-bg" ) ;
for ( var i = 0 ; i < tmp . length ; i ++ ) {
if ( tmp [ i ] . innerHTML . contains ( "x86" ) ) {
tmp [ i ] . classList . add ( "x86-instruction" ) ;
var currelement = tmp [ i ] ;
while ( ! currelement . classList . value . contains ( "HyperMD-codeblock-end" ) ) {
currelement . classList . add ( "x86-instruction" ) ;
if ( currelement . nextElementSibling != null ) {
currelement = currelement . nextElementSibling ;
if ( currelement . classList . value . contains ( "HyperMD-codeblock-end" ) ) {
break ;
}
} else {
console . log ( "end of document reached before end of codeblock" ) ;
break ;
}
var orightml = currelement . innerHTML ;
var innerpart = orightml . split ( ">" ) [ 1 ] . split ( "<" ) [ 0 ] ;
var firstspace = innerpart . indexOf ( " " ) ;
var innerpart = '<span class="cm-hmd-codeblock x86-instruction">' + innerpart . split ( " " ) [ 0 ] + "</span>" + innerpart . slice ( firstspace , innerpart . length ) ;
var testing = orightml . split ( ">" ) [ 0 ] + ">" + innerpart + "<" + orightml . split ( ">" ) [ 1 ] . split ( "<" ) [ 1 ] ;
currelement . innerHTML = testing ;
console . log ( currelement . innerHTML ) ;
}
console . log ( "Done with that x86 codeblock" ) ;
}
}
}
} ) ;
this . addCommand ( {
2023-02-03 22:30:39 +00:00
id : "create-flow-diagram" ,
name : "Convert x86 assembly into a flow diagram on a canvas" ,
2023-02-03 18:11:50 +00:00
editorCallback : ( editor , view ) => {
console . log ( editor . getSelection ( ) ) ;
console . log ( this . app . vault . getName ( ) ) ;
2023-02-03 22:30:39 +00:00
let nodes = [ ] ;
var tmp = editor . getSelection ( ) . split ( "\n" ) ;
let lines = [ ] ;
var nodeid = 1 ;
var workingx = 0 ;
var workingy = 0 ;
tmp . forEach ( ( element ) => {
if ( element != "" ) {
lines . push ( element ) ;
}
} ) ;
var currnode = "```\n" ;
lines . forEach ( ( line , linenum ) => {
console . log ( line ) ;
if ( line . split ( "" ) [ 0 ] == " " || line . split ( "" ) [ 0 ] == " " ) {
if ( line . trim ( ) . split ( "" ) [ 0 ] == "j" ) {
currnode = currnode + line + "```" ;
nodes . push ( { "id" : nodeid , "x" : workingx , "y" : workingy , "width" : 250 , "height" : 300 , "type" : "text" , "text" : currnode } ) ;
nodeid = nodeid + 1 ;
workingy = workingy + 350 ;
currnode = "```\n" ;
} else {
currnode = currnode + line + "\n" ;
}
} else {
}
} ) ;
var thing = '{ "nodes":' + JSON . stringify ( nodes ) + "}" ;
console . log ( thing ) ;
this . app . vault . create ( "./testing.canvas" , thing ) ;
2023-02-03 18:11:50 +00:00
}
} ) ;
this . addCommand ( {
id : "open-sample-modal-complex" ,
name : "Open sample modal (complex)" ,
checkCallback : ( checking ) => {
const markdownView = this . app . workspace . getActiveViewOfType ( import _obsidian . MarkdownView ) ;
if ( markdownView ) {
if ( ! checking ) {
new SampleModal ( this . app ) . open ( ) ;
}
return true ;
}
}
} ) ;
this . addSettingTab ( new SampleSettingTab ( this . app , this ) ) ;
this . registerDomEvent ( document , "click" , ( evt ) => {
console . log ( "click1" , evt ) ;
} ) ;
this . registerInterval ( window . setInterval ( ( ) => console . log ( "setInterval" ) , 5 * 60 * 1e3 ) ) ;
}
onunload ( ) {
}
async loadSettings ( ) {
this . settings = Object . assign ( { } , DEFAULT _SETTINGS , await this . loadData ( ) ) ;
}
async saveSettings ( ) {
await this . saveData ( this . settings ) ;
}
} ;
var SampleModal = class extends import _obsidian . Modal {
constructor ( app ) {
super ( app ) ;
}
onOpen ( ) {
const { contentEl } = this ;
contentEl . setText ( "Woah!" ) ;
}
onClose ( ) {
const { contentEl } = this ;
contentEl . empty ( ) ;
}
} ;
var SampleSettingTab = class extends import _obsidian . PluginSettingTab {
constructor ( app , plugin ) {
super ( app , plugin ) ;
this . plugin = plugin ;
}
display ( ) {
const { containerEl } = this ;
containerEl . empty ( ) ;
containerEl . createEl ( "h2" , { text : "Settings for my awesome plugin." } ) ;
new import _obsidian . Setting ( containerEl ) . setName ( "Setting #1" ) . setDesc ( "It's a secret" ) . addText ( ( text ) => text . setPlaceholder ( "Enter your secret" ) . setValue ( this . plugin . settings . mySetting ) . onChange ( async ( value ) => {
console . log ( "Secret: " + value ) ;
this . plugin . settings . mySetting = value ;
await this . plugin . saveSettings ( ) ;
} ) ) ;
}
} ;