Keep QWord ribbon above document viewport
This commit is contained in:
@@ -23,6 +23,43 @@ describe("qwordCurrentPageFromViewport", () => {
|
||||
});
|
||||
|
||||
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("переключает вкладки ленты и показывает команды выбранной вкладки", () => {
|
||||
const originalResizeObserver = globalThis.ResizeObserver;
|
||||
const originalRequestAnimationFrame = window.requestAnimationFrame;
|
||||
|
||||
@@ -686,8 +686,7 @@ export function QWord({ document, zoom = 100, onChange, onStatusChange }: QWordP
|
||||
|
||||
return (
|
||||
<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
|
||||
ref={fileInputRef}
|
||||
className="hidden-file-input"
|
||||
@@ -984,8 +983,9 @@ export function QWord({ document, zoom = 100, onChange, onStatusChange }: QWordP
|
||||
</section>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section ref={stageRef} className={stageClassName} style={stageStyle} onScroll={refreshPageView} aria-label="Редактор QWord">
|
||||
<div className="page-ruler" aria-hidden="true">
|
||||
{Array.from({ length: 9 }, (_, index) => (
|
||||
<span key={index}>{index + 1}</span>
|
||||
|
||||
@@ -365,6 +365,10 @@ button {
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.qword-layout {
|
||||
grid-template-rows: auto minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.document-stage,
|
||||
.spreadsheet-stage,
|
||||
.slide-stage {
|
||||
@@ -393,6 +397,9 @@ button {
|
||||
}
|
||||
|
||||
.word-module-toolbar {
|
||||
position: relative;
|
||||
top: auto;
|
||||
z-index: 3;
|
||||
display: block;
|
||||
min-height: 154px;
|
||||
padding: 0;
|
||||
@@ -2227,6 +2234,11 @@ button {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.word-module-toolbar {
|
||||
max-height: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.file-title-input {
|
||||
min-width: 0;
|
||||
flex: 1 1 220px;
|
||||
|
||||
Reference in New Issue
Block a user