You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create 🏛template (use copy button in the top right corner):
- template:: switch header color
template-list-as:: template
template-shortcut::
template-version:: 1
plugin-version:: 4.2.0
link:: [Showroom](https://github.com/stdword/logseq13-full-house-plugin/discussions/49)
arg-toggle-color::
-```javascript``{
// do not modify block's contentblocks.skip()
var colors = ['yellow', 'red', 'pink', 'green', 'blue', 'purple', 'gray']
var current =c.currentBlock.props['background-color']
if (current)
current =current.toLowerCase()
if (c.args['toggle-color']) {
colors =c.args['toggle-color'].toLowerCase()
if (colors.includes(', '))
colors =colors.split(', ').map(c=>c.trim())
else
colors = [colors]
colors =colors.map(c=> {
if (c.startsWith('\\#'))
c =c.slice(1)
if (/^(?:[0-9a-f]{3}){1,2}$/i.test(c))
return'#'+ c
return c
})
}
var nextIndex =0if (!current)
nextIndex =0elseif (current &&!colors.includes(current))
nextIndex =nullelse {
nextIndex =colors.indexOf(current) +1if (nextIndex >=colors.length)
nextIndex =null
}
var next = nextIndex ===null?null: colors[nextIndex]
constselected= (awaitlogseq.Editor.getSelectedBlocks()) ?? [c.currentBlock]
for (constuuidofselected.map(b=>b.uuid))
awaitlogseq.Editor.upsertBlockProperty(uuid, 'background-color', next)
if (cursor.selection())
if (next) {
var [ color ] =dev.cssVars([`--ls-highlight-color-${next}`])
color =dev.color(color)
logseq.UI.showMsg(`[:p "Background color has been changed to " [:font {:color "${color}"} "${next}"]]`, ' success')
}
elselogseq.UI.showMsg(`[:p "Background color has been " [:i "removed"]]`, 'success')
}`````
Reload the application (⌘R or Ctrl+R for Win) to register shortcut command
Got to Settings → Keymap (g s)
Bind any shortcut you want for command «Insert 🏛️template: "color header"»
Reload the application again (⌘R or Ctrl+R for Win) to register just chosen shortcut
In the block Edit Mode or in the block Selection Mode use chosen shortcut to cycle through all available header colors
Configuring
Defining your own sequence of colors
Use property arg-toggle-color:: for that. You can specify the colors in any available in CSS form.
arg-toggle-color:: green, red
arg-toggle-color:: green
arg-toggle-color:: rgb(128,128,128), c5def5, \#777, black, hsl(0,50%,50%)
Note: Color values yellow, red, pink, green, blue, purple, gray are predefined by your current theme. Note: To use color in HEX format do not specify hash sign «#» OR escape it «#» to prevent it act as Logseq tag reference. Note: Use colon WITH space «,␣» to specify several colors (ex: red,␣green) and colon WITHOUT space «,» to separate one color parts (ex: rgb(128,128,128)).
Set different shortcuts for different colors
Fill property arg-toggle-color with first color (ex: arg-toggle-color:: green)
Create another 🏛️template (ex: for red color):
- template:: switch header color (red)
template-list-as:: template
template-shortcut::
arg-toggle-color:: red
-``{ blocks.skip() }````await layout('switch header color')``
Reload the application (⌘R or Ctrl+R for Win) to register shortcut command
Got to Settings → Keymap (g s)
Bind any shortcut you want for command «Insert 🏛️template: "color header (red)"»
Reload the application again (⌘R or Ctrl+R for Win) to register just chosen shortcut
Now, you can use two different shortcuts to set the exact header color
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
inspired by this post & this one
Steps
🏛template
(use copy button in the top right corner):g s
)Configuring
Defining your own sequence of colors
Use property
arg-toggle-color::
for that. You can specify the colors in any available in CSS form.arg-toggle-color:: green, red arg-toggle-color:: green arg-toggle-color:: rgb(128,128,128), c5def5, \#777, black, hsl(0,50%,50%)
Note: Color values
yellow
,red
,pink
,green
,blue
,purple
,gray
are predefined by your current theme.Note: To use color in HEX format do not specify hash sign «#» OR escape it «#» to prevent it act as Logseq tag reference.
Note: Use colon WITH space «,␣» to specify several colors (ex:
red,␣green
) and colon WITHOUT space «,» to separate one color parts (ex:rgb(128,128,128)
).Set different shortcuts for different colors
arg-toggle-color
with first color (ex:arg-toggle-color:: green
)🏛️template
(ex: forred
color):g s
)Additional info
Beta Was this translation helpful? Give feedback.
All reactions