fix(editor): load the float responsive rule + test applyAlignment (#145 review)
Review of #157 (Request changes) caught two blockers: 1. DEAD responsive CSS: the `@media (max-width:600px)` float-reset was added to `image-resize.module.css`, which is imported NOWHERE — the image container's classes come from `common/node-resize.module.css` (via buildResizeClasses). So on mobile a floated image kept its px width + float and crushed the text, exactly the failure the rule promised to prevent. Moved the rule to `common/node-resize.module.css` (the module actually imported by the resize node views); its `:global([data-image-align=...])` selectors are data-attr based, so they work unchanged. Reverted the dead addition from the (pre-existing, orphaned) image-resize.module.css. 2. `applyAlignment` was untested. Exported it and added `image.spec.ts` (vitest/ jsdom) covering all five align values, the data-image-align mirror, and the floatLeft -> left reset-then-apply (the guard against a leaked float). Switched the float writes to the canonical CSSOM `cssFloat` property (portable: browsers + jsdom; behavior identical to the `.float` alias). editor-ext build + client tsc clean; 6 image.spec tests green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -73,3 +73,18 @@
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Float image (#145): on narrow screens a floated image would crowd the text to
|
||||
an unreadable column, so collapse it to full width and drop the float.
|
||||
`!important` is required because applyAlignment sets `float`/`padding` inline,
|
||||
which a normal rule cannot override. Keys off the `data-image-align` attribute
|
||||
the image node view mirrors onto its container. This module is the one actually
|
||||
imported by the resize node views (node-resize-handles.ts), so the rule loads. */
|
||||
@media (max-width: 600px) {
|
||||
:global([data-image-align="floatLeft"]),
|
||||
:global([data-image-align="floatRight"]) {
|
||||
float: none !important;
|
||||
width: 100% !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,17 +62,3 @@
|
||||
.resizing .handleBar {
|
||||
background-color: light-dark(var(--mantine-color-blue-6), var(--mantine-color-blue-4));
|
||||
}
|
||||
|
||||
/* Float image (#145): on narrow screens a floated image would crowd the text to
|
||||
an unreadable column, so collapse it to full width and drop the float.
|
||||
`!important` is required because applyAlignment sets `float`/`padding` inline,
|
||||
which a normal rule cannot override. Keys off the data-image-align attribute
|
||||
the node view mirrors onto the container. */
|
||||
@media (max-width: 600px) {
|
||||
:global([data-image-align="floatLeft"]),
|
||||
:global([data-image-align="floatRight"]) {
|
||||
float: none !important;
|
||||
width: 100% !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user