@@ -19,17 +19,18 @@ import {
19
19
20
20
splitByLines , splitBySentences , splitByWords ,
21
21
removeNewLines , removeHTML , parseYoutubeTimestamp ,
22
- lowerCase , upperCase , titleCaseWords , titleCaseSentences , magicBold ,
22
+ lowerCase , upperCase , titleCaseWords , titleCaseSentences ,
23
23
} from './commands'
24
+ import { MARKUP , magicQuotes , magicWrap } from './commands/magic_markup'
24
25
import { improveCursorMovementFeature , improveSearchFeature , spareBlocksFeature } from './features'
25
26
import { borderView , columnsView , galleryView , hideDotRefs , tabularView } from './views'
26
27
import { getChosenBlocks , p , scrollToBlock } from './utils'
27
- import { magicCode , magicHighlight , magicItalics , magicRef , magicStrikethrough , magicTag , magicUnderline } from './commands/magic_markup'
28
28
29
29
30
30
const DEV = process . env . NODE_ENV === 'development'
31
31
32
32
const defaultSpareBlocksSpace = 20
33
+ const defaultMagicQuotes = '""'
33
34
34
35
const settingsSchema : SettingSchemaDesc [ ] = [
35
36
{
@@ -50,6 +51,15 @@ const settingsSchema: SettingSchemaDesc[] = [
50
51
` . trim ( ) ,
51
52
default : null ,
52
53
} ,
54
+ {
55
+ key : 'magicQuotes' ,
56
+ title : 'Use this quotes for «Magic quotes» command' ,
57
+ description : `
58
+ <p>Default is <code>${ defaultMagicQuotes } </code>.</p>
59
+ ` . trim ( ) ,
60
+ type : 'string' ,
61
+ default : defaultMagicQuotes ,
62
+ } ,
53
63
{
54
64
key : 'headingFeatures' ,
55
65
type : 'heading' ,
@@ -208,6 +218,18 @@ async function postInit(settings) {
208
218
await onAppSettingsChanged ( settings , undefined )
209
219
}
210
220
async function onAppSettingsChanged ( current , old ) {
221
+ if ( current . magicQuotes !== old ?. magicQuotes ) {
222
+ if ( current . magicQuotes . length === 0 )
223
+ current . magicQuotes = defaultMagicQuotes
224
+ if ( current . magicQuotes . length === 1 )
225
+ current . magicQuotes += current . magicQuotes
226
+ if ( current . magicQuotes . length > 2 )
227
+ current . magicQuotes = current . magicQuotes . slice ( 0 , 2 )
228
+
229
+ if ( current . magicQuotes !== logseq . settings ! . magicQuotes )
230
+ logseq . settings ! . magicQuotes = current . magicQuotes
231
+ }
232
+
211
233
if ( ! old || current . enableHomeEnd !== old . enableHomeEnd ) {
212
234
improveCursorMovementFeature ( false )
213
235
if ( current . enableHomeEnd === 'Yes' )
@@ -447,42 +469,65 @@ async function main() {
447
469
label : ICON + ' Magic **bold**' , key : 'mc-7-update-14-magic-bold' ,
448
470
// @ts -expect-error
449
471
keybinding : { } ,
450
- } , ( e ) => updateBlocksCommand ( magicBold , false , false ) )
472
+ } , ( e ) => updateBlocksCommand (
473
+ ( content , level , block , parent ) => { return magicWrap ( block , content , MARKUP . bold ) } ,
474
+ false , false ) )
451
475
logseq . App . registerCommandPalette ( {
452
476
label : ICON + ' Magic _italics_' , key : 'mc-7-update-15-magic-italics' ,
453
477
// @ts -expect-error
454
478
keybinding : { } ,
455
- } , ( e ) => updateBlocksCommand ( magicItalics , false , false ) )
479
+ } , ( e ) => updateBlocksCommand (
480
+ ( content , level , block , parent ) => { return magicWrap ( block , content , MARKUP . italics ) } ,
481
+ false , false ) )
456
482
logseq . App . registerCommandPalette ( {
457
483
label : ICON + ' Magic ~~strikethrough~~' , key : 'mc-7-update-16-magic-strikethrough' ,
458
484
// @ts -expect-error
459
485
keybinding : { } ,
460
- } , ( e ) => updateBlocksCommand ( magicStrikethrough , false , false ) )
486
+ } , ( e ) => updateBlocksCommand (
487
+ ( content , level , block , parent ) => { return magicWrap ( block , content , MARKUP . strikethrough ) } ,
488
+ false , false ) )
461
489
logseq . App . registerCommandPalette ( {
462
490
label : ICON + ' Magic ==highlight==' , key : 'mc-7-update-17-magic-highlight' ,
463
491
// @ts -expect-error
464
492
keybinding : { } ,
465
- } , ( e ) => updateBlocksCommand ( magicHighlight , false , false ) )
493
+ } , ( e ) => updateBlocksCommand (
494
+ ( content , level , block , parent ) => { return magicWrap ( block , content , MARKUP . highlight ) } ,
495
+ false , false ) )
466
496
logseq . App . registerCommandPalette ( {
467
497
label : ICON + ' Magic underline' , key : 'mc-7-update-18-magic-underline' ,
468
498
// @ts -expect-error
469
499
keybinding : { } ,
470
- } , ( e ) => updateBlocksCommand ( magicUnderline , false , false ) )
500
+ } , ( e ) => updateBlocksCommand (
501
+ ( content , level , block , parent ) => { return magicWrap ( block , content , MARKUP . underline ) } ,
502
+ false , false ) )
471
503
logseq . App . registerCommandPalette ( {
472
504
label : ICON + ' Magic `code`' , key : 'mc-7-update-19-magic-code' ,
473
505
// @ts -expect-error
474
506
keybinding : { } ,
475
- } , ( e ) => updateBlocksCommand ( magicCode , false , false ) )
507
+ } , ( e ) => updateBlocksCommand (
508
+ ( content , level , block , parent ) => { return magicWrap ( block , content , MARKUP . code ) } ,
509
+ false , false ) )
476
510
logseq . App . registerCommandPalette ( {
477
511
label : ICON + ' Magic [[reference]]' , key : 'mc-7-update-20-magic-ref' ,
478
512
// @ts -expect-error
479
513
keybinding : { } ,
480
- } , ( e ) => updateBlocksCommand ( magicRef , false , false ) )
514
+ } , ( e ) => updateBlocksCommand (
515
+ ( content , level , block , parent ) => { return magicWrap ( block , content , MARKUP . ref ) } ,
516
+ false , false ) )
481
517
logseq . App . registerCommandPalette ( {
482
518
label : ICON + ' Magic #tag' , key : 'mc-7-update-21-magic-tag' ,
483
519
// @ts -expect-error
484
520
keybinding : { } ,
485
- } , ( e ) => updateBlocksCommand ( magicTag , false , false ) )
521
+ } , ( e ) => updateBlocksCommand (
522
+ ( content , level , block , parent ) => { return magicWrap ( block , content , MARKUP . tag ) } ,
523
+ false , false ) )
524
+ logseq . App . registerCommandPalette ( {
525
+ label : ICON + ' Magic "quotes"' , key : 'mc-7-update-22-magic-quotes' ,
526
+ // @ts -expect-error
527
+ keybinding : { } ,
528
+ } , ( e ) => updateBlocksCommand (
529
+ ( content , level , block , parent ) => { return magicQuotes ( block , content , settings . magicQuotes ) } ,
530
+ false , false ) )
486
531
487
532
488
533
// Navigation
0 commit comments