@sw7d/paper-renderer 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/paper-renderer.js +2416 -1987
- package/dist/src/components/PaperEditor.vue.d.ts +17 -0
- package/dist/src/composables/paperHelpers.d.ts +7 -0
- package/dist/src/composables/usePaperCursor.d.ts +39 -0
- package/dist/src/types/document.d.ts +8 -0
- package/dist/src/types/paper.d.ts +9 -0
- package/dist/style.css +2 -2
- package/package.json +1 -1
|
@@ -17,6 +17,12 @@ declare function applyParagraphFormat(fmt: {
|
|
|
17
17
|
justification?: 'left' | 'center' | 'right';
|
|
18
18
|
firstLineIndent?: number;
|
|
19
19
|
}): boolean;
|
|
20
|
+
/** 对当前选区切换字符格式(顶部工具栏 / 右键菜单 / 快捷键共用) */
|
|
21
|
+
declare function toggleTextFormat(fmt: {
|
|
22
|
+
bold?: boolean;
|
|
23
|
+
italic?: boolean;
|
|
24
|
+
underline?: boolean;
|
|
25
|
+
}): boolean;
|
|
20
26
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
21
27
|
document: {
|
|
22
28
|
save: () => Promise<string>;
|
|
@@ -110,6 +116,10 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
|
110
116
|
paragraphFormat: {
|
|
111
117
|
apply: typeof applyParagraphFormat;
|
|
112
118
|
};
|
|
119
|
+
/** 字符格式:对文字选区切换加粗 / 斜体 / 下划线(无选区时返回 false) */
|
|
120
|
+
textFormat: {
|
|
121
|
+
apply: typeof toggleTextFormat;
|
|
122
|
+
};
|
|
113
123
|
state: import("vue").ComputedRef<{
|
|
114
124
|
blocks: ContentBlock[];
|
|
115
125
|
pages: {
|
|
@@ -200,6 +210,13 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
|
200
210
|
justification: "left" | "center" | "right";
|
|
201
211
|
firstLineIndent: number;
|
|
202
212
|
};
|
|
213
|
+
/** 文字选区 + 选中文字的字符格式(供工具栏 B/I/U 高亮与禁用态) */
|
|
214
|
+
textFormat: {
|
|
215
|
+
enabled: boolean;
|
|
216
|
+
bold: boolean;
|
|
217
|
+
italic: boolean;
|
|
218
|
+
underline: boolean;
|
|
219
|
+
};
|
|
203
220
|
}>;
|
|
204
221
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
205
222
|
change: () => any;
|
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
* 包含字号转换、段落构建、题块创建、文本解析等工具函数
|
|
6
6
|
*/
|
|
7
7
|
import type { ContentBlock, Paragraph, InlineElement, PageSettings } from '../types/paper';
|
|
8
|
+
/** 独立图片段落左右内边距(px):图片不紧贴题框边框 */
|
|
9
|
+
export declare const STANDALONE_IMAGE_INSET = 8;
|
|
10
|
+
/**
|
|
11
|
+
* 段落是否仅由图片构成(允许行尾换行符与全空白文本)。
|
|
12
|
+
* 独立图片段落左右需要预留内边距,避免图片紧贴题框边框。
|
|
13
|
+
*/
|
|
14
|
+
export declare function isStandaloneImageParagraph(para: Paragraph): boolean;
|
|
8
15
|
/**
|
|
9
16
|
* 计算段落对齐偏移(居中/居右时整段水平平移量,px)。
|
|
10
17
|
* 与 ParagraphRenderer 渲染逻辑保持一致:基于片段首行宽度计算。
|
|
@@ -13,6 +13,13 @@ export interface CursorState {
|
|
|
13
13
|
paraIndex: number;
|
|
14
14
|
charOffset: number;
|
|
15
15
|
}
|
|
16
|
+
/** 文字区间选区:anchor=拖选起点、focus=拖选终点,均为段内纯文字字符偏移 */
|
|
17
|
+
export interface TextSelectionState {
|
|
18
|
+
blockId: string;
|
|
19
|
+
paraIndex: number;
|
|
20
|
+
anchor: number;
|
|
21
|
+
focus: number;
|
|
22
|
+
}
|
|
16
23
|
export declare function usePaperCursor(blocks: Ref<ContentBlock[]>, settings: Ref<PageSettings>, reflowAllBlocks: () => void, markDirty: () => void): {
|
|
17
24
|
cursor: Ref<{
|
|
18
25
|
blockId: string | null;
|
|
@@ -33,6 +40,8 @@ export declare function usePaperCursor(blocks: Ref<ContentBlock[]>, settings: Re
|
|
|
33
40
|
bold: boolean;
|
|
34
41
|
italic: boolean;
|
|
35
42
|
color: string;
|
|
43
|
+
/** 下划线:在 <u>作答横线</u> 中间打字时新字继承下划线,避免横线被打字截断 */
|
|
44
|
+
underline?: boolean;
|
|
36
45
|
};
|
|
37
46
|
splitAtCursor: () => boolean;
|
|
38
47
|
backspace: () => boolean;
|
|
@@ -47,4 +56,34 @@ export declare function usePaperCursor(blocks: Ref<ContentBlock[]>, settings: Re
|
|
|
47
56
|
moveCursorRight: () => boolean;
|
|
48
57
|
moveToParaStart: () => boolean;
|
|
49
58
|
moveToParaEnd: () => boolean;
|
|
59
|
+
textSelection: Ref<{
|
|
60
|
+
blockId: string;
|
|
61
|
+
paraIndex: number;
|
|
62
|
+
anchor: number;
|
|
63
|
+
focus: number;
|
|
64
|
+
} | null, TextSelectionState | {
|
|
65
|
+
blockId: string;
|
|
66
|
+
paraIndex: number;
|
|
67
|
+
anchor: number;
|
|
68
|
+
focus: number;
|
|
69
|
+
} | null>;
|
|
70
|
+
setTextSelection: (blockId: string, paraIndex: number, anchor: number, focus: number) => void;
|
|
71
|
+
clearTextSelection: () => void;
|
|
72
|
+
getSelectionRange: () => {
|
|
73
|
+
blockId: string;
|
|
74
|
+
paraIndex: number;
|
|
75
|
+
start: number;
|
|
76
|
+
end: number;
|
|
77
|
+
} | null;
|
|
78
|
+
selectionFormat: import("vue").ComputedRef<{
|
|
79
|
+
enabled: boolean;
|
|
80
|
+
bold: boolean;
|
|
81
|
+
italic: boolean;
|
|
82
|
+
underline: boolean;
|
|
83
|
+
}>;
|
|
84
|
+
applyTextFormat: (fmt: {
|
|
85
|
+
bold?: boolean;
|
|
86
|
+
italic?: boolean;
|
|
87
|
+
underline?: boolean;
|
|
88
|
+
}) => boolean;
|
|
50
89
|
};
|
|
@@ -284,6 +284,8 @@ export interface TextProps {
|
|
|
284
284
|
backgroundColor?: string;
|
|
285
285
|
/** 选项标签标记(如 A. B. C.) */
|
|
286
286
|
isLabel?: boolean;
|
|
287
|
+
/** 作答横线空白宽度锁定(每个空白字符的宽度),与 TextInline.blankCharWidth 对应 */
|
|
288
|
+
blankCharWidth?: number;
|
|
287
289
|
}
|
|
288
290
|
export interface LatexNode {
|
|
289
291
|
type: 'latex';
|
|
@@ -298,6 +300,8 @@ export interface LatexNode {
|
|
|
298
300
|
export interface LatexProps {
|
|
299
301
|
raw: string;
|
|
300
302
|
fontSize: number;
|
|
303
|
+
/** 下划线:文字选区加下划线时在公式底部画线 */
|
|
304
|
+
underline?: boolean;
|
|
301
305
|
}
|
|
302
306
|
export interface MathmlNode {
|
|
303
307
|
type: 'mathml';
|
|
@@ -312,6 +316,8 @@ export interface MathmlNode {
|
|
|
312
316
|
export interface MathmlProps {
|
|
313
317
|
raw: string;
|
|
314
318
|
fontSize: number;
|
|
319
|
+
/** 下划线:文字选区加下划线时在公式底部画线 */
|
|
320
|
+
underline?: boolean;
|
|
315
321
|
}
|
|
316
322
|
export interface UnderlineNode {
|
|
317
323
|
type: 'underline';
|
|
@@ -417,6 +423,8 @@ export interface ImageProps {
|
|
|
417
423
|
src?: string;
|
|
418
424
|
width?: number;
|
|
419
425
|
height?: number;
|
|
426
|
+
/** 下划线:文字选区加下划线时在图片底部画线 */
|
|
427
|
+
underline?: boolean;
|
|
420
428
|
[key: string]: any;
|
|
421
429
|
}
|
|
422
430
|
export interface FooterSection {
|
|
@@ -86,6 +86,11 @@ export interface TextInline extends BaseInline {
|
|
|
86
86
|
backgroundColor?: string;
|
|
87
87
|
/** 垂直偏移量(正=下移,负=上移),用于上下标 */
|
|
88
88
|
verticalAlign?: number;
|
|
89
|
+
/**
|
|
90
|
+
* 作答横线空白宽度锁定:value 全为空白时,每个空白字符按此宽度渲染。
|
|
91
|
+
* 供题库 <u> …</u> 这类作答横线使用(半角空格实测仅 4px,肉眼几乎不可见)。
|
|
92
|
+
*/
|
|
93
|
+
blankCharWidth?: number;
|
|
89
94
|
}
|
|
90
95
|
export interface FormulaInline extends BaseInline {
|
|
91
96
|
type: 'formula';
|
|
@@ -94,6 +99,8 @@ export interface FormulaInline extends BaseInline {
|
|
|
94
99
|
rawLatex?: string;
|
|
95
100
|
/** 原始 MathML 字符串(当 data-latex 为空时),用于序列化 */
|
|
96
101
|
rawMathml?: string;
|
|
102
|
+
/** 下划线:文字选区加下划线时,在公式底部画一条线 */
|
|
103
|
+
underline?: boolean;
|
|
97
104
|
}
|
|
98
105
|
export interface UnderlineInline extends BaseInline {
|
|
99
106
|
type: 'underline';
|
|
@@ -135,6 +142,8 @@ export interface ImageInline extends BaseInline {
|
|
|
135
142
|
rawHtml?: string;
|
|
136
143
|
/** 解析时无尺寸信息,尺寸需按真实图片比例自适应(加载后回写并清除) */
|
|
137
144
|
autoSize?: boolean;
|
|
145
|
+
/** 下划线:文字选区加下划线时,在图片底部画一条线 */
|
|
146
|
+
underline?: boolean;
|
|
138
147
|
}
|
|
139
148
|
export interface EnterInline extends BaseInline {
|
|
140
149
|
type: 'enter';
|
package/dist/style.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/dist/style.css
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 63298733 bytes
|
|
4
|
+
sha256: a4560604a2e328ebe4d85bd0dc95406270cb1dd1fe505369a7c17e69c9f14adb
|