Keep QWord ribbon above document viewport

This commit is contained in:
Курнат Андрей
2026-06-02 09:19:05 +03:00
parent ddb04c32a4
commit c72e78ac82
3 changed files with 52 additions and 3 deletions
+37
View File
@@ -23,6 +23,43 @@ describe("qwordCurrentPageFromViewport", () => {
}); });
describe("QWord", () => { describe("QWord", () => {
it("держит ленту QWord вне прокручиваемой области документа", () => {
const originalResizeObserver = globalThis.ResizeObserver;
const originalRequestAnimationFrame = window.requestAnimationFrame;
globalThis.ResizeObserver = class {
observe() {}
disconnect() {}
} as unknown as typeof ResizeObserver;
window.requestAnimationFrame = ((callback: FrameRequestCallback) => {
callback(0);
return 1;
}) as typeof window.requestAnimationFrame;
const document: WordDocument = {
id: "word-ribbon-layout-test",
title: "Лента.docx",
updatedAt: "2026-06-02T00:00:00.000Z",
html: "<p>Текст</p>"
};
try {
const view = render(<QWord document={document} onChange={vi.fn()} />);
const toolbar = view.container.querySelector(".word-module-toolbar") as HTMLElement;
const stage = view.container.querySelector(".document-stage") as HTMLElement;
expect(toolbar).toBeInTheDocument();
expect(stage).toBeInTheDocument();
expect(stage).not.toContainElement(toolbar);
expect(toolbar.querySelector(".word-ribbon-tabs")).toBeInTheDocument();
expect(stage.querySelector(".page-ruler")).toBeInTheDocument();
expect(stage.querySelector(".paper-frame")).toBeInTheDocument();
} finally {
globalThis.ResizeObserver = originalResizeObserver;
window.requestAnimationFrame = originalRequestAnimationFrame;
}
});
it("переключает вкладки ленты и показывает команды выбранной вкладки", () => { it("переключает вкладки ленты и показывает команды выбранной вкладки", () => {
const originalResizeObserver = globalThis.ResizeObserver; const originalResizeObserver = globalThis.ResizeObserver;
const originalRequestAnimationFrame = window.requestAnimationFrame; const originalRequestAnimationFrame = window.requestAnimationFrame;
+3 -3
View File
@@ -686,8 +686,7 @@ export function QWord({ document, zoom = 100, onChange, onStatusChange }: QWordP
return ( return (
<div className="editor-layout qword-layout"> <div className="editor-layout qword-layout">
<section ref={stageRef} className={stageClassName} style={stageStyle} onScroll={refreshPageView} aria-label="Редактор QWord"> <div className="module-toolbar word-module-toolbar">
<div className="module-toolbar word-module-toolbar">
<input <input
ref={fileInputRef} ref={fileInputRef}
className="hidden-file-input" className="hidden-file-input"
@@ -984,8 +983,9 @@ export function QWord({ document, zoom = 100, onChange, onStatusChange }: QWordP
</section> </section>
) : null} ) : null}
</div> </div>
</div> </div>
<section ref={stageRef} className={stageClassName} style={stageStyle} onScroll={refreshPageView} aria-label="Редактор QWord">
<div className="page-ruler" aria-hidden="true"> <div className="page-ruler" aria-hidden="true">
{Array.from({ length: 9 }, (_, index) => ( {Array.from({ length: 9 }, (_, index) => (
<span key={index}>{index + 1}</span> <span key={index}>{index + 1}</span>
+12
View File
@@ -365,6 +365,10 @@ button {
min-height: 0; min-height: 0;
} }
.qword-layout {
grid-template-rows: auto minmax(0, 1fr);
}
.document-stage, .document-stage,
.spreadsheet-stage, .spreadsheet-stage,
.slide-stage { .slide-stage {
@@ -393,6 +397,9 @@ button {
} }
.word-module-toolbar { .word-module-toolbar {
position: relative;
top: auto;
z-index: 3;
display: block; display: block;
min-height: 154px; min-height: 154px;
padding: 0; padding: 0;
@@ -2227,6 +2234,11 @@ button {
overflow-y: auto; overflow-y: auto;
} }
.word-module-toolbar {
max-height: none;
overflow: hidden;
}
.file-title-input { .file-title-input {
min-width: 0; min-width: 0;
flex: 1 1 220px; flex: 1 1 220px;