2025-08-02 12:09:34 +08:00
/ *
THIS IS A GENERATED / BUNDLED FILE BY ESBUILD
if you want to view the source , please visit the github repository of this plugin
* /
2026-05-06 17:32:44 +08:00
"use strict" ;
2025-08-02 12:09:34 +08:00
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 _ _defNormalProp = ( obj , key , value ) => key in obj ? _ _defProp ( obj , key , { enumerable : true , configurable : true , writable : true , value } ) : obj [ key ] = value ;
var _ _export = ( target , all ) => {
for ( var name in all )
_ _defProp ( target , name , { get : all [ name ] , enumerable : true } ) ;
} ;
2026-05-06 17:32:44 +08:00
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 } ) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
return to ;
2025-08-02 12:09:34 +08:00
} ;
2026-05-06 17:32:44 +08:00
var _ _toESM = ( mod , isNodeMode , target ) => ( target = mod != null ? _ _create ( _ _getProtoOf ( mod ) ) : { } , _ _copyProps (
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || ! mod || ! mod . _ _esModule ? _ _defProp ( target , "default" , { value : mod , enumerable : true } ) : target ,
mod
) ) ;
var _ _toCommonJS = ( mod ) => _ _copyProps ( _ _defProp ( { } , "__esModule" , { value : true } ) , mod ) ;
var _ _publicField = ( obj , key , value ) => {
_ _defNormalProp ( obj , typeof key !== "symbol" ? key + "" : key , value ) ;
return value ;
2025-08-02 12:09:34 +08:00
} ;
// src/main.ts
2026-05-06 17:32:44 +08:00
var main _exports = { } ;
_ _export ( main _exports , {
2025-08-02 12:09:34 +08:00
default : ( ) => CoreSearchAssistantPlugin
} ) ;
2026-05-06 17:32:44 +08:00
module . exports = _ _toCommonJS ( main _exports ) ;
2025-08-02 12:09:34 +08:00
// src/Events.ts
2026-05-06 17:32:44 +08:00
var import _obsidian = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
var EVENT _SEARCH _RESULT _ITEM _DETECTED = "search-result-item-detected" ;
var EVENT _SORT _ORDER _CHANGED = "sort-order-changed" ;
var CoreSearchAssistantEvents = class extends import _obsidian . Events {
trigger ( name , ... data ) {
super . trigger ( name , ... data ) ;
}
on ( name , callback , ctx ) {
return super . on ( name , callback , ctx ) ;
}
} ;
2026-05-06 17:32:44 +08:00
// src/ModeScope.ts
var ModeScope = class {
constructor ( ) {
this . _depth = 0 ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
get inSearchMode ( ) {
return this . _depth > 0 ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
get depth ( ) {
return this . _depth ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
push ( ) {
this . _depth ++ ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
pop ( ) {
this . _depth -- ;
if ( this . depth < 0 ) {
throw "[ERROR in Core Search Assistant] ModeScope.depth < 0" ;
}
}
reset ( ) {
this . _depth = 0 ;
2025-08-02 12:09:34 +08:00
}
} ;
// src/Setting.ts
2026-05-06 17:32:44 +08:00
var import _obsidian6 = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
// src/ui/HotkeySetter.ts
2026-05-06 17:32:44 +08:00
var import _obsidian5 = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
2026-05-06 17:32:44 +08:00
// node_modules/svelte/src/runtime/internal/utils.js
2025-08-02 12:09:34 +08:00
function noop ( ) {
}
function run ( fn ) {
return fn ( ) ;
}
function blank _object ( ) {
2026-05-06 17:32:44 +08:00
return /* @__PURE__ */ Object . create ( null ) ;
2025-08-02 12:09:34 +08:00
}
function run _all ( fns ) {
fns . forEach ( run ) ;
}
function is _function ( thing ) {
return typeof thing === "function" ;
}
function safe _not _equal ( a , b ) {
2026-05-06 17:32:44 +08:00
return a != a ? b == b : a !== b || a && typeof a === "object" || typeof a === "function" ;
2025-08-02 12:09:34 +08:00
}
function is _empty ( obj ) {
return Object . keys ( obj ) . length === 0 ;
}
2026-05-06 17:32:44 +08:00
function subscribe ( store , ... callbacks ) {
if ( store == null ) {
for ( const callback of callbacks ) {
callback ( void 0 ) ;
}
2025-08-02 12:09:34 +08:00
return noop ;
}
2026-05-06 17:32:44 +08:00
const unsub = store . subscribe ( ... callbacks ) ;
2025-08-02 12:09:34 +08:00
return unsub . unsubscribe ? ( ) => unsub . unsubscribe ( ) : unsub ;
}
2026-05-06 17:32:44 +08:00
function component _subscribe ( component , store , callback ) {
component . $$ . on _destroy . push ( subscribe ( store , callback ) ) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
// node_modules/svelte/src/runtime/internal/globals.js
var globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : (
// @ts-ignore Node typings have this
global
) ;
// node_modules/svelte/src/runtime/internal/ResizeObserverSingleton.js
var ResizeObserverSingleton = class _ResizeObserverSingleton {
/** @param {ResizeObserverOptions} options */
constructor ( options ) {
/ * *
* @ private
* @ readonly
* @ type { WeakMap < Element , import ( './private.js' ) . Listener > }
* /
_ _publicField ( this , "_listeners" , "WeakMap" in globals ? /* @__PURE__ */ new WeakMap ( ) : void 0 ) ;
/ * *
* @ private
* @ type { ResizeObserver }
* /
_ _publicField ( this , "_observer" ) ;
/** @type {ResizeObserverOptions} */
_ _publicField ( this , "options" ) ;
this . options = options ;
}
/ * *
* @ param { Element } element
* @ param { import ( './private.js' ) . Listener } listener
* @ returns { ( ) => void }
* /
observe ( element2 , listener ) {
this . _listeners . set ( element2 , listener ) ;
this . _getObserver ( ) . observe ( element2 , this . options ) ;
return ( ) => {
this . _listeners . delete ( element2 ) ;
this . _observer . unobserve ( element2 ) ;
} ;
}
/ * *
* @ private
* /
_getObserver ( ) {
return this . _observer ? ? ( this . _observer = new ResizeObserver ( ( entries ) => {
for ( const entry of entries ) {
_ResizeObserverSingleton . entries . set ( entry . target , entry ) ;
this . _listeners . get ( entry . target ) ? . ( entry ) ;
}
} ) ) ;
}
} ;
ResizeObserverSingleton . entries = "WeakMap" in globals ? /* @__PURE__ */ new WeakMap ( ) : void 0 ;
// node_modules/svelte/src/runtime/internal/dom.js
2025-08-02 12:09:34 +08:00
var is _hydrating = false ;
function start _hydrating ( ) {
is _hydrating = true ;
}
function end _hydrating ( ) {
is _hydrating = false ;
}
function append ( target , node ) {
target . appendChild ( node ) ;
}
function append _styles ( target , style _sheet _id , styles ) {
const append _styles _to = get _root _for _style ( target ) ;
if ( ! append _styles _to . getElementById ( style _sheet _id ) ) {
const style = element ( "style" ) ;
style . id = style _sheet _id ;
style . textContent = styles ;
append _stylesheet ( append _styles _to , style ) ;
}
}
function get _root _for _style ( node ) {
if ( ! node )
return document ;
const root = node . getRootNode ? node . getRootNode ( ) : node . ownerDocument ;
2026-05-06 17:32:44 +08:00
if ( root && /** @type {ShadowRoot} */
root . host ) {
return (
/** @type {ShadowRoot} */
root
) ;
2025-08-02 12:09:34 +08:00
}
return node . ownerDocument ;
}
function append _stylesheet ( node , style ) {
2026-05-06 17:32:44 +08:00
append (
/** @type {Document} */
node . head || node ,
style
) ;
return style . sheet ;
2025-08-02 12:09:34 +08:00
}
function insert ( target , node , anchor ) {
target . insertBefore ( node , anchor || null ) ;
}
function detach ( node ) {
2026-05-06 17:32:44 +08:00
if ( node . parentNode ) {
node . parentNode . removeChild ( node ) ;
}
2025-08-02 12:09:34 +08:00
}
function destroy _each ( iterations , detaching ) {
for ( let i = 0 ; i < iterations . length ; i += 1 ) {
if ( iterations [ i ] )
iterations [ i ] . d ( detaching ) ;
}
}
function element ( name ) {
return document . createElement ( name ) ;
}
function text ( data ) {
return document . createTextNode ( data ) ;
}
function space ( ) {
return text ( " " ) ;
}
function listen ( node , event , handler , options ) {
node . addEventListener ( event , handler , options ) ;
return ( ) => node . removeEventListener ( event , handler , options ) ;
}
function attr ( node , attribute , value ) {
if ( value == null )
node . removeAttribute ( attribute ) ;
else if ( node . getAttribute ( attribute ) !== value )
node . setAttribute ( attribute , value ) ;
}
function children ( element2 ) {
return Array . from ( element2 . childNodes ) ;
}
function set _data ( text2 , data ) {
data = "" + data ;
2026-05-06 17:32:44 +08:00
if ( text2 . data === data )
return ;
text2 . data = /** @type {string} */
data ;
2025-08-02 12:09:34 +08:00
}
function toggle _class ( element2 , name , toggle ) {
2026-05-06 17:32:44 +08:00
element2 . classList . toggle ( name , ! ! toggle ) ;
}
function custom _event ( type , detail , { bubbles = false , cancelable = false } = { } ) {
return new CustomEvent ( type , { detail , bubbles , cancelable } ) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
function get _custom _elements _slots ( element2 ) {
const result = { } ;
element2 . childNodes . forEach (
/** @param {Element} node */
( node ) => {
result [ node . slot || "default" ] = true ;
}
) ;
return result ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
// node_modules/svelte/src/runtime/internal/lifecycle.js
2025-08-02 12:09:34 +08:00
var current _component ;
function set _current _component ( component ) {
current _component = component ;
}
function get _current _component ( ) {
if ( ! current _component )
throw new Error ( "Function called outside component initialization" ) ;
return current _component ;
}
function onMount ( fn ) {
get _current _component ( ) . $$ . on _mount . push ( fn ) ;
}
function onDestroy ( fn ) {
get _current _component ( ) . $$ . on _destroy . push ( fn ) ;
}
function createEventDispatcher ( ) {
const component = get _current _component ( ) ;
2026-05-06 17:32:44 +08:00
return ( type , detail , { cancelable = false } = { } ) => {
2025-08-02 12:09:34 +08:00
const callbacks = component . $$ . callbacks [ type ] ;
if ( callbacks ) {
2026-05-06 17:32:44 +08:00
const event = custom _event (
/** @type {string} */
type ,
detail ,
{ cancelable }
) ;
2025-08-02 12:09:34 +08:00
callbacks . slice ( ) . forEach ( ( fn ) => {
fn . call ( component , event ) ;
} ) ;
2026-05-06 17:32:44 +08:00
return ! event . defaultPrevented ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
return true ;
2025-08-02 12:09:34 +08:00
} ;
}
2026-05-06 17:32:44 +08:00
// node_modules/svelte/src/runtime/internal/scheduler.js
2025-08-02 12:09:34 +08:00
var dirty _components = [ ] ;
var binding _callbacks = [ ] ;
var render _callbacks = [ ] ;
var flush _callbacks = [ ] ;
2026-05-06 17:32:44 +08:00
var resolved _promise = /* @__PURE__ */ Promise . resolve ( ) ;
2025-08-02 12:09:34 +08:00
var update _scheduled = false ;
function schedule _update ( ) {
if ( ! update _scheduled ) {
update _scheduled = true ;
resolved _promise . then ( flush ) ;
}
}
function add _render _callback ( fn ) {
render _callbacks . push ( fn ) ;
}
2026-05-06 17:32:44 +08:00
var seen _callbacks = /* @__PURE__ */ new Set ( ) ;
2025-08-02 12:09:34 +08:00
var flushidx = 0 ;
function flush ( ) {
2026-05-06 17:32:44 +08:00
if ( flushidx !== 0 ) {
return ;
}
2025-08-02 12:09:34 +08:00
const saved _component = current _component ;
do {
2026-05-06 17:32:44 +08:00
try {
while ( flushidx < dirty _components . length ) {
const component = dirty _components [ flushidx ] ;
flushidx ++ ;
set _current _component ( component ) ;
update ( component . $$ ) ;
}
} catch ( e ) {
dirty _components . length = 0 ;
flushidx = 0 ;
throw e ;
2025-08-02 12:09:34 +08:00
}
set _current _component ( null ) ;
dirty _components . length = 0 ;
flushidx = 0 ;
while ( binding _callbacks . length )
binding _callbacks . pop ( ) ( ) ;
for ( let i = 0 ; i < render _callbacks . length ; i += 1 ) {
const callback = render _callbacks [ i ] ;
if ( ! seen _callbacks . has ( callback ) ) {
seen _callbacks . add ( callback ) ;
callback ( ) ;
}
}
render _callbacks . length = 0 ;
} while ( dirty _components . length ) ;
while ( flush _callbacks . length ) {
flush _callbacks . pop ( ) ( ) ;
}
update _scheduled = false ;
seen _callbacks . clear ( ) ;
set _current _component ( saved _component ) ;
}
function update ( $$ ) {
if ( $$ . fragment !== null ) {
$$ . update ( ) ;
run _all ( $$ . before _update ) ;
const dirty = $$ . dirty ;
$$ . dirty = [ - 1 ] ;
$$ . fragment && $$ . fragment . p ( $$ . ctx , dirty ) ;
$$ . after _update . forEach ( add _render _callback ) ;
}
}
2026-05-06 17:32:44 +08:00
function flush _render _callbacks ( fns ) {
const filtered = [ ] ;
const targets = [ ] ;
render _callbacks . forEach ( ( c ) => fns . indexOf ( c ) === - 1 ? filtered . push ( c ) : targets . push ( c ) ) ;
targets . forEach ( ( c ) => c ( ) ) ;
render _callbacks = filtered ;
}
// node_modules/svelte/src/runtime/internal/transitions.js
var outroing = /* @__PURE__ */ new Set ( ) ;
2025-08-02 12:09:34 +08:00
var outros ;
function group _outros ( ) {
outros = {
r : 0 ,
c : [ ] ,
p : outros
2026-05-06 17:32:44 +08:00
// parent group
2025-08-02 12:09:34 +08:00
} ;
}
function check _outros ( ) {
if ( ! outros . r ) {
run _all ( outros . c ) ;
}
outros = outros . p ;
}
function transition _in ( block , local ) {
if ( block && block . i ) {
outroing . delete ( block ) ;
block . i ( local ) ;
}
}
function transition _out ( block , local , detach2 , callback ) {
if ( block && block . o ) {
if ( outroing . has ( block ) )
return ;
outroing . add ( block ) ;
outros . c . push ( ( ) => {
outroing . delete ( block ) ;
if ( callback ) {
if ( detach2 )
block . d ( 1 ) ;
callback ( ) ;
}
} ) ;
block . o ( local ) ;
2026-05-06 17:32:44 +08:00
} else if ( callback ) {
callback ( ) ;
2025-08-02 12:09:34 +08:00
}
}
2026-05-06 17:32:44 +08:00
// node_modules/svelte/src/runtime/internal/each.js
function ensure _array _like ( array _like _or _iterator ) {
return array _like _or _iterator ? . length !== void 0 ? array _like _or _iterator : Array . from ( array _like _or _iterator ) ;
}
// node_modules/svelte/src/shared/boolean_attributes.js
var _boolean _attributes = (
/** @type {const} */
[
"allowfullscreen" ,
"allowpaymentrequest" ,
"async" ,
"autofocus" ,
"autoplay" ,
"checked" ,
"controls" ,
"default" ,
"defer" ,
"disabled" ,
"formnovalidate" ,
"hidden" ,
"inert" ,
"ismap" ,
"loop" ,
"multiple" ,
"muted" ,
"nomodule" ,
"novalidate" ,
"open" ,
"playsinline" ,
"readonly" ,
"required" ,
"reversed" ,
"selected"
]
) ;
var boolean _attributes = /* @__PURE__ */ new Set ( [ ... _boolean _attributes ] ) ;
// node_modules/svelte/src/runtime/internal/Component.js
2025-08-02 12:09:34 +08:00
function create _component ( block ) {
block && block . c ( ) ;
}
2026-05-06 17:32:44 +08:00
function mount _component ( component , target , anchor ) {
const { fragment , after _update } = component . $$ ;
2025-08-02 12:09:34 +08:00
fragment && fragment . m ( target , anchor ) ;
2026-05-06 17:32:44 +08:00
add _render _callback ( ( ) => {
const new _on _destroy = component . $$ . on _mount . map ( run ) . filter ( is _function ) ;
if ( component . $$ . on _destroy ) {
component . $$ . on _destroy . push ( ... new _on _destroy ) ;
} else {
run _all ( new _on _destroy ) ;
}
component . $$ . on _mount = [ ] ;
} ) ;
2025-08-02 12:09:34 +08:00
after _update . forEach ( add _render _callback ) ;
}
function destroy _component ( component , detaching ) {
const $$ = component . $$ ;
if ( $$ . fragment !== null ) {
2026-05-06 17:32:44 +08:00
flush _render _callbacks ( $$ . after _update ) ;
2025-08-02 12:09:34 +08:00
run _all ( $$ . on _destroy ) ;
$$ . fragment && $$ . fragment . d ( detaching ) ;
$$ . on _destroy = $$ . fragment = null ;
$$ . ctx = [ ] ;
}
}
function make _dirty ( component , i ) {
if ( component . $$ . dirty [ 0 ] === - 1 ) {
dirty _components . push ( component ) ;
schedule _update ( ) ;
component . $$ . dirty . fill ( 0 ) ;
}
component . $$ . dirty [ i / 31 | 0 ] |= 1 << i % 31 ;
}
2026-05-06 17:32:44 +08:00
function init ( component , options , instance8 , create _fragment8 , not _equal , props , append _styles2 = null , dirty = [ - 1 ] ) {
2025-08-02 12:09:34 +08:00
const parent _component = current _component ;
set _current _component ( component ) ;
const $$ = component . $$ = {
fragment : null ,
2026-05-06 17:32:44 +08:00
ctx : [ ] ,
// state
2025-08-02 12:09:34 +08:00
props ,
update : noop ,
not _equal ,
bound : blank _object ( ) ,
2026-05-06 17:32:44 +08:00
// lifecycle
2025-08-02 12:09:34 +08:00
on _mount : [ ] ,
on _destroy : [ ] ,
on _disconnect : [ ] ,
before _update : [ ] ,
after _update : [ ] ,
context : new Map ( options . context || ( parent _component ? parent _component . $$ . context : [ ] ) ) ,
2026-05-06 17:32:44 +08:00
// everything else
2025-08-02 12:09:34 +08:00
callbacks : blank _object ( ) ,
dirty ,
skip _bound : false ,
root : options . target || parent _component . $$ . root
} ;
append _styles2 && append _styles2 ( $$ . root ) ;
let ready = false ;
$$ . ctx = instance8 ? instance8 ( component , options . props || { } , ( i , ret , ... rest ) => {
const value = rest . length ? rest [ 0 ] : ret ;
if ( $$ . ctx && not _equal ( $$ . ctx [ i ] , $$ . ctx [ i ] = value ) ) {
if ( ! $$ . skip _bound && $$ . bound [ i ] )
$$ . bound [ i ] ( value ) ;
if ( ready )
make _dirty ( component , i ) ;
}
return ret ;
} ) : [ ] ;
$$ . update ( ) ;
ready = true ;
run _all ( $$ . before _update ) ;
$$ . fragment = create _fragment8 ? create _fragment8 ( $$ . ctx ) : false ;
if ( options . target ) {
if ( options . hydrate ) {
start _hydrating ( ) ;
const nodes = children ( options . target ) ;
$$ . fragment && $$ . fragment . l ( nodes ) ;
nodes . forEach ( detach ) ;
} else {
$$ . fragment && $$ . fragment . c ( ) ;
}
if ( options . intro )
transition _in ( component . $$ . fragment ) ;
2026-05-06 17:32:44 +08:00
mount _component ( component , options . target , options . anchor ) ;
2025-08-02 12:09:34 +08:00
end _hydrating ( ) ;
flush ( ) ;
}
set _current _component ( parent _component ) ;
}
var SvelteElement ;
if ( typeof HTMLElement === "function" ) {
SvelteElement = class extends HTMLElement {
2026-05-06 17:32:44 +08:00
constructor ( $$componentCtor , $$slots , use _shadow _dom ) {
2025-08-02 12:09:34 +08:00
super ( ) ;
2026-05-06 17:32:44 +08:00
/** The Svelte component constructor */
_ _publicField ( this , "$$ctor" ) ;
/** Slots */
_ _publicField ( this , "$$s" ) ;
/** The Svelte component instance */
_ _publicField ( this , "$$c" ) ;
/** Whether or not the custom element is connected */
_ _publicField ( this , "$$cn" , false ) ;
/** Component props data */
_ _publicField ( this , "$$d" , { } ) ;
/** `true` if currently in the process of reflecting component props back to attributes */
_ _publicField ( this , "$$r" , false ) ;
/** @type {Record<string, CustomElementPropDefinition>} Props definition (name, reflected, type etc) */
_ _publicField ( this , "$$p_d" , { } ) ;
/** @type {Record<string, Function[]>} Event listeners */
_ _publicField ( this , "$$l" , { } ) ;
/** @type {Map<Function, Function>} Event listener unsubscribe functions */
_ _publicField ( this , "$$l_u" , /* @__PURE__ */ new Map ( ) ) ;
this . $$ctor = $$componentCtor ;
this . $$s = $$slots ;
if ( use _shadow _dom ) {
this . attachShadow ( { mode : "open" } ) ;
}
}
addEventListener ( type , listener , options ) {
this . $$l [ type ] = this . $$l [ type ] || [ ] ;
this . $$l [ type ] . push ( listener ) ;
if ( this . $$c ) {
const unsub = this . $$c . $on ( type , listener ) ;
this . $$l _u . set ( listener , unsub ) ;
}
super . addEventListener ( type , listener , options ) ;
}
removeEventListener ( type , listener , options ) {
super . removeEventListener ( type , listener , options ) ;
if ( this . $$c ) {
const unsub = this . $$l _u . get ( listener ) ;
if ( unsub ) {
unsub ( ) ;
this . $$l _u . delete ( listener ) ;
}
}
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
async connectedCallback ( ) {
this . $$cn = true ;
if ( ! this . $$c ) {
let create _slot = function ( name ) {
return ( ) => {
let node ;
const obj = {
c : function create ( ) {
node = element ( "slot" ) ;
if ( name !== "default" ) {
attr ( node , "name" , name ) ;
}
} ,
/ * *
* @ param { HTMLElement } target
* @ param { HTMLElement } [ anchor ]
* /
m : function mount ( target , anchor ) {
insert ( target , node , anchor ) ;
} ,
d : function destroy ( detaching ) {
if ( detaching ) {
detach ( node ) ;
}
}
} ;
return obj ;
} ;
} ;
await Promise . resolve ( ) ;
if ( ! this . $$cn || this . $$c ) {
return ;
}
const $$slots = { } ;
const existing _slots = get _custom _elements _slots ( this ) ;
for ( const name of this . $$s ) {
if ( name in existing _slots ) {
$$slots [ name ] = [ create _slot ( name ) ] ;
}
}
for ( const attribute of this . attributes ) {
const name = this . $$g _p ( attribute . name ) ;
if ( ! ( name in this . $$d ) ) {
this . $$d [ name ] = get _custom _element _value ( name , attribute . value , this . $$p _d , "toProp" ) ;
}
}
for ( const key in this . $$p _d ) {
if ( ! ( key in this . $$d ) && this [ key ] !== void 0 ) {
this . $$d [ key ] = this [ key ] ;
delete this [ key ] ;
}
}
this . $$c = new this . $$ctor ( {
target : this . shadowRoot || this ,
props : {
... this . $$d ,
$$slots ,
$$scope : {
ctx : [ ]
}
}
} ) ;
const reflect _attributes = ( ) => {
this . $$r = true ;
for ( const key in this . $$p _d ) {
this . $$d [ key ] = this . $$c . $$ . ctx [ this . $$c . $$ . props [ key ] ] ;
if ( this . $$p _d [ key ] . reflect ) {
const attribute _value = get _custom _element _value (
key ,
this . $$d [ key ] ,
this . $$p _d ,
"toAttribute"
) ;
if ( attribute _value == null ) {
this . removeAttribute ( this . $$p _d [ key ] . attribute || key ) ;
} else {
this . setAttribute ( this . $$p _d [ key ] . attribute || key , attribute _value ) ;
}
}
}
this . $$r = false ;
} ;
this . $$c . $$ . after _update . push ( reflect _attributes ) ;
reflect _attributes ( ) ;
for ( const type in this . $$l ) {
for ( const listener of this . $$l [ type ] ) {
const unsub = this . $$c . $on ( type , listener ) ;
this . $$l _u . set ( listener , unsub ) ;
}
}
this . $$l = { } ;
2025-08-02 12:09:34 +08:00
}
}
2026-05-06 17:32:44 +08:00
// We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte
// and setting attributes through setAttribute etc, this is helpful
2025-08-02 12:09:34 +08:00
attributeChangedCallback ( attr2 , _oldValue , newValue ) {
2026-05-06 17:32:44 +08:00
if ( this . $$r )
return ;
attr2 = this . $$g _p ( attr2 ) ;
this . $$d [ attr2 ] = get _custom _element _value ( attr2 , newValue , this . $$p _d , "toProp" ) ;
this . $$c ? . $set ( { [ attr2 ] : this . $$d [ attr2 ] } ) ;
2025-08-02 12:09:34 +08:00
}
disconnectedCallback ( ) {
2026-05-06 17:32:44 +08:00
this . $$cn = false ;
Promise . resolve ( ) . then ( ( ) => {
if ( ! this . $$cn && this . $$c ) {
this . $$c . $destroy ( ) ;
this . $$c = void 0 ;
}
} ) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
$$g _p ( attribute _name ) {
return Object . keys ( this . $$p _d ) . find (
( key ) => this . $$p _d [ key ] . attribute === attribute _name || ! this . $$p _d [ key ] . attribute && key . toLowerCase ( ) === attribute _name
) || attribute _name ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
} ;
}
function get _custom _element _value ( prop , value , props _definition , transform ) {
const type = props _definition [ prop ] ? . type ;
value = type === "Boolean" && typeof value !== "boolean" ? value != null : value ;
if ( ! transform || ! props _definition [ prop ] ) {
return value ;
} else if ( transform === "toAttribute" ) {
switch ( type ) {
case "Object" :
case "Array" :
return value == null ? null : JSON . stringify ( value ) ;
case "Boolean" :
return value ? "" : null ;
case "Number" :
return value == null ? null : value ;
default :
return value ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
} else {
switch ( type ) {
case "Object" :
case "Array" :
return value && JSON . parse ( value ) ;
case "Boolean" :
return value ;
case "Number" :
return value != null ? + value : value ;
default :
return value ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
}
2025-08-02 12:09:34 +08:00
}
var SvelteComponent = class {
2026-05-06 17:32:44 +08:00
constructor ( ) {
/ * *
* # # # PRIVATE API
*
* Do not use , may change at any time
*
* @ type { any }
* /
_ _publicField ( this , "$$" ) ;
/ * *
* # # # PRIVATE API
*
* Do not use , may change at any time
*
* @ type { any }
* /
_ _publicField ( this , "$$set" ) ;
}
/** @returns {void} */
2025-08-02 12:09:34 +08:00
$destroy ( ) {
destroy _component ( this , 1 ) ;
this . $destroy = noop ;
}
2026-05-06 17:32:44 +08:00
/ * *
* @ template { Extract < keyof Events , string > } K
* @ param { K } type
* @ param { ( ( e : Events [ K ] ) => void ) | null | undefined } callback
* @ returns { ( ) => void }
* /
2025-08-02 12:09:34 +08:00
$on ( type , callback ) {
2026-05-06 17:32:44 +08:00
if ( ! is _function ( callback ) ) {
return noop ;
}
2025-08-02 12:09:34 +08:00
const callbacks = this . $$ . callbacks [ type ] || ( this . $$ . callbacks [ type ] = [ ] ) ;
callbacks . push ( callback ) ;
return ( ) => {
const index = callbacks . indexOf ( callback ) ;
if ( index !== - 1 )
callbacks . splice ( index , 1 ) ;
} ;
}
2026-05-06 17:32:44 +08:00
/ * *
* @ param { Partial < Props > } props
* @ returns { void }
* /
$set ( props ) {
if ( this . $$set && ! is _empty ( props ) ) {
2025-08-02 12:09:34 +08:00
this . $$ . skip _bound = true ;
2026-05-06 17:32:44 +08:00
this . $$set ( props ) ;
2025-08-02 12:09:34 +08:00
this . $$ . skip _bound = false ;
}
}
} ;
2026-05-06 17:32:44 +08:00
// node_modules/svelte/src/shared/version.js
var PUBLIC _VERSION = "4" ;
// node_modules/svelte/src/runtime/internal/disclose-version/index.js
if ( typeof window !== "undefined" )
( window . _ _svelte || ( window . _ _svelte = { v : /* @__PURE__ */ new Set ( ) } ) ) . v . add ( PUBLIC _VERSION ) ;
// src/ui/HotKeyEntry.svelte
var import _obsidian4 = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
// src/ui/HotkeySetting.svelte
2026-05-06 17:32:44 +08:00
var import _obsidian3 = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
// src/utils/Keymap.ts
2026-05-06 17:32:44 +08:00
var import _obsidian2 = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
var CODE _KEY _MAP = {
Semicolon : ";" ,
Quote : "'" ,
Comma : "," ,
Period : "." ,
Slash : "/" ,
BracketLeft : "[" ,
BracketRight : "]" ,
BackSlash : "\\" ,
Backquote : "`" ,
Space : " " ,
Minus : "-" ,
Equal : "="
} ;
for ( let i = 0 ; i < 10 ; i ++ ) {
CODE _KEY _MAP [ ` Digit ${ i } ` ] = i . toString ( ) ;
}
for ( let i = 65 ; i < 91 ; i ++ ) {
const char = String . fromCharCode ( i ) ;
const upChar = char . toUpperCase ( ) ;
CODE _KEY _MAP [ ` Key ${ upChar } ` ] = char ;
}
function convertCodeToKey ( code ) {
2026-05-06 17:32:44 +08:00
return CODE _KEY _MAP [ code ] ? ? code ;
2025-08-02 12:09:34 +08:00
}
function convertKeyToText ( key ) {
switch ( key ) {
case "ArrowLeft" :
return "\u2190" ;
case "ArrowRight" :
return "\u2192" ;
case "ArrowUp" :
return "\u2191" ;
case "ArrowDown" :
return "\u2193" ;
case "Mod" :
2026-05-06 17:32:44 +08:00
return import _obsidian2 . Platform . isMacOS ? "\u2318" : "Ctrl" ;
2025-08-02 12:09:34 +08:00
case "Ctrl" :
2026-05-06 17:32:44 +08:00
return import _obsidian2 . Platform . isMacOS ? "\u2303" : "Ctrl" ;
2025-08-02 12:09:34 +08:00
case "Meta" :
2026-05-06 17:32:44 +08:00
return import _obsidian2 . Platform . isMacOS ? "\u2318" : "Win" ;
2025-08-02 12:09:34 +08:00
case "Alt" :
2026-05-06 17:32:44 +08:00
return import _obsidian2 . Platform . isMacOS ? "\u2325" : "Alt" ;
2025-08-02 12:09:34 +08:00
case "Shift" :
2026-05-06 17:32:44 +08:00
return import _obsidian2 . Platform . isMacOS ? "\u21E7" : "Shift" ;
2025-08-02 12:09:34 +08:00
case " " :
return "Space" ;
case "Enter" :
return "\u21B5" ;
default :
return key . charAt ( 0 ) . toUpperCase ( ) + key . slice ( 1 ) ;
}
}
function convertHotkeyToText ( hotkey ) {
const parts = [ ] ;
hotkey . modifiers . forEach ( ( mod ) => {
parts . push ( convertKeyToText ( mod ) ) ;
} ) ;
const modifierPart = parts . join ( " " ) ;
const keyPart = convertKeyToText ( hotkey . key ) ;
return ` ${ modifierPart } ${ keyPart } ` ;
}
function compileModifiers ( modifiers ) {
return modifiers . map ( ( modifier ) => {
2026-05-06 17:32:44 +08:00
return "Mod" === modifier ? import _obsidian2 . Platform . isMacOS ? "Meta" : "Ctrl" : modifier ;
2025-08-02 12:09:34 +08:00
} ) . sort ( ) . join ( "," ) ;
}
function decompileModifiers ( modifiersId ) {
const modifiers = [ ] ;
const parts = modifiersId . split ( "," ) ;
parts . forEach ( ( s ) => {
2026-05-06 17:32:44 +08:00
if ( import _obsidian2 . Platform . isMacOS && s === "Meta" || ! import _obsidian2 . Platform . isMacOS && s === "Ctrl" ) {
2025-08-02 12:09:34 +08:00
modifiers . push ( "Mod" ) ;
return ;
}
if ( s === "Alt" || s === "Shift" || s === "Meta" || s === "Ctrl" ) {
modifiers . push ( s ) ;
return ;
}
} ) ;
return modifiers ;
}
function getModifiers ( evt ) {
const modifiers = [ ] ;
evt . ctrlKey && modifiers . push ( "Ctrl" ) ;
evt . metaKey && modifiers . push ( "Meta" ) ;
evt . altKey && modifiers . push ( "Alt" ) ;
evt . shiftKey && modifiers . push ( "Shift" ) ;
return compileModifiers ( modifiers ) ;
}
function getHotkey ( evt ) {
const modifiers = decompileModifiers ( getModifiers ( evt ) ) ;
const key = convertCodeToKey ( evt . code ) ;
return {
modifiers ,
key
} ;
}
function contain ( hotkeys , hotkey ) {
const hotkeyId = convertHotkeyToText ( hotkey ) ;
return hotkeys . some ( ( key ) => {
return hotkeyId === convertHotkeyToText ( key ) ;
} ) ;
}
// src/ui/HotkeySetting.svelte
function add _css ( target ) {
append _styles ( target , "svelte-2wacg2" , ".icon-container.svelte-2wacg2{display:inline-block;cursor:pointer;width:16px;height:16px;border-radius:10px;line-height:16px;text-align:center}.icon-container.svelte-2wacg2:hover{background-color:var(--background-modifier-error);color:var(--text-on-accent)}.setting-hotkey.svelte-2wacg2{font-size:12px;background-color:var(--background-secondary-alt);border-radius:4px;padding:0 10px;min-height:24px;align-self:flex-end;position:relative}" ) ;
}
function create _fragment ( ctx ) {
let span1 ;
2026-05-06 17:32:44 +08:00
let t0 _value = convertHotkeyToText (
/*hotkey*/
ctx [ 0 ]
) + "" ;
2025-08-02 12:09:34 +08:00
let t0 ;
let t1 ;
let span0 ;
let mounted ;
let dispose ;
return {
c ( ) {
span1 = element ( "span" ) ;
t0 = text ( t0 _value ) ;
t1 = space ( ) ;
span0 = element ( "span" ) ;
attr ( span0 , "class" , "icon-container svelte-2wacg2" ) ;
attr ( span1 , "class" , "setting-hotkey svelte-2wacg2" ) ;
} ,
m ( target , anchor ) {
insert ( target , span1 , anchor ) ;
append ( span1 , t0 ) ;
append ( span1 , t1 ) ;
append ( span1 , span0 ) ;
ctx [ 3 ] ( span0 ) ;
if ( ! mounted ) {
2026-05-06 17:32:44 +08:00
dispose = listen (
span0 ,
"click" ,
/*onIconClicked*/
ctx [ 2 ]
) ;
2025-08-02 12:09:34 +08:00
mounted = true ;
}
} ,
p ( ctx2 , [ dirty ] ) {
2026-05-06 17:32:44 +08:00
if ( dirty & /*hotkey*/
1 && t0 _value !== ( t0 _value = convertHotkeyToText (
/*hotkey*/
ctx2 [ 0 ]
) + "" ) )
2025-08-02 12:09:34 +08:00
set _data ( t0 , t0 _value ) ;
} ,
i : noop ,
o : noop ,
d ( detaching ) {
2026-05-06 17:32:44 +08:00
if ( detaching ) {
2025-08-02 12:09:34 +08:00
detach ( span1 ) ;
2026-05-06 17:32:44 +08:00
}
2025-08-02 12:09:34 +08:00
ctx [ 3 ] ( null ) ;
mounted = false ;
dispose ( ) ;
}
} ;
}
function instance ( $$self , $$props , $$invalidate ) {
let { hotkey } = $$props ;
let iconContainerEl ;
const dispatcher = createEventDispatcher ( ) ;
onMount ( ( ) => {
if ( iconContainerEl instanceof HTMLSpanElement ) {
2026-05-06 17:32:44 +08:00
( 0 , import _obsidian3 . setIcon ) ( iconContainerEl , "cross" , 8 ) ;
2025-08-02 12:09:34 +08:00
}
} ) ;
function onIconClicked ( ) {
dispatcher ( "removed" ) ;
}
function span0 _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
iconContainerEl = $$value ;
$$invalidate ( 1 , iconContainerEl ) ;
} ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "hotkey" in $$props2 )
$$invalidate ( 0 , hotkey = $$props2 . hotkey ) ;
} ;
return [ hotkey , iconContainerEl , onIconClicked , span0 _binding ] ;
}
var HotkeySetting = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance , create _fragment , safe _not _equal , { hotkey : 0 } , add _css ) ;
}
} ;
var HotkeySetting _default = HotkeySetting ;
2026-05-06 17:32:44 +08:00
// src/ui/HotKeyEntry.svelte
2025-08-02 12:09:34 +08:00
function add _css2 ( target ) {
append _styles ( target , "svelte-1my40ui" , ".item-container.svelte-1my40ui{display:flex;align-items:center;padding:18px 0 18px 0;border-top:1px solid var(--background-modifier-border)}.info-container.svelte-1my40ui{flex:1 1 auto;flex-grow:1;margin-right:20px}.control-container.svelte-1my40ui{flex:1 1 auto;text-align:right;display:flex;justify-content:flex-end;align-items:center}.hotkeys-container.svelte-1my40ui{display:flex;flex-direction:column;margin-right:6px}.setting-hotkey.svelte-1my40ui{font-size:12px;background-color:var(--interactive-accent);border-radius:4px;padding:0 10px;min-height:24px;align-self:flex-end;position:relative;color:var(--text-on-accent)}.icon-container.svelte-1my40ui{padding:4px 6px;border-radius:4px;color:var(--text-faint);cursor:pointer;height:26px}.icon-container.svelte-1my40ui:hover{background-color:var(--background-secondary-alt);color:var(--text-normal)}.icon-container.svelte-1my40ui .clickable-icon{color:unset;cursor:unset;margin:unset}.icon-container.svelte-1my40ui .setting-editor-extra-setting-button{line-height:0}.icon-container.svelte-1my40ui .clickable-icon svg{position:relative;bottom:2px}" ) ;
}
function get _each _context ( ctx , list , i ) {
const child _ctx = ctx . slice ( ) ;
child _ctx [ 13 ] = list [ i ] ;
return child _ctx ;
}
function create _each _block ( ctx ) {
let hotkeysetting ;
let current ;
function removed _handler ( ) {
2026-05-06 17:32:44 +08:00
return (
/*removed_handler*/
ctx [ 8 ] (
/*hotkey*/
ctx [ 13 ]
)
) ;
}
hotkeysetting = new HotkeySetting _default ( { props : { hotkey : (
/*hotkey*/
ctx [ 13 ]
) } } ) ;
2025-08-02 12:09:34 +08:00
hotkeysetting . $on ( "removed" , removed _handler ) ;
return {
c ( ) {
create _component ( hotkeysetting . $$ . fragment ) ;
} ,
m ( target , anchor ) {
mount _component ( hotkeysetting , target , anchor ) ;
current = true ;
} ,
p ( new _ctx , dirty ) {
ctx = new _ctx ;
const hotkeysetting _changes = { } ;
2026-05-06 17:32:44 +08:00
if ( dirty & /*_hotkeys*/
16 )
hotkeysetting _changes . hotkey = /*hotkey*/
ctx [ 13 ] ;
2025-08-02 12:09:34 +08:00
hotkeysetting . $set ( hotkeysetting _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( hotkeysetting . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( hotkeysetting . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
destroy _component ( hotkeysetting , detaching ) ;
}
} ;
}
function create _if _block ( ctx ) {
let div ;
return {
c ( ) {
div = element ( "div" ) ;
div . textContent = "Press hotkey..." ;
attr ( div , "class" , "setting-hotkey svelte-1my40ui" ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
} ,
d ( detaching ) {
2026-05-06 17:32:44 +08:00
if ( detaching ) {
2025-08-02 12:09:34 +08:00
detach ( div ) ;
2026-05-06 17:32:44 +08:00
}
2025-08-02 12:09:34 +08:00
}
} ;
}
function create _fragment2 ( ctx ) {
let div3 ;
let div0 ;
let t0 ;
let t1 ;
let div2 ;
let div1 ;
let t2 ;
let t3 ;
let span0 ;
let t4 ;
let span1 ;
let current ;
let mounted ;
let dispose ;
2026-05-06 17:32:44 +08:00
let each _value = ensure _array _like (
/*_hotkeys*/
ctx [ 4 ] ? ? [ ]
) ;
2025-08-02 12:09:34 +08:00
let each _blocks = [ ] ;
for ( let i = 0 ; i < each _value . length ; i += 1 ) {
each _blocks [ i ] = create _each _block ( get _each _context ( ctx , each _value , i ) ) ;
}
const out = ( i ) => transition _out ( each _blocks [ i ] , 1 , 1 , ( ) => {
each _blocks [ i ] = null ;
} ) ;
2026-05-06 17:32:44 +08:00
let if _block = (
/*_listening*/
ctx [ 3 ] && create _if _block ( ctx )
) ;
2025-08-02 12:09:34 +08:00
return {
c ( ) {
div3 = element ( "div" ) ;
div0 = element ( "div" ) ;
2026-05-06 17:32:44 +08:00
t0 = text (
/*actionName*/
ctx [ 0 ]
) ;
2025-08-02 12:09:34 +08:00
t1 = space ( ) ;
div2 = element ( "div" ) ;
div1 = element ( "div" ) ;
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . c ( ) ;
}
t2 = space ( ) ;
if ( if _block )
if _block . c ( ) ;
t3 = space ( ) ;
span0 = element ( "span" ) ;
t4 = space ( ) ;
span1 = element ( "span" ) ;
attr ( div0 , "class" , "info-container svelte-1my40ui" ) ;
attr ( div1 , "class" , "hotkeys-container svelte-1my40ui" ) ;
attr ( span0 , "class" , "icon-container svelte-1my40ui" ) ;
attr ( span1 , "class" , "icon-container svelte-1my40ui" ) ;
attr ( div2 , "class" , "control-container svelte-1my40ui" ) ;
attr ( div3 , "class" , "item-container svelte-1my40ui" ) ;
} ,
m ( target , anchor ) {
insert ( target , div3 , anchor ) ;
append ( div3 , div0 ) ;
append ( div0 , t0 ) ;
append ( div3 , t1 ) ;
append ( div3 , div2 ) ;
append ( div2 , div1 ) ;
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
2026-05-06 17:32:44 +08:00
if ( each _blocks [ i ] ) {
each _blocks [ i ] . m ( div1 , null ) ;
}
2025-08-02 12:09:34 +08:00
}
append ( div1 , t2 ) ;
if ( if _block )
if _block . m ( div1 , null ) ;
append ( div2 , t3 ) ;
append ( div2 , span0 ) ;
ctx [ 9 ] ( span0 ) ;
append ( div2 , t4 ) ;
append ( div2 , span1 ) ;
ctx [ 11 ] ( span1 ) ;
current = true ;
if ( ! mounted ) {
dispose = [
2026-05-06 17:32:44 +08:00
listen (
span0 ,
"click" ,
/*click_handler*/
ctx [ 10 ]
) ,
listen (
span1 ,
"click" ,
/*click_handler_1*/
ctx [ 12 ]
)
2025-08-02 12:09:34 +08:00
] ;
mounted = true ;
}
} ,
p ( ctx2 , [ dirty ] ) {
2026-05-06 17:32:44 +08:00
if ( ! current || dirty & /*actionName*/
1 )
set _data (
t0 ,
/*actionName*/
ctx2 [ 0 ]
) ;
if ( dirty & /*_hotkeys, dispatcher*/
48 ) {
each _value = ensure _array _like (
/*_hotkeys*/
ctx2 [ 4 ] ? ? [ ]
) ;
2025-08-02 12:09:34 +08:00
let i ;
for ( i = 0 ; i < each _value . length ; i += 1 ) {
const child _ctx = get _each _context ( ctx2 , each _value , i ) ;
if ( each _blocks [ i ] ) {
each _blocks [ i ] . p ( child _ctx , dirty ) ;
transition _in ( each _blocks [ i ] , 1 ) ;
} else {
each _blocks [ i ] = create _each _block ( child _ctx ) ;
each _blocks [ i ] . c ( ) ;
transition _in ( each _blocks [ i ] , 1 ) ;
each _blocks [ i ] . m ( div1 , t2 ) ;
}
}
group _outros ( ) ;
for ( i = each _value . length ; i < each _blocks . length ; i += 1 ) {
out ( i ) ;
}
check _outros ( ) ;
}
2026-05-06 17:32:44 +08:00
if (
/*_listening*/
ctx2 [ 3 ]
) {
2025-08-02 12:09:34 +08:00
if ( if _block ) {
} else {
if _block = create _if _block ( ctx2 ) ;
if _block . c ( ) ;
if _block . m ( div1 , null ) ;
}
} else if ( if _block ) {
if _block . d ( 1 ) ;
if _block = null ;
}
} ,
i ( local ) {
if ( current )
return ;
for ( let i = 0 ; i < each _value . length ; i += 1 ) {
transition _in ( each _blocks [ i ] ) ;
}
current = true ;
} ,
o ( local ) {
each _blocks = each _blocks . filter ( Boolean ) ;
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
transition _out ( each _blocks [ i ] ) ;
}
current = false ;
} ,
d ( detaching ) {
2026-05-06 17:32:44 +08:00
if ( detaching ) {
2025-08-02 12:09:34 +08:00
detach ( div3 ) ;
2026-05-06 17:32:44 +08:00
}
2025-08-02 12:09:34 +08:00
destroy _each ( each _blocks , detaching ) ;
if ( if _block )
if _block . d ( ) ;
ctx [ 9 ] ( null ) ;
ctx [ 11 ] ( null ) ;
mounted = false ;
run _all ( dispose ) ;
}
} ;
}
var ICON _SIZE = 22 ;
function instance2 ( $$self , $$props , $$invalidate ) {
let _hotkeys ;
let _listening ;
let { actionName } = $$props ;
let { hotkeys } = $$props ;
2026-05-06 17:32:44 +08:00
const listening = false ;
2025-08-02 12:09:34 +08:00
let restoreButtonEl ;
let addHotkeyButtonEl ;
const dispatcher = createEventDispatcher ( ) ;
onMount ( ( ) => {
if ( restoreButtonEl ) {
2026-05-06 17:32:44 +08:00
const component = new import _obsidian4 . ExtraButtonComponent ( restoreButtonEl ) . setTooltip ( "Restore default" ) ;
( 0 , import _obsidian4 . setIcon ) ( component . extraSettingsEl , "reset" , ICON _SIZE ) ;
2025-08-02 12:09:34 +08:00
}
if ( addHotkeyButtonEl ) {
2026-05-06 17:32:44 +08:00
const component = new import _obsidian4 . ExtraButtonComponent ( addHotkeyButtonEl ) . setTooltip ( "Customize this action" ) ;
( 0 , import _obsidian4 . setIcon ) ( component . extraSettingsEl , "any-key" , ICON _SIZE ) ;
2025-08-02 12:09:34 +08:00
}
} ) ;
const removed _handler = ( hotkey ) => {
dispatcher ( "removed" , { removed : hotkey } ) ;
} ;
function span0 _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
restoreButtonEl = $$value ;
$$invalidate ( 1 , restoreButtonEl ) ;
} ) ;
}
const click _handler = ( ) => {
dispatcher ( "restored" ) ;
} ;
function span1 _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
addHotkeyButtonEl = $$value ;
$$invalidate ( 2 , addHotkeyButtonEl ) ;
} ) ;
}
const click _handler _1 = ( ) => {
dispatcher ( "start-listening-keys" ) ;
} ;
$$self . $$set = ( $$props2 ) => {
if ( "actionName" in $$props2 )
$$invalidate ( 0 , actionName = $$props2 . actionName ) ;
if ( "hotkeys" in $$props2 )
$$invalidate ( 6 , hotkeys = $$props2 . hotkeys ) ;
} ;
$$self . $$ . update = ( ) => {
2026-05-06 17:32:44 +08:00
if ( $$self . $$ . dirty & /*hotkeys*/
64 ) {
2025-08-02 12:09:34 +08:00
$ :
2026-05-06 17:32:44 +08:00
$$invalidate ( 4 , _hotkeys = [ ... hotkeys ? ? [ ] ] ) ;
2025-08-02 12:09:34 +08:00
}
} ;
2026-05-06 17:32:44 +08:00
$ :
$$invalidate ( 3 , _listening = listening ) ;
2025-08-02 12:09:34 +08:00
return [
actionName ,
restoreButtonEl ,
addHotkeyButtonEl ,
_listening ,
_hotkeys ,
dispatcher ,
hotkeys ,
listening ,
removed _handler ,
span0 _binding ,
click _handler ,
span1 _binding ,
click _handler _1
] ;
}
2026-05-06 17:32:44 +08:00
var HotKeyEntry = class extends SvelteComponent {
2025-08-02 12:09:34 +08:00
constructor ( options ) {
super ( ) ;
init ( this , options , instance2 , create _fragment2 , safe _not _equal , { actionName : 0 , hotkeys : 6 , listening : 7 } , add _css2 ) ;
}
2026-05-06 17:32:44 +08:00
get listening ( ) {
return this . $$ . ctx [ 7 ] ;
}
2025-08-02 12:09:34 +08:00
} ;
2026-05-06 17:32:44 +08:00
var HotKeyEntry _default = HotKeyEntry ;
2025-08-02 12:09:34 +08:00
// src/ui/HotkeySetter.ts
var HotkeySetter = class {
constructor ( app2 , containerEl , text2 , currentHotkeys , defaultHotkeys ) {
this . shouldReflect = ( _ ) => true ;
this . onRestored = ( ) => {
const { component } = this ;
if ( ! component )
return ;
const renewed = [ ... this . defaultHotkeys ] ;
if ( this . shouldReflect ( renewed ) ) {
this . currentHotkeys = renewed ;
component . $set ( {
hotkeys : renewed
} ) ;
}
} ;
this . onRemoved = ( evt ) => {
const { component } = this ;
if ( ! component )
return ;
if ( ! ( evt instanceof CustomEvent ) )
return ;
const removed = evt . detail . removed ;
const renewed = [ ... this . currentHotkeys ] ;
renewed . remove ( removed ) ;
if ( this . shouldReflect ( renewed ) ) {
this . currentHotkeys = renewed ;
component . $set ( {
hotkeys : renewed
} ) ;
}
} ;
this . onStartListening = ( ) => {
const { component } = this ;
if ( ! component )
return ;
component . $set ( {
listening : true
} ) ;
2026-05-06 17:32:44 +08:00
this . scope = new import _obsidian5 . Scope ( ) ;
2025-08-02 12:09:34 +08:00
this . app . keymap . pushScope ( this . scope ) ;
this . scope . register ( null , null , ( evt ) => {
evt . preventDefault ( ) ;
if ( evt . key === "Escape" ) {
component . $set ( {
listening : false
} ) ;
if ( this . scope )
this . app . keymap . popScope ( this . scope ) ;
return ;
}
const hotkey = getHotkey ( evt ) ;
const collision = contain ( this . currentHotkeys , hotkey ) ;
if ( collision )
return ;
const renewed = [ ... this . currentHotkeys ] ;
renewed . push ( hotkey ) ;
if ( ! this . shouldReflect ( renewed , hotkey ) )
return ;
this . currentHotkeys = renewed ;
component . $set ( {
hotkeys : renewed
} ) ;
component . $set ( {
listening : false
} ) ;
if ( this . scope )
this . app . keymap . popScope ( this . scope ) ;
} ) ;
} ;
this . app = app2 ;
this . containerEl = containerEl ;
this . text = text2 ;
this . currentHotkeys = [ ... currentHotkeys ] ;
this . defaultHotkeys = [ ... defaultHotkeys ] ;
this . component = this . attachComponent ( ) ;
}
unload ( ) {
this . onunload ( ) ;
}
2026-05-06 17:32:44 +08:00
/ * *
* @ param cb : should return true if you want to adopt the current change
* /
2025-08-02 12:09:34 +08:00
onChanged ( cb ) {
this . shouldReflect = cb ;
return this ;
}
attachComponent ( ) {
2026-05-06 17:32:44 +08:00
const component = new HotKeyEntry _default ( {
2025-08-02 12:09:34 +08:00
target : this . containerEl ,
props : {
actionName : this . text ,
hotkeys : this . currentHotkeys
}
} ) ;
component . $on ( "removed" , this . onRemoved ) ;
component . $on ( "restored" , this . onRestored ) ;
component . $on ( "start-listening-keys" , this . onStartListening ) ;
return component ;
}
onunload ( ) {
2026-05-06 17:32:44 +08:00
this . component ? . $destroy ( ) ;
2025-08-02 12:09:34 +08:00
if ( this . scope ) {
this . app . keymap . popScope ( this . scope ) ;
}
}
} ;
// src/Setting.ts
var AVAILABLE _OUTLINE _WIDTHS = [ 0 , 3 , 5 , 7 , 10 ] ;
var AUTO _PREVIEW _MODE _IDS = [ "none" , "singleView" , "cardView" ] ;
var autoPreviewModeInfos = {
none : "none" ,
singleView : "single view" ,
cardView : "card view"
} ;
var AVAILABLE _CARD _LAYOUT = [ "2x2" , "2x3" , "3x2" , "3x3" ] ;
var DEFAULT _SETTINGS = {
keepSelectedItemsCentered : false ,
outlineWidth : 5 ,
autoPreviewMode : "cardView" ,
cardViewLayout : "2x3" ,
splitDirection : "horizontal" ,
autoToggleSidebar : false ,
renderCardsManually : false ,
2026-05-06 17:32:44 +08:00
// hideIframe: false,
2025-08-02 12:09:34 +08:00
searchModeHotkeys : {
selectNext : [
{ modifiers : [ "Ctrl" ] , key : "n" } ,
{ modifiers : [ ] , key : "ArrowDown" }
] ,
selectPrevious : [
{ modifiers : [ "Ctrl" ] , key : "p" } ,
{ modifiers : [ ] , key : "ArrowUp" }
] ,
previewModal : [ { modifiers : [ "Ctrl" ] , key : " " } ] ,
open : [ { modifiers : [ "Ctrl" ] , key : "Enter" } ] ,
openInNewPane : [ { modifiers : [ "Ctrl" , "Shift" ] , key : "Enter" } ] ,
showOptions : [ { modifiers : [ "Shift" ] , key : " " } ] ,
nextPage : [ { modifiers : [ "Ctrl" ] , key : "]" } ] ,
previousPage : [ { modifiers : [ "Ctrl" ] , key : "[" } ] ,
copyLink : [ { modifiers : [ "Ctrl" ] , key : "i" } ]
} ,
previewModalHotkeys : {
scrollDown : [
{ modifiers : [ "Ctrl" ] , key : "n" } ,
{ modifiers : [ ] , key : "ArrowDown" }
] ,
scrollUp : [
{ modifiers : [ "Ctrl" ] , key : "p" } ,
{ modifiers : [ ] , key : "ArrowUp" }
] ,
bigScrollDown : [ { modifiers : [ ] , key : " " } ] ,
bigScrollUp : [ { modifiers : [ "Shift" ] , key : " " } ] ,
open : [ { modifiers : [ "Ctrl" ] , key : "Enter" } ] ,
openInNewPage : [ { modifiers : [ "Ctrl" , "Shift" ] , key : "Enter" } ] ,
closeModal : [ { modifiers : [ "Ctrl" ] , key : " " } ] ,
focusNext : [ { modifiers : [ ] , key : "Tab" } ] ,
focusPrevious : [ { modifiers : [ "Shift" ] , key : "Tab" } ] ,
togglePreviewMode : [ { modifiers : [ "Ctrl" ] , key : "e" } ] ,
copyLink : [ { modifiers : [ "Ctrl" ] , key : "i" } ]
}
} ;
2026-05-06 17:32:44 +08:00
var CoreSearchAssistantSettingTab = class extends import _obsidian6 . PluginSettingTab {
2025-08-02 12:09:34 +08:00
constructor ( app2 , plugin2 ) {
super ( app2 , plugin2 ) ;
this . plugin = plugin2 ;
this . hotkeySetters = [ ] ;
}
display ( ) {
this . hide ( ) ;
const { containerEl } = this ;
containerEl . empty ( ) ;
2026-05-06 17:32:44 +08:00
new import _obsidian6 . Setting ( containerEl ) . setName ( "Keep selected item centered" ) . addToggle ( ( component ) => {
component . setValue (
this . plugin . settings ? . keepSelectedItemsCentered ? ? DEFAULT _SETTINGS . keepSelectedItemsCentered
) . onChange ( ( value ) => {
2025-08-02 12:09:34 +08:00
if ( ! this . plugin . settings ) {
return ;
}
this . plugin . settings . keepSelectedItemsCentered = value ;
this . plugin . saveSettings ( ) ;
} ) ;
} ) ;
2026-05-06 17:32:44 +08:00
new import _obsidian6 . Setting ( containerEl ) . setName ( "Outline width (px)" ) . setDesc ( "An outline appears when you enter search mode." ) . addDropdown ( ( component ) => {
2025-08-02 12:09:34 +08:00
AVAILABLE _OUTLINE _WIDTHS . forEach ( ( width ) => {
const text2 = width . toString ( ) ;
component . addOption ( text2 , text2 ) ;
} ) ;
2026-05-06 17:32:44 +08:00
component . setValue (
validOutlineWidth ( this . plugin . settings ? . outlineWidth ) . toString ( )
) . onChange ( ( value ) => {
2025-08-02 12:09:34 +08:00
const width = Number . parseInt ( value ) ;
if ( ! this . plugin . settings ) {
return ;
}
if ( ! AVAILABLE _OUTLINE _WIDTHS . includes ( width ) ) {
return ;
}
this . plugin . settings . outlineWidth = width ;
this . plugin . saveSettings ( ) ;
} ) ;
} ) ;
2026-05-06 17:32:44 +08:00
new import _obsidian6 . Setting ( containerEl ) . setName ( "Auto preview mode" ) . addDropdown ( ( component ) => {
component . addOptions ( autoPreviewModeInfos ) . setValue ( this . plugin . settings ? . autoPreviewMode ? ? "cardView" ) . onChange ( ( id ) => {
2025-08-02 12:09:34 +08:00
if ( ! this . plugin . settings ) {
return ;
}
if ( ! AUTO _PREVIEW _MODE _IDS . includes ( id ) ) {
return ;
}
this . plugin . settings . autoPreviewMode = id ;
this . plugin . saveSettings ( ) ;
} ) ;
} ) ;
2026-05-06 17:32:44 +08:00
new import _obsidian6 . Setting ( containerEl ) . setName ( "Default layout of card view" ) . addDropdown ( ( component ) => {
2025-08-02 12:09:34 +08:00
AVAILABLE _CARD _LAYOUT . forEach ( ( layout ) => {
component . addOption ( layout , layout ) ;
} ) ;
2026-05-06 17:32:44 +08:00
component . setValue (
this . plugin . settings ? . cardViewLayout ? ? DEFAULT _SETTINGS . cardViewLayout
) . onChange ( ( value ) => {
2025-08-02 12:09:34 +08:00
if ( ! this . plugin . settings ) {
return ;
}
if ( ! AVAILABLE _CARD _LAYOUT . includes ( value ) ) {
return ;
}
this . plugin . settings . cardViewLayout = value ;
this . plugin . saveSettings ( ) ;
} ) ;
} ) ;
2026-05-06 17:32:44 +08:00
new import _obsidian6 . Setting ( containerEl ) . setName ( "Default split direction" ) . setDesc ( "This applies when you open a file in a new pane" ) . addDropdown ( ( component ) => {
2025-08-02 12:09:34 +08:00
if ( ! this . plugin . settings ) {
return ;
}
component . addOptions ( {
horizontal : "horizontal" ,
vertical : "vertical"
2026-05-06 17:32:44 +08:00
} ) . setValue ( this . plugin . settings . splitDirection ) . onChange ( async ( direction ) => {
2025-08-02 12:09:34 +08:00
if ( ! this . plugin . settings ) {
return ;
}
2026-05-06 17:32:44 +08:00
if ( direction === "horizontal" || direction === "vertical" ) {
2025-08-02 12:09:34 +08:00
this . plugin . settings . splitDirection = direction ;
2026-05-06 17:32:44 +08:00
await this . plugin . saveSettings ( ) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
} ) ;
2025-08-02 12:09:34 +08:00
} ) ;
2026-05-06 17:32:44 +08:00
new import _obsidian6 . Setting ( containerEl ) . setName ( "Toggle sidebars automatically" ) . setDesc (
"Automatically collapse the other sidebar when entering the search mode and the search panel when exiting the search mode"
) . addToggle ( ( component ) => {
2025-08-02 12:09:34 +08:00
if ( ! this . plugin . settings ) {
return ;
}
component . setValue ( this . plugin . settings . autoToggleSidebar ) . onChange ( ( value ) => {
if ( ! this . plugin . settings ) {
return ;
}
this . plugin . settings . autoToggleSidebar = value ;
this . plugin . saveSettings ( ) ;
} ) ;
} ) ;
2026-05-06 17:32:44 +08:00
new import _obsidian6 . Setting ( containerEl ) . setName ( "Render cards manually" ) . setDesc ( "If enabled, you must hit the enter key to render cards." ) . addToggle ( ( component ) => {
2025-08-02 12:09:34 +08:00
if ( ! this . plugin . settings )
return ;
component . setValue ( this . plugin . settings . renderCardsManually ) . onChange ( ( value ) => {
if ( ! this . plugin . settings )
return ;
this . plugin . settings . renderCardsManually = value ;
this . plugin . saveSettings ( ) ;
} ) ;
} ) ;
containerEl . createEl ( "h2" , { text : "Hotkeys" } ) ;
const { settings } = this . plugin ;
containerEl . createEl ( "h3" , { text : "Search mode" } ) ;
if ( ! settings )
return ;
SEARCH _MODE _HOTKEY _ACTION _IDS . forEach ( ( actionId ) => {
const hotkeys = settings . searchModeHotkeys [ actionId ] ;
const defaultHotkeys = DEFAULT _SETTINGS . searchModeHotkeys [ actionId ] ;
const description = SEARCH _MODE _HOTKEY _ACTION _INFO [ actionId ] ;
2026-05-06 17:32:44 +08:00
const hotkeySetter = new HotkeySetter (
this . app ,
containerEl ,
description ,
hotkeys ,
defaultHotkeys
) . onChanged ( ( renewed , added ) => {
2025-08-02 12:09:34 +08:00
if ( added ) {
if ( added . modifiers . length === 0 )
return false ;
const collision = SEARCH _MODE _HOTKEY _ACTION _IDS . some ( ( actionId2 ) => {
const hotkeys2 = settings . searchModeHotkeys [ actionId2 ] ;
return contain ( hotkeys2 , added ) ;
} ) ;
if ( collision ) {
2026-05-06 17:32:44 +08:00
new import _obsidian6 . Notice ( "Hotkeys are conflicting!" ) ;
2025-08-02 12:09:34 +08:00
return false ;
}
}
settings . searchModeHotkeys [ actionId ] = renewed ;
this . plugin . saveSettings ( ) ;
return true ;
} ) ;
this . hotkeySetters . push ( hotkeySetter ) ;
} ) ;
containerEl . createEl ( "h3" , { text : "Preview Modal" } ) ;
PREVIEW _MODAL _HOTKEY _ACTION _IDS . forEach ( ( actionId ) => {
const hotkeys = settings . previewModalHotkeys [ actionId ] ;
const defaultHotkeys = DEFAULT _SETTINGS . previewModalHotkeys [ actionId ] ;
const description = PREVIEW _MODAL _HOTKEY _ACTION _INFO [ actionId ] ;
DEFAULT _SETTINGS . previewModalHotkeys [ actionId ] ;
2026-05-06 17:32:44 +08:00
const hotkeySetter = new HotkeySetter (
this . app ,
containerEl ,
description ,
hotkeys ,
defaultHotkeys
) . onChanged ( ( renewed , added ) => {
2025-08-02 12:09:34 +08:00
if ( added ) {
const collision = PREVIEW _MODAL _HOTKEY _ACTION _IDS . some ( ( actionId2 ) => {
const hotkeys2 = settings . previewModalHotkeys [ actionId2 ] ;
return contain ( hotkeys2 , added ) ;
} ) ;
if ( collision ) {
2026-05-06 17:32:44 +08:00
new import _obsidian6 . Notice ( "Hotkeys are conflicting!" ) ;
2025-08-02 12:09:34 +08:00
return false ;
}
}
settings . previewModalHotkeys [ actionId ] = renewed ;
this . plugin . saveSettings ( ) ;
return true ;
} ) ;
this . hotkeySetters . push ( hotkeySetter ) ;
} ) ;
}
hide ( ) {
super . hide ( ) ;
this . hotkeySetters . forEach ( ( s ) => s . unload ( ) ) ;
this . hotkeySetters = [ ] ;
}
} ;
function validOutlineWidth ( width ) {
if ( typeof width !== "number" ) {
return DEFAULT _SETTINGS . outlineWidth ;
}
if ( ! Number . isInteger ( width ) ) {
return DEFAULT _SETTINGS . outlineWidth ;
}
if ( ! AVAILABLE _OUTLINE _WIDTHS . includes ( width ) ) {
return DEFAULT _SETTINGS . outlineWidth ;
}
2026-05-06 17:32:44 +08:00
return width ;
}
function parseCardLayout ( layout ) {
const [ row , column ] = layout . split ( "x" ) ;
return [ Number . parseInt ( row ? ? "0" ) , Number . parseInt ( column ? ? "0" ) ] ;
}
var SEARCH _MODE _HOTKEY _ACTION _IDS = [
"selectNext" ,
"selectPrevious" ,
"previewModal" ,
"open" ,
"openInNewPane" ,
"showOptions" ,
"nextPage" ,
"previousPage" ,
"copyLink"
] ;
var SEARCH _MODE _HOTKEY _ACTION _INFO = {
selectNext : "Select the next item" ,
selectPrevious : "Select the previous item" ,
previewModal : "Preview the selected item" ,
open : "Open the selected item" ,
openInNewPane : "Open the selected item in a new pane" ,
showOptions : "Set search options" ,
nextPage : "Move to the next set of cards" ,
previousPage : "Move to the previous set of cards" ,
copyLink : "Copy wiki link of the selected item"
} ;
var PREVIEW _MODAL _HOTKEY _ACTION _IDS = [
"scrollDown" ,
"scrollUp" ,
"bigScrollDown" ,
"bigScrollUp" ,
"open" ,
"openInNewPage" ,
"closeModal" ,
"focusNext" ,
"focusPrevious" ,
"togglePreviewMode" ,
"copyLink"
] ;
var PREVIEW _MODAL _HOTKEY _ACTION _INFO = {
scrollDown : "Scroll down a bit" ,
scrollUp : "Scroll up a bit" ,
bigScrollDown : "Scroll down a lot" ,
bigScrollUp : "Scroll up a lot" ,
open : "Open the selected item" ,
openInNewPage : "Open the selected item in a new pane" ,
closeModal : "Close the modal" ,
focusNext : "Focus on the next match" ,
focusPrevious : "Focus on the previous match" ,
togglePreviewMode : "Toggle preview mode" ,
copyLink : "Copy wiki link of the selected item"
} ;
// src/components/OptionModal.ts
var import _obsidian7 = require ( "obsidian" ) ;
// src/types/Option.ts
var searchOptions = {
matchingCase : {
iconId : "uppercase-lowercase-a" ,
description : "Toggle matching case"
} ,
explainSearch : {
iconId : "info" ,
description : "Toggle explanation of search term"
} ,
collapseAll : {
iconId : "bullet-list" ,
description : "Toggle collapsing results"
} ,
extraContext : {
iconId : "expand-vertically" ,
description : "Toggle showing more context"
} ,
alphabetical : {
iconId : "down-arrow-with-tail" ,
description : "Sort by file name (A \u2192 Z)"
} ,
alphabeticalReverse : {
iconId : "up-arrow-with-tail" ,
description : "Sort by file name (Z \u2192 A)"
} ,
byModifiedTime : {
iconId : "down-arrow-with-tail" ,
description : "Sort by modified time (new \u2192 old)"
} ,
byModifiedTimeReverse : {
iconId : "up-arrow-with-tail" ,
description : "Sort by modified time (old \u2192 new)"
} ,
byCreatedTime : {
iconId : "down-arrow-with-tail" ,
description : "Sort by created time (new \u2192 old)"
} ,
byCreatedTimeReverse : {
iconId : "up-arrow-with-tail" ,
description : "Sort by created time (old \u2192 new)"
}
} ;
// src/components/OptionModal.ts
var OptionModal = class extends import _obsidian7 . Modal {
constructor ( app2 , plugin2 , modeScope ) {
super ( app2 ) ;
this . plugin = plugin2 ;
this . modeScope = modeScope ;
this . items = [
{
id : "matchingCase" ,
key : "a" ,
onChoose : ( ) => {
this . plugin . searchInterface ? . toggleMatchingCase ( ) ;
this . plugin . searchInterface ? . renewSortOrderInfo ( ) ;
this . plugin . controller ? . reset ( ) ;
}
} ,
{
id : "explainSearch" ,
key : "s" ,
onChoose : ( ) => {
this . plugin . searchInterface ? . toggleExplainSearch ( ) ;
}
} ,
{
id : "collapseAll" ,
key : "d" ,
onChoose : ( ) => {
this . plugin . searchInterface ? . toggleCollapseAll ( ) ;
}
} ,
{
id : "extraContext" ,
key : "f" ,
onChoose : ( ) => {
this . plugin . searchInterface ? . toggleExtraContext ( ) ;
}
} ,
{
id : "alphabetical" ,
key : "g" ,
onChoose : ( ) => {
const changed = this . plugin . searchInterface ? . setSortOrder ( "alphabetical" ) ;
if ( changed ) {
this . plugin . searchInterface ? . renewSortOrderInfo ( ) ;
this . plugin . controller ? . reset ( ) ;
}
}
} ,
{
id : "alphabeticalReverse" ,
key : "h" ,
onChoose : ( ) => {
const changed = this . plugin . searchInterface ? . setSortOrder (
"alphabeticalReverse"
) ;
if ( changed ) {
this . plugin . searchInterface ? . renewSortOrderInfo ( ) ;
this . plugin . controller ? . reset ( ) ;
}
}
} ,
{
id : "byModifiedTime" ,
key : "j" ,
onChoose : ( ) => {
const changed = this . plugin . searchInterface ? . setSortOrder ( "byModifiedTime" ) ;
if ( changed ) {
this . plugin . searchInterface ? . renewSortOrderInfo ( ) ;
this . plugin . controller ? . reset ( ) ;
}
}
} ,
{
id : "byModifiedTimeReverse" ,
key : "k" ,
onChoose : ( ) => {
const changed = this . plugin . searchInterface ? . setSortOrder (
"byModifiedTimeReverse"
) ;
if ( changed ) {
this . plugin . searchInterface ? . renewSortOrderInfo ( ) ;
this . plugin . controller ? . reset ( ) ;
}
}
} ,
{
id : "byCreatedTime" ,
key : "l" ,
onChoose : ( ) => {
const changed = this . plugin . searchInterface ? . setSortOrder ( "byCreatedTime" ) ;
if ( changed ) {
this . plugin . searchInterface ? . renewSortOrderInfo ( ) ;
this . plugin . controller ? . reset ( ) ;
}
}
} ,
{
id : "byCreatedTimeReverse" ,
key : ";" ,
onChoose : ( ) => {
const changed = this . plugin . searchInterface ? . setSortOrder (
"byCreatedTimeReverse"
) ;
if ( changed ) {
this . plugin . searchInterface ? . renewSortOrderInfo ( ) ;
this . plugin . controller ? . reset ( ) ;
}
}
}
] ;
}
onOpen ( ) {
this . modeScope . push ( ) ;
this . items . forEach ( ( item ) => {
this . scope . register ( [ ] , item . key , item . onChoose ) ;
} ) ;
this . renderOptions ( ) ;
}
onClose ( ) {
const { containerEl } = this ;
containerEl . empty ( ) ;
setTimeout ( ( ) => this . modeScope . pop ( ) , 100 ) ;
}
renderOptions ( ) {
const { contentEl } = this ;
contentEl . empty ( ) ;
this . containerEl . addClass ( "core-search-assistant_option-modal" ) ;
this . items . forEach ( ( item ) => {
const entryEl = contentEl . createEl ( "div" , {
cls : "suggestion-item"
} ) ;
const iconEl = entryEl . createEl ( "span" , {
cls : "suggestion-icon"
} ) ;
( 0 , import _obsidian7 . setIcon ) ( iconEl , searchOptions [ item . id ] . iconId ) ;
entryEl . createEl ( "span" , {
text : searchOptions [ item . id ] . description ,
cls : "suggestion-content"
} ) ;
entryEl . createEl ( "kbd" , {
text : item . key . toUpperCase ( ) ,
cls : "suggestion-hotkey"
} ) ;
} ) ;
}
2025-08-02 12:09:34 +08:00
} ;
// src/components/PreviewModal.ts
2026-05-06 17:32:44 +08:00
var import _obsidian13 = require ( "obsidian" ) ;
// src/interfaces/ViewGenerator.ts
var import _obsidian8 = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
// src/utils/Util.ts
2026-05-06 17:32:44 +08:00
async function delay ( millisecond ) {
await new Promise ( ( resolve ) => setTimeout ( resolve , millisecond ) ) ;
2025-08-02 12:09:34 +08:00
}
function scrollIteration ( editor ) {
const line = lineCount ( editor ) ;
if ( line === void 0 ) {
return void 0 ;
}
return Math . max ( Math . floor ( line / 1e3 ) , 1 ) ;
}
function lineCount ( editor ) {
2026-05-06 17:32:44 +08:00
const line = editor ? . cm ? . state ? . doc ? . length ;
2025-08-02 12:09:34 +08:00
return typeof line === "number" ? line : void 0 ;
}
2026-05-06 17:32:44 +08:00
async function retry ( cb , interval , trials , check = ( got ) => got !== void 0 ) {
for ( let i = 0 ; i < trials ; i ++ ) {
const got = cb ( ) ;
if ( check ( got ) ) {
return got ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
await delay ( interval ) ;
}
return void 0 ;
2025-08-02 12:09:34 +08:00
}
function shallowClone ( obj ) {
return Object . assign ( { } , obj ) ;
}
function deepClone ( obj ) {
if ( obj === null )
return obj ;
if ( typeof obj !== "object" )
return obj ;
2026-05-06 17:32:44 +08:00
if ( Array . isArray ( obj ) ) {
2025-08-02 12:09:34 +08:00
const clone2 = new Array ( obj . length ) ;
obj . forEach ( ( value , id ) => {
clone2 [ id ] = deepClone ( value ) ;
} ) ;
return clone2 ;
}
const clone = shallowClone ( obj ) ;
for ( const key in clone ) {
const value = clone [ key ] ;
clone [ key ] = deepClone ( value ) ;
}
return clone ;
}
function deepMerge ( a , b ) {
if ( b === void 0 ) {
return deepClone ( a ) ;
2026-05-06 17:32:44 +08:00
}
if ( a === void 0 ) {
2025-08-02 12:09:34 +08:00
return deepClone ( b ) ;
}
if ( typeof a !== typeof b ) {
throw new Error ( ` failed to deepMerge ${ a } and ${ b } ` ) ;
}
if ( typeof b !== "object" )
return deepClone ( b ) ;
if ( b === null ) {
return deepClone ( a ) ;
2026-05-06 17:32:44 +08:00
}
if ( a === null ) {
2025-08-02 12:09:34 +08:00
return deepClone ( b ) ;
}
2026-05-06 17:32:44 +08:00
if ( Array . isArray ( b ) ) {
if ( Array . isArray ( a ) ) {
2025-08-02 12:09:34 +08:00
return deepClone ( b ) ;
}
2026-05-06 17:32:44 +08:00
throw new Error ( ` failed to deepMerge ${ a } and ${ b } ` ) ;
}
if ( Array . isArray ( a ) ) {
2025-08-02 12:09:34 +08:00
throw new Error ( ` failed to deepMerge ${ a } and ${ b } ` ) ;
}
const clone = shallowClone ( a ) ;
for ( const key in a ) {
clone [ key ] = deepMerge ( a [ key ] , b [ key ] ) ;
}
for ( const key in b ) {
clone [ key ] = deepMerge ( a [ key ] , b [ key ] ) ;
}
return clone ;
}
// src/interfaces/ViewGenerator.ts
var ViewGenerator = class {
constructor ( app2 , containerEl , file ) {
this . extensions = [ ] ;
this . app = app2 ;
this . containerEl = containerEl ;
this . leaf = new import _obsidian8 . WorkspaceLeaf ( this . app ) ;
this . file = file ;
}
2026-05-06 17:32:44 +08:00
async load ( mode ) {
await this . onload ( mode ) ;
return this ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
async unload ( ) {
this . onunload ( ) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
async toggleViewMode ( ) {
for ( const ext of this . extensions ) {
if ( ! await ext . isMine ( this . leaf ) )
continue ;
await ext . toggleViewMode ( this . leaf ) ;
return ;
}
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
async onload ( mode ) {
const fileType = fileTypeMap [ this . file . extension ] ;
if ( ! fileType )
return ;
this . containerEl . appendChild ( this . leaf . containerEl ) ;
await this . openFile ( ) ;
for ( const ext of this . extensions ) {
if ( ! await ext . isMine ( this . leaf ) )
continue ;
await ext . setViewMode ( this . leaf , mode ? ? "preview" ) ;
return ;
}
2025-08-02 12:09:34 +08:00
}
onunload ( ) {
this . leaf . detach ( ) ;
}
2026-05-06 17:32:44 +08:00
async openFile ( ) {
const { leaf , file } = this ;
await leaf . openFile ( file ) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
// it should be called once because is is not idempotent
// it can be called even when view mode = 'preview'
2025-08-02 12:09:34 +08:00
highlightMatches ( matches , cls ) {
const view = this . leaf . view ;
if ( ! ( view instanceof import _obsidian8 . MarkdownView ) ) {
return ;
}
const editor = view . editor ;
const ranges = [ ] ;
matches . forEach ( ( match ) => {
const range = {
from : editor . offsetToPos ( match [ 0 ] ) ,
to : editor . offsetToPos ( match [ 1 ] )
} ;
ranges . push ( range ) ;
} ) ;
editor . addHighlights ( ranges , cls ) ;
}
2026-05-06 17:32:44 +08:00
async scrollIntoView ( match , center ) {
const view = this . leaf . view ;
if ( ! ( view instanceof import _obsidian8 . MarkdownView ) ) {
return ;
}
if ( view . getMode ( ) !== "source" ) {
return ;
}
const editor = view . editor ;
const range = {
from : editor . offsetToPos ( match [ 0 ] ) ,
to : editor . offsetToPos ( match [ 1 ] )
} ;
const iter = scrollIteration ( editor ) ;
if ( iter === void 0 ) {
return ;
}
for ( let i = 0 ; i < iter ; i ++ ) {
editor . scrollIntoView ( range , center ) ;
await delay ( 1 ) ;
}
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
async focusOn ( match , cls , center ) {
const view = this . leaf . view ;
if ( ! ( view instanceof import _obsidian8 . MarkdownView ) ) {
return ;
}
if ( view . getMode ( ) !== "source" ) {
return ;
}
await this . scrollIntoView ( match , center ) ;
const { editor } = view ;
editor . removeHighlights ( cls ) ;
const range = {
from : editor . offsetToPos ( match [ 0 ] ) ,
to : editor . offsetToPos ( match [ 1 ] )
} ;
editor . addHighlights ( [ range ] , cls ) ;
2025-08-02 12:09:34 +08:00
}
registerExtension ( ext ) {
this . extensions . push ( ext ) ;
return this ;
}
} ;
var fileTypeMap = {
md : "md" ,
png : "image" ,
jpg : "image" ,
jpeg : "image" ,
gif : "image" ,
bmp : "image" ,
svg : "image" ,
webp : "image" ,
mp3 : "audio" ,
webm : "audio" ,
wav : "audio" ,
m4a : "audio" ,
ogg : "audio" ,
"3gp" : "audio" ,
flac : "audio" ,
mp4 : "movie" ,
ogv : "movie" ,
pdf : "pdf"
} ;
// src/interfaces/viewGeneratorExtensions/Excalidraw.ts
2026-05-06 17:32:44 +08:00
var import _obsidian9 = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
var excalidrawPluginId = "obsidian-excalidraw-plugin" ;
var excalidrawViewType = "excalidraw" ;
var ExcalidrawViewGeneratorExtension = class {
constructor ( app2 ) {
this . app = app2 ;
const excalidraw = this . app . plugins . plugins [ excalidrawPluginId ] ;
if ( ! isExcalidrawPlugin ( excalidraw ) ) {
this . excalidraw = void 0 ;
} else {
this . excalidraw = excalidraw ;
}
}
isMine ( leaf ) {
return leaf . view . getViewType ( ) === excalidrawViewType ;
}
2026-05-06 17:32:44 +08:00
// https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/109fe05302bde0e8fe4e97c3bad6ca3f51f6b6b1/src/main.ts#L953-L986
async setViewMode ( leaf , mode ) {
const { excalidraw } = this ;
if ( ! excalidraw )
return ;
excalidraw . excalidrawFileModes [ leaf . id ] = "markdown" ;
await excalidraw . setMarkdownView ( leaf ) ;
if ( ! ( leaf . view instanceof import _obsidian9 . MarkdownView ) )
return ;
await leaf . view . setState (
{
... leaf . view . getState ( ) ,
2025-08-02 12:09:34 +08:00
mode
2026-05-06 17:32:44 +08:00
} ,
{ }
) ;
leaf . view . editor . blur ( ) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
async toggleViewMode ( leaf ) {
const { excalidraw } = this ;
if ( ! excalidraw )
return ;
excalidraw . excalidrawFileModes [ leaf . id ] = "markdown" ;
await excalidraw . setMarkdownView ( leaf ) ;
if ( ! ( leaf . view instanceof import _obsidian9 . MarkdownView ) )
return ;
const mode = leaf . view . getMode ( ) ;
await leaf . view . setState (
{
... leaf . view . getState ( ) ,
2025-08-02 12:09:34 +08:00
mode : mode === "preview" ? "source" : "preview"
2026-05-06 17:32:44 +08:00
} ,
{ }
) ;
leaf . view . editor . blur ( ) ;
2025-08-02 12:09:34 +08:00
}
} ;
function isExcalidrawPlugin ( plugin2 ) {
if ( ! ( plugin2 instanceof import _obsidian9 . Plugin ) )
return false ;
const { excalidrawFileModes , setMarkdownView } = plugin2 ;
if ( typeof excalidrawFileModes !== "object" )
return false ;
if ( typeof setMarkdownView !== "function" )
return false ;
return true ;
}
// src/interfaces/viewGeneratorExtensions/Kanban.ts
2026-05-06 17:32:44 +08:00
var import _obsidian10 = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
var kanbanPluginId = "obsidian-kanban" ;
var frontMatterKey = "kanban-plugin" ;
var kanbanViewType = "kanban" ;
var KanbanViewGeneratorExtension = class {
constructor ( app2 ) {
this . app = app2 ;
const kanban = this . app . plugins . plugins [ kanbanPluginId ] ;
if ( IsKanbanPlugin ( kanban ) ) {
this . kanban = kanban ;
}
if ( kanban === void 0 ) {
this . kanban = void 0 ;
}
}
isMine ( leaf ) {
const { view } = leaf ;
2026-05-06 17:32:44 +08:00
if ( view . getViewType ( ) === kanbanViewType )
2025-08-02 12:09:34 +08:00
return true ;
if ( ! ( view instanceof import _obsidian10 . TextFileView ) )
return false ;
const fileCache = this . app . metadataCache . getFileCache ( view . file ) ;
2026-05-06 17:32:44 +08:00
const fileIsKanban = ! ! fileCache ? . frontmatter && ! ! fileCache . frontmatter [ frontMatterKey ] ;
2025-08-02 12:09:34 +08:00
return fileIsKanban ;
}
2026-05-06 17:32:44 +08:00
// https://github.com/mgmeyers/obsidian-kanban/blob/350fc891a8489f70551d288ae914534424c8c095/src/main.ts#L317-L345
async setViewMode ( leaf , mode ) {
const { kanban } = this ;
if ( ! kanban )
return ;
if ( mode === "source" ) {
kanban . kanbanFileModes [ leaf . id ] = "markdown" ;
await kanban . setMarkdownView ( leaf ) ;
await leaf . view . setState (
{
... leaf . view . getState ( ) ,
2025-08-02 12:09:34 +08:00
mode : "source"
2026-05-06 17:32:44 +08:00
} ,
{ }
) ;
if ( leaf . view instanceof import _obsidian10 . MarkdownView ) {
leaf . view . editor . blur ( ) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
} else {
kanban . kanbanFileModes [ leaf . id ] = kanbanViewType ;
await kanban . setKanbanView ( leaf ) ;
}
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
async toggleViewMode ( leaf ) {
const { kanban } = this ;
if ( ! kanban )
return ;
const mode = kanban . kanbanFileModes [ leaf . id ] ;
await this . setViewMode ( leaf , mode === "markdown" ? "preview" : "source" ) ;
2025-08-02 12:09:34 +08:00
}
} ;
function IsKanbanPlugin ( plugin2 ) {
if ( ! ( plugin2 instanceof import _obsidian10 . Plugin ) )
return false ;
const { kanbanFileModes , setKanbanView , setMarkdownView } = plugin2 ;
if ( typeof kanbanFileModes !== "object" )
return false ;
if ( typeof setMarkdownView !== "function" )
return false ;
if ( typeof setKanbanView !== "function" )
return false ;
return true ;
}
// src/interfaces/viewGeneratorExtensions/Markdown.ts
2026-05-06 17:32:44 +08:00
var import _obsidian11 = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
var MarkdownViewGeneratorExtension = class {
isMine ( leaf ) {
return leaf . view instanceof import _obsidian11 . MarkdownView ;
}
2026-05-06 17:32:44 +08:00
async setViewMode ( leaf , mode ) {
await leaf . view . setState (
{
... leaf . view . getState ( ) ,
2025-08-02 12:09:34 +08:00
mode
2026-05-06 17:32:44 +08:00
} ,
{ }
) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
async toggleViewMode ( leaf ) {
if ( ! ( leaf . view instanceof import _obsidian11 . MarkdownView ) )
return ;
await this . setViewMode (
leaf ,
leaf . view . getMode ( ) === "preview" ? "source" : "preview"
) ;
2025-08-02 12:09:34 +08:00
}
} ;
// src/interfaces/viewGeneratorExtensions/NonMarkdown.ts
2026-05-06 17:32:44 +08:00
var import _obsidian12 = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
var NON _MARKDOWN _FILE _TYPES = [ "image" , "audio" , "pdf" , "video" ] ;
var NonMarkdownViewGeneratorExtension = class {
isMine ( leaf ) {
if ( ! ( leaf . view instanceof import _obsidian12 . FileView ) )
return false ;
2026-05-06 17:32:44 +08:00
return NON _MARKDOWN _FILE _TYPES . includes (
leaf . view . getViewType ( )
) ;
2025-08-02 12:09:34 +08:00
}
setViewMode ( _leaf , _mode ) {
return ;
}
toggleViewMode ( _ ) {
return ;
}
} ;
2026-05-06 17:32:44 +08:00
// node_modules/svelte/src/runtime/store/index.js
2025-08-02 12:09:34 +08:00
var subscriber _queue = [ ] ;
function writable ( value , start = noop ) {
let stop ;
2026-05-06 17:32:44 +08:00
const subscribers = /* @__PURE__ */ new Set ( ) ;
2025-08-02 12:09:34 +08:00
function set ( new _value ) {
if ( safe _not _equal ( value , new _value ) ) {
value = new _value ;
if ( stop ) {
const run _queue = ! subscriber _queue . length ;
for ( const subscriber of subscribers ) {
subscriber [ 1 ] ( ) ;
subscriber _queue . push ( subscriber , value ) ;
}
if ( run _queue ) {
for ( let i = 0 ; i < subscriber _queue . length ; i += 2 ) {
subscriber _queue [ i ] [ 0 ] ( subscriber _queue [ i + 1 ] ) ;
}
subscriber _queue . length = 0 ;
}
}
}
}
function update2 ( fn ) {
set ( fn ( value ) ) ;
}
function subscribe2 ( run2 , invalidate = noop ) {
const subscriber = [ run2 , invalidate ] ;
subscribers . add ( subscriber ) ;
if ( subscribers . size === 1 ) {
2026-05-06 17:32:44 +08:00
stop = start ( set , update2 ) || noop ;
2025-08-02 12:09:34 +08:00
}
run2 ( value ) ;
return ( ) => {
subscribers . delete ( subscriber ) ;
2026-05-06 17:32:44 +08:00
if ( subscribers . size === 0 && stop ) {
2025-08-02 12:09:34 +08:00
stop ( ) ;
stop = null ;
}
} ;
}
return { set , update : update2 , subscribe : subscribe2 } ;
}
// src/ui/store.ts
var app = writable ( ) ;
var plugin = writable ( ) ;
// src/ui/PreviewModalContent.svelte
function add _css3 ( target ) {
append _styles ( target , "svelte-6cqu2r" , ".core-search-assistant_preview-modal_view-container.svelte-6cqu2r{min-width:700px}.core-search-assistant_preview-modal_view-container.svelte-6cqu2r .highlight-search-match{color:var(--highlight-search-match);background-color:var(--highlight-search-match-bg)}.core-search-assistant_preview-modal_view-container.svelte-6cqu2r .focus-search-match{background-color:var(--focus-search-match-bg)}.core-search-assistant_preview-modal_view-container.svelte-6cqu2r .workspace-leaf{contain:initial !important}.core-search-assistant_preview-modal_view-container.svelte-6cqu2r .view-content{overflow:unset}.core-search-assistant_preview-modal_view-container.svelte-6cqu2r .markdown-preview-view{overflow:unset}.core-search-assistant_preview-modal_view-container.svelte-6cqu2r .workspace-leaf-content{overflow:unset}.core-search-assistant_preview-modal_view-container.svelte-6cqu2r .workspace-leaf-resize-handle{display:none}.core-search-assistant_preview-modal_view-container.svelte-6cqu2r .view-header{display:none}.core-search-assistant_preview-modal_view-container.svelte-6cqu2r .markdown-preview-view{padding:0}.core-search-assistant_preview-modal_view-container.svelte-6cqu2r .markdown-source-view{pointer-events:none}.core-search-assistant_preview-modal_view-container.svelte-6cqu2r .workspace-leaf-content[data-type='pdf']{height:990px}.core-search-assistant_preview-modal_view-container.svelte-6cqu2r .markdown-source-view.mod-cm6 .cm-editor{flex:initial;display:initial}.core-search-assistant_preview-modal_view-container.svelte-6cqu2r .markdown-source-view.mod-cm6{display:initial}.core-search-assistant_preview-modal_view-container.svelte-6cqu2r .markdown-source-view.mod-cm6 .cm-scroller{padding:0}" ) ;
}
function create _fragment3 ( ctx ) {
let div ;
return {
c ( ) {
div = element ( "div" ) ;
attr ( div , "class" , "core-search-assistant_preview-modal_view-container svelte-6cqu2r" ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
ctx [ 5 ] ( div ) ;
} ,
p : noop ,
i : noop ,
o : noop ,
d ( detaching ) {
2026-05-06 17:32:44 +08:00
if ( detaching ) {
2025-08-02 12:09:34 +08:00
detach ( div ) ;
2026-05-06 17:32:44 +08:00
}
2025-08-02 12:09:34 +08:00
ctx [ 5 ] ( null ) ;
}
} ;
}
function instance3 ( $$self , $$props , $$invalidate ) {
let $app ;
component _subscribe ( $$self , app , ( $$value ) => $$invalidate ( 7 , $app = $$value ) ) ;
let { file } = $$props ;
let { matches } = $$props ;
let contentContainerEl ;
let renderer ;
2026-05-06 17:32:44 +08:00
onMount ( async ( ) => {
2025-08-02 12:09:34 +08:00
if ( ! file ) {
return ;
}
if ( ! contentContainerEl ) {
return ;
}
const fileType = fileTypeMap [ file . extension ] ;
if ( fileType !== void 0 ) {
contentContainerEl . empty ( ) ;
2026-05-06 17:32:44 +08:00
renderer = await new ViewGenerator ( $app , contentContainerEl , file ) . registerExtension ( new ExcalidrawViewGeneratorExtension ( $app ) ) . registerExtension ( new KanbanViewGeneratorExtension ( $app ) ) . registerExtension ( new MarkdownViewGeneratorExtension ( ) ) . registerExtension ( new NonMarkdownViewGeneratorExtension ( ) ) . load ( "source" ) ;
2025-08-02 12:09:34 +08:00
highlightMatches ( ) ;
}
2026-05-06 17:32:44 +08:00
} ) ;
2025-08-02 12:09:34 +08:00
onDestroy ( ( ) => {
2026-05-06 17:32:44 +08:00
setTimeout ( ( ) => renderer ? . unload ( ) , 1e3 ) ;
2025-08-02 12:09:34 +08:00
} ) ;
2026-05-06 17:32:44 +08:00
async function toggleViewMode ( ) {
await renderer ? . toggleViewMode ( ) ;
2025-08-02 12:09:34 +08:00
}
function focusOn ( matchId , center ) {
if ( ! matches )
return ;
const match = matches [ matchId ] ;
if ( match === void 0 ) {
return ;
}
2026-05-06 17:32:44 +08:00
renderer ? . focusOn ( match , "focus-search-match" , center ) ;
2025-08-02 12:09:34 +08:00
}
function highlightMatches ( ) {
2026-05-06 17:32:44 +08:00
renderer ? . highlightMatches ( matches ? ? [ ] , "highlight-search-match" ) ;
2025-08-02 12:09:34 +08:00
}
function div _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
contentContainerEl = $$value ;
$$invalidate ( 0 , contentContainerEl ) ;
} ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "file" in $$props2 )
$$invalidate ( 1 , file = $$props2 . file ) ;
if ( "matches" in $$props2 )
$$invalidate ( 2 , matches = $$props2 . matches ) ;
} ;
return [ contentContainerEl , file , matches , toggleViewMode , focusOn , div _binding ] ;
}
var PreviewModalContent = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
2026-05-06 17:32:44 +08:00
init (
this ,
options ,
instance3 ,
create _fragment3 ,
safe _not _equal ,
{
file : 1 ,
matches : 2 ,
toggleViewMode : 3 ,
focusOn : 4
} ,
add _css3
) ;
2025-08-02 12:09:34 +08:00
}
get toggleViewMode ( ) {
return this . $$ . ctx [ 3 ] ;
}
get focusOn ( ) {
return this . $$ . ctx [ 4 ] ;
}
} ;
var PreviewModalContent _default = PreviewModalContent ;
2026-05-06 17:32:44 +08:00
// src/utils/Link.ts
function generateInternalLinkFrom ( app2 , file ) {
const text2 = getDisplayText ( app2 . metadataCache , file ) ;
return app2 . fileManager . generateMarkdownLink ( file , "" , void 0 , text2 ) ;
}
function getDisplayText ( metadataCache , file ) {
const cache = metadataCache . getFileCache ( file ) ;
if ( ! cache )
return void 0 ;
const title = getTitle ( cache . frontmatter ) ;
if ( title !== void 0 ) {
return title ;
}
const h1 = getFirstH1 ( cache . headings ) ;
if ( h1 !== void 0 ) {
return h1 ;
}
return void 0 ;
}
function getTitle ( frontmatter ) {
return frontmatter ? . title ;
}
function getFirstH1 ( headings ) {
if ( ! headings )
return void 0 ;
for ( const heading of headings ) {
if ( heading . level !== 1 )
continue ;
return heading . heading ;
}
return void 0 ;
}
2025-08-02 12:09:34 +08:00
// src/components/PreviewModal.ts
var SCROLL _AMOUNT = 70 ;
var PreviewModal = class extends import _obsidian13 . Modal {
constructor ( app2 , plugin2 , modeScope , item ) {
super ( app2 ) ;
this . plugin = plugin2 ;
this . modeScope = modeScope ;
this . item = item ;
this . currentFocus = - 1 ;
}
2026-05-06 17:32:44 +08:00
async onOpen ( ) {
await this . renderView ( ) ;
this . modeScope . push ( ) ;
const hotkeyMap = this . plugin . settings ? . previewModalHotkeys ;
if ( ! hotkeyMap )
return ;
hotkeyMap . closeModal . forEach ( ( hotkey ) => {
this . scope . register ( hotkey . modifiers , hotkey . key , ( ) => {
this . shouldRestoreSelection = true ;
this . close ( ) ;
2025-08-02 12:09:34 +08:00
} ) ;
2026-05-06 17:32:44 +08:00
} ) ;
hotkeyMap . open . forEach ( ( hotkey ) => {
this . scope . register ( hotkey . modifiers , hotkey . key , ( ) => {
this . openAndFocus ( this . currentFocus ) ;
this . plugin . controller ? . exit ( ) ;
this . shouldRestoreSelection = false ;
this . close ( ) ;
2025-08-02 12:09:34 +08:00
} ) ;
2026-05-06 17:32:44 +08:00
} ) ;
hotkeyMap . openInNewPage . forEach ( ( hotkey ) => {
this . scope . register ( hotkey . modifiers , hotkey . key , ( ) => {
this . openAndFocus (
this . currentFocus ,
this . plugin . settings ? . splitDirection
) ;
this . plugin . controller ? . exit ( ) ;
this . shouldRestoreSelection = false ;
this . close ( ) ;
2025-08-02 12:09:34 +08:00
} ) ;
2026-05-06 17:32:44 +08:00
} ) ;
hotkeyMap . bigScrollDown . forEach ( ( hotkey ) => {
this . scope . register ( hotkey . modifiers , hotkey . key , ( ) => {
this . scroll ( "down" ) ;
2025-08-02 12:09:34 +08:00
} ) ;
2026-05-06 17:32:44 +08:00
} ) ;
hotkeyMap . bigScrollUp . forEach ( ( hotkey ) => {
this . scope . register ( hotkey . modifiers , hotkey . key , ( ) => {
this . scroll ( "up" ) ;
2025-08-02 12:09:34 +08:00
} ) ;
2026-05-06 17:32:44 +08:00
} ) ;
hotkeyMap . scrollDown . forEach ( ( hotkey ) => {
this . scope . register ( hotkey . modifiers , hotkey . key , ( ) => {
this . scroll ( "down" , SCROLL _AMOUNT ) ;
2025-08-02 12:09:34 +08:00
} ) ;
2026-05-06 17:32:44 +08:00
} ) ;
hotkeyMap . scrollUp . forEach ( ( hotkey ) => {
this . scope . register ( hotkey . modifiers , hotkey . key , ( ) => {
this . scroll ( "up" , SCROLL _AMOUNT ) ;
} ) ;
} ) ;
hotkeyMap . focusNext . forEach ( ( hotkey ) => {
this . scope . register ( hotkey . modifiers , hotkey . key , ( evt ) => {
evt . preventDefault ( ) ;
const numMatches = this . countMatches ( ) ;
if ( numMatches === void 0 || numMatches === 0 ) {
return ;
}
this . currentFocus = cyclicId ( ++ this . currentFocus , numMatches ) ;
this . previewContent ? . focusOn ( this . currentFocus , true ) ;
2025-08-02 12:09:34 +08:00
} ) ;
2026-05-06 17:32:44 +08:00
} ) ;
hotkeyMap . focusPrevious . forEach ( ( hotkey ) => {
this . scope . register ( hotkey . modifiers , hotkey . key , ( evt ) => {
evt . preventDefault ( ) ;
const numMatches = this . countMatches ( ) ;
if ( numMatches === void 0 || numMatches === 0 ) {
return ;
}
this . currentFocus = cyclicId ( -- this . currentFocus , numMatches ) ;
this . previewContent ? . focusOn ( this . currentFocus , true ) ;
2025-08-02 12:09:34 +08:00
} ) ;
2026-05-06 17:32:44 +08:00
} ) ;
hotkeyMap . togglePreviewMode . forEach ( ( hotkey ) => {
this . scope . register ( hotkey . modifiers , hotkey . key , ( evt ) => {
( async ( ) => {
2025-08-02 12:09:34 +08:00
evt . preventDefault ( ) ;
2026-05-06 17:32:44 +08:00
await this . previewContent ? . toggleViewMode ( ) ;
} ) ( ) ;
2025-08-02 12:09:34 +08:00
} ) ;
2026-05-06 17:32:44 +08:00
} ) ;
hotkeyMap . copyLink . forEach ( ( hotkey ) => {
this . scope . register ( hotkey . modifiers , hotkey . key , ( ) => {
const { file } = this . item ;
const internalLink = generateInternalLinkFrom ( this . app , file ) ;
navigator . clipboard . writeText ( internalLink ) ;
new import _obsidian13 . Notice ( "Copy wiki link!" ) ;
2025-08-02 12:09:34 +08:00
} ) ;
} ) ;
}
onClose ( ) {
2026-05-06 17:32:44 +08:00
this . previewContent ? . $destroy ( ) ;
2025-08-02 12:09:34 +08:00
setTimeout ( ( ) => {
if ( this . modeScope . depth > 1 ) {
this . modeScope . pop ( ) ;
}
} , 100 ) ;
}
2026-05-06 17:32:44 +08:00
async renderView ( ) {
const { contentEl } = this ;
contentEl . empty ( ) ;
contentEl . hide ( ) ;
this . previewContent = new PreviewModalContent _default ( {
target : contentEl ,
props : {
file : this . item . file ,
matches : this . item . result . content
}
2025-08-02 12:09:34 +08:00
} ) ;
2026-05-06 17:32:44 +08:00
contentEl . show ( ) ;
2025-08-02 12:09:34 +08:00
}
countMatches ( ) {
2026-05-06 17:32:44 +08:00
return this . item . result . content ? . length ;
2025-08-02 12:09:34 +08:00
}
scroll ( direction , px ) {
const { containerEl , contentEl } = this ;
2026-05-06 17:32:44 +08:00
const move = ( px ? ? containerEl . clientHeight / 2 ) * ( direction === "up" ? - 1 : 1 ) ;
2025-08-02 12:09:34 +08:00
contentEl . scrollBy ( {
top : move ,
behavior : "smooth"
} ) ;
}
2026-05-06 17:32:44 +08:00
async openAndFocus ( matchId , direction ) {
const { item } = this ;
const leaf = direction === void 0 ? this . app . workspace . getMostRecentLeaf ( ) : this . app . workspace . splitActiveLeaf ( direction ) ;
await leaf . openFile ( item . file ) ;
this . app . workspace . setActiveLeaf ( leaf , true , true ) ;
const match = item ? . result ? . content ? . [ matchId ] ;
if ( ! match ) {
return ;
}
const { view } = leaf ;
if ( ! ( view instanceof import _obsidian13 . MarkdownView ) ) {
return ;
}
const editor = view . editor ;
const range = {
from : editor . offsetToPos ( match [ 0 ] ) ,
to : editor . offsetToPos ( match [ 1 ] )
} ;
editor . addHighlights ( [ range ] , "obsidian-search-match-highlight" ) ;
const iter = scrollIteration ( editor ) ;
if ( iter === void 0 ) {
return ;
}
for ( let i = 0 ; i < iter ; i ++ ) {
editor . scrollIntoView ( range , true ) ;
}
editor . setCursor ( range . from ) ;
2025-08-02 12:09:34 +08:00
}
} ;
function cyclicId ( id , total ) {
return ( id % total + total ) % total ;
}
// src/Controller.ts
2026-05-06 17:32:44 +08:00
var obsidian = _ _toESM ( require ( "obsidian" ) , 1 ) ;
var import _obsidian14 = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
// src/ui/CardContainer.svelte
function add _css4 ( target ) {
append _styles ( target , "svelte-1g7kfgn" , ".core-search-assistant_card-container.svelte-1g7kfgn.svelte-1g7kfgn{overflow:hidden;display:flex;flex-direction:column;height:100%;position:relative;box-shadow:0 2px 5px rgba(0, 0, 0, 0.2);border-radius:10px;cursor:pointer;background-color:var(--background-primary);box-sizing:content-box}.core-search-assistant_card-container.svelte-1g7kfgn.svelte-1g7kfgn:hover{border:5px solid var(--interactive-accent);margin:-5px}.core-search-assistant_card-container.is-selected.svelte-1g7kfgn.svelte-1g7kfgn{border:5px solid var(--interactive-accent);margin:-5px}.card-container-header.svelte-1g7kfgn.svelte-1g7kfgn{padding:5px 10px;background-color:var(--background-secondary);display:flex;color:var(--text-muted)}.file-name-container.svelte-1g7kfgn.svelte-1g7kfgn{font-size:1rem;line-height:1.2rem;overflow-wrap:break-word;min-width:0;flex:1}.file-name-container.svelte-1g7kfgn span.matched-in-path{color:var(--text-normal);font-weight:bold}.content-container-wrapper.svelte-1g7kfgn.svelte-1g7kfgn{padding:5px;flex:1;height:100%;min-height:0}.content-container.svelte-1g7kfgn.svelte-1g7kfgn{overflow:hidden;height:100%;font-size:0.8rem;line-height:1.2}.content-container.svelte-1g7kfgn div.content-not-supported-file-format.svelte-1g7kfgn{font-size:1rem;color:var(--text-muted)}.content-container.svelte-1g7kfgn p{font-size:0.8rem;line-height:1.2}.content-container.svelte-1g7kfgn code{font-size:0.8rem;line-height:1.2}.content-container.svelte-1g7kfgn div{font-size:0.8rem}.content-container.svelte-1g7kfgn li{font-size:0.8rem;line-height:1.2}.content-container.svelte-1g7kfgn h1{font-size:1rem;line-height:1.2;margin:5px}.content-container.svelte-1g7kfgn h2{font-size:1rem;line-height:1.2;margin:5px}.content-container.svelte-1g7kfgn h3{font-size:1rem;line-height:1.2;margin:5px}.content-container.svelte-1g7kfgn h4{font-size:1rem;line-height:1.2;margin:5px}.content-container.svelte-1g7kfgn h5{font-size:1rem;line-height:1.2;margin:5px}.content-container.svelte-1g7kfgn h6{font-size:1rem;line-height:1.2;margin:5px}.content-container.svelte-1g7kfgn a{pointer-events:none}.content-container.svelte-1g7kfgn .workspace-leaf{contain:initial !important;height:100%}.content-container.svelte-1g7kfgn .workspace-leaf-resize-handle{display:none}.content-container.svelte-1g7kfgn .view-header{display:none}.content-container.svelte-1g7kfgn .view-content{flex:1;overflow:hidden}.content-container.svelte-1g7kfgn .markdown-preview-view{padding:0;overflow:hidden}.content-container.svelte-1g7kfgn .modal-content{margin:0}" ) ;
}
function create _fragment4 ( ctx ) {
let div5 ;
let div1 ;
let div0 ;
let t0 ;
let div4 ;
let div3 ;
let div2 ;
2026-05-06 17:32:44 +08:00
let t1 _value = ` ${ /*file*/
ctx [ 1 ] . extension . toUpperCase ( ) } file ` ;
2025-08-02 12:09:34 +08:00
let t1 ;
let div5 _data _path _value ;
let mounted ;
let dispose ;
return {
c ( ) {
div5 = element ( "div" ) ;
div1 = element ( "div" ) ;
div0 = element ( "div" ) ;
t0 = space ( ) ;
div4 = element ( "div" ) ;
div3 = element ( "div" ) ;
div2 = element ( "div" ) ;
t1 = text ( t1 _value ) ;
attr ( div0 , "class" , "file-name-container svelte-1g7kfgn" ) ;
attr ( div1 , "class" , "card-container-header svelte-1g7kfgn" ) ;
attr ( div2 , "class" , "content-not-supported-file-format svelte-1g7kfgn" ) ;
attr ( div3 , "class" , "content-container svelte-1g7kfgn" ) ;
attr ( div4 , "class" , "content-container-wrapper svelte-1g7kfgn" ) ;
attr ( div5 , "class" , "core-search-assistant_card-container svelte-1g7kfgn" ) ;
2026-05-06 17:32:44 +08:00
attr (
div5 ,
"data-id" ,
/*id*/
ctx [ 0 ]
) ;
attr ( div5 , "data-path" , div5 _data _path _value = /*file*/
ctx [ 1 ] . path ) ;
attr ( div5 , "role" , "button" ) ;
toggle _class (
div5 ,
"is-selected" ,
/*selected*/
ctx [ 2 ]
) ;
2025-08-02 12:09:34 +08:00
} ,
m ( target , anchor ) {
insert ( target , div5 , anchor ) ;
append ( div5 , div1 ) ;
append ( div1 , div0 ) ;
ctx [ 8 ] ( div0 ) ;
append ( div5 , t0 ) ;
append ( div5 , div4 ) ;
append ( div4 , div3 ) ;
append ( div3 , div2 ) ;
append ( div2 , t1 ) ;
ctx [ 9 ] ( div3 ) ;
if ( ! mounted ) {
2026-05-06 17:32:44 +08:00
dispose = listen (
div5 ,
"click" ,
/*onClicked*/
ctx [ 5 ]
) ;
2025-08-02 12:09:34 +08:00
mounted = true ;
}
} ,
p ( ctx2 , [ dirty ] ) {
2026-05-06 17:32:44 +08:00
if ( dirty & /*file*/
2 && t1 _value !== ( t1 _value = ` ${ /*file*/
ctx2 [ 1 ] . extension . toUpperCase ( ) } file ` ))
2025-08-02 12:09:34 +08:00
set _data ( t1 , t1 _value ) ;
2026-05-06 17:32:44 +08:00
if ( dirty & /*id*/
1 ) {
attr (
div5 ,
"data-id" ,
/*id*/
ctx2 [ 0 ]
) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
if ( dirty & /*file*/
2 && div5 _data _path _value !== ( div5 _data _path _value = /*file*/
ctx2 [ 1 ] . path ) ) {
2025-08-02 12:09:34 +08:00
attr ( div5 , "data-path" , div5 _data _path _value ) ;
}
2026-05-06 17:32:44 +08:00
if ( dirty & /*selected*/
4 ) {
toggle _class (
div5 ,
"is-selected" ,
/*selected*/
ctx2 [ 2 ]
) ;
2025-08-02 12:09:34 +08:00
}
} ,
i : noop ,
o : noop ,
d ( detaching ) {
2026-05-06 17:32:44 +08:00
if ( detaching ) {
2025-08-02 12:09:34 +08:00
detach ( div5 ) ;
2026-05-06 17:32:44 +08:00
}
2025-08-02 12:09:34 +08:00
ctx [ 8 ] ( null ) ;
ctx [ 9 ] ( null ) ;
mounted = false ;
dispose ( ) ;
}
} ;
}
function renderFileName ( fileName , containerEl ) {
containerEl . appendText ( fileName ) ;
}
function instance4 ( $$self , $$props , $$invalidate ) {
let $app ;
component _subscribe ( $$self , app , ( $$value ) => $$invalidate ( 11 , $app = $$value ) ) ;
let { id } = $$props ;
let { file } = $$props ;
let { selected } = $$props ;
let { focusEl } = $$props ;
let contentContainerEl ;
let fileNameContainerEl ;
let renderer ;
const dispatch = createEventDispatcher ( ) ;
function path ( ) {
return file . path ;
}
2026-05-06 17:32:44 +08:00
onMount ( async ( ) => {
2025-08-02 12:09:34 +08:00
if ( ! fileNameContainerEl ) {
return ;
}
renderFileName ( file . name , fileNameContainerEl ) ;
if ( ! contentContainerEl ) {
return ;
}
const fileType = fileTypeMap [ file . extension ] ;
if ( fileType !== void 0 ) {
contentContainerEl . empty ( ) ;
2026-05-06 17:32:44 +08:00
renderer = await new ViewGenerator ( $app , contentContainerEl , file ) . registerExtension ( new ExcalidrawViewGeneratorExtension ( $app ) ) . registerExtension ( new KanbanViewGeneratorExtension ( $app ) ) . registerExtension ( new MarkdownViewGeneratorExtension ( ) ) . registerExtension ( new NonMarkdownViewGeneratorExtension ( ) ) . load ( "preview" ) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
focusEl ? . focus ( ) ;
} ) ;
2025-08-02 12:09:34 +08:00
onDestroy ( ( ) => {
2026-05-06 17:32:44 +08:00
setTimeout ( ( ) => renderer ? . unload ( ) , 1e3 ) ;
2025-08-02 12:09:34 +08:00
} ) ;
2026-05-06 17:32:44 +08:00
async function onClicked ( ) {
await openFile ( ) ;
dispatch ( "click" ) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
async function openFile ( ) {
const leaf = $app . workspace . getMostRecentLeaf ( ) ;
await leaf . openFile ( file ) ;
$app . workspace . setActiveLeaf ( leaf , true , true ) ;
2025-08-02 12:09:34 +08:00
}
function div0 _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
fileNameContainerEl = $$value ;
$$invalidate ( 4 , fileNameContainerEl ) ;
} ) ;
}
function div3 _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
contentContainerEl = $$value ;
$$invalidate ( 3 , contentContainerEl ) ;
} ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "id" in $$props2 )
$$invalidate ( 0 , id = $$props2 . id ) ;
if ( "file" in $$props2 )
$$invalidate ( 1 , file = $$props2 . file ) ;
if ( "selected" in $$props2 )
$$invalidate ( 2 , selected = $$props2 . selected ) ;
if ( "focusEl" in $$props2 )
$$invalidate ( 6 , focusEl = $$props2 . focusEl ) ;
} ;
return [
id ,
file ,
selected ,
contentContainerEl ,
fileNameContainerEl ,
onClicked ,
focusEl ,
path ,
div0 _binding ,
div3 _binding
] ;
}
var CardContainer = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
2026-05-06 17:32:44 +08:00
init (
this ,
options ,
instance4 ,
create _fragment4 ,
safe _not _equal ,
{
id : 0 ,
file : 1 ,
selected : 2 ,
focusEl : 6 ,
path : 7
} ,
add _css4
) ;
2025-08-02 12:09:34 +08:00
}
get path ( ) {
return this . $$ . ctx [ 7 ] ;
}
} ;
var CardContainer _default = CardContainer ;
// src/ui/CardViewComponent.svelte
function add _css5 ( target ) {
append _styles ( target , "svelte-pwex1j" , ".card-view-container.svelte-pwex1j{position:absolute;top:0;left:0;width:100%;height:100%;z-index:var(--layer-modal);padding:20px 30px;display:flex;justify-content:center}.card-view-background.svelte-pwex1j{position:absolute;top:0;left:0;width:100%;height:100%;background-color:var(--background-modifier-cover)}.cards-container.svelte-pwex1j{display:grid;grid-gap:20px;height:100%;width:100%;min-height:0}" ) ;
}
function create _fragment5 ( ctx ) {
let div2 ;
let div0 ;
let t ;
let div1 ;
let mounted ;
let dispose ;
return {
c ( ) {
div2 = element ( "div" ) ;
div0 = element ( "div" ) ;
t = space ( ) ;
div1 = element ( "div" ) ;
attr ( div0 , "class" , "card-view-background svelte-pwex1j" ) ;
attr ( div1 , "class" , "cards-container svelte-pwex1j" ) ;
attr ( div2 , "class" , "card-view-container svelte-pwex1j" ) ;
} ,
m ( target , anchor ) {
insert ( target , div2 , anchor ) ;
append ( div2 , div0 ) ;
append ( div2 , t ) ;
append ( div2 , div1 ) ;
ctx [ 10 ] ( div1 ) ;
if ( ! mounted ) {
2026-05-06 17:32:44 +08:00
dispose = listen (
div0 ,
"click" ,
/*click_handler*/
ctx [ 9 ]
) ;
2025-08-02 12:09:34 +08:00
mounted = true ;
}
} ,
p : noop ,
i : noop ,
o : noop ,
d ( detaching ) {
2026-05-06 17:32:44 +08:00
if ( detaching ) {
2025-08-02 12:09:34 +08:00
detach ( div2 ) ;
2026-05-06 17:32:44 +08:00
}
2025-08-02 12:09:34 +08:00
ctx [ 10 ] ( null ) ;
mounted = false ;
dispose ( ) ;
}
} ;
}
function cardsPerPage ( layout ) {
if ( ! checkLayout ( layout ) )
return 0 ;
return layout [ 0 ] * layout [ 1 ] ;
}
function setLayout ( contentEl , layout ) {
if ( ! contentEl )
return ;
if ( ! checkLayout ( layout ) )
return ;
contentEl . style . gridTemplateColumns = ` repeat( ${ layout [ 1 ] } , minmax(0, 1fr)) ` ;
contentEl . style . gridTemplateRows = ` repeat( ${ layout [ 0 ] } , 1fr) ` ;
}
function checkLayout ( layout ) {
const check = ( x ) => Number . isInteger ( x ) && x > 0 ;
return check ( layout [ 0 ] ) && check ( layout [ 1 ] ) ;
}
function instance5 ( $$self , $$props , $$invalidate ) {
let { layout } = $$props ;
let { focusEl } = $$props ;
let contentEl ;
let cards = [ ] ;
const dispatcher = createEventDispatcher ( ) ;
function addCard ( file ) {
if ( ! contentEl )
return ;
if ( ! focusEl )
return ;
if ( cards . length >= cardsPerPage ( layout ) )
return ;
const card = new CardContainer _default ( {
target : contentEl ,
props : {
file ,
id : cards . length ,
selected : false ,
focusEl
}
} ) ;
cards . push ( card ) ;
}
function renderPage ( files ) {
files . forEach ( ( file ) => {
addCard ( file ) ;
} ) ;
}
function focusOn ( id ) {
const pos = id % cardsPerPage ( layout ) ;
[ - 1 , 0 , 1 ] . forEach ( ( i ) => {
const card = cards [ pos + i ] ;
if ( ! card )
return ;
2026-05-06 17:32:44 +08:00
if ( i === 0 ) {
2025-08-02 12:09:34 +08:00
card . $set ( { selected : true } ) ;
} else {
card . $set ( { selected : false } ) ;
}
} ) ;
}
function detachCards ( ) {
cards . forEach ( ( card ) => {
card . $destroy ( ) ;
} ) ;
cards = [ ] ;
}
function checkCardsRenderedCorrectly ( files ) {
if ( ! checkLayout ( layout ) )
return false ;
for ( let i = 0 ; i < cardsPerPage ( layout ) ; i ++ ) {
const file = files [ i ] ;
const card = cards [ i ] ;
2026-05-06 17:32:44 +08:00
if ( file ? . path !== card ? . path ( ) ) {
2025-08-02 12:09:34 +08:00
return false ;
}
}
return true ;
}
onMount ( ( ) => {
setLayout ( contentEl , layout ) ;
} ) ;
onDestroy ( ( ) => {
detachCards ( ) ;
} ) ;
const click _handler = ( ) => {
dispatcher ( "should-destroy" ) ;
} ;
function div1 _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
contentEl = $$value ;
$$invalidate ( 0 , contentEl ) ;
} ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "layout" in $$props2 )
$$invalidate ( 2 , layout = $$props2 . layout ) ;
if ( "focusEl" in $$props2 )
$$invalidate ( 3 , focusEl = $$props2 . focusEl ) ;
} ;
return [
contentEl ,
dispatcher ,
layout ,
focusEl ,
addCard ,
renderPage ,
focusOn ,
detachCards ,
checkCardsRenderedCorrectly ,
click _handler ,
div1 _binding
] ;
}
var CardViewComponent = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
2026-05-06 17:32:44 +08:00
init (
this ,
options ,
instance5 ,
create _fragment5 ,
safe _not _equal ,
{
layout : 2 ,
focusEl : 3 ,
addCard : 4 ,
renderPage : 5 ,
focusOn : 6 ,
detachCards : 7 ,
checkCardsRenderedCorrectly : 8
} ,
add _css5
) ;
2025-08-02 12:09:34 +08:00
}
get addCard ( ) {
return this . $$ . ctx [ 4 ] ;
}
get renderPage ( ) {
return this . $$ . ctx [ 5 ] ;
}
get focusOn ( ) {
return this . $$ . ctx [ 6 ] ;
}
get detachCards ( ) {
return this . $$ . ctx [ 7 ] ;
}
get checkCardsRenderedCorrectly ( ) {
return this . $$ . ctx [ 8 ] ;
}
} ;
var CardViewComponent _default = CardViewComponent ;
2026-05-06 17:32:44 +08:00
// src/ui/Outline.svelte
2025-08-02 12:09:34 +08:00
function add _css6 ( target ) {
2026-05-06 17:32:44 +08:00
append _styles ( target , "svelte-f5i2qg" , ".outline-container.svelte-f5i2qg{position:absolute;top:0;left:0;width:100%;height:100%;z-index:var(--layer-modal);pointer-events:none}" ) ;
2025-08-02 12:09:34 +08:00
}
function create _fragment6 ( ctx ) {
2026-05-06 17:32:44 +08:00
let div ;
return {
c ( ) {
div = element ( "div" ) ;
attr ( div , "class" , "outline-container svelte-f5i2qg" ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
ctx [ 2 ] ( div ) ;
} ,
p : noop ,
i : noop ,
o : noop ,
d ( detaching ) {
if ( detaching ) {
detach ( div ) ;
}
ctx [ 2 ] ( null ) ;
}
} ;
}
var STYLE _VAR _COLOR _SEARCH _MODE _OUTLINE = "--search-mode-outline" ;
function instance6 ( $$self , $$props , $$invalidate ) {
let { lineWidth } = $$props ;
let el ;
onMount ( ( ) => {
if ( ! el )
return ;
$$invalidate ( 0 , el . style . outline = ` ${ lineWidth } px solid var( ${ STYLE _VAR _COLOR _SEARCH _MODE _OUTLINE } ) ` , el ) ;
$$invalidate ( 0 , el . style . outlineOffset = ` - ${ lineWidth } px ` , el ) ;
} ) ;
function div _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
el = $$value ;
$$invalidate ( 0 , el ) ;
} ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "lineWidth" in $$props2 )
$$invalidate ( 1 , lineWidth = $$props2 . lineWidth ) ;
} ;
return [ el , lineWidth , div _binding ] ;
}
var Outline = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance6 , create _fragment6 , safe _not _equal , { lineWidth : 1 } , add _css6 ) ;
}
} ;
var Outline _default = Outline ;
// src/ui/WorkspacePreview.svelte
function add _css7 ( target ) {
append _styles ( target , "svelte-1fata0e" , ".core-search-assistant_workspace-preview_container.svelte-1fata0e{position:absolute;top:0;left:0;width:100%;height:100%;z-index:var(--layer-modal);background-color:var(--background-primary);padding:20px 30px;overflow:auto}.core-search-assistant_workspace-preview_container.svelte-1fata0e .highlight-search-match{color:var(--highlight-search-match);background-color:var(--highlight-search-match-bg)}.core-search-assistant_workspace-preview_container.svelte-1fata0e .focus-search-match{background-color:var(--focus-search-match-bg)}.core-search-assistant_workspace-preview_container.svelte-1fata0e .workspace-leaf{contain:initial !important;height:100%}.core-search-assistant_workspace-preview_container.svelte-1fata0e .workspace-leaf-resize-handle{display:none}.core-search-assistant_workspace-preview_container.svelte-1fata0e .view-header{display:none}.core-search-assistant_workspace-preview_container.svelte-1fata0e .view-content{overflow:hidden}.core-search-assistant_workspace-preview_container.svelte-1fata0e .markdown-preview-view{padding:0}.core-search-assistant_workspace-preview_container.svelte-1fata0e .modal-content{margin:0}.core-search-assistant_workspace-preview_container.svelte-1fata0e .markdown-source-view.mod-cm6 .cm-editor{flex:initial;display:initial}.core-search-assistant_workspace-preview_container.svelte-1fata0e .markdown-source-view.mod-cm6{display:initial}.core-search-assistant_workspace-preview_container.svelte-1fata0e .markdown-source-view{pointer-events:none}.core-search-assistant_workspace-preview_container.svelte-1fata0e .markdown-source-view.mod-cm6 .cm-scroller{padding:0}" ) ;
}
function create _fragment7 ( ctx ) {
2025-08-02 12:09:34 +08:00
let div1 ;
let div0 ;
2026-05-06 17:32:44 +08:00
let t _value = ` ${ /*file*/
ctx [ 0 ] . extension . toUpperCase ( ) } file ` ;
2025-08-02 12:09:34 +08:00
let t ;
return {
c ( ) {
div1 = element ( "div" ) ;
div0 = element ( "div" ) ;
t = text ( t _value ) ;
attr ( div0 , "class" , "content-not-supported-file-format" ) ;
attr ( div1 , "class" , "core-search-assistant_workspace-preview_container svelte-1fata0e" ) ;
} ,
m ( target , anchor ) {
insert ( target , div1 , anchor ) ;
append ( div1 , div0 ) ;
append ( div0 , t ) ;
ctx [ 4 ] ( div1 ) ;
} ,
p ( ctx2 , [ dirty ] ) {
2026-05-06 17:32:44 +08:00
if ( dirty & /*file*/
1 && t _value !== ( t _value = ` ${ /*file*/
ctx2 [ 0 ] . extension . toUpperCase ( ) } file ` ))
2025-08-02 12:09:34 +08:00
set _data ( t , t _value ) ;
} ,
i : noop ,
o : noop ,
d ( detaching ) {
2026-05-06 17:32:44 +08:00
if ( detaching ) {
2025-08-02 12:09:34 +08:00
detach ( div1 ) ;
2026-05-06 17:32:44 +08:00
}
2025-08-02 12:09:34 +08:00
ctx [ 4 ] ( null ) ;
}
} ;
}
2026-05-06 17:32:44 +08:00
function instance7 ( $$self , $$props , $$invalidate ) {
2025-08-02 12:09:34 +08:00
let $app ;
component _subscribe ( $$self , app , ( $$value ) => $$invalidate ( 6 , $app = $$value ) ) ;
let { file } = $$props ;
let { matches } = $$props ;
let { focusEl } = $$props ;
let containerEl ;
let renderer ;
2026-05-06 17:32:44 +08:00
onMount ( async ( ) => {
2025-08-02 12:09:34 +08:00
if ( ! containerEl )
return ;
const fileType = fileTypeMap [ file . extension ] ;
if ( fileType !== void 0 ) {
containerEl . empty ( ) ;
2026-05-06 17:32:44 +08:00
renderer = await new ViewGenerator ( $app , containerEl , file ) . registerExtension ( new ExcalidrawViewGeneratorExtension ( $app ) ) . registerExtension ( new KanbanViewGeneratorExtension ( $app ) ) . registerExtension ( new MarkdownViewGeneratorExtension ( ) ) . registerExtension ( new NonMarkdownViewGeneratorExtension ( ) ) . load ( "source" ) ;
2025-08-02 12:09:34 +08:00
highlightMatches ( ) ;
}
2026-05-06 17:32:44 +08:00
focusEl ? . focus ( ) ;
} ) ;
2025-08-02 12:09:34 +08:00
onDestroy ( ( ) => {
2026-05-06 17:32:44 +08:00
setTimeout ( ( ) => renderer ? . unload ( ) , 1e3 ) ;
2025-08-02 12:09:34 +08:00
} ) ;
function highlightMatches ( ) {
2026-05-06 17:32:44 +08:00
renderer ? . highlightMatches ( matches ? ? [ ] , "highlight-search-match" ) ;
2025-08-02 12:09:34 +08:00
}
function div1 _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
containerEl = $$value ;
$$invalidate ( 1 , containerEl ) ;
} ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "file" in $$props2 )
$$invalidate ( 0 , file = $$props2 . file ) ;
if ( "matches" in $$props2 )
$$invalidate ( 2 , matches = $$props2 . matches ) ;
if ( "focusEl" in $$props2 )
$$invalidate ( 3 , focusEl = $$props2 . focusEl ) ;
} ;
return [ file , containerEl , matches , focusEl , div1 _binding ] ;
}
var WorkspacePreview = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
2026-05-06 17:32:44 +08:00
init ( this , options , instance7 , create _fragment7 , safe _not _equal , { file : 0 , matches : 2 , focusEl : 3 } , add _css7 ) ;
2025-08-02 12:09:34 +08:00
}
} ;
var WorkspacePreview _default = WorkspacePreview ;
// src/Controller.ts
var DELAY _TO _RELOAD _IN _MILLISECOND = 1e3 ;
var RETRY _INTERVAL = 1 ;
var RETRY _TRIALS = 1e3 ;
var DELAY _TO _RENDER _CARD _VIEW _ON _ENTRY _IN _MILLISECOND = 100 ;
var Controller = class extends obsidian . Component {
constructor ( app2 , plugin2 , events , searchInterface ) {
super ( ) ;
this . app = app2 ;
this . plugin = plugin2 ;
this . events = events ;
this . searchInterface = searchInterface ;
this . modeScope = new ModeScope ( ) ;
2026-05-06 17:32:44 +08:00
this . cardViewCheckDebouncer = ( 0 , import _obsidian14 . debounce ) (
this . onCheckCardView ,
DELAY _TO _RELOAD _IN _MILLISECOND ,
true
) ;
2025-08-02 12:09:34 +08:00
this . countSearchItemDetected = 0 ;
}
onunload ( ) {
this . exit ( ) ;
}
onload ( ) {
this . saveLayout ( ) ;
this . setSearchModeTriggers ( ) ;
}
2026-05-06 17:32:44 +08:00
async enter ( ) {
if ( this . modeScope . inSearchMode ) {
return ;
}
this . setHotkeys ( ) ;
this . addChildren ( ) ;
if ( this . plugin . settings ? . autoToggleSidebar ) {
this . collapseOppositeSidedock ( ) ;
}
const shouldDetectSearchItems = this . plugin . settings ? . autoPreviewMode === "cardView" && this . plugin . settings . renderCardsManually === false ;
if ( shouldDetectSearchItems ) {
this . searchInterface . startWatching ( this . events ) ;
await delay ( DELAY _TO _RENDER _CARD _VIEW _ON _ENTRY _IN _MILLISECOND ) ;
this . renewCardViewPage ( ) ;
this . cardViewCheckDebouncer ( ) ;
}
this . modeScope . push ( ) ;
2025-08-02 12:09:34 +08:00
}
reset ( ) {
if ( ! this . modeScope . inSearchMode ) {
return ;
}
this . forget ( ) ;
this . unfocus ( ) ;
2026-05-06 17:32:44 +08:00
this . cardViewComponent ? . detachCards ( ) ;
2025-08-02 12:09:34 +08:00
this . countSearchItemDetected = 0 ;
}
exit ( reason ) {
if ( ! this . modeScope . inSearchMode ) {
return ;
}
this . reset ( ) ;
this . detachHotkeys ( ) ;
this . removeChildren ( ) ;
if ( this . shouldCollapseSidedock ( reason ) ) {
this . collapseSidedock ( ) ;
}
2026-05-06 17:32:44 +08:00
if ( this . plugin . settings ? . autoToggleSidebar ) {
2025-08-02 12:09:34 +08:00
this . restoreOppositeSidedock ( ) ;
}
this . countSearchItemDetected = 0 ;
this . searchInterface . stopWatching ( ) ;
this . unfocus ( ) ;
this . modeScope . reset ( ) ;
}
focus ( ) {
if ( this . currentFocusId === void 0 ) {
return ;
}
this . searchInterface . focusOn ( this . currentFocusId ) ;
2026-05-06 17:32:44 +08:00
this . cardViewComponent ? . focusOn ( this . currentFocusId ) ;
2025-08-02 12:09:34 +08:00
}
open ( direction ) {
if ( this . currentFocusId === void 0 ) {
return ;
}
this . searchInterface . open ( this . currentFocusId , direction ) ;
}
2026-05-06 17:32:44 +08:00
async renewCardViewPage ( ) {
if ( this . plugin . settings ? . autoPreviewMode !== "cardView" )
return ;
this . cardViewComponent ? . detachCards ( ) ;
this . cardViewComponent ? . renderPage ( this . filesToBeRendered ( ) ) ;
if ( this . currentFocusId !== void 0 ) {
this . cardViewComponent ? . focusOn ( this . currentFocusId ? ? 0 ) ;
}
2025-08-02 12:09:34 +08:00
}
filesToBeRendered ( ) {
const cardsPerPage2 = this . cardsPerPage ( ) ;
if ( cardsPerPage2 === void 0 ) {
return [ ] ;
}
2026-05-06 17:32:44 +08:00
const pageId = Math . floor ( ( this . currentFocusId ? ? 0 ) / cardsPerPage2 ) ;
const items = this . plugin . searchInterface ? . resultItems ;
2025-08-02 12:09:34 +08:00
if ( ! items )
return [ ] ;
return items . slice ( pageId * cardsPerPage2 ) . map ( ( item ) => item . file ) ;
}
collapseSidedock ( ) {
2026-05-06 17:32:44 +08:00
this . searchInterface . collapseSidedock ( ) ;
2025-08-02 12:09:34 +08:00
}
collapseOppositeSidedock ( ) {
2026-05-06 17:32:44 +08:00
const collapsed = this . searchInterface . oppositeSidedock ? . collapsed ;
this . searchInterface . collapseOppositeSidedock ( ) ;
2025-08-02 12:09:34 +08:00
this . _restoreOppositeSidedock = ( ) => {
if ( collapsed === false ) {
2026-05-06 17:32:44 +08:00
this . searchInterface . expandOppositeSidedock ( ) ;
2025-08-02 12:09:34 +08:00
}
} ;
}
restoreOppositeSidedock ( ) {
const restoreOppositeSidedock = this . _restoreOppositeSidedock ;
if ( restoreOppositeSidedock === void 0 ) {
return void 0 ;
}
return restoreOppositeSidedock ( ) ;
}
addChildren ( ) {
this . removeChildren ( ) ;
const { settings } = this . plugin ;
if ( settings === void 0 ) {
throw "[ERROR in Core Search Assistant] failed to addChildren: failed to read setting" ;
}
this . outline = new Outline _default ( {
target : document . body ,
props : {
lineWidth : settings . outlineWidth
}
} ) ;
if ( settings . autoPreviewMode === "cardView" ) {
this . renewCardViewComponent ( ) ;
}
}
removeChildren ( ) {
2026-05-06 17:32:44 +08:00
this . outline ? . $destroy ( ) ;
2025-08-02 12:09:34 +08:00
this . outline = void 0 ;
2026-05-06 17:32:44 +08:00
this . cardViewComponent ? . $destroy ( ) ;
2025-08-02 12:09:34 +08:00
this . cardViewComponent = void 0 ;
2026-05-06 17:32:44 +08:00
this . workspacePreviewComponent ? . $destroy ( ) ;
2025-08-02 12:09:34 +08:00
this . workspacePreviewComponent = void 0 ;
}
forget ( ) {
this . currentFocusId = void 0 ;
this . countSearchItemDetected = 0 ;
}
navigateForward ( ) {
let updated = true ;
2026-05-06 17:32:44 +08:00
const numResults = this . searchInterface . count ( ) ? ? 0 ;
2025-08-02 12:09:34 +08:00
if ( this . currentFocusId === void 0 ) {
this . currentFocusId = 0 ;
} else {
this . currentFocusId ++ ;
if ( this . currentFocusId >= numResults ) {
this . currentFocusId = numResults - 1 ;
updated = false ;
}
}
if ( ! updated )
return ;
const { settings } = this . plugin ;
if ( ! settings )
return ;
if ( settings . autoPreviewMode === "cardView" && this . shouldTransitNextPageInCardView ( ) ) {
this . renewCardViewPage ( ) ;
} else if ( settings . autoPreviewMode === "singleView" ) {
this . renewWorkspacePreviewComponent ( ) ;
}
this . focus ( ) ;
}
navigateBack ( ) {
if ( this . currentFocusId === void 0 ) {
return ;
}
let updated = true ;
this . currentFocusId -- ;
if ( this . currentFocusId < 0 ) {
this . currentFocusId = 0 ;
updated = false ;
}
if ( ! updated )
return ;
const { settings } = this . plugin ;
if ( ! settings )
return ;
if ( settings . autoPreviewMode === "cardView" && this . shouldTransitPreviousPageInCardView ( ) ) {
this . renewCardViewPage ( ) ;
} else if ( settings . autoPreviewMode === "singleView" ) {
this . renewWorkspacePreviewComponent ( ) ;
}
this . focus ( ) ;
}
moveToNextPage ( ) {
const pageId = this . pageId ;
if ( pageId === void 0 )
return ;
const pageCount = this . pageCount ;
if ( pageCount === void 0 )
return ;
if ( pageId >= pageCount - 1 )
return ;
const cardsPerPage2 = this . cardsPerPage ( ) ;
if ( cardsPerPage2 === void 0 )
return ;
this . currentFocusId = cardsPerPage2 * ( pageId + 1 ) ;
this . renewCardViewPage ( ) ;
this . focus ( ) ;
}
moveToPreviousPage ( ) {
const pageId = this . pageId ;
if ( pageId === void 0 )
return ;
const pageCount = this . pageCount ;
if ( pageCount === void 0 )
return ;
if ( pageId <= 0 )
return ;
const cardsPerPage2 = this . cardsPerPage ( ) ;
if ( cardsPerPage2 === void 0 )
return ;
this . currentFocusId = cardsPerPage2 * ( pageId - 1 ) ;
this . renewCardViewPage ( ) ;
this . focus ( ) ;
}
unfocus ( ) {
this . searchInterface . unfocus ( ) ;
}
openPreviewModal ( ) {
const { currentFocusId } = this ;
if ( currentFocusId === void 0 ) {
return ;
}
const item = this . searchInterface . getResultItemAt ( currentFocusId ) ;
if ( ! item ) {
return ;
}
new PreviewModal ( this . app , this . plugin , this . modeScope , item ) . open ( ) ;
}
shouldTransitNextPageInCardView ( ) {
if ( this . currentFocusId === void 0 || this . currentFocusId === 0 ) {
return false ;
}
if ( ! this . plugin . settings ) {
return false ;
}
const [ row , column ] = parseCardLayout ( this . plugin . settings . cardViewLayout ) ;
const cardsPerPage2 = row * column ;
return this . currentFocusId % cardsPerPage2 === 0 ;
}
shouldTransitPreviousPageInCardView ( ) {
if ( ! this . plugin . settings ) {
return false ;
}
const [ row , column ] = parseCardLayout ( this . plugin . settings . cardViewLayout ) ;
const cardsPerPage2 = row * column ;
if ( this . currentFocusId === void 0 ) {
return false ;
}
return ( this . currentFocusId + 1 ) % cardsPerPage2 === 0 ;
}
get pageId ( ) {
if ( this . currentFocusId === void 0 )
return void 0 ;
const cardsPerPage2 = this . cardsPerPage ( ) ;
if ( cardsPerPage2 === void 0 )
return void 0 ;
const pageId = Math . floor ( this . currentFocusId / cardsPerPage2 ) ;
return pageId ;
}
get pageCount ( ) {
2026-05-06 17:32:44 +08:00
const numResults = this . plugin . searchInterface ? . count ( ) ;
2025-08-02 12:09:34 +08:00
const cardsPerPage2 = this . cardsPerPage ( ) ;
if ( cardsPerPage2 === void 0 )
return void 0 ;
2026-05-06 17:32:44 +08:00
const pageCount = Math . ceil ( ( numResults ? ? 0 ) / cardsPerPage2 ) ;
2025-08-02 12:09:34 +08:00
return pageCount ;
}
cardsPerPage ( ) {
if ( ! this . plugin . settings ) {
return void 0 ;
}
const [ row , column ] = parseCardLayout ( this . plugin . settings . cardViewLayout ) ;
return row * column ;
}
2026-05-06 17:32:44 +08:00
/ * *
* check layout change
* use for detecting whether layout - change really occurs
* @ returns callback which returns
* /
2025-08-02 12:09:34 +08:00
saveLayout ( ) {
2026-05-06 17:32:44 +08:00
this . app . workspace . onLayoutReady ( async ( ) => {
const inputEl = await retry (
( ) => this . searchInterface . searchInputEl ,
RETRY _INTERVAL ,
RETRY _TRIALS
) ;
this . _layoutChanged = async ( ) => inputEl !== await retry (
( ) => this . searchInterface . searchInputEl ,
RETRY _INTERVAL ,
RETRY _TRIALS
) ;
2025-08-02 12:09:34 +08:00
} ) ;
}
2026-05-06 17:32:44 +08:00
async layoutChanged ( ) {
const shouldRenewController = await this . _layoutChanged ? . ( ) ;
if ( shouldRenewController === void 0 ) {
throw "[ERROR in Core Search Assistant] failed to renewRequired: saveLayout was not called." ;
}
return shouldRenewController ;
}
2025-08-02 12:09:34 +08:00
setSearchModeTriggers ( ) {
2026-05-06 17:32:44 +08:00
this . registerEvent (
this . events . on (
EVENT _SEARCH _RESULT _ITEM _DETECTED ,
this . onSearchResultItemDetected
)
) ;
this . registerEvent (
this . events . on ( EVENT _SORT _ORDER _CHANGED , this . onSortOrderChanged )
) ;
this . app . workspace . onLayoutReady ( async ( ) => {
const appContainerEl = await retry (
( ) => this . app . dom . appContainerEl ,
RETRY _INTERVAL ,
RETRY _TRIALS
) ;
2025-08-02 12:09:34 +08:00
if ( appContainerEl === void 0 ) {
throw "[ERROR in Core Search Assistant] failed to find the app container element" ;
}
2026-05-06 17:32:44 +08:00
const inputEl = await retry (
( ) => this . plugin . searchInterface ? . searchInputEl ,
RETRY _INTERVAL ,
RETRY _TRIALS
) ;
2025-08-02 12:09:34 +08:00
if ( inputEl === void 0 ) {
throw "[ERROR in Core Search Assistant] failed to find the search input form." ;
}
2026-05-06 17:32:44 +08:00
const matchingCaseButtonEl = await retry (
( ) => this . plugin . searchInterface ? . matchingCaseButtonEl ,
RETRY _INTERVAL ,
RETRY _TRIALS
) ;
2025-08-02 12:09:34 +08:00
if ( matchingCaseButtonEl === void 0 ) {
throw "[ERROR in Core Search Assistant] failed to find the matching case button." ;
}
this . registerDomEvent ( appContainerEl , "click" , ( evt ) => {
const targetEl = evt . target ;
if ( ! ( targetEl instanceof HTMLElement ) ) {
return ;
}
2026-05-06 17:32:44 +08:00
if ( this . plugin . searchInterface ? . searchLeaf ? . containerEl . contains (
targetEl
) ) {
2025-08-02 12:09:34 +08:00
if ( ! this . plugin . searchInterface . isBuiltInElementToOpenFile ( targetEl ) )
return ;
}
2026-05-06 17:32:44 +08:00
if ( this . plugin . searchInterface ? . tabHeaderEl ? . contains ( targetEl ) ) {
2025-08-02 12:09:34 +08:00
return ;
}
2026-05-06 17:32:44 +08:00
if ( this . plugin . searchInterface ? . isShowMoreContextButton ( targetEl ) ) {
2025-08-02 12:09:34 +08:00
return ;
}
if ( this . modeScope . depth === 1 ) {
this . exit ( { id : "mouse" , event : evt } ) ;
}
} ) ;
this . registerDomEvent ( matchingCaseButtonEl , "click" , ( ) => {
if ( this . modeScope . inSearchMode ) {
this . reset ( ) ;
}
} ) ;
this . registerDomEvent ( inputEl , "input" , ( ) => {
if ( ! this . modeScope . inSearchMode ) {
this . enter ( ) ;
}
this . reset ( ) ;
} ) ;
this . registerDomEvent ( inputEl , "keypress" , ( evt ) => {
if ( evt . key !== "Enter" ) {
return ;
}
if ( ! this . modeScope . inSearchMode ) {
this . enter ( ) ;
}
this . reset ( ) ;
} ) ;
this . registerDomEvent ( inputEl , "focus" , ( ) => {
if ( ! this . modeScope . inSearchMode ) {
this . enter ( ) ;
}
} ) ;
2026-05-06 17:32:44 +08:00
} ) ;
2025-08-02 12:09:34 +08:00
}
setHotkeys ( ) {
2026-05-06 17:32:44 +08:00
const hotkeyMap = this . plugin . settings ? . searchModeHotkeys ;
2025-08-02 12:09:34 +08:00
if ( ! hotkeyMap )
return ;
const scope = new obsidian . Scope ( ) ;
this . app . keymap . pushScope ( scope ) ;
hotkeyMap . selectNext . forEach ( ( hotkey ) => {
scope . register ( hotkey . modifiers , hotkey . key , ( evt ) => {
evt . preventDefault ( ) ;
this . navigateForward ( ) ;
} ) ;
} ) ;
hotkeyMap . selectPrevious . forEach ( ( hotkey ) => {
scope . register ( hotkey . modifiers , hotkey . key , ( evt ) => {
evt . preventDefault ( ) ;
this . navigateBack ( ) ;
} ) ;
} ) ;
hotkeyMap . open . forEach ( ( hotkey ) => {
scope . register ( hotkey . modifiers , hotkey . key , ( evt ) => {
evt . preventDefault ( ) ;
this . open ( ) ;
this . exit ( ) ;
} ) ;
} ) ;
hotkeyMap . openInNewPane . forEach ( ( hotkey ) => {
scope . register ( hotkey . modifiers , hotkey . key , ( evt ) => {
evt . preventDefault ( ) ;
2026-05-06 17:32:44 +08:00
this . open ( this . plugin . settings ? . splitDirection ) ;
2025-08-02 12:09:34 +08:00
this . exit ( ) ;
} ) ;
} ) ;
hotkeyMap . previewModal . forEach ( ( hotkey ) => {
scope . register ( hotkey . modifiers , hotkey . key , ( ) => {
if ( this . app . vault . config . legacyEditor ) {
return ;
}
this . openPreviewModal ( ) ;
} ) ;
} ) ;
hotkeyMap . showOptions . forEach ( ( hotkey ) => {
scope . register ( hotkey . modifiers , hotkey . key , ( ) => {
new OptionModal ( this . app , this . plugin , this . modeScope ) . open ( ) ;
} ) ;
} ) ;
hotkeyMap . nextPage . forEach ( ( hotkey ) => {
scope . register ( hotkey . modifiers , hotkey . key , ( ) => {
2026-05-06 17:32:44 +08:00
if ( this . plugin . settings ? . autoPreviewMode === "cardView" ) {
2025-08-02 12:09:34 +08:00
this . moveToNextPage ( ) ;
}
} ) ;
} ) ;
hotkeyMap . previousPage . forEach ( ( hotkey ) => {
scope . register ( hotkey . modifiers , hotkey . key , ( ) => {
2026-05-06 17:32:44 +08:00
if ( this . plugin . settings ? . autoPreviewMode === "cardView" ) {
2025-08-02 12:09:34 +08:00
this . moveToPreviousPage ( ) ;
}
} ) ;
} ) ;
hotkeyMap . copyLink . forEach ( ( hotkey ) => {
scope . register ( hotkey . modifiers , hotkey . key , ( ) => {
2026-05-06 17:32:44 +08:00
const item = this . searchInterface . getResultItemAt (
this . currentFocusId ? ? 0
) ;
2025-08-02 12:09:34 +08:00
if ( ! item )
return ;
const { file } = item ;
const internalLink = generateInternalLinkFrom ( this . app , file ) ;
navigator . clipboard . writeText ( internalLink ) ;
new import _obsidian14 . Notice ( "Copy wiki link!" ) ;
} ) ;
} ) ;
scope . register ( [ ] , "Escape" , ( evt ) => {
evt . preventDefault ( ) ;
this . exit ( ) ;
} ) ;
scope . register ( [ ] , "Enter" , ( evt ) => {
setTimeout ( this . focusOnInput , 100 ) ;
2026-05-06 17:32:44 +08:00
const shouldRenderCardsManually = this . plugin . settings ? . autoPreviewMode === "cardView" && this . plugin . settings . renderCardsManually ;
2025-08-02 12:09:34 +08:00
if ( shouldRenderCardsManually ) {
evt . preventDefault ( ) ;
this . reset ( ) ;
this . renewCardViewPage ( ) ;
}
} ) ;
this . _detachHotkeys = ( ) => {
this . app . keymap . popScope ( scope ) ;
} ;
}
detachHotkeys ( ) {
const detachHotkeys = this . _detachHotkeys ;
if ( detachHotkeys === void 0 ) {
return ;
}
detachHotkeys ( ) ;
}
get onSearchResultItemDetected ( ) {
return ( ) => {
2026-05-06 17:32:44 +08:00
if ( this . plugin . settings ? . autoPreviewMode !== "cardView" ) {
2025-08-02 12:09:34 +08:00
return ;
}
if ( this . currentFocusId !== void 0 ) {
return ;
}
if ( this . countSearchItemDetected === 0 ) {
2026-05-06 17:32:44 +08:00
this . cardViewComponent ? . detachCards ( ) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
const item = this . searchInterface . getResultItemAt (
this . countSearchItemDetected
) ;
2025-08-02 12:09:34 +08:00
if ( ! item )
return ;
2026-05-06 17:32:44 +08:00
this . cardViewComponent ? . addCard ( item . file ) ;
2025-08-02 12:09:34 +08:00
this . cardViewCheckDebouncer ( ) ;
this . countSearchItemDetected ++ ;
} ;
}
renewCardViewComponent ( ) {
2026-05-06 17:32:44 +08:00
this . cardViewComponent ? . $destroy ( ) ;
2025-08-02 12:09:34 +08:00
const { settings } = this . plugin ;
if ( ! settings )
return ;
const focusEl = this . searchInterface . searchInputEl ;
if ( ! focusEl )
return ;
const layout = parseCardLayout ( settings . cardViewLayout ) ;
this . app . workspace . onLayoutReady ( ( ) => {
const containerEl = this . app . workspace . rootSplit . containerEl ;
const cardViewComponent = new CardViewComponent _default ( {
target : containerEl ,
props : {
layout ,
focusEl
}
} ) ;
this . cardViewComponent = cardViewComponent ;
} ) ;
}
renewWorkspacePreviewComponent ( ) {
2026-05-06 17:32:44 +08:00
this . workspacePreviewComponent ? . $destroy ( ) ;
2025-08-02 12:09:34 +08:00
if ( this . currentFocusId === void 0 )
return ;
const focusEl = this . searchInterface . searchInputEl ;
if ( ! focusEl )
return ;
const item = this . searchInterface . getResultItemAt ( this . currentFocusId ) ;
if ( ! item )
return ;
this . app . workspace . onLayoutReady ( ( ) => {
const containerEl = this . app . workspace . rootSplit . containerEl ;
const workspacePreviewComponent = new WorkspacePreview _default ( {
target : containerEl ,
props : {
file : item . file ,
2026-05-06 17:32:44 +08:00
matches : item . result . content ? ? [ ] ,
2025-08-02 12:09:34 +08:00
focusEl
}
} ) ;
this . workspacePreviewComponent = workspacePreviewComponent ;
} ) ;
}
get focusOnInput ( ) {
2026-05-06 17:32:44 +08:00
return async ( ) => {
const inputEl = await retry (
( ) => this . plugin . searchInterface ? . searchInputEl ,
RETRY _INTERVAL ,
RETRY _TRIALS
) ;
2025-08-02 12:09:34 +08:00
if ( inputEl === void 0 ) {
throw "[ERROR in Core Search Assistant] failed to find the search input form." ;
}
inputEl . focus ( ) ;
2026-05-06 17:32:44 +08:00
} ;
2025-08-02 12:09:34 +08:00
}
get onSortOrderChanged ( ) {
return ( ) => {
this . reset ( ) ;
2026-05-06 17:32:44 +08:00
if ( this . plugin . settings ? . autoPreviewMode === "cardView" ) {
2025-08-02 12:09:34 +08:00
this . renewCardViewPage ( ) ;
}
} ;
}
shouldCollapseSidedock ( reason ) {
2026-05-06 17:32:44 +08:00
if ( ! this . plugin . settings ? . autoToggleSidebar ) {
2025-08-02 12:09:34 +08:00
return false ;
}
if ( reason === void 0 ) {
return true ;
}
if ( reason . id !== "mouse" ) {
return true ;
}
const targetEl = reason . event . target ;
if ( ! ( targetEl instanceof HTMLElement ) ) {
return true ;
}
2026-05-06 17:32:44 +08:00
return ! this . searchInterface . sideDock ? . containerEl . contains ( targetEl ) ;
2025-08-02 12:09:34 +08:00
}
get onCheckCardView ( ) {
return ( ) => {
const { cardViewComponent } = this ;
if ( ! cardViewComponent )
return ;
2026-05-06 17:32:44 +08:00
const ok = cardViewComponent . checkCardsRenderedCorrectly (
this . filesToBeRendered ( )
) ;
2025-08-02 12:09:34 +08:00
if ( ! ok ) {
this . reset ( ) ;
this . renewCardViewPage ( ) ;
}
} ;
}
} ;
// src/interfaces/SearchComponentInterface.ts
2026-05-06 17:32:44 +08:00
var import _obsidian16 = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
// src/types/Guards.ts
2026-05-06 17:32:44 +08:00
var import _obsidian15 = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
var SORT _ORDER _IN _SEARCH = [
"alphabeticalReverse" ,
"alphabetical" ,
"byModifiedTime" ,
"byModifiedTimeReverse" ,
"byCreatedTime" ,
"byCreatedTimeReverse"
] ;
function isSearchView ( view ) {
if ( typeof view !== "object" ) {
return false ;
}
if ( view === null ) {
return false ;
}
const {
matchingCase ,
explainSearch ,
dom ,
setCollapseAll ,
setExplainSearch ,
setExtraContext ,
setMatchingCase ,
setSortOrder ,
searchInfoEl ,
searchComponent
} = view ;
if ( typeof matchingCase !== "boolean" ) {
return false ;
}
if ( typeof explainSearch !== "boolean" ) {
return false ;
}
if ( ! isSearchDom ( dom ) ) {
return false ;
}
if ( typeof searchComponent !== "object" ) {
return false ;
}
if ( typeof searchInfoEl !== "object" ) {
return false ;
}
if ( ! ( searchInfoEl instanceof HTMLDivElement ) ) {
return false ;
}
if ( ! ( setCollapseAll instanceof Function ) ) {
return false ;
}
if ( ! ( setExplainSearch instanceof Function ) ) {
return false ;
}
if ( ! ( setExtraContext instanceof Function ) ) {
return false ;
}
if ( ! ( setMatchingCase instanceof Function ) ) {
return false ;
}
if ( ! ( setSortOrder instanceof Function ) ) {
return false ;
}
return true ;
}
function isSearchDom ( obj ) {
if ( typeof obj !== "object" ) {
return false ;
}
if ( obj === null ) {
return false ;
}
const { extraContext , collapseAll , sortOrder , vChildren , childrenEl } = obj ;
if ( typeof extraContext !== "boolean" ) {
return false ;
}
if ( typeof collapseAll !== "boolean" ) {
return false ;
}
if ( typeof sortOrder !== "string" ) {
return false ;
}
if ( ! SORT _ORDER _IN _SEARCH . includes ( sortOrder ) ) {
return false ;
}
if ( ! isSearchResultItemGroup ( vChildren ) ) {
return false ;
}
if ( typeof childrenEl !== "object" ) {
return false ;
}
if ( ! ( childrenEl instanceof HTMLElement ) ) {
return false ;
}
return true ;
}
function isSearchResultItemGroup ( obj ) {
if ( typeof obj !== "object" || obj === null ) {
return false ;
}
const { _children : children2 } = obj ;
if ( typeof children2 !== "object" ) {
return false ;
}
2026-05-06 17:32:44 +08:00
if ( ! Array . isArray ( children2 ) ) {
2025-08-02 12:09:34 +08:00
return false ;
}
for ( const child of children2 ) {
if ( ! isSearchResultItem ( child ) ) {
return false ;
}
}
return true ;
}
function isSearchResultItem ( obj ) {
if ( typeof obj !== "object" || obj === null ) {
return false ;
}
const { file , containerEl } = obj ;
if ( ! ( file instanceof import _obsidian15 . TFile ) ) {
return false ;
}
if ( ! ( containerEl instanceof HTMLElement ) ) {
return false ;
}
return true ;
}
// src/utils/LinkedList.ts
var LinkedList = class {
constructor ( events , eventId ) {
2026-05-06 17:32:44 +08:00
this . unlinkedPool = /* @__PURE__ */ new Map ( ) ;
2025-08-02 12:09:34 +08:00
this . events = events ;
this . eventId = eventId ;
}
2026-05-06 17:32:44 +08:00
// attach nodes recursively
2025-08-02 12:09:34 +08:00
structure ( cur , pre ) {
let linked = false ;
if ( pre === void 0 ) {
this . setRoot ( cur ) ;
linked = true ;
this . signal ( ) ;
} else if ( this . tail !== void 0 && pre === this . tail . entity ) {
this . link ( cur ) ;
linked = true ;
this . unlinkedPool . delete ( cur ) ;
this . signal ( ) ;
}
if ( linked ) {
if ( ! this . unlinkedPool . has ( cur ) ) {
return ;
}
const next = this . unlinkedPool . get ( cur ) ;
if ( next === void 0 ) {
return ;
}
this . structure ( next , cur ) ;
} else {
if ( pre ) {
this . unlinkedPool . set ( pre , cur ) ;
}
}
}
setRoot ( entity ) {
const rootNode = {
entity ,
pre : void 0 ,
next : void 0
} ;
this . head = rootNode ;
this . tail = rootNode ;
}
link ( cur ) {
if ( ! this . tail ) {
return ;
}
const currentTail = this . tail ;
currentTail . next = {
entity : cur ,
pre : currentTail ,
next : void 0
} ;
this . tail = currentTail . next ;
}
clean ( ) {
this . head = void 0 ;
this . tail = void 0 ;
2026-05-06 17:32:44 +08:00
this . unlinkedPool = /* @__PURE__ */ new Map ( ) ;
2025-08-02 12:09:34 +08:00
}
2026-05-06 17:32:44 +08:00
// let outside know a node is attached
2025-08-02 12:09:34 +08:00
signal ( ) {
this . events . trigger ( this . eventId ) ;
}
} ;
// src/interfaces/SearchComponentInterface.ts
var SearchComponentInterface = class extends import _obsidian16 . Component {
constructor ( app2 , plugin2 , events ) {
super ( ) ;
this . observationConfig = {
childList : true
} ;
2026-05-06 17:32:44 +08:00
this . onObservedCallback = async ( mutations , _observer ) => {
2025-08-02 12:09:34 +08:00
for ( const mutation of mutations ) {
if ( mutation . addedNodes . length === 0 ) {
continue ;
}
const pre = mutation . previousSibling ;
if ( ! ( pre instanceof HTMLElement ) ) {
continue ;
}
for ( const node of Array . from ( mutation . addedNodes ) ) {
if ( ! ( node instanceof HTMLElement ) ) {
continue ;
}
const isSearchResultItem2 = node . tagName === "DIV" && node . hasClass ( "tree-item" ) && node . hasClass ( "search-result" ) ;
if ( ! isSearchResultItem2 ) {
continue ;
}
if ( ! this . linkedList ) {
return ;
}
2026-05-06 17:32:44 +08:00
this . linkedList . structure (
node ,
this . isRootSearchResult ( pre ) ? void 0 : pre
) ;
2025-08-02 12:09:34 +08:00
}
}
2026-05-06 17:32:44 +08:00
} ;
2025-08-02 12:09:34 +08:00
this . app = app2 ;
this . plugin = plugin2 ;
this . events = events ;
2026-05-06 17:32:44 +08:00
this . observer = new MutationObserver (
this . onObservedCallback . bind ( this )
) ;
2025-08-02 12:09:34 +08:00
}
onload ( ) {
this . app . workspace . onLayoutReady ( ( ) => {
this . renewSortOrderInfo ( ) ;
this . registerDomEvent ( document , "click" , ( ) => {
this . renewSortOrderInfo ( this . events ) ;
} ) ;
} ) ;
}
onunload ( ) {
2026-05-06 17:32:44 +08:00
this . sortOrderContainerEl ? . empty ( ) ;
this . sortOrderContainerEl ? . remove ( ) ;
2025-08-02 12:09:34 +08:00
this . observer . disconnect ( ) ;
}
toggleMatchingCase ( ) {
const view = this . searchView ;
2026-05-06 17:32:44 +08:00
view ? . setMatchingCase ( ! view . matchingCase ) ;
2025-08-02 12:09:34 +08:00
}
toggleExplainSearch ( ) {
const view = this . searchView ;
2026-05-06 17:32:44 +08:00
view ? . setExplainSearch ( ! view . explainSearch ) ;
2025-08-02 12:09:34 +08:00
}
toggleCollapseAll ( ) {
const view = this . searchView ;
2026-05-06 17:32:44 +08:00
view ? . setCollapseAll ( ! view . dom . collapseAll ) ;
2025-08-02 12:09:34 +08:00
}
toggleExtraContext ( ) {
const view = this . searchView ;
2026-05-06 17:32:44 +08:00
view ? . setExtraContext ( ! view . dom . extraContext ) ;
2025-08-02 12:09:34 +08:00
}
setSortOrder ( sortOrder ) {
const view = this . searchView ;
2026-05-06 17:32:44 +08:00
const originalOrder = view ? . dom . sortOrder ;
view ? . setSortOrder ( sortOrder ) ;
2025-08-02 12:09:34 +08:00
return sortOrder !== originalOrder ;
}
focusOn ( pos ) {
this . unfocus ( ) ;
const item = this . getResultItemAt ( pos ) ;
if ( ! item ) {
return ;
}
2026-05-06 17:32:44 +08:00
item . containerEl . addClass (
"core-search-assistant_search-result-items-focus"
) ;
item . containerEl . scrollIntoView (
this . plugin . settings ? . keepSelectedItemsCentered ? { block : "center" } : { block : "nearest" }
) ;
2025-08-02 12:09:34 +08:00
}
unfocus ( ) {
const items = this . resultItems ;
items . forEach ( ( item ) => {
2026-05-06 17:32:44 +08:00
item . containerEl . removeClass (
"core-search-assistant_search-result-items-focus"
) ;
2025-08-02 12:09:34 +08:00
} ) ;
}
2026-05-06 17:32:44 +08:00
async open ( pos , direction ) {
const item = this . getResultItemAt ( pos ) ;
if ( ! item ) {
return ;
}
const { file } = item ;
const leaf = direction === void 0 ? this . app . workspace . getMostRecentLeaf ( ) : this . app . workspace . splitActiveLeaf ( direction ) ;
await leaf . openFile ( file ) ;
this . app . workspace . setActiveLeaf ( leaf , true , true ) ;
2025-08-02 12:09:34 +08:00
}
renewSortOrderInfo ( events ) {
if ( ! this . sortOrderContainerEl ) {
this . createSortOrderEls ( ) ;
}
const view = this . searchView ;
if ( ! view ) {
return ;
}
const sortOrder = view . dom . sortOrder ;
if ( ! this . sortOrderContentEl ) {
return ;
}
const originalContent = this . sortOrderContentEl . textContent ;
this . sortOrderContentEl . textContent = searchOptions [ sortOrder ] . description ;
if ( events !== void 0 && originalContent !== this . sortOrderContentEl . textContent ) {
events . trigger ( EVENT _SORT _ORDER _CHANGED ) ;
}
}
count ( ) {
2026-05-06 17:32:44 +08:00
const results = this . searchView ? . dom . vChildren . _children ;
2025-08-02 12:09:34 +08:00
if ( ! results ) {
return 0 ;
}
return results . length ;
}
get resultItems ( ) {
2026-05-06 17:32:44 +08:00
return this . searchView ? . dom . vChildren . _children ? ? [ ] ;
2025-08-02 12:09:34 +08:00
}
getResultItemAt ( pos ) {
2026-05-06 17:32:44 +08:00
return this . searchView ? . dom . vChildren . _children [ pos ] ;
2025-08-02 12:09:34 +08:00
}
get searchInputEl ( ) {
2026-05-06 17:32:44 +08:00
return this . searchView ? . searchComponent . inputEl ;
2025-08-02 12:09:34 +08:00
}
startWatching ( events ) {
2026-05-06 17:32:44 +08:00
this . linkedList = new LinkedList (
events ,
EVENT _SEARCH _RESULT _ITEM _DETECTED
) ;
const childrenContainerEl = this . searchView ? . dom . childrenEl ;
2025-08-02 12:09:34 +08:00
if ( ! ( childrenContainerEl instanceof HTMLElement ) ) {
throw "[ERROR in Core Search Assistant] failed to SearchComponentInterface#startWatching: childrenContainerEl is not an instance of HTMLElement" ;
}
this . observer . observe ( childrenContainerEl , this . observationConfig ) ;
}
stopWatching ( ) {
this . observer . disconnect ( ) ;
}
collapseOppositeSidedock ( ) {
const sideDock = this . oppositeSidedock ;
if ( sideDock === void 0 ) {
throw "[ERROR in Core Search Assistant] failed to collapseOppositeSidedock: failed to fetch the opposite sidedock" ;
}
sideDock . collapse ( ) ;
}
expandOppositeSidedock ( ) {
const sideDock = this . oppositeSidedock ;
if ( sideDock === void 0 ) {
throw "[ERROR in Core Search Assistant] failed to expandOppositeSidedock: failed to fetch the opposite sidedock" ;
}
sideDock . expand ( ) ;
}
collapseSidedock ( ) {
const sideDock = this . sideDock ;
if ( sideDock === void 0 ) {
throw "[ERROR in Core Search Assistant] failed to collapseSidedock: failed to fetch the sidedock" ;
}
sideDock . collapse ( ) ;
}
get sideDock ( ) {
const leaf = this . searchLeaf ;
if ( leaf === void 0 ) {
return void 0 ;
}
const parent = leaf . getRoot ( ) ;
if ( parent instanceof import _obsidian16 . WorkspaceSidedock ) {
return parent ;
}
2026-05-06 17:32:44 +08:00
return void 0 ;
2025-08-02 12:09:34 +08:00
}
get oppositeSidedock ( ) {
const leaf = this . searchLeaf ;
if ( leaf === void 0 ) {
return void 0 ;
}
const parent = leaf . getRoot ( ) ;
if ( parent === this . app . workspace . leftSplit ) {
const opposite = this . app . workspace . rightSplit ;
return opposite instanceof import _obsidian16 . WorkspaceSidedock ? opposite : void 0 ;
2026-05-06 17:32:44 +08:00
}
if ( parent === this . app . workspace . rightSplit ) {
2025-08-02 12:09:34 +08:00
const opposite = this . app . workspace . leftSplit ;
return opposite instanceof import _obsidian16 . WorkspaceSidedock ? opposite : void 0 ;
}
2026-05-06 17:32:44 +08:00
return void 0 ;
2025-08-02 12:09:34 +08:00
}
createSortOrderEls ( ) {
this . sortOrderContainerEl = createEl ( "div" , {
cls : "search-info-container"
} ) ;
this . sortOrderContentEl = this . sortOrderContainerEl . createEl ( "div" ) ;
const view = this . searchView ;
if ( ! view ) {
2026-05-06 17:32:44 +08:00
return ;
2025-08-02 12:09:34 +08:00
}
this . sortOrderContainerEl . insertAfter ( view . searchInfoEl ) ;
}
get matchingCaseButtonEl ( ) {
2026-05-06 17:32:44 +08:00
return this . searchView ? . matchingCaseButtonEl ;
2025-08-02 12:09:34 +08:00
}
get tabHeaderEl ( ) {
2026-05-06 17:32:44 +08:00
return this . searchLeaf ? . tabHeaderEl ;
2025-08-02 12:09:34 +08:00
}
isBuiltInElementToOpenFile ( el ) {
const isFileNameContainerEl = el . tagName === "DIV" && el . hasClass ( "tree-item-inner" ) ;
const isMatchCountContainerEl = el . tagName === "DIV" && el . hasClass ( "tree-item-flair-outer" ) ;
const isMatchContainerEl = el . tagName === "DIV" && el . hasClass ( "search-result-file-match" ) ;
if ( isFileNameContainerEl || isMatchContainerEl || isMatchCountContainerEl ) {
return true ;
}
const parentEl = el . parentElement ;
if ( parentEl === null ) {
return false ;
}
2026-05-06 17:32:44 +08:00
return this . isBuiltInElementToOpenFile ( parentEl ) ;
2025-08-02 12:09:34 +08:00
}
isShowMoreContextButton ( el ) {
return el . tagName === "DIV" && el . hasClass ( "search-result-hover-button" ) ;
}
2026-05-06 17:32:44 +08:00
// get changeSortOrderButtonEl(): HTMLElement | undefined {
// const changeSortOrderButtonEl =
// this.searchView?.headerDom.navButtonsEl.querySelector(
// 'div.nav-action-button[aria-label="Change sort order"]'
// );
// return changeSortOrderButtonEl instanceof HTMLElement
// ? changeSortOrderButtonEl
// : undefined;
// }
2025-08-02 12:09:34 +08:00
get searchView ( ) {
const leaf = this . searchLeaf ;
if ( ! leaf ) {
return void 0 ;
}
const view = leaf . view ;
return isSearchView ( view ) ? view : void 0 ;
}
get searchLeaf ( ) {
return this . app . workspace . getLeavesOfType ( "search" ) [ 0 ] ;
}
isRootSearchResult ( el ) {
return el . tagName === "DIV" && ! el . hasClass ( "tree-item" ) && ! el . hasClass ( "search-result" ) ;
}
2026-05-06 17:32:44 +08:00
// async watchSortOrderChangeByClick() {
// const callback = async (evt: Event) => {
// this.renewSortOrderInfo();
// if (evt.currentTarget === null) {
// return;
// }
// evt.currentTarget.removeEventListener('click', callback);
// };
// await new Promise((resolve) => setTimeout(resolve, 1)); // prevent callback from being called immediately
// document.addEventListener('click', callback);
// }
// getSortOrderSettingButton(): HTMLElement | undefined {
// const view = this.getSearchView();
// const buttonsEl = view?.headerDom.navButtonsEl;
// if (!buttonsEl) {
// return undefined;
// }
// const sortOrderSettingButtonEl = buttonsEl.querySelector(
// 'div.nav-action-button[aria-label="Change sort order"]'
// );
// return sortOrderSettingButtonEl
// ? (sortOrderSettingButtonEl as HTMLElement)
// : undefined;
// }
2025-08-02 12:09:34 +08:00
} ;
// src/main.ts
2026-05-06 17:32:44 +08:00
var import _obsidian17 = require ( "obsidian" ) ;
2025-08-02 12:09:34 +08:00
var CoreSearchAssistantPlugin = class extends import _obsidian17 . Plugin {
2026-05-06 17:32:44 +08:00
async onload ( ) {
await this . loadSettings ( ) ;
this . events = new CoreSearchAssistantEvents ( ) ;
this . searchInterface = this . addChild (
new SearchComponentInterface ( this . app , this , this . events )
) ;
this . controller = this . addChild (
new Controller ( this . app , this , this . events , this . searchInterface )
) ;
this . watchLayoutChange ( ) ;
this . setSvelteStoreValues ( ) ;
this . addSettingTab ( new CoreSearchAssistantSettingTab ( this . app , this ) ) ;
}
// override onunload() {}
async loadSettings ( ) {
this . settings = deepMerge ( DEFAULT _SETTINGS , await this . loadData ( ) ) ;
}
async saveSettings ( ) {
await this . saveData ( this . settings ) ;
2025-08-02 12:09:34 +08:00
}
renewController ( ) {
if ( this . controller ) {
this . removeChild ( this . controller ) ;
}
if ( this . events === void 0 ) {
throw "[ERROR in Core Search Interface] failed to renewController: plugin.events = undefined" ;
}
if ( this . searchInterface === void 0 ) {
throw "[ERROR in Core Search Interface] failed to renewController: plugin.searchInterface = undefined" ;
}
2026-05-06 17:32:44 +08:00
this . controller = this . addChild (
new Controller ( this . app , this , this . events , this . searchInterface )
) ;
2025-08-02 12:09:34 +08:00
}
watchLayoutChange ( ) {
this . app . workspace . onLayoutReady ( ( ) => {
2026-05-06 17:32:44 +08:00
this . app . workspace . on ( "layout-change" , async ( ) => {
if ( await this . controller ? . layoutChanged ( ) ) {
2025-08-02 12:09:34 +08:00
this . renewController ( ) ;
}
2026-05-06 17:32:44 +08:00
} ) ;
2025-08-02 12:09:34 +08:00
} ) ;
}
setSvelteStoreValues ( ) {
plugin . set ( this ) ;
app . set ( this . app ) ;
}
} ;
2026-05-06 17:32:44 +08:00
/* nosourcemap */