Skip to content

Commit ea78345

Browse files
committed
change: removed nanoid, replaced with in-house uuid generation
1 parent 498279c commit ea78345

File tree

1 file changed

+93
-80
lines changed

1 file changed

+93
-80
lines changed

src/main.ts

Lines changed: 93 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -47,43 +47,43 @@ export default class GistrPlugin extends Plugin
4747
Rehash Reading View
4848
*/
4949

50-
renderModeReading( ): void
50+
renderModeReading( ): void
5151
{
52-
this.app.workspace.iterateRootLeaves( ( leaf: WorkspaceLeaf ) =>
52+
this.app.workspace.iterateRootLeaves( ( leaf: WorkspaceLeaf ) =>
5353
{
54-
if ( leaf.view instanceof MarkdownView && leaf.view.getMode( ) === "preview" )
55-
leaf.view.previewMode.rerender( true )
56-
} )
57-
}
54+
if ( leaf.view instanceof MarkdownView && leaf.view.getMode( ) === "preview" )
55+
leaf.view.previewMode.rerender( true )
56+
} )
57+
}
5858

5959
/*
6060
Development use re-rendering
6161
*/
6262

63-
async renderDevelopment( )
63+
async renderDevelopment( )
6464
{
65-
for ( const leaf of this.app.workspace.getLeavesOfType( 'markdown' ) )
65+
for ( const leaf of this.app.workspace.getLeavesOfType( 'markdown' ) )
6666
{
67-
const view = leaf.view as MarkdownView
68-
const state = view.getState( )
69-
const etateEph = view.getEphemeralState( )
67+
const view = leaf.view as MarkdownView
68+
const state = view.getState( )
69+
const etateEph = view.getEphemeralState( )
7070

71-
view.previewMode.rerender( true )
71+
view.previewMode.rerender( true )
7272

73-
const editor = view.editor
74-
editor.setValue ( editor.getValue( ) )
73+
const editor = view.editor
74+
editor.setValue ( editor.getValue( ) )
7575

76-
if ( state.mode === 'preview' )
76+
if ( state.mode === 'preview' )
7777
{
78-
state.mode = 'source'
79-
await view.setState( state, { history: false } )
80-
state.mode = 'preview'
81-
await view.setState( state, { history: false } )
82-
}
78+
state.mode = 'source'
79+
await view.setState( state, { history: false } )
80+
state.mode = 'preview'
81+
await view.setState( state, { history: false } )
82+
}
8383

84-
view.setEphemeralState( etateEph )
85-
}
86-
}
84+
view.setEphemeralState( etateEph )
85+
}
86+
}
8787

8888
/*
8989
Portal > Initialize
@@ -115,13 +115,25 @@ export default class GistrPlugin extends Plugin
115115
{
116116
console.debug( lng( "base_debug_loading", process.env.NAME, process.env.PLUGIN_VERSION, process.env.AUTHOR ) )
117117

118+
if ( process.env.ENV === "dev" )
119+
{
120+
console.log( process.env.NODE_ENV )
121+
console.log( process.env.ENV )
122+
console.log( process.env.BUILD )
123+
console.log( process.env.PLUGIN_VERSION )
124+
console.log( process.env.BUILD_GUID )
125+
console.log( process.env.BUILD_UUID )
126+
console.log( process.env.BUILD_DATE )
127+
console.log( process.env.AUTHOR )
128+
}
129+
118130
await this.loadSettings ( )
119131
await this.InitializePortal ( )
120132
this.addSettingTab ( new SettingsSection( this.app, this ) )
121133
this.registerPortal ( )
122134
SaturynCodeblock ( this )
123135

124-
this.app.workspace.onLayoutReady( async ( ) =>
136+
this.app.workspace.onLayoutReady( async ( ) =>
125137
{
126138
if ( this.settings.firststart === true )
127139
{
@@ -167,7 +179,7 @@ export default class GistrPlugin extends Plugin
167179
} )
168180
)
169181

170-
} )
182+
} )
171183

172184
/*
173185
Command Palette Items
@@ -399,7 +411,6 @@ export default class GistrPlugin extends Plugin
399411
const { sy_enable_autosave } = await SettingsGet( this )
400412
if ( sy_enable_autosave )
401413
{
402-
403414
await denounce_register[ file.path ]( note_full, file )
404415

405416
if ( process.env.ENV === "dev" )
@@ -438,11 +449,11 @@ export default class GistrPlugin extends Plugin
438449
Ribbon > Unregister
439450
*/
440451

