2022-09-29 15:36:06 +02: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 _ _create = Object . create ;
var _ _defProp = Object . defineProperty ;
2022-10-19 16:35:21 +02:00
var _ _defProps = Object . defineProperties ;
2022-09-29 15:36:06 +02:00
var _ _getOwnPropDesc = Object . getOwnPropertyDescriptor ;
2022-10-19 16:35:21 +02:00
var _ _getOwnPropDescs = Object . getOwnPropertyDescriptors ;
2022-09-29 15:36:06 +02:00
var _ _getOwnPropNames = Object . getOwnPropertyNames ;
2022-10-19 16:35:21 +02:00
var _ _getOwnPropSymbols = Object . getOwnPropertySymbols ;
2022-09-29 15:36:06 +02:00
var _ _getProtoOf = Object . getPrototypeOf ;
var _ _hasOwnProp = Object . prototype . hasOwnProperty ;
2022-10-19 16:35:21 +02:00
var _ _propIsEnum = Object . prototype . propertyIsEnumerable ;
var _ _defNormalProp = ( obj , key , value ) => key in obj ? _ _defProp ( obj , key , { enumerable : true , configurable : true , writable : true , value } ) : obj [ key ] = value ;
var _ _spreadValues = ( a , b ) => {
for ( var prop in b || ( b = { } ) )
if ( _ _hasOwnProp . call ( b , prop ) )
_ _defNormalProp ( a , prop , b [ prop ] ) ;
if ( _ _getOwnPropSymbols )
for ( var prop of _ _getOwnPropSymbols ( b ) ) {
if ( _ _propIsEnum . call ( b , prop ) )
_ _defNormalProp ( a , prop , b [ prop ] ) ;
}
return a ;
} ;
var _ _spreadProps = ( a , b ) => _ _defProps ( a , _ _getOwnPropDescs ( b ) ) ;
2022-09-29 15:36:06 +02:00
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 ( ) ) ;
} ) ;
} ;
// src/main.ts
_ _export ( exports , {
default : ( ) => SimpleTimeTrackerPlugin
} ) ;
var import _obsidian3 = _ _toModule ( require ( "obsidian" ) ) ;
// src/settings.ts
var defaultSettings = {
timestampFormat : "YY-MM-DD hh:mm:ss" ,
2023-05-23 18:18:28 +02:00
csvDelimiter : "," ,
fineGrainedDurations : true
2022-09-29 15:36:06 +02:00
} ;
// src/settings-tab.ts
var import _obsidian = _ _toModule ( require ( "obsidian" ) ) ;
var SimpleTimeTrackerSettingsTab = class extends import _obsidian . PluginSettingTab {
constructor ( app , plugin ) {
super ( app , plugin ) ;
this . plugin = plugin ;
}
display ( ) {
this . containerEl . empty ( ) ;
this . containerEl . createEl ( "h2" , { text : "Super Simple Time Tracker Settings" } ) ;
new import _obsidian . Setting ( this . containerEl ) . setName ( "Timestamp Display Format" ) . setDesc ( createFragment ( ( f ) => {
f . createSpan ( { text : "The way that timestamps in time tracker tables should be displayed. Uses " } ) ;
f . createEl ( "a" , { text : "moment.js" , href : "https://momentjs.com/docs/#/parsing/string-format/" } ) ;
f . createSpan ( { text : " syntax." } ) ;
} ) ) . addText ( ( t ) => {
t . setValue ( String ( this . plugin . settings . timestampFormat ) ) ;
t . onChange ( ( v ) => _ _async ( this , null , function * ( ) {
this . plugin . settings . timestampFormat = v . length ? v : defaultSettings . timestampFormat ;
yield this . plugin . saveSettings ( ) ;
} ) ) ;
} ) ;
new import _obsidian . Setting ( this . containerEl ) . setName ( "CSV Delimiter" ) . setDesc ( "The delimiter character that should be used when copying a tracker table as CSV. For example, some languages use a semicolon instead of a comma." ) . addText ( ( t ) => {
t . setValue ( String ( this . plugin . settings . csvDelimiter ) ) ;
t . onChange ( ( v ) => _ _async ( this , null , function * ( ) {
this . plugin . settings . csvDelimiter = v . length ? v : defaultSettings . csvDelimiter ;
yield this . plugin . saveSettings ( ) ;
} ) ) ;
} ) ;
2023-05-23 18:18:28 +02:00
new import _obsidian . Setting ( this . containerEl ) . setName ( "Fine-Grained Durations" ) . setDesc ( "Whether durations should include days, months and years. If this is disabled, additional time units will be displayed as part of the hours." ) . addToggle ( ( t ) => {
t . setValue ( this . plugin . settings . fineGrainedDurations ) ;
t . onChange ( ( v ) => _ _async ( this , null , function * ( ) {
this . plugin . settings . fineGrainedDurations = v ;
yield this . plugin . saveSettings ( ) ;
} ) ) ;
} ) ;
2022-09-29 15:36:06 +02:00
this . containerEl . createEl ( "hr" ) ;
this . containerEl . createEl ( "p" , { text : "If you like this plugin and want to support its development, you can do so through my website by clicking this fancy image!" } ) ;
2023-05-23 18:06:29 +02:00
this . containerEl . createEl ( "a" , { href : "https://ellpeck.de/support" } ) . createEl ( "img" , {
attr : { src : "https://ellpeck.de/res/generalsupport.png" } ,
cls : "simple-time-tracker-support"
} ) ;
2022-09-29 15:36:06 +02:00
}
} ;
// src/tracker.ts
var import _obsidian2 = _ _toModule ( require ( "obsidian" ) ) ;
2023-05-23 18:06:29 +02:00
function saveTracker ( tracker , app , fileName , section ) {
2022-09-29 15:36:06 +02:00
return _ _async ( this , null , function * ( ) {
2023-05-23 18:06:29 +02:00
let file = app . vault . getAbstractFileByPath ( fileName ) ;
2022-09-29 16:05:39 +02:00
if ( ! file )
return ;
let content = yield app . vault . read ( file ) ;
2022-09-29 15:36:06 +02:00
let lines = content . split ( "\n" ) ;
let prev = lines . filter ( ( _ , i ) => i <= section . lineStart ) . join ( "\n" ) ;
let next = lines . filter ( ( _ , i ) => i >= section . lineEnd ) . join ( "\n" ) ;
content = ` ${ prev }
$ { JSON . stringify ( tracker ) }
$ { next } ` ;
yield app . vault . modify ( file , content ) ;
} ) ;
}
function loadTracker ( json ) {
if ( json ) {
try {
return JSON . parse ( json ) ;
} catch ( e ) {
console . log ( ` Failed to parse Tracker from ${ json } ` ) ;
}
}
return { entries : [ ] } ;
}
2023-05-23 18:06:29 +02:00
function displayTracker ( tracker , element , file , getSectionInfo , settings ) {
2023-07-03 17:23:47 +02:00
element . classList . add ( "simple-time-tracker-container" ) ;
2022-09-29 15:36:06 +02:00
let running = isRunning ( tracker ) ;
2022-10-10 14:51:11 +02:00
let btn = new import _obsidian2 . ButtonComponent ( element ) . setClass ( "clickable-icon" ) . setIcon ( ` lucide- ${ running ? "stop" : "play" } -circle ` ) . setTooltip ( running ? "End" : "Start" ) . onClick ( ( ) => _ _async ( this , null , function * ( ) {
2022-09-29 15:36:06 +02:00
if ( running ) {
2022-10-19 16:35:21 +02:00
endRunningEntry ( tracker ) ;
2022-09-29 15:36:06 +02:00
} else {
2022-10-19 16:35:21 +02:00
startNewEntry ( tracker , newSegmentNameBox . getValue ( ) ) ;
2022-09-29 15:36:06 +02:00
}
2023-05-23 18:06:29 +02:00
yield saveTracker ( tracker , this . app , file , getSectionInfo ( ) ) ;
2022-09-29 15:36:06 +02:00
} ) ) ;
btn . buttonEl . addClass ( "simple-time-tracker-btn" ) ;
2022-10-19 16:35:21 +02:00
let newSegmentNameBox = new import _obsidian2 . TextComponent ( element ) . setPlaceholder ( "Segment name" ) . setDisabled ( running ) ;
newSegmentNameBox . inputEl . addClass ( "simple-time-tracker-txt" ) ;
2022-09-29 15:36:06 +02:00
let timer = element . createDiv ( { cls : "simple-time-tracker-timers" } ) ;
let currentDiv = timer . createEl ( "div" , { cls : "simple-time-tracker-timer" } ) ;
let current = currentDiv . createEl ( "span" , { cls : "simple-time-tracker-timer-time" } ) ;
currentDiv . createEl ( "span" , { text : "Current" } ) ;
let totalDiv = timer . createEl ( "div" , { cls : "simple-time-tracker-timer" } ) ;
let total = totalDiv . createEl ( "span" , { cls : "simple-time-tracker-timer-time" , text : "0s" } ) ;
totalDiv . createEl ( "span" , { text : "Total" } ) ;
if ( tracker . entries . length > 0 ) {
let table = element . createEl ( "table" , { cls : "simple-time-tracker-table" } ) ;
2022-10-10 14:40:36 +02:00
table . createEl ( "tr" ) . append ( createEl ( "th" , { text : "Segment" } ) , createEl ( "th" , { text : "Start time" } ) , createEl ( "th" , { text : "End time" } ) , createEl ( "th" , { text : "Duration" } ) , createEl ( "th" ) ) ;
2022-10-19 16:35:21 +02:00
for ( let entry of tracker . entries )
2023-05-23 18:06:29 +02:00
addEditableTableRow ( tracker , entry , table , newSegmentNameBox , running , file , getSectionInfo , settings , 0 ) ;
2022-09-29 15:36:06 +02:00
let buttons = element . createEl ( "div" , { cls : "simple-time-tracker-bottom" } ) ;
new import _obsidian2 . ButtonComponent ( buttons ) . setButtonText ( "Copy as table" ) . onClick ( ( ) => navigator . clipboard . writeText ( createMarkdownTable ( tracker , settings ) ) ) ;
new import _obsidian2 . ButtonComponent ( buttons ) . setButtonText ( "Copy as CSV" ) . onClick ( ( ) => navigator . clipboard . writeText ( createCsv ( tracker , settings ) ) ) ;
}
2023-05-23 18:18:28 +02:00
setCountdownValues ( tracker , current , total , currentDiv , settings ) ;
2022-09-29 15:36:06 +02:00
let intervalId = window . setInterval ( ( ) => {
if ( ! element . isConnected ) {
window . clearInterval ( intervalId ) ;
return ;
}
2023-05-23 18:18:28 +02:00
setCountdownValues ( tracker , current , total , currentDiv , settings ) ;
2022-09-29 15:36:06 +02:00
} , 1e3 ) ;
}
2022-10-19 16:35:21 +02:00
function startSubEntry ( entry , name ) {
if ( ! entry . subEntries ) {
entry . subEntries = [ _ _spreadProps ( _ _spreadValues ( { } , entry ) , { name : ` Part 1 ` } ) ] ;
entry . startTime = null ;
entry . endTime = null ;
2022-09-29 15:36:06 +02:00
}
2022-10-19 16:35:21 +02:00
if ( ! name )
name = ` Part ${ entry . subEntries . length + 1 } ` ;
entry . subEntries . push ( { name , startTime : ( 0 , import _obsidian2 . moment ) ( ) . unix ( ) , endTime : null , subEntries : null } ) ;
2022-09-29 15:36:06 +02:00
}
2022-10-19 16:35:21 +02:00
function startNewEntry ( tracker , name ) {
if ( ! name )
name = ` Segment ${ tracker . entries . length + 1 } ` ;
let entry = { name , startTime : ( 0 , import _obsidian2 . moment ) ( ) . unix ( ) , endTime : null , subEntries : null } ;
tracker . entries . push ( entry ) ;
}
function endRunningEntry ( tracker ) {
let entry = getRunningEntry ( tracker . entries ) ;
entry . endTime = ( 0 , import _obsidian2 . moment ) ( ) . unix ( ) ;
}
function removeEntry ( entries , toRemove ) {
if ( entries . contains ( toRemove ) ) {
entries . remove ( toRemove ) ;
return true ;
} else {
for ( let entry of entries ) {
if ( entry . subEntries && removeEntry ( entry . subEntries , toRemove ) ) {
if ( entry . subEntries . length == 1 ) {
let single = entry . subEntries [ 0 ] ;
entry . startTime = single . startTime ;
entry . endTime = single . endTime ;
entry . subEntries = null ;
}
return true ;
}
}
}
return false ;
}
function isRunning ( tracker ) {
return ! ! getRunningEntry ( tracker . entries ) ;
}
function getRunningEntry ( entries ) {
for ( let entry of entries ) {
if ( entry . subEntries ) {
let running = getRunningEntry ( entry . subEntries ) ;
if ( running )
return running ;
} else {
if ( ! entry . endTime )
return entry ;
}
}
return null ;
}
function getDuration ( entry ) {
if ( entry . subEntries ) {
return getTotalDuration ( entry . subEntries ) ;
} else {
2022-09-29 15:36:06 +02:00
let endTime = entry . endTime ? import _obsidian2 . moment . unix ( entry . endTime ) : ( 0 , import _obsidian2 . moment ) ( ) ;
2022-10-19 16:35:21 +02:00
return endTime . diff ( import _obsidian2 . moment . unix ( entry . startTime ) ) ;
}
}
function getTotalDuration ( entries ) {
let ret = 0 ;
for ( let entry of entries )
ret += getDuration ( entry ) ;
return ret ;
}
2023-05-23 18:18:28 +02:00
function setCountdownValues ( tracker , current , total , currentDiv , settings ) {
2022-10-19 16:35:21 +02:00
let running = getRunningEntry ( tracker . entries ) ;
if ( running && ! running . endTime ) {
2023-05-23 18:18:28 +02:00
current . setText ( formatDuration ( getDuration ( running ) , settings ) ) ;
2022-10-19 16:35:21 +02:00
currentDiv . hidden = false ;
} else {
currentDiv . hidden = true ;
2022-09-29 15:36:06 +02:00
}
2023-05-23 18:18:28 +02:00
total . setText ( formatDuration ( getTotalDuration ( tracker . entries ) , settings ) ) ;
2022-09-29 15:36:06 +02:00
}
function formatTimestamp ( timestamp , settings ) {
return import _obsidian2 . moment . unix ( timestamp ) . format ( settings . timestampFormat ) ;
}
2023-07-03 17:23:47 +02:00
function unFormatTimestamp ( formatted , settings ) {
return ( 0 , import _obsidian2 . moment ) ( formatted , settings . timestampFormat ) . unix ( ) ;
}
2023-05-23 18:18:28 +02:00
function formatDuration ( totalTime , settings ) {
2022-09-29 15:36:06 +02:00
let ret = "" ;
2023-05-23 18:18:28 +02:00
let duration = import _obsidian2 . moment . duration ( totalTime ) ;
let hours ;
if ( settings . fineGrainedDurations ) {
if ( duration . years ( ) > 0 )
ret += duration . years ( ) + "y " ;
if ( duration . months ( ) > 0 )
ret += duration . months ( ) + "M " ;
if ( duration . days ( ) > 0 )
ret += duration . days ( ) + "d " ;
hours = duration . hours ( ) ;
} else {
hours = Math . floor ( duration . asHours ( ) ) ;
}
if ( hours > 0 )
ret += hours + "h " ;
2022-09-29 15:36:06 +02:00
if ( duration . minutes ( ) > 0 )
ret += duration . minutes ( ) + "m " ;
ret += duration . seconds ( ) + "s" ;
return ret ;
}
function createMarkdownTable ( tracker , settings ) {
let table = [ [ "Segment" , "Start time" , "End time" , "Duration" ] ] ;
for ( let entry of tracker . entries )
2022-10-19 16:35:21 +02:00
table . push ( ... createTableSection ( entry , settings ) ) ;
2023-05-23 18:18:28 +02:00
table . push ( [ "**Total**" , "" , "" , ` ** ${ formatDuration ( getTotalDuration ( tracker . entries ) , settings ) } ** ` ] ) ;
2022-09-29 15:36:06 +02:00
let ret = "" ;
let widths = Array . from ( Array ( 4 ) . keys ( ) ) . map ( ( i ) => Math . max ( ... table . map ( ( a ) => a [ i ] . length ) ) ) ;
for ( let r = 0 ; r < table . length ; r ++ ) {
if ( r == 1 )
2023-05-23 16:48:18 +02:00
ret += "| " + Array . from ( Array ( 4 ) . keys ( ) ) . map ( ( i ) => "-" . repeat ( widths [ i ] ) ) . join ( " | " ) + " |\n" ;
2022-09-29 15:36:06 +02:00
let row = [ ] ;
for ( let i = 0 ; i < 4 ; i ++ )
row . push ( table [ r ] [ i ] . padEnd ( widths [ i ] , " " ) ) ;
2023-05-23 16:48:18 +02:00
ret += "| " + row . join ( " | " ) + " |\n" ;
2022-09-29 15:36:06 +02:00
}
return ret ;
}
function createCsv ( tracker , settings ) {
let ret = "" ;
2022-10-19 16:35:21 +02:00
for ( let entry of tracker . entries ) {
for ( let row of createTableSection ( entry , settings ) )
ret += row . join ( settings . csvDelimiter ) + "\n" ;
}
2022-09-29 15:36:06 +02:00
return ret ;
}
2022-10-19 16:35:21 +02:00
function createTableSection ( entry , settings ) {
let ret = [ [
2022-09-29 15:36:06 +02:00
entry . name ,
2022-10-19 16:35:21 +02:00
entry . startTime ? formatTimestamp ( entry . startTime , settings ) : "" ,
2022-09-29 15:36:06 +02:00
entry . endTime ? formatTimestamp ( entry . endTime , settings ) : "" ,
2023-05-23 18:18:28 +02:00
entry . endTime || entry . subEntries ? formatDuration ( getDuration ( entry ) , settings ) : ""
2022-10-19 16:35:21 +02:00
] ] ;
if ( entry . subEntries ) {
for ( let sub of entry . subEntries )
ret . push ( ... createTableSection ( sub , settings ) ) ;
}
return ret ;
}
2023-07-03 17:23:47 +02:00
var EditableField = class {
constructor ( row , indent , value ) {
this . cell = row . createEl ( "td" ) ;
this . label = this . cell . createEl ( "span" , { text : value } ) ;
this . label . style . marginLeft = ` ${ indent } em ` ;
this . box = new import _obsidian2 . TextComponent ( this . cell ) . setValue ( value ) ;
this . box . inputEl . classList . add ( "simple-time-tracker-input" ) ;
this . box . inputEl . hide ( ) ;
}
editing ( ) {
return this . label . hidden ;
}
beginEdit ( value ) {
this . label . hidden = true ;
this . box . setValue ( value ) ;
this . box . inputEl . show ( ) ;
}
endEdit ( ) {
let value = this . box . getValue ( ) ;
this . label . setText ( value ) ;
this . box . inputEl . hide ( ) ;
this . label . hidden = false ;
return value ;
}
} ;
2023-05-23 18:06:29 +02:00
function addEditableTableRow ( tracker , entry , table , newSegmentNameBox , running , file , getSectionInfo , settings , indent ) {
2022-10-19 16:35:21 +02:00
let row = table . createEl ( "tr" ) ;
2023-07-03 17:23:47 +02:00
let nameField = new EditableField ( row , indent , entry . name ) ;
let startValue = entry . startTime ? formatTimestamp ( entry . startTime , settings ) : "" ;
let startField = new EditableField ( row , indent , startValue ) ;
let endValue = entry . endTime ? formatTimestamp ( entry . endTime , settings ) : "" ;
let endField = new EditableField ( row , indent , endValue ) ;
2023-05-23 18:18:28 +02:00
row . createEl ( "td" , { text : entry . endTime || entry . subEntries ? formatDuration ( getDuration ( entry ) , settings ) : "" } ) ;
2022-10-19 16:35:21 +02:00
let entryButtons = row . createEl ( "td" ) ;
if ( ! running ) {
new import _obsidian2 . ButtonComponent ( entryButtons ) . setClass ( "clickable-icon" ) . setIcon ( ` lucide-play ` ) . setTooltip ( "Continue" ) . onClick ( ( ) => _ _async ( this , null , function * ( ) {
startSubEntry ( entry , newSegmentNameBox . getValue ( ) ) ;
2023-05-23 18:06:29 +02:00
yield saveTracker ( tracker , this . app , file , getSectionInfo ( ) ) ;
2022-10-19 16:35:21 +02:00
} ) ) ;
}
let editButton = new import _obsidian2 . ButtonComponent ( entryButtons ) . setClass ( "clickable-icon" ) . setTooltip ( "Edit" ) . setIcon ( "lucide-pencil" ) . onClick ( ( ) => _ _async ( this , null , function * ( ) {
2023-07-03 17:23:47 +02:00
if ( nameField . editing ( ) ) {
entry . name = nameField . endEdit ( ) ;
entry . startTime = unFormatTimestamp ( startField . endEdit ( ) , settings ) ;
entry . endTime = unFormatTimestamp ( endField . endEdit ( ) , settings ) ;
yield saveTracker ( tracker , this . app , file , getSectionInfo ( ) ) ;
2022-10-19 16:35:21 +02:00
editButton . setIcon ( "lucide-pencil" ) ;
} else {
2023-07-03 17:23:47 +02:00
nameField . beginEdit ( entry . name ) ;
startField . beginEdit ( formatTimestamp ( entry . startTime , settings ) ) ;
endField . beginEdit ( formatTimestamp ( entry . endTime , settings ) ) ;
2022-10-19 16:35:21 +02:00
editButton . setIcon ( "lucide-check" ) ;
}
} ) ) ;
new import _obsidian2 . ButtonComponent ( entryButtons ) . setClass ( "clickable-icon" ) . setTooltip ( "Remove" ) . setIcon ( "lucide-trash" ) . onClick ( ( ) => _ _async ( this , null , function * ( ) {
removeEntry ( tracker . entries , entry ) ;
2023-05-23 18:06:29 +02:00
yield saveTracker ( tracker , this . app , file , getSectionInfo ( ) ) ;
2022-10-19 16:35:21 +02:00
} ) ) ;
if ( entry . subEntries ) {
for ( let sub of entry . subEntries )
2023-05-23 18:06:29 +02:00
addEditableTableRow ( tracker , sub , table , newSegmentNameBox , running , file , getSectionInfo , settings , indent + 1 ) ;
2022-10-19 16:35:21 +02:00
}
2022-09-29 15:36:06 +02:00
}
// src/main.ts
var SimpleTimeTrackerPlugin = class extends import _obsidian3 . Plugin {
onload ( ) {
return _ _async ( this , null , function * ( ) {
yield this . loadSettings ( ) ;
this . addSettingTab ( new SimpleTimeTrackerSettingsTab ( this . app , this ) ) ;
this . registerMarkdownCodeBlockProcessor ( "simple-time-tracker" , ( s , e , i ) => {
let tracker = loadTracker ( s ) ;
e . empty ( ) ;
2023-05-23 18:06:29 +02:00
displayTracker ( tracker , e , i . sourcePath , ( ) => i . getSectionInfo ( e ) , this . settings ) ;
2022-09-29 15:36:06 +02:00
} ) ;
this . addCommand ( {
id : ` insert ` ,
name : ` Insert Time Tracker ` ,
editorCallback : ( e , _ ) => {
e . replaceSelection ( "```simple-time-tracker\n```\n" ) ;
}
} ) ;
} ) ;
}
loadSettings ( ) {
return _ _async ( this , null , function * ( ) {
this . settings = Object . assign ( { } , defaultSettings , yield this . loadData ( ) ) ;
} ) ;
}
saveSettings ( ) {
return _ _async ( this , null , function * ( ) {
yield this . saveData ( this . settings ) ;
} ) ;
}
} ;
2023-07-03 18:58:04 +02:00
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsic3JjL21haW4udHMiLCAic3JjL3NldHRpbmdzLnRzIiwgInNyYy9zZXR0aW5ncy10YWIudHMiLCAic3JjL3RyYWNrZXIudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImltcG9ydCB7IFBsdWdpbiB9IGZyb20gXCJvYnNpZGlhblwiO1xuaW1wb3J0IHsgZGVmYXVsdFNldHRpbmdzLCBTaW1wbGVUaW1lVHJhY2tlclNldHRpbmdzIH0gZnJvbSBcIi4vc2V0dGluZ3NcIjtcbmltcG9ydCB7IFNpbXBsZVRpbWVUcmFja2VyU2V0dGluZ3NUYWIgfSBmcm9tIFwiLi9zZXR0aW5ncy10YWJcIjtcbmltcG9ydCB7IGRpc3BsYXlUcmFja2VyLCBsb2FkVHJhY2tlciwgVHJhY2tlciB9IGZyb20gXCIuL3RyYWNrZXJcIjtcblxuZXhwb3J0IGRlZmF1bHQgY2xhc3MgU2ltcGxlVGltZVRyYWNrZXJQbHVnaW4gZXh0ZW5kcyBQbHVnaW4ge1xuXG4gICAgc2V0dGluZ3M6IFNpbXBsZVRpbWVUcmFja2VyU2V0dGluZ3M7XG5cbiAgICBhc3luYyBv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