refactor(文书纸): 统一 A4 纸规格并收敛各渲染场景的纸宽与页边距
This commit is contained in:
@@ -996,15 +996,10 @@ function requestClose() {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
/* 纸的比例与页边距由 DocumentPaper 的 .doc-paper--a4 给(统一 A4 规格,
|
||||
见 utils/document-paper.ts),这里只留「桌子」和纸的观感 —— 别再写 max-width/padding,
|
||||
写了就会和 A4 规格打架(% 页边距以包含块宽度为基准,纸一被收窄就算错)。 */
|
||||
.preview-paper {
|
||||
max-width: 820px;
|
||||
min-height: 460px;
|
||||
padding: 34px 44px;
|
||||
margin: 0 auto;
|
||||
color: #1c2b33;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.9;
|
||||
background: #fff;
|
||||
border-radius: var(--r);
|
||||
box-shadow: var(--sh);
|
||||
}
|
||||
|
||||
@@ -247,14 +247,23 @@ onBeforeUnmount(() => {
|
||||
<!-- 工具栏的第二行(原型 mdDocEd 里「插入签署占位符」那一行)。
|
||||
放在工具栏与正文之间,让"插入什么"与"排版成什么样"在同一条视觉带里。 -->
|
||||
<slot name="toolbar-extra" />
|
||||
<Editor
|
||||
class="pane-content"
|
||||
:model-value="props.modelValue"
|
||||
:default-config="editorConfig"
|
||||
:mode="editorMode"
|
||||
@update:model-value="emit('update:modelValue', $event)"
|
||||
@on-created="handleCreated"
|
||||
/>
|
||||
<!-- 纸桌 → 纸壳 → 纸 三层,缺一不可:
|
||||
`.pane-desk` 提供灰底与唯一滚动条;
|
||||
`.pane-sheet` 负责限宽居中 —— % 页边距以**包含块**宽度为基准,
|
||||
限宽必须落在这里,落到纸上就会按更宽的桌面算(页边距偏大);
|
||||
`.pane-content` 才是白纸本身(A4 比例 + 页边距)。 -->
|
||||
<div class="pane-desk">
|
||||
<div class="pane-sheet">
|
||||
<Editor
|
||||
class="pane-content"
|
||||
:model-value="props.modelValue"
|
||||
:default-config="editorConfig"
|
||||
:mode="editorMode"
|
||||
@update:model-value="emit('update:modelValue', $event)"
|
||||
@on-created="handleCreated"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -273,27 +282,59 @@ onBeforeUnmount(() => {
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.pane-content {
|
||||
/* 编辑区左右页边距,模拟 Word 文档版心:宽屏约 96px,窄窗口自动收窄 */
|
||||
--pane-gutter: clamp(20px, 8%, 96px);
|
||||
|
||||
/* 纸桌:灰底 + **唯一**的滚动条(纸自己不许再滚,否则会出现两个滚动条) */
|
||||
.pane-desk {
|
||||
flex: 1;
|
||||
min-height: 340px;
|
||||
padding: 16px 20px;
|
||||
overflow: auto;
|
||||
background: #eef3f6;
|
||||
}
|
||||
|
||||
/* WangEditor 默认 [data-slate-editor] 只有 padding: 0 10px,正文会贴着边框;
|
||||
这里补上左右留白,粘贴的 Word 正文才呈现"纸张版心"的观感 */
|
||||
/* 纸壳:只负责限宽居中,并作为**容器查询上下文**。
|
||||
它的宽度 == 纸宽,所以纸里的 `cqw` 就等于「纸宽的 1%」——
|
||||
用 `min-height: 141.43cqw`(= 297/210)表达「至少一页 A4」,纸窄时按纸宽自动缩,
|
||||
不必再为「纸比容器窄」写第二套数字。 */
|
||||
.pane-sheet {
|
||||
width: 100%;
|
||||
max-width: var(--doc-paper-max-w);
|
||||
margin: 0 auto;
|
||||
container-type: inline-size;
|
||||
}
|
||||
|
||||
/* 白纸:A4 比例(下限)+ 一般文书页边距,走统一 A4 规格(utils/document-paper.ts)。
|
||||
原来那套 `--pane-gutter: clamp(20px, 8%, 96px)` 只是"看着像版心",
|
||||
与签署预览的页边距对不上,编辑时看到的换行位置和签出来不一样。
|
||||
**用 min-height 而不是 aspect-ratio**:aspect-ratio 会被 WangEditor 内层的
|
||||
滚动容器吃掉(正文 1574px 而纸定死在 1160px,正文直接露到灰桌上);
|
||||
min-height 只是下限,正文多了纸自己长高,滚动交给纸桌。 */
|
||||
.pane-content {
|
||||
width: 100%;
|
||||
min-height: var(--doc-paper-min-h-cqw);
|
||||
padding: var(--doc-paper-pad-y-cqw) var(--doc-paper-pad-x-cqw);
|
||||
background: #fff;
|
||||
box-shadow: var(--sh);
|
||||
}
|
||||
|
||||
/* 编辑面本身不再要 padding —— 页边距已由纸(.pane-content)给;
|
||||
WangEditor 默认的 `padding: 0 10px` 也要一并清掉 */
|
||||
.pane-content :deep([data-slate-editor]) {
|
||||
padding: 0 var(--pane-gutter);
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* 空文档提示绝对定位于纸的内层容器,WangEditor 自带一点偏移(实测右下各偏 ~10/17px),
|
||||
这里拉回版心原点,否则空文档时提示文字不与正文左边界对齐 */
|
||||
.pane-content :deep(.w-e-text-container) {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* 占位符绝对定位于 .w-e-text-container(而非编辑区),不跟随上面的 padding,
|
||||
需单独对齐到同一版心,否则空文档时提示文字会贴左边框 */
|
||||
.pane-content :deep(.w-e-text-placeholder) {
|
||||
right: var(--pane-gutter);
|
||||
left: var(--pane-gutter);
|
||||
top: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
width: auto;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* 粘贴的 Word 表格:解除绝对列宽、允许单元格换行,
|
||||
|
||||
Reference in New Issue
Block a user