Skip to content

Commit cd7af77

Browse files
committed
feat(menu): drop Full screen, keep Maximise
Maximise (added in the previous commit) covers the same ground inside Logseq's window — having both buttons is redundant. Removes the fullScreenItem wiring from both surfaces, the :fullscreen CSS block, the fullscreenchange resize listeners, the overlayHost fullscreen branch, the Full screen / Exit full screen i18n strings, and their menuLabels entries. fitInlineTableWidth now only branches on the maximise class.
1 parent 2cd422b commit cd7af77

4 files changed

Lines changed: 11 additions & 71 deletions

File tree

src/index.js

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -241,28 +241,9 @@ if (isInBrowser) {
241241
outline: 2px solid var(--ls-active-primary-color, #2563eb) !important;
242242
outline-offset: -2px;
243243
}
244-
/* Full-screen view uses the browser's native Fullscreen API so the
245-
element overlays Logseq's UI regardless of ancestor stacking /
246-
transform contexts. The DOM doesn't move, so inline editing,
247-
the toolbar (mounted into the fullscreen element when active),
248-
drag-drop and right-click menus all keep working. */
249-
.lsp-mdtable-renderer:fullscreen {
250-
margin: 0; padding: 24px 32px;
251-
background: var(--ls-primary-background-color, #fff);
252-
overflow: auto; box-sizing: border-box;
253-
}
254-
.lsp-mdtable-renderer:fullscreen .lsp-mdtable-scroll { overflow: auto; }
255-
.lsp-mdtable-renderer:fullscreen table.lsp-mdt {
256-
width: 100% !important; min-width: max-content;
257-
}
258-
.lsp-mdtable-renderer:fullscreen table.lsp-mdt th,
259-
.lsp-mdtable-renderer:fullscreen table.lsp-mdt td {
260-
padding: 8px 12px !important; font-size: 14px;
261-
}
262-
.lsp-mdtable-renderer:fullscreen .lsp-mdtable-text { font-size: 14px; }
263-
/* Maximise: same look as fullscreen, but bounded by Logseq's window
264-
rather than the OS desktop. The renderer is reparented to <body>
265-
so ancestor transforms/overflow can't constrain this overlay. */
244+
/* Maximise: expand the renderer to fill Logseq's window. The
245+
renderer is reparented to <body> so ancestor transforms/overflow
246+
can't constrain this overlay. */
266247
.lsp-mdtable-renderer.lsp-mdt-max {
267248
position: fixed; inset: 0; z-index: 2147483645;
268249
margin: 0; padding: 24px 32px;
@@ -427,8 +408,6 @@ if (isInBrowser) {
427408
sortColDesc: i18n.t('Sort column descending'),
428409
pinToolbar: i18n.t('Pin toolbar'),
429410
unpinToolbar: i18n.t('Unpin toolbar'),
430-
fullScreen: i18n.t('Full screen'),
431-
exitFullScreen: i18n.t('Exit full screen'),
432411
maximise: i18n.t('Maximise'),
433412
exitMaximise: i18n.t('Exit maximise')
434413
}

src/locales/en/translation.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
"delete column": "delete column",
1010
"normalise data": "normalise data (trim whitespace in cells)",
1111
"readable data": "readable data (align table source)",
12-
"Full screen": "Full screen",
13-
"Exit full screen": "Exit full screen",
1412
"Maximise": "Maximise",
1513
"Exit maximise": "Exit maximise",
1614
"Move row up": "Move row up",

src/locales/zh-CN/translation.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
"delete column": "删除列",
1010
"normalise data": "规范化数据(去除单元格首尾空格)",
1111
"readable data": "可读化(对齐表格源码)",
12-
"Full screen": "全屏",
13-
"Exit full screen": "退出全屏",
1412
"Maximise": "最大化",
1513
"Exit maximise": "退出最大化",
1614
"Move row up": "上移行",

src/utils/inlineEditable.js

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,10 @@ export const fitInlineTableWidth = (root) => {
6464
s.style.maxWidth = '0px' // reflow to natural layout
6565
s.style.paddingRight = '' // measure true overflow without our spacer
6666
})
67-
// In fullscreen the renderer itself defines the available width; the
67+
// When maximised the renderer itself defines the available width; the
6868
// Logseq block clip ancestor is irrelevant. Let the scroll wrapper fill
69-
// the fullscreen viewport so the table can render edge-to-edge.
70-
const doc = root.ownerDocument
71-
const fsEl = doc.fullscreenElement || doc.webkitFullscreenElement
72-
const maximised = root.classList.contains('lsp-mdt-max')
73-
if ((fsEl && fsEl.contains(root)) || maximised) {
69+
// the window so the table can render edge-to-edge.
70+
if (root.classList.contains('lsp-mdt-max')) {
7471
scrolls.forEach(s => {
7572
s.style.maxWidth = '100%'
7673
if (s.scrollWidth > s.clientWidth + 1) {
@@ -111,8 +108,6 @@ const bindResizeRefit = (root) => {
111108
}, 100)
112109
}
113110
win.addEventListener('resize', refitAll)
114-
doc.addEventListener('fullscreenchange', refitAll)
115-
doc.addEventListener('webkitfullscreenchange', refitAll)
116111
}
117112

118113
// Called from the renderer's ref on every (re-)mount, regardless of whether
@@ -435,20 +430,15 @@ const ICONS = {
435430
sortColAsc: SVG('<path d="M11 5h3M11 10h6M11 15h9"/><polyline points="4 8 7 5 10 8"/><line x1="7" y1="5" x2="7" y2="19"/>'),
436431
sortColDesc: SVG('<path d="M11 5h9M11 10h6M11 15h3"/><polyline points="4 16 7 19 10 16"/><line x1="7" y1="5" x2="7" y2="19"/>'),
437432
pin: SVG('<line x1="12" y1="17" x2="12" y2="22"/><path d="M9 3h6l-1 6 3 3v2H7v-2l3-3-1-6z"/>'),
438-
fullscreen: SVG('<polyline points="4 9 4 4 9 4"/><polyline points="20 9 20 4 15 4"/><polyline points="4 15 4 20 9 20"/><polyline points="20 15 20 20 15 20"/>'),
439-
exitFullscreen: SVG('<polyline points="9 4 9 9 4 9"/><polyline points="15 4 15 9 20 9"/><polyline points="4 15 9 15 9 20"/><polyline points="20 15 15 15 15 20"/>'),
440433
// Maximise = expand to Logseq's window bounds (covers sidebars/blocks).
441-
// Distinct glyph from fullscreen so the two are distinguishable in the bar:
442-
// a framed box with inward arrows.
434+
// A framed box with inward arrows; the exit variant has the arrows outward.
443435
maximise: SVG('<rect x="3" y="3" width="18" height="18" rx="1"/><polyline points="8 13 8 16 11 16"/><polyline points="16 11 16 8 13 8"/>'),
444436
exitMaximise: SVG('<rect x="3" y="3" width="18" height="18" rx="1"/><polyline points="13 8 16 8 16 11"/><polyline points="11 16 8 16 8 13"/>')
445437
}
446438

447-
// Overlay host for popovers/toolbars: when the renderer is in native
448-
// fullscreen, doc.body sits beneath the fullscreen element's top layer and
449-
// our popups would be invisible. Mount them inside the fullscreen element
450-
// in that case so they share the top layer.
451-
const overlayHost = (doc) => doc.fullscreenElement || doc.webkitFullscreenElement || doc.body
439+
// Overlay host for popovers/toolbars. The renderer is reparented to <body>
440+
// while maximised, so mounting popups on <body> keeps them above it.
441+
const overlayHost = (doc) => doc.body
452442

453443
const closeMenu = (doc) => {
454444
const el = doc.querySelector('.lsp-mdt-menu')
@@ -502,29 +492,6 @@ const buildItems = (root, opts, cell) => {
502492

503493
const isPinned = (opts) => !!(opts.isPinned && opts.isPinned())
504494

505-
// Full-screen toggle item; lives next to Pin/Unpin in both the right-click
506-
// menu and the pinned toolbar. Uses the native Fullscreen API on the
507-
// renderer root so the DOM doesn't move and all editing hooks stay bound.
508-
// `after(nowFs)` lets the surface refresh its item state.
509-
const fullScreenItem = (root, opts, after) => {
510-
const doc = root.ownerDocument
511-
const fsEl = doc.fullscreenElement || doc.webkitFullscreenElement
512-
const isFs = fsEl === root
513-
const L = opts.menuLabels || {}
514-
return {
515-
icon: isFs ? ICONS.exitFullscreen : ICONS.fullscreen,
516-
label: isFs ? (L.exitFullScreen || 'Exit full screen') : (L.fullScreen || 'Full screen'),
517-
enabled: true,
518-
action: () => {
519-
try {
520-
if (isFs) (doc.exitFullscreen || doc.webkitExitFullscreen).call(doc)
521-
else (root.requestFullscreen || root.webkitRequestFullscreen).call(root)
522-
} catch (e) { console.warn('[mdtable] fullscreen toggle failed', e) }
523-
if (after) after(!isFs)
524-
}
525-
}
526-
}
527-
528495
// Maximise = expand the renderer to fill Logseq's window (covering sidebars
529496
// and other blocks), without entering OS-level fullscreen. Implementation:
530497
// reparent the renderer to <body> so ancestor transforms / overflow / stacking
@@ -580,7 +547,7 @@ const bindMaximiseEsc = (doc) => {
580547
}, true)
581548
}
582549

583-
// Maximise toggle item; mirrors fullScreenItem's shape.
550+
// Maximise toggle item; lives next to Pin/Unpin in both surfaces.
584551
const maximiseItem = (root, opts, after) => {
585552
const max = isMaximised(root)
586553
const L = opts.menuLabels || {}
@@ -691,7 +658,6 @@ const buildToolbar = (root, opts, cell) => {
691658
const aRow = Array.from(cell.closest('table.lsp-mdt').querySelectorAll('tr')).indexOf(aTr)
692659
const aCol = Array.from(aTr.querySelectorAll('th,td')).indexOf(cell)
693660
const all = items.concat([{ sep: true },
694-
fullScreenItem(root, opts, () => buildToolbar(root, opts, cell)),
695661
maximiseItem(root, opts, () => buildToolbar(root, opts, cell)),
696662
pinItem(opts, () => removeToolbar(doc))]) // pinned bar's toggle = unpin
697663

@@ -728,7 +694,6 @@ const openContextMenu = (root, opts, cell, ev) => {
728694

729695
const { items, ord } = buildItems(root, opts, cell)
730696
const all = items.concat([{ sep: true },
731-
fullScreenItem(root, opts),
732697
maximiseItem(root, opts),
733698
pinItem(opts, (now) => { if (now) buildToolbar(root, opts, cell); else removeToolbar(doc) })])
734699

0 commit comments

Comments
 (0)