@@ -396,32 +396,55 @@ const translator: Record<string, Translator> = {
396
396
placeholder : "Enter any text" ,
397
397
} ,
398
398
"created by" : {
399
- callback : ( { source, target } ) => [
400
- {
401
- type : "data-pattern" ,
402
- arguments : [
403
- { type : "variable" , value : source } ,
404
- { type : "constant" , value : ":create/user" } ,
405
- { type : "variable" , value : `${ source } -User` } ,
406
- ] ,
407
- } ,
408
- {
409
- type : "data-pattern" ,
410
- arguments : [
411
- { type : "variable" , value : `${ source } -User` } ,
412
- { type : "constant" , value : ":user/display-page" } ,
413
- { type : "variable" , value : `${ source } -User-Display` } ,
414
- ] ,
415
- } ,
416
- {
417
- type : "data-pattern" ,
418
- arguments : [
419
- { type : "variable" , value : `${ source } -User-Display` } ,
420
- { type : "constant" , value : ":node/title" } ,
421
- { type : "constant" , value : `"${ normalizePageTitle ( target ) } "` } ,
422
- ] ,
423
- } ,
424
- ] ,
399
+ callback : ( { source, target } ) => {
400
+ const initialDatalog : DatalogClause [ ] = [
401
+ {
402
+ type : "data-pattern" ,
403
+ arguments : [
404
+ { type : "variable" , value : source } ,
405
+ { type : "constant" , value : ":create/user" } ,
406
+ { type : "variable" , value : `${ source } -User` } ,
407
+ ] ,
408
+ } ,
409
+ {
410
+ type : "data-pattern" ,
411
+ arguments : [
412
+ { type : "variable" , value : `${ source } -User` } ,
413
+ { type : "constant" , value : ":user/display-page" } ,
414
+ { type : "variable" , value : `${ source } -User-Display` } ,
415
+ ] ,
416
+ } ,
417
+ ] ;
418
+ return INPUT_REGEX . test ( target )
419
+ ? [
420
+ ...initialDatalog ,
421
+ {
422
+ type : "data-pattern" ,
423
+ arguments : [
424
+ { type : "variable" , value : `${ source } -User-Display` } ,
425
+ { type : "constant" , value : ":node/title" } ,
426
+ {
427
+ type : "variable" ,
428
+ value : target . replace ( INPUT_REGEX , "" ) ,
429
+ } ,
430
+ ] ,
431
+ } ,
432
+ ]
433
+ : [
434
+ ...initialDatalog ,
435
+ {
436
+ type : "data-pattern" ,
437
+ arguments : [
438
+ { type : "variable" , value : `${ source } -User-Display` } ,
439
+ { type : "constant" , value : ":node/title" } ,
440
+ {
441
+ type : "constant" ,
442
+ value : `"${ normalizePageTitle ( target ) } "` ,
443
+ } ,
444
+ ] ,
445
+ } ,
446
+ ] ;
447
+ } ,
425
448
targetOptions : ( ) =>
426
449
(
427
450
window . roamAlphaAPI . data . fast . q (
@@ -756,7 +779,7 @@ const translator: Record<string, Translator> = {
756
779
{ type : "variable" , value : `${ target } -TLDraw-Value` } ,
757
780
] ,
758
781
} ,
759
- } ,
782
+ } ,
760
783
{
761
784
type : "fn-expr" ,
762
785
fn : "get" ,
0 commit comments