/ *
THIS IS A GENERATED / BUNDLED FILE BY ESBUILD
if you want to view the source , please visit the github repository of this plugin
* /
var _ _create = Object . create ;
var _ _defProp = Object . defineProperty ;
var _ _getOwnPropDesc = Object . getOwnPropertyDescriptor ;
var _ _getOwnPropNames = Object . getOwnPropertyNames ;
var _ _getProtoOf = Object . getPrototypeOf ;
var _ _hasOwnProp = Object . prototype . hasOwnProperty ;
var _ _markAsModule = ( target ) => _ _defProp ( target , "__esModule" , { value : true } ) ;
var _ _export = ( target , all ) => {
_ _markAsModule ( target ) ;
for ( var name in all )
_ _defProp ( target , name , { get : all [ name ] , enumerable : true } ) ;
} ;
var _ _reExport = ( target , module2 , desc ) => {
if ( module2 && typeof module2 === "object" || typeof module2 === "function" ) {
for ( let key of _ _getOwnPropNames ( module2 ) )
if ( ! _ _hasOwnProp . call ( target , key ) && key !== "default" )
_ _defProp ( target , key , { get : ( ) => module2 [ key ] , enumerable : ! ( desc = _ _getOwnPropDesc ( module2 , key ) ) || desc . enumerable } ) ;
}
return target ;
} ;
var _ _toModule = ( module2 ) => {
return _ _reExport ( _ _markAsModule ( _ _defProp ( module2 != null ? _ _create ( _ _getProtoOf ( module2 ) ) : { } , "default" , module2 && module2 . _ _esModule && "default" in module2 ? { get : ( ) => module2 . default , enumerable : true } : { value : module2 , enumerable : true } ) ) , module2 ) ;
} ;
var _ _async = ( _ _this , _ _arguments , generator ) => {
return new Promise ( ( resolve , reject ) => {
var fulfilled = ( value ) => {
try {
step ( generator . next ( value ) ) ;
} catch ( e ) {
reject ( e ) ;
}
} ;
var rejected = ( value ) => {
try {
step ( generator . throw ( value ) ) ;
} catch ( e ) {
reject ( e ) ;
}
} ;
var step = ( x ) => x . done ? resolve ( x . value ) : Promise . resolve ( x . value ) . then ( fulfilled , rejected ) ;
step ( ( generator = generator . apply ( _ _this , _ _arguments ) ) . next ( ) ) ;
} ) ;
} ;
// main.ts
_ _export ( exports , {
default : ( ) => ObsidianColumns
} ) ;
var import _obsidian2 = _ _toModule ( require ( "obsidian" ) ) ;
// obsidian-settings/settings.ts
var import _obsidian = _ _toModule ( require ( "obsidian" ) ) ;
var parseBoolean = ( value ) => {
return value == "yes" || value == "true" ;
} ;
var parseObject = ( value , typ ) => {
if ( typ == "string" ) {
return value ;
}
if ( typ == "boolean" ) {
return parseBoolean ( value ) ;
}
if ( typ == "number" ) {
return parseFloat ( value ) ;
}
} ;
function display ( obj , DEFAULT _SETTINGS2 , name ) {
const { containerEl } = obj ;
containerEl . empty ( ) ;
containerEl . createEl ( "h2" , { text : "Settings for " + name } ) ;
let keyvals = Object . entries ( DEFAULT _SETTINGS2 ) ;
for ( let keyval of keyvals ) {
let setting = new import _obsidian . Setting ( containerEl ) . setName ( keyval [ 1 ] . name ) . setDesc ( keyval [ 1 ] . desc ) ;
if ( typeof keyval [ 1 ] . value == "boolean" ) {
setting . addToggle ( ( toggle ) => toggle . setValue ( obj . plugin . settings [ keyval [ 0 ] ] . value ) . onChange ( ( bool ) => {
obj . plugin . settings [ keyval [ 0 ] ] . value = bool ;
obj . plugin . saveSettings ( ) ;
} ) ) ;
} else {
setting . addText ( ( text ) => text . setPlaceholder ( String ( keyval [ 1 ] . value ) ) . setValue ( String ( obj . plugin . settings [ keyval [ 0 ] ] . value ) ) . onChange ( ( value ) => {
obj . plugin . settings [ keyval [ 0 ] ] . value = parseObject ( value , typeof keyval [ 1 ] . value ) ;
obj . plugin . saveSettings ( ) ;
} ) ) ;
}
}
}
function loadSettings ( obj , DEFAULT _SETTINGS2 ) {
obj . settings = DEFAULT _SETTINGS2 ;
obj . loadData ( ) . then ( ( data ) => {
if ( data ) {
let items = Object . entries ( data ) ;
items . forEach ( ( item ) => {
obj . settings [ item [ 0 ] ] . value = item [ 1 ] ;
} ) ;
}
} ) ;
}
function saveSettings ( obj , DEFAULT _SETTINGS2 ) {
return _ _async ( this , null , function * ( ) {
let saveData = { } ;
Object . entries ( obj . settings ) . forEach ( ( i ) => {
saveData [ i [ 0 ] ] = i [ 1 ] . value ;
} ) ;
yield obj . saveData ( saveData ) ;
} ) ;
}
// main.ts
var NAME = "Obsidian Columns" ;
var COLUMNNAME = "col" ;
var COLUMNMD = COLUMNNAME + "-md" ;
var TOKEN = "!!!" ;
var SETTINGSDELIM = "\n===\n" ;
var DEFAULT _SETTINGS = {
wrapSize : { value : 100 , name : "Minimum width of column" , desc : "Columns will have this minimum width before wrapping to a new row. 0 disables column wrapping. Useful for smaller devices" } ,
defaultSpan : { value : 1 , name : "The default span of an item" , desc : "The default width of a column. If the minimum width is specified, the width of the column will be multiplied by this setting." }
} ;
var parseSettings = ( settings ) => {
let o = { } ;
settings . split ( "\n" ) . map ( ( i ) => {
return i . split ( ";" ) ;
} ) . reduce ( ( a , b ) => {
a . push ( ... b ) ;
return a ;
} ) . map ( ( i ) => {
return i . split ( "=" ) . map ( ( j ) => {
return j . trim ( ) ;
} ) . slice ( 0 , 2 ) ;
} ) . forEach ( ( i ) => {
o [ i [ 0 ] ] = i [ 1 ] ;
} ) ;
return o ;
} ;
var ObsidianColumns = class extends import _obsidian2 . Plugin {
constructor ( ) {
super ( ... arguments ) ;
this . generateCssString = ( span ) => {
let o = { } ;
o . flexGrow = span . toString ( ) ;
o . flexBasis = ( this . settings . wrapSize . value * span ) . toString ( ) + "px" ;
o . width = ( this . settings . wrapSize . value * span ) . toString ( ) + "px" ;
return o ;
} ;
this . applyStyle = ( el , styles ) => {
Object . assign ( el . style , styles ) ;
} ;
this . processChild = ( c ) => {
if ( c . firstChild != null && "tagName" in c . firstChild && c . firstChild . tagName == "BR" ) {
c . removeChild ( c . firstChild ) ;
}
let firstChild = c ;
while ( firstChild != null ) {
if ( "style" in firstChild ) {
firstChild . style . marginTop = "0px" ;
}
firstChild = firstChild . firstChild ;
}
let lastChild = c ;
while ( lastChild != null ) {
if ( "style" in lastChild ) {
lastChild . style . marginBottom = "0px" ;
}
lastChild = lastChild . lastChild ;
}
} ;
}
onload ( ) {
return _ _async ( this , null , function * ( ) {
yield this . loadSettings ( ) ;
this . addSettingTab ( new ObsidianColumnsSettings ( this . app , this ) ) ;
this . registerMarkdownCodeBlockProcessor ( COLUMNMD , ( source , el , ctx ) => {
let split = source . split ( SETTINGSDELIM ) ;
let settings = { } ;
if ( split . length > 1 ) {
source = split . slice ( 1 ) . join ( SETTINGSDELIM ) ;
settings = parseSettings ( split [ 0 ] ) ;
}
const sourcePath = ctx . sourcePath ;
let child = el . createDiv ( ) ;
let renderChild = new import _obsidian2 . MarkdownRenderChild ( child ) ;
ctx . addChild ( renderChild ) ;
import _obsidian2 . MarkdownRenderer . renderMarkdown ( source , child , sourcePath , renderChild ) ;
if ( "flexGrow" in settings ) {
let flexGrow = parseFloat ( settings . flexGrow ) ;
let CSS = this . generateCssString ( flexGrow ) ;
delete CSS . width ;
this . applyStyle ( child , CSS ) ;
}
} ) ;
this . registerMarkdownCodeBlockProcessor ( COLUMNNAME , ( source , el , ctx ) => {
const sourcePath = ctx . sourcePath ;
let child = createDiv ( ) ;
let renderChild = new import _obsidian2 . MarkdownRenderChild ( child ) ;
ctx . addChild ( renderChild ) ;
import _obsidian2 . MarkdownRenderer . renderMarkdown ( source , child , sourcePath , renderChild ) ;
let parent = el . createEl ( "div" , { cls : "columnParent" } ) ;
Array . from ( child . children ) . forEach ( ( c ) => {
let cc = parent . createEl ( "div" , { cls : "columnChild" } ) ;
let renderCc = new import _obsidian2 . MarkdownRenderChild ( cc ) ;
ctx . addChild ( renderCc ) ;
this . applyStyle ( cc , this . generateCssString ( this . settings . defaultSpan . value ) ) ;
cc . appendChild ( c ) ;
if ( c . classList . contains ( "block-language-" + COLUMNMD ) && c . childNodes [ 0 ] . style . flexGrow != "" ) {
cc . style . flexGrow = c . childNodes [ 0 ] . style . flexGrow ;
cc . style . flexBasis = c . childNodes [ 0 ] . style . flexBasis ;
cc . style . width = c . childNodes [ 0 ] . style . flexBasis ;
}
this . processChild ( c ) ;
} ) ;
} ) ;
let processList = ( element , context ) => {
for ( let child of Array . from ( element . children ) ) {
if ( child == null ) {
continue ;
}
if ( child . nodeName != "UL" && child . nodeName != "OL" ) {
continue ;
}
for ( let listItem of Array . from ( child . children ) ) {
if ( listItem == null ) {
continue ;
}
if ( ! listItem . textContent . trim ( ) . startsWith ( TOKEN + COLUMNNAME ) ) {
processList ( listItem , context ) ;
continue ;
}
child . removeChild ( listItem ) ;
let colParent = element . createEl ( "div" , { cls : "columnParent" } ) ;
let renderColP = new import _obsidian2 . MarkdownRenderChild ( colParent ) ;
context . addChild ( renderColP ) ;
let itemList = listItem . querySelector ( "ul, ol" ) ;
if ( itemList == null ) {
continue ;
}
for ( let itemListItem of Array . from ( itemList . children ) ) {
let childDiv = colParent . createEl ( "div" , { cls : "columnChild" } ) ;
let renderColC = new import _obsidian2 . MarkdownRenderChild ( childDiv ) ;
context . addChild ( renderColC ) ;
let span = parseFloat ( itemListItem . textContent . split ( "\n" ) [ 0 ] . split ( " " ) [ 0 ] ) ;
if ( isNaN ( span ) ) {
span = this . settings . defaultSpan . value ;
}
this . applyStyle ( childDiv , this . generateCssString ( span ) ) ;
let afterText = false ;
processList ( itemListItem , context ) ;
for ( let itemListItemChild of Array . from ( itemListItem . childNodes ) ) {
if ( afterText ) {
childDiv . appendChild ( itemListItemChild ) ;
}
if ( itemListItemChild . nodeName == "#text" ) {
afterText = true ;
}
}
this . processChild ( childDiv ) ;
}
}
}
} ;
this . registerMarkdownPostProcessor ( ( element , context ) => {
processList ( element , context ) ;
} ) ;
} ) ;
}
onunload ( ) {
}
loadSettings ( ) {
return _ _async ( this , null , function * ( ) {
loadSettings ( this , DEFAULT _SETTINGS ) ;
} ) ;
}
saveSettings ( ) {
return _ _async ( this , null , function * ( ) {
yield saveSettings ( this , DEFAULT _SETTINGS ) ;
} ) ;
}
} ;
var ObsidianColumnsSettings = class extends import _obsidian2 . PluginSettingTab {
constructor ( app , plugin ) {
super ( app , plugin ) ;
this . plugin = plugin ;
}
display ( ) {
display ( this , DEFAULT _SETTINGS , NAME ) ;
}
} ;