mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-11-19 20:24:49 +01:00
feat: compact layout for tablets (#9910)
* feat: allow the hiding of top picks * feat: allow the hiding of default fonts * refactor: rename to compactMode * feat: introduce layout (incomplete) * tweak icons * do not show border * lint * add isTouchMobile to device * add isTouchMobile to device * refactor to use showCompactSidebar instead * hide library label in compact * fix icon color in dark theme * fix library and share btns getting hidden in smaller tablet widths * update tests * use a smaller gap between shapes * proper fix of range * quicker switching between different popovers * to not show properties panel at all when editing text * fix switching between different popovers for texts * fix popover not closable and font search auto focus * change properties for a new or editing text * change icon for more style settings * use bolt icon for extra actions * fix breakpoints * use rem for icon sizes * fix tests * improve switching between triggers (incomplete) * improve trigger switching (complete) * clean up code * put compact into app state * fix button size * remove redundant PanelComponentProps["compactMode"] * move fontSize UI on top * mobile detection (breakpoints incomplete) * tweak compact mode detection * rename appState prop & values * update snapshots --------- Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
@@ -542,6 +542,7 @@ export const textWysiwyg = ({
|
||||
if (isDestroyed) {
|
||||
return;
|
||||
}
|
||||
|
||||
isDestroyed = true;
|
||||
// cleanup must be run before onSubmit otherwise when app blurs the wysiwyg
|
||||
// it'd get stuck in an infinite loop of blur→onSubmit after we re-focus the
|
||||
@@ -625,14 +626,24 @@ export const textWysiwyg = ({
|
||||
const isPropertiesTrigger =
|
||||
target instanceof HTMLElement &&
|
||||
target.classList.contains("properties-trigger");
|
||||
const isPropertiesContent =
|
||||
(target instanceof HTMLElement || target instanceof SVGElement) &&
|
||||
!!(target as Element).closest(".properties-content");
|
||||
const inShapeActionsMenu =
|
||||
(target instanceof HTMLElement || target instanceof SVGElement) &&
|
||||
(!!(target as Element).closest(`.${CLASSES.SHAPE_ACTIONS_MENU}`) ||
|
||||
!!(target as Element).closest(".compact-shape-actions-island"));
|
||||
|
||||
setTimeout(() => {
|
||||
editable.onblur = handleSubmit;
|
||||
|
||||
// case: clicking on the same property → no change → no update → no focus
|
||||
if (!isPropertiesTrigger) {
|
||||
editable.focus();
|
||||
// If we interacted within shape actions menu or its popovers/triggers,
|
||||
// keep submit disabled and don't steal focus back to textarea.
|
||||
if (inShapeActionsMenu || isPropertiesTrigger || isPropertiesContent) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, re-enable submit on blur and refocus the editor.
|
||||
editable.onblur = handleSubmit;
|
||||
editable.focus();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -655,6 +666,7 @@ export const textWysiwyg = ({
|
||||
event.preventDefault();
|
||||
app.handleCanvasPanUsingWheelOrSpaceDrag(event);
|
||||
}
|
||||
|
||||
temporarilyDisableSubmit();
|
||||
return;
|
||||
}
|
||||
@@ -662,15 +674,20 @@ export const textWysiwyg = ({
|
||||
const isPropertiesTrigger =
|
||||
target instanceof HTMLElement &&
|
||||
target.classList.contains("properties-trigger");
|
||||
const isPropertiesContent =
|
||||
(target instanceof HTMLElement || target instanceof SVGElement) &&
|
||||
!!(target as Element).closest(".properties-content");
|
||||
|
||||
if (
|
||||
((event.target instanceof HTMLElement ||
|
||||
event.target instanceof SVGElement) &&
|
||||
event.target.closest(
|
||||
(event.target.closest(
|
||||
`.${CLASSES.SHAPE_ACTIONS_MENU}, .${CLASSES.ZOOM_ACTIONS}`,
|
||||
) &&
|
||||
) ||
|
||||
event.target.closest(".compact-shape-actions-island")) &&
|
||||
!isWritableElement(event.target)) ||
|
||||
isPropertiesTrigger
|
||||
isPropertiesTrigger ||
|
||||
isPropertiesContent
|
||||
) {
|
||||
temporarilyDisableSubmit();
|
||||
} else if (
|
||||
|
||||
Reference in New Issue
Block a user