@@ -7,7 +7,7 @@ interface SupernotePluginSettings {
77 showTOC : boolean ;
88 showExportButtons : boolean ;
99 collapseRecognizedText : boolean ,
10- noteImageMaxWidth : number ;
10+ noteImageMaxDim : number ;
1111}
1212
1313const DEFAULT_SETTINGS : SupernotePluginSettings = {
@@ -16,7 +16,7 @@ const DEFAULT_SETTINGS: SupernotePluginSettings = {
1616 showTOC : true ,
1717 showExportButtons : true ,
1818 collapseRecognizedText : false ,
19- noteImageMaxWidth : 1400 , // Default to (nearly) the full width of the image
19+ noteImageMaxDim : 800 , // Sensible default for Nomad pages to be legible but not too big. Unit: px
2020}
2121
2222function generateTimestamp ( ) : string {
@@ -165,8 +165,13 @@ export class SupernoteView extends FileView {
165165 for ( let i = 0 ; i < images . length ; i ++ ) {
166166 const imageDataUrl = images [ i ] . toDataURL ( ) ;
167167
168+ const pageContainer = container . createEl ( "div" , {
169+ cls : 'page-container' ,
170+ } )
171+ pageContainer . setAttr ( 'style' , 'max-width: ' + this . settings . noteImageMaxDim + 'px;' )
172+
168173 if ( images . length > 1 && this . settings . showTOC ) {
169- const a = container . createEl ( "a" ) ;
174+ const a = pageContainer . createEl ( "a" ) ;
170175 a . id = `page${ i + 1 } ` ;
171176 a . href = "#toc" ;
172177 a . createEl ( "h3" , { text : `Page ${ i + 1 } ` } ) ;
@@ -178,31 +183,31 @@ export class SupernoteView extends FileView {
178183
179184 // If Collapse Text setting is enabled, place the text into an HTML `details` element
180185 if ( this . settings . collapseRecognizedText ) {
181- text = container . createEl ( 'details' , {
186+ text = pageContainer . createEl ( 'details' , {
182187 text : '\n' + sn . pages [ i ] . text ,
188+ cls : 'page-recognized-text' ,
183189 } ) ;
184190 text . createEl ( 'summary' , { text : `Page ${ i + 1 } Recognized Text` } ) ;
185191 } else {
186- text = container . createEl ( 'div' , {
192+ text = pageContainer . createEl ( 'div' , {
187193 text : sn . pages [ i ] . text ,
194+ cls : 'page-recognized-text' ,
188195 } ) ;
189196 }
190-
191- text . setAttr ( 'style' , 'user-select: text; white-space: pre-line; margin-top: 1.2em;' ) ;
192197 }
193198
194199 // Show the img of the page
195- const imgElement = container . createEl ( "img" ) ;
200+ const imgElement = pageContainer . createEl ( "img" ) ;
196201 imgElement . src = imageDataUrl ;
197202 if ( this . settings . invertColorsWhenDark ) {
198203 imgElement . addClass ( "supernote-invert-dark" ) ;
199204 }
200- imgElement . setAttr ( 'style' , 'width: 100%; max-width : ' + this . settings . noteImageMaxWidth + 'px' ) // Note width responsive to container width, up to the set max width
205+ imgElement . setAttr ( 'style' , 'max-height : ' + this . settings . noteImageMaxDim + 'px;' )
201206 imgElement . draggable = true ;
202207
203208 // Create a button to save image to vault
204209 if ( this . settings . showExportButtons ) {
205- const saveButton = container . createEl ( "button" , {
210+ const saveButton = pageContainer . createEl ( "button" , {
206211 text : "Save image to vault" ,
207212 cls : "mod-cta" ,
208213 } ) ;
@@ -469,14 +474,14 @@ class SupernoteSettingTab extends PluginSettingTab {
469474 ) ;
470475
471476 new Setting ( containerEl )
472- . setName ( 'Max image width in .note files' )
473- . setDesc ( 'Maximum width of the note image when viewing .note files, in pixels . Does not affect exported images and markdown.' )
477+ . setName ( 'Max image side length in .note files' )
478+ . setDesc ( 'Maximum width and height (in pixels) of the note image when viewing .note files. Does not affect exported images and markdown.' )
474479 . addSlider ( text => text
475- . setLimits ( 100 , 1400 , 50 ) // Width of an A5X/A6X2/Nomad page is 1404 px (with no upscaling)
480+ . setLimits ( 200 , 1900 , 100 ) // Resolution of an A5X/A6X2/Nomad page is 1404 x 1872 px (with no upscaling)
476481 . setDynamicTooltip ( )
477- . setValue ( this . plugin . settings . noteImageMaxWidth )
482+ . setValue ( this . plugin . settings . noteImageMaxDim )
478483 . onChange ( async ( value ) => {
479- this . plugin . settings . noteImageMaxWidth = value ;
484+ this . plugin . settings . noteImageMaxDim = value ;
480485 await this . plugin . saveSettings ( ) ;
481486 } )
482487 ) ;
0 commit comments