441-
async unregisterRibbon( )
452+
async unregisterRibbon( )
442453
{
443-
this.ribbonIcon_pub.remove( )
454+
this.ribbonIcon_pub.remove( )
444455
this.ribbonIcon_sec.remove( )
445-
}
456+
}
446457

447458
/*
448459
Ribbon > Register > Debug
@@ -484,88 +495,88 @@ export default class GistrPlugin extends Plugin
484495
removeButtonFromAllLeaves
485496
*/
486497

487-
async addHeaderButtons( viewActions: Element, button: LeafButtonBase )
498+
async addHeaderButtons( viewActions: Element, button: LeafButtonBase )
488499
{
489-
const { id, icon, name } = button
490-
const iconSize = GetIconSize( )
491-
const classNames = [ 'view-action', 'clickable-icon', Env.pluginId ]
492-
const btn_Ico = GetButtonIcon( name, id, icon, iconSize, classNames )
500+
const { id, icon, name } = button
501+
const iconSize = GetIconSize( )
502+
const classNames = [ 'view-action', 'clickable-icon', Env.pluginId ]
503+
const btn_Ico = GetButtonIcon( name, id, icon, iconSize, classNames )
493504

494-
btn_Ico.addEventListener( 'click', ( ) =>
505+
btn_Ico.addEventListener( 'click', ( ) =>
495506
{
496507
this.reloadPlugin( this.app, this )
497-
})
508+
})
498509

499-
viewActions.prepend( btn_Ico )
500-
}
510+
viewActions.prepend( btn_Ico )
511+
}
501512

502513
/*
503514
Leafy > Remove button from header leaf
504515
*/
505516

506-
async removeButtonFromLeaf( leaf: WorkspaceLeaf, button: LeafButtonBase )
517+
async removeButtonFromLeaf( leaf: WorkspaceLeaf, button: LeafButtonBase )
507518
{
508-
const activeLeaf = leaf?.view.containerEl
509-
const viewActions = activeLeaf?.getElementsByClassName( 'view-actions' )[ 0 ]
519+
const activeLeaf = leaf?.view.containerEl
520+
const viewActions = activeLeaf?.getElementsByClassName( 'view-actions' )[ 0 ]
510521

511-
if ( !viewActions ) return
522+
if ( !viewActions ) return
512523

513524
/*
514525
Remove existing elements
515526
*/
516527

517-
viewActions.getElementsByClassName( `view-action ${ Env.pluginId } ${ button.id }` )[ 0 ]?.detach( )
518-
}
528+
viewActions.getElementsByClassName( `view-action ${ Env.pluginId } ${ button.id }` )[ 0 ]?.detach( )
529+
}
519530

520531
/*
521532
Leafy > Add button to header leaf
522533
*/
523534

