Skip to content

Commit 4a660f5

Browse files
committed
feat: different icons for windows & other platforms
1 parent 6b1e700 commit 4a660f5

File tree

4 files changed

+30
-22
lines changed

4 files changed

+30
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Missing, but helpful commands for [Logseq](https://logseq.com).
6565
## FAQ
6666
### How to change default shortcut for the particular command?
6767
1. Open «Settings» → «Keymap» (or press `g s`).
68-
2. Copy this emoji «🪚» and insert it to search input.
68+
2. Copy this emoji «🪚» (for Windows use «🔪») and insert it to search input.
6969
3. Change any shortcut you want <br/><img width="700px" src="https://github.com/stdword/logseq13-shorten-my-links/assets/1984175/76d23bb5-f7fb-4ed5-acee-ddb138cbd334"/>
7070

7171

src/app.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { BlockEntity, SettingSchemaDesc } from '@logseq/libs/dist/LSPlugin.user'
22

3-
import { reverseBlocksCommand, shuffleBlocksCommand, sortBlocksCommand, splitByParagraphsCommand, toggleAutoHeadingCommand } from './commands'
3+
import { ICON, reverseBlocksCommand, shuffleBlocksCommand, sortBlocksCommand, splitByParagraphsCommand, toggleAutoHeadingCommand } from './commands'
44
import { getChosenBlocks, p, scrollToBlock } from './utils'
55

66

@@ -35,22 +35,22 @@ async function main() {
3535

3636
// Decoration
3737
logseq.App.registerCommandPalette({
38-
label: '🪚 Toggle auto heading', key: 'auto-heading',
38+
label: ICON + ' Toggle auto heading', key: 'auto-heading',
3939
keybinding: {mac: 'mod+1', binding: 'ctrl+1', mode: 'global'},
4040
}, (e) => toggleAutoHeadingCommand({togglingBasedOnFirstBlock: true}) )
4141

4242

4343
// Splitting
4444
logseq.App.registerCommandPalette({
45-
label: '🪚 Split by paragraphs', key: 'split-by-paragraphs',
45+
label: ICON + ' Split by paragraphs', key: 'split-by-paragraphs',
4646
// @ts-expect-error
4747
keybinding: {},
4848
}, (e) => splitByParagraphsCommand() )
4949

5050

5151
// Navigation
5252
logseq.App.registerCommandPalette({
53-
label: '🪚 Go to (↖︎) parent block', key: 'edit-block-1-deep-dive-out',
53+
label: ICON + ' Go to (↖︎) parent block', key: 'edit-block-1-deep-dive-out',
5454
keybinding: {mac: 'mod+alt+left', binding: 'ctrl+alt+left', mode: 'global'},
5555
}, async (e) => {
5656
const [blocks] = await getChosenBlocks()
@@ -66,7 +66,7 @@ async function main() {
6666
} )
6767

6868
logseq.App.registerCommandPalette({
69-
label: '🪚 Go to (↘︎) last child block', key: 'edit-block-2-deep-dive-in',
69+
label: ICON + ' Go to (↘︎) last child block', key: 'edit-block-2-deep-dive-in',
7070
keybinding: {mac: 'mod+alt+right', binding: 'ctrl+alt+right', mode: 'global'},
7171
}, async (e) => {
7272
const [blocks] = await getChosenBlocks()
@@ -83,8 +83,8 @@ async function main() {
8383
} )
8484

8585
logseq.App.registerCommandPalette({
86-
label: '🪚 Go to |↑| previous sibling block', key: 'edit-block-5-prev-sibling',
8786
keybinding: {mac: 'ctrl+shift+up', binding: 'ctrl+shift+up', mode: 'global'},
87+
label: ICON + ' Go to |↑| previous sibling block', key: 'edit-block-5-prev-sibling',
8888
}, async (e) => {
8989
const [blocks] = await getChosenBlocks()
9090
const [first] = blocks
@@ -103,8 +103,8 @@ async function main() {
103103
} )
104104

105105
logseq.App.registerCommandPalette({
106-
label: '🪚 Go to |↓| next sibling block', key: 'edit-block-6-next-sibling',
107106
keybinding: {mac: 'ctrl+shift+down', binding: 'ctrl+shift+down', mode: 'global'},
107+
label: ICON + ' Go to |↓| next sibling block', key: 'edit-block-6-next-sibling',
108108
}, async (e) => {
109109
const [blocks] = await getChosenBlocks()
110110
const [first] = blocks
@@ -123,7 +123,7 @@ async function main() {
123123
} )
124124

125125
logseq.App.registerCommandPalette({
126-
label: '🪚 Go to (↑) previous block', key: 'edit-block-3-step-up',
126+
label: ICON + ' Go to (↑) previous block', key: 'edit-block-3-step-up',
127127
keybinding: {mac: 'mod+alt+up', binding: 'ctrl+alt+up', mode: 'global'},
128128
}, async (e) => {
129129
const [blocks] = await getChosenBlocks()
@@ -163,7 +163,7 @@ async function main() {
163163
} )
164164

165165
logseq.App.registerCommandPalette({
166-
label: '🪚 Go to (↓) next block', key: 'edit-block-4-step-down',
166+
label: ICON + ' Go to (↓) next block', key: 'edit-block-4-step-down',
167167
keybinding: {mac: 'mod+alt+down', binding: 'ctrl+alt+down', mode: 'global'},
168168
}, async (e) => {
169169
const [blocks] = await getChosenBlocks()
@@ -211,7 +211,7 @@ async function main() {
211211

212212
// Movements
213213
logseq.App.registerCommandPalette({
214-
label: '🪚 Move block (⤒) on top of siblings', key: 'move-block-1-on-top',
214+
label: ICON + ' Move block (⤒) on top of siblings', key: 'move-block-1-on-top',
215215
keybinding: {mac: 'mod+alt+shift+up', binding: 'ctrl+alt+shift+up', mode: 'global'},
216216
}, async (e) => {
217217
const [blocks] = await getChosenBlocks()
@@ -236,7 +236,7 @@ async function main() {
236236
} )
237237

238238
logseq.App.registerCommandPalette({
239-
label: '🪚 Move block (⤓) on bottom of siblings', key: 'move-block-2-on-bottom',
239+
label: ICON + ' Move block (⤓) on bottom of siblings', key: 'move-block-2-on-bottom',
240240
keybinding: {mac: 'mod+alt+shift+down', binding: 'ctrl+alt+shift+down', mode: 'global'},
241241
}, async (e) => {
242242
const [blocks] = await getChosenBlocks()
@@ -261,8 +261,8 @@ async function main() {
261261
} )
262262

263263
logseq.App.registerCommandPalette({
264-
label: '🪚 Outdent (⇤) children of the block', key: 'move-block-0-outdent-children',
265264
keybinding: {mac: 'mod+alt+tab', binding: 'ctrl+alt+tab', mode: 'global'},
265+
label: ICON + ' Outdent (⇤) children of the block', key: 'move-block-0-outdent-children',
266266
}, async (e) => {
267267
const [blocks] = await getChosenBlocks()
268268
for (const block of blocks) {
@@ -283,23 +283,23 @@ async function main() {
283283

284284
// Transformations
285285
logseq.App.registerCommandPalette({
286-
label: '🪚 Sort blocks', key: 'transform-1-sort-blocks',
286+
label: ICON + ' Sort blocks', key: 'transform-1-sort-blocks',
287287
// @ts-expect-error
288288
keybinding: {},
289289
}, (e) => sortBlocksCommand() )
290290
logseq.Editor.registerBlockContextMenuItem(
291-
'🪚 Sort blocks', async (e) => sortBlocksCommand(e.uuid) )
291+
ICON + ' Sort blocks', async (e) => sortBlocksCommand(e.uuid) )
292292

293293
logseq.App.registerCommandPalette({
294-
label: '🪚 Reverse blocks', key: 'transform-2-reverse-blocks',
294+
label: ICON + ' Reverse blocks', key: 'transform-2-reverse-blocks',
295295
// @ts-expect-error
296296
keybinding: {},
297297
}, (e) => reverseBlocksCommand() )
298298
logseq.Editor.registerBlockContextMenuItem(
299-
'🪚 Reverse blocks', async (e) => reverseBlocksCommand(e.uuid) )
299+
ICON + ' Reverse blocks', async (e) => reverseBlocksCommand(e.uuid) )
300300

301301
logseq.App.registerCommandPalette({
302-
label: '🪚 Shuffle blocks', key: 'transform-3-shuffle-blocks',
302+
label: ICON + ' Shuffle blocks', key: 'transform-3-shuffle-blocks',
303303
// @ts-expect-error
304304
keybinding: {},
305305
}, (e) => shuffleBlocksCommand() )

src/commands.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import '@logseq/libs'
22

3-
import { PropertiesUtils, getChosenBlocks, sleep, transformSelectedBlocksCommand } from './utils'
3+
import { PropertiesUtils, getChosenBlocks, isWindows, sleep, transformSelectedBlocksCommand } from './utils'
44
import { BlockEntity, IBatchBlock } from '@logseq/libs/dist/LSPlugin'
55

66

7+
// there is no `saw` emoji in Windows — use `kitchen knife`: it has the same colors
8+
export const ICON = isWindows ? '🔪' : '🪚'
9+
10+
711
export async function toggleAutoHeadingCommand(opts: {togglingBasedOnFirstBlock: boolean}) {
812
const HEADING_REGEX = /^#+ /
913
const PROPERTY = PropertiesUtils.headingProperty
@@ -48,7 +52,7 @@ export async function sortBlocksCommand(contextBlockUUID: string | null = null)
4852
if (blocks.length === 0) {
4953
await logseq.UI.showMsg(
5054
`[:div
51-
[:b "🪚 Sort Blocks Command"]
55+
[:b "${ICON} Sort Blocks Command"]
5256
[:p "Select some blocks to use the command"]]`,
5357
'warning',
5458
{timeout: 10000},
@@ -75,7 +79,7 @@ export async function reverseBlocksCommand(contextBlockUUID: string | null = nul
7579
if (blocks.length === 0) {
7680
await logseq.UI.showMsg(
7781
`[:div
78-
[:b "🪚 Reverse Blocks Command"]
82+
[:b "${ICON} Reverse Blocks Command"]
7983
[:p "Select some blocks to use the command"]]`,
8084
'warning',
8185
{timeout: 10000},
@@ -101,7 +105,7 @@ export async function shuffleBlocksCommand(contextBlockUUID: string | null = nul
101105
if (blocks.length === 0) {
102106
await logseq.UI.showMsg(
103107
`[:div
104-
[:b "🪚 Shuffle Blocks Command"]
108+
[:b "${ICON} Shuffle Blocks Command"]
105109
[:p "Select some blocks to use the command"]]`,
106110
'warning',
107111
{timeout: 10000},

src/utils/other.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { logseq as packageInfo } from '../../package.json'
22

33

4+
export const isMacOS = navigator.userAgent.toUpperCase().indexOf('MAC') >= 0
5+
export const isWindows = navigator.userAgent.toUpperCase().indexOf('WIN') >= 0
6+
7+
48
/**
59
* Tagged template printing function
610
* @usage console.log(p`Hello, Logseq!`)

0 commit comments

Comments
 (0)