diff --git a/src/editor/core/draw/Draw.ts b/src/editor/core/draw/Draw.ts index c65be6d..bcf2008 100644 --- a/src/editor/core/draw/Draw.ts +++ b/src/editor/core/draw/Draw.ts @@ -172,7 +172,7 @@ export class Draw { height: 0, ascent: 0, elementList: [], - rowFlex: this.elementList[0].rowFlex + rowFlex: this.elementList?.[1].rowFlex }) } for (let i = 0; i < this.elementList.length; i++) { diff --git a/src/editor/index.ts b/src/editor/index.ts index dd50901..e1de861 100644 --- a/src/editor/index.ts +++ b/src/editor/index.ts @@ -6,6 +6,7 @@ import { Draw } from './core/draw/Draw' import { Command } from './core/command/Command' import { CommandAdapt } from './core/command/CommandAdapt' import { Listener } from './core/listener/Listener' +import { RowFlex } from './dataset/enum/Row' export default class Editor { @@ -54,4 +55,10 @@ export default class Editor { this.command = new Command(new CommandAdapt(draw)) } +} + +// 对外属性 +export { + Editor, + RowFlex } \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 73a24fd..536bd54 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,11 +1,17 @@ import './style.css' -import Editor from './editor' +import Editor, { RowFlex } from './editor' window.onload = function () { const canvas = document.querySelector('canvas') if (!canvas) return - const text = `\n主诉:\n发热三天,咳嗽五天。\n现病史:\n发病前14天内有病历报告社区的旅行时或居住史;发病前14天内与新型冠状病毒感染的患者或无症状感染者有接触史;发病前14天内解除过来自病历报告社区的发热或有呼吸道症状的患者;聚集性发病,2周内在小范围如家庭、办公室、学校班级等场所,出现2例及以上发热或呼吸道症状的病例。\n既往史:\n有糖尿病10年,有高血压2年,有传染性疾病1年。\n体格检查:\nT:36.5℃,P:80bpm,R:20次/分,BP:120/80mmHg;\n辅助检查:\n2020年6月10日,普放:血细胞比容36.50%(偏低)40~50;单核细胞绝对值0.75*10^9/L(偏高)参考值:0.1~0.6;\n门诊诊断:\n1.高血压\n处置治疗:\n1.超声引导下甲状腺细针穿刺术;\n2.乙型肝炎表面抗体测定;\n3.膜式病变细胞采集术、后颈皮下肤层;\n4.氯化钠注射液 250ml/袋、1袋;\n5.七叶皂苷钠片(欧开)、30mg/片*24/盒、1片、口服、BID(每日两次)、1天` + const text = `人民医院门诊病历\n\n主诉:\n发热三天,咳嗽五天。\n现病史:\n发病前14天内有病历报告社区的旅行时或居住史;发病前14天内与新型冠状病毒感染的患者或无症状感染者有接触史;发病前14天内解除过来自病历报告社区的发热或有呼吸道症状的患者;聚集性发病,2周内在小范围如家庭、办公室、学校班级等场所,出现2例及以上发热或呼吸道症状的病例。\n既往史:\n有糖尿病10年,有高血压2年,有传染性疾病1年。\n体格检查:\nT:36.5℃,P:80bpm,R:20次/分,BP:120/80mmHg;\n辅助检查:\n2020年6月10日,普放:血细胞比容36.50%(偏低)40~50;单核细胞绝对值0.75*10^9/L(偏高)参考值:0.1~0.6;\n门诊诊断:\n1.高血压\n处置治疗:\n1.超声引导下甲状腺细针穿刺术;\n2.乙型肝炎表面抗体测定;\n3.膜式病变细胞采集术、后颈皮下肤层;\n4.氯化钠注射液 250ml/袋、1袋;\n5.七叶皂苷钠片(欧开)、30mg/片*24/盒、1片、口服、BID(每日两次)、1天` + // 模拟行居中 + const centerText = ['人民医院门诊病历'] + const centerIndex: number[] = centerText.map(c => { + const i = text.indexOf(c) + return ~i ? Array(c.length).fill(i).map((_, j) => i + j) : [] + }).flat() // 模拟加粗字 const boldText = ['主诉:', '现病史:', '既往史:', '体格检查:', '辅助检查:', '门诊诊断:', '处置治疗:'] const boldIndex: number[] = boldText.map(b => { @@ -26,6 +32,13 @@ window.onload = function () { }).flat() // 组合数据 const data = text.split('').map((value, index) => { + if (centerIndex.includes(index)) { + return { + value, + size: 32, + rowFlex: RowFlex.CENTER + } + } if (boldIndex.includes(index)) { return { value,