524-
async addButtonToLeaf( leaf: WorkspaceLeaf, button: LeafButtonBase )
535+
async addButtonToLeaf( leaf: WorkspaceLeaf, button: LeafButtonBase )
525536
{
526-
const activeLeaf = leaf?.view.containerEl
527-
const viewActions = activeLeaf?.getElementsByClassName( 'view-actions' )[ 0 ]
537+
const activeLeaf = leaf?.view.containerEl
538+
const viewActions = activeLeaf?.getElementsByClassName( 'view-actions' )[ 0 ]
528539

529-
if ( !viewActions ) return
540+
if ( !viewActions ) return
530541

531542
/*
532543
Remove existing elements
533544
*/
534545

535-
viewActions.getElementsByClassName( `view-action ${ Env.pluginId } ${ button.id }` )[ 0 ]?.detach( )
546+
viewActions.getElementsByClassName( `view-action ${ Env.pluginId } ${ button.id }` )[ 0 ]?.detach( )
536547

537548
/*
538549
Add new button
539550
*/
540551

541-
this.addHeaderButtons( viewActions, button )
542-
}
552+
this.addHeaderButtons( viewActions, button )
553+
}
543554

544555
/*
545556
Leafy > Add button to all leafs
546557
*/
547558

548-
async addButtonToAllLeaves( )
559+
async addButtonToAllLeaves( )
549560
{
550-
this.app.workspace.iterateAllLeaves( ( leaf ) =>
551-
this.addButtonToLeaf( leaf, LeafButton_Refresh )
552-
)
561+
this.app.workspace.iterateAllLeaves( ( leaf ) =>
562+
this.addButtonToLeaf( leaf, LeafButton_Refresh )
563+
)
553564

554-
this.app.workspace.onLayoutChange( )
555-
}
565+
this.app.workspace.onLayoutChange( )
566+
}
556567

557568
/*
558569
Leafy > remove button from all leafs
559570
*/
560571

561-
async removeButtonFromAllLeaves( )
572+
async removeButtonFromAllLeaves( )
562573
{
563-
this.app.workspace.iterateAllLeaves( ( leaf ) =>
564-
this.removeButtonFromLeaf( leaf, LeafButton_Refresh )
565-
)
574+
this.app.workspace.iterateAllLeaves( ( leaf ) =>
575+
this.removeButtonFromLeaf( leaf, LeafButton_Refresh )
576+
)
566577

567-
this.app.workspace.onLayoutChange( )
568-
}
578+
this.app.workspace.onLayoutChange( )
579+
}
569580

570581
/*
571582
Settings > Load
@@ -630,26 +641,26 @@ export default class GistrPlugin extends Plugin
630641
utilizes env variables in rollup.config.js
631642
*/
632643

633-
async versionCheck( )
644+
async versionCheck( )
634645
{
635-
const ver_running = this.manifest.version
636-
const ver_stable = await requestUrl( lng( "ver_url", "main" ) ).then( async ( res ) =>
646+
const ver_running = this.manifest.version
647+
const ver_stable = await requestUrl( lng( "ver_url", "main" ) ).then( async ( res ) =>
637648
{
638-
if ( res.status === 200 )
649+
if ( res.status === 200 )
639650
{
640-
const resp = await res.json
641-
return resp.version
642-
}
643-
} )
651+
const resp = await res.json
652+
return resp.version
653+
}
654+
} )
644655

645-
const ver_beta = await requestUrl( lng( "ver_url", "beta" ) ).then( async ( res ) =>
656+
const ver_beta = await requestUrl( lng( "ver_url", "beta" ) ).then( async ( res ) =>
646657
{
647-
if ( res.status === 200 )
658+
if ( res.status === 200 )
648659
{
649-
const resp = await res.json
650-
return resp.version
651-
}
652-
} )
660+
const resp = await res.json
661+
return resp.version
662+
}
663+
} )
653664

654665
/*
655666
Output notice to user on possible updates
@@ -682,13 +693,15 @@ export default class GistrPlugin extends Plugin
682693
badge: AssetGithubIcon,
683694
} )
684695
}
685-
}
696+
}
686697

687698
/*
688-
Portal > Generate UUID
699+
Generate UUID
700+
701+
utilized to generate temp ids for portal and gist embed frame ids
689702
*/
690703

691-
private generateUuid( )
704+
public generateUuid( )
692705
{
693706
const uuid = crypto.randomUUID( );
694707
return `${ uuid }`

0 commit comments

Comments
 (0)