Skip to content

Commit 8452622

Browse files
committed
feat(settings): pin toolbar by default; drop inline-renderer toggles
Add a `toolbarPinned` setting (default true) so new users get the inline-table toolbar pinned out of the box; runtime toggling via the toolbar/right-click menu still writes the same key. Remove the `enableInlineRenderer` and `inlineEditable` settings. Both were on by default and there's no real reason to expose disabling them — the inline renderer is the plugin's whole point. The renderer is still gated on the host's experimental block-renderer API, and the now always-on editable branch was inlined.
1 parent 58e03f1 commit 8452622

1 file changed

Lines changed: 34 additions & 45 deletions

File tree

src/index.js

Lines changed: 34 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@ const applyTheme = (mode) => {
2020

2121
// Settings schema
2222
const settingsSchema = [
23-
{
24-
key: 'enableInlineRenderer',
25-
type: 'boolean',
26-
default: true,
27-
title: 'Inline table rendering',
28-
description: "Render markdown-table blocks inline as tables (replacing Logseq's native outline view). Requires a Logseq version that supports the experimental block renderer API; ignored on older versions. Reload the plugin after changing this."
29-
},
30-
{
31-
key: 'inlineEditable',
32-
type: 'boolean',
33-
default: true,
34-
title: 'Edit inline tables in place',
35-
description: "Make the inline-rendered table's cells editable directly (debounced auto-save back to the block). When off, the inline table is read-only. Requires \"Inline table rendering\". Reload the plugin after changing this."
36-
},
3723
{
3824
key: 'inlineEditDebounceMs',
3925
type: 'number',
@@ -54,6 +40,13 @@ const settingsSchema = [
5440
default: -1,
5541
title: 'Monospace table font size offset (px)',
5642
description: "Adjust the monospace table-source font size relative to Logseq's base font, in pixels (e.g. -1 = 1px smaller, 0 = same, 2 = 2px larger). Reload the plugin after changing this."
43+
},
44+
{
45+
key: 'toolbarPinned',
46+
type: 'boolean',
47+
default: true,
48+
title: 'Pin inline table toolbar by default',
49+
description: 'When enabled, the inline table toolbar stays pinned above the focused table. You can still toggle pinning at runtime from the toolbar/right-click menu.'
5750
}
5851
]
5952

@@ -203,9 +196,8 @@ if (isInBrowser) {
203196
// Inline block renderer: replace Logseq's native view for markdown-table
204197
// blocks with an editable table. Host-mounted via the experimental
205198
// Experiments API; a clean no-op on older Logseq hosts.
206-
const inlineEnabled = logseq.settings?.enableInlineRenderer !== false
207199
const hasBlockRenderer = typeof logseq.Experiments?.registerBlockRenderer === 'function'
208-
if (inlineEnabled && hasBlockRenderer) {
200+
if (hasBlockRenderer) {
209201
logseq.provideStyle(`
210202
/* min-width:0 lets this shrink inside Logseq's flex block layout;
211203
without it the max-content table stretches the whole block past
@@ -386,7 +378,6 @@ if (isInBrowser) {
386378
React.createElement('td', { key: ci, style: cellStyle }, row[ci] ?? '')))))
387379
]))
388380
})
389-
const editable = logseq.settings?.inlineEditable !== false
390381
const dbRaw = Number(logseq.settings?.inlineEditDebounceMs)
391382
const debounceMs = Number.isFinite(dbRaw) && dbRaw >= 0 ? dbRaw : 500
392383
return React.createElement('div',
@@ -396,36 +387,34 @@ if (isInBrowser) {
396387
ref: (el) => {
397388
if (!el) return
398389
prepareInlineRenderer(el)
399-
if (editable) {
400-
const inlineOpts = {
401-
segments,
402-
blockId: id,
403-
updateBlock: (b, c) => logseqEditor.updateBlock(b, c),
404-
debounceMs,
405-
isPinned: () => logseq.settings?.toolbarPinned === true,
406-
setPinned: (v) => { try { logseq.updateSettings({ toolbarPinned: !!v }) } catch (e) { /* noop */ } },
407-
menuLabels: {
408-
insertRowAbove: i18n.t('Insert row above'),
409-
insertRowBelow: i18n.t('Insert row below'),
410-
deleteRow: i18n.t('Delete row'),
411-
insertColLeft: i18n.t('Insert column left'),
412-
insertColRight: i18n.t('Insert column right'),
413-
deleteCol: i18n.t('Delete column'),
414-
moveRowUp: i18n.t('Move row up'),
415-
moveRowDown: i18n.t('Move row down'),
416-
moveColLeft: i18n.t('Move column left'),
417-
moveColRight: i18n.t('Move column right'),
418-
sortColAsc: i18n.t('Sort column ascending'),
419-
sortColDesc: i18n.t('Sort column descending'),
420-
pinToolbar: i18n.t('Pin toolbar'),
421-
unpinToolbar: i18n.t('Unpin toolbar'),
422-
fullScreen: i18n.t('Full screen'),
423-
exitFullScreen: i18n.t('Exit full screen')
424-
}
390+
const inlineOpts = {
391+
segments,
392+
blockId: id,
393+
updateBlock: (b, c) => logseqEditor.updateBlock(b, c),
394+
debounceMs,
395+
isPinned: () => logseq.settings?.toolbarPinned === true,
396+
setPinned: (v) => { try { logseq.updateSettings({ toolbarPinned: !!v }) } catch (e) { /* noop */ } },
397+
menuLabels: {
398+
insertRowAbove: i18n.t('Insert row above'),
399+
insertRowBelow: i18n.t('Insert row below'),
400+
deleteRow: i18n.t('Delete row'),
401+
insertColLeft: i18n.t('Insert column left'),
402+
insertColRight: i18n.t('Insert column right'),
403+
deleteCol: i18n.t('Delete column'),
404+
moveRowUp: i18n.t('Move row up'),
405+
moveRowDown: i18n.t('Move row down'),
406+
moveColLeft: i18n.t('Move column left'),
407+
moveColRight: i18n.t('Move column right'),
408+
sortColAsc: i18n.t('Sort column ascending'),
409+
sortColDesc: i18n.t('Sort column descending'),
410+
pinToolbar: i18n.t('Pin toolbar'),
411+
unpinToolbar: i18n.t('Unpin toolbar'),
412+
fullScreen: i18n.t('Full screen'),
413+
exitFullScreen: i18n.t('Exit full screen')
425414
}
426-
attachInlineEditing(el, inlineOpts)
427-
resumePinnedToolbar(el, inlineOpts)
428415
}
416+
attachInlineEditing(el, inlineOpts)
417+
resumePinnedToolbar(el, inlineOpts)
429418
}
430419
}, children)
431420
}

0 commit comments

Comments
 (0)