kordoc 3.5.4 → 3.8.0
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/README.md +23 -1
- package/dist/{-KX7VLNW5.js → -ATVQYFSW.js} +21 -5
- package/dist/{chunk-WEAP42T3.js → chunk-3R3YK7EM.js} +2 -2
- package/dist/chunk-3R3YK7EM.js.map +1 -0
- package/dist/{chunk-XZTDYOZV.cjs → chunk-ITJIALN5.cjs} +2 -2
- package/dist/{chunk-XZTDYOZV.cjs.map → chunk-ITJIALN5.cjs.map} +1 -1
- package/dist/{chunk-VEB43O2L.js → chunk-QV25HMU7.js} +2 -2
- package/dist/chunk-QV25HMU7.js.map +1 -0
- package/dist/{chunk-DK2IE43H.js → chunk-SLKF72QF.js} +1682 -718
- package/dist/chunk-SLKF72QF.js.map +1 -0
- package/dist/cli.js +4 -4
- package/dist/index.cjs +1908 -944
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +130 -8
- package/dist/index.d.ts +130 -8
- package/dist/index.js +1681 -717
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +3 -3
- package/dist/{parser-W5TBEAVX.js → parser-7G5F7PT2.js} +2 -2
- package/dist/{parser-XT65AEDJ.js → parser-DCK42RMA.js} +2 -2
- package/dist/{parser-CPTBEGQP.cjs → parser-GUSJH44K.cjs} +14 -14
- package/dist/{parser-CPTBEGQP.cjs.map → parser-GUSJH44K.cjs.map} +1 -1
- package/dist/{watch-VOSNRZAY.js → watch-GVZESOCE.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-DK2IE43H.js.map +0 -1
- package/dist/chunk-VEB43O2L.js.map +0 -1
- package/dist/chunk-WEAP42T3.js.map +0 -1
- /package/dist/{-KX7VLNW5.js.map → -ATVQYFSW.js.map} +0 -0
- /package/dist/{parser-W5TBEAVX.js.map → parser-7G5F7PT2.js.map} +0 -0
- /package/dist/{parser-XT65AEDJ.js.map → parser-DCK42RMA.js.map} +0 -0
- /package/dist/{watch-VOSNRZAY.js.map → watch-GVZESOCE.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -254,6 +254,11 @@ interface PatchSkip {
|
|
|
254
254
|
before?: string;
|
|
255
255
|
/** 편집 쪽 내용 요약 (최대 80자) */
|
|
256
256
|
after?: string;
|
|
257
|
+
/**
|
|
258
|
+
* 부분 적용 표시 — 변경이 적용은 됐지만(applied 계상) 편집 원형 그대로는
|
|
259
|
+
* 아님 (예: 셀 내 줄 추가를 마지막 문단에 병합). 완전 미적용 skip과 구분.
|
|
260
|
+
*/
|
|
261
|
+
partial?: boolean;
|
|
257
262
|
}
|
|
258
263
|
/** patchHwpx 옵션 */
|
|
259
264
|
interface PatchOptions {
|
|
@@ -308,6 +313,32 @@ interface WatchOptions {
|
|
|
308
313
|
silent?: boolean;
|
|
309
314
|
}
|
|
310
315
|
|
|
316
|
+
/** 양식 필드 매칭 공용 유틸 — filler.ts, filler-hwpx.ts에서 공유 */
|
|
317
|
+
/**
|
|
318
|
+
* 채울 값 — 문자열이면 같은 라벨 모든 등장에 동일값(단일 양식),
|
|
319
|
+
* 배열이면 등장 순서대로 하나씩 소진(2~30장 반복 양식·명부형 표).
|
|
320
|
+
*/
|
|
321
|
+
type FillValue = string | string[];
|
|
322
|
+
/**
|
|
323
|
+
* 다중값 커서 — 라벨별 값 소비 상태를 추적한다.
|
|
324
|
+
* 스칼라 값은 무한 반복(기존 동작), 배열 값은 적용 순서대로 소진되며
|
|
325
|
+
* 다 쓰면 available=false가 되어 이후 등장은 채우지 않는다.
|
|
326
|
+
*/
|
|
327
|
+
declare class ValueCursor {
|
|
328
|
+
private values;
|
|
329
|
+
private nextIdx;
|
|
330
|
+
constructor(values: Map<string, FillValue>);
|
|
331
|
+
keys(): IterableIterator<string>;
|
|
332
|
+
has(key: string): boolean;
|
|
333
|
+
isArray(key: string): boolean;
|
|
334
|
+
/** 남은 값이 있으면 true (스칼라는 항상 true) */
|
|
335
|
+
available(key: string): boolean;
|
|
336
|
+
/** 현재 값 미리보기 (소진 없음) */
|
|
337
|
+
peek(key: string): string | undefined;
|
|
338
|
+
/** 값 소비 — 배열이면 커서 전진, 소진 시 undefined */
|
|
339
|
+
consume(key: string): string | undefined;
|
|
340
|
+
}
|
|
341
|
+
|
|
311
342
|
/** 문서 비교 엔진 — IR 레벨 블록 비교로 신구대조표 생성 */
|
|
312
343
|
|
|
313
344
|
/**
|
|
@@ -366,6 +397,8 @@ interface FillResult {
|
|
|
366
397
|
*
|
|
367
398
|
* @param blocks 원본 IRBlock[] (변경하지 않음 — deep clone)
|
|
368
399
|
* @param values 채울 값 맵 (라벨 → 새 값). 라벨은 접두사 매칭 지원.
|
|
400
|
+
* 값이 배열이면 같은 라벨의 등장 순서대로 하나씩 소진(반복 양식·명부형 표),
|
|
401
|
+
* 문자열이면 모든 등장에 동일값.
|
|
369
402
|
* @returns FillResult
|
|
370
403
|
*
|
|
371
404
|
* @example
|
|
@@ -379,7 +412,7 @@ interface FillResult {
|
|
|
379
412
|
* })
|
|
380
413
|
* ```
|
|
381
414
|
*/
|
|
382
|
-
declare function fillFormFields(blocks: IRBlock[], values: Record<string,
|
|
415
|
+
declare function fillFormFields(blocks: IRBlock[], values: Record<string, FillValue>): FillResult;
|
|
383
416
|
|
|
384
417
|
/**
|
|
385
418
|
* HWPX 원본 서식 유지 채우기 — section XML 오프셋 splice (v3.1, 바이트 보존)
|
|
@@ -417,10 +450,12 @@ interface HwpxFillResult {
|
|
|
417
450
|
* HWPX 원본을 직접 수정하여 서식 필드를 채움 — 스타일 100% 보존.
|
|
418
451
|
*
|
|
419
452
|
* @param hwpxBuffer 원본 HWPX 파일 버퍼
|
|
420
|
-
* @param values 채울 값 맵 (라벨 → 값)
|
|
453
|
+
* @param values 채울 값 맵 (라벨 → 값). 값이 배열이면 같은 라벨의 등장 순서대로
|
|
454
|
+
* 하나씩 소진된다 — 2~30장 반복 양식·명부형 표(헤더+여러 데이터 행) 채우기용.
|
|
455
|
+
* 문자열이면 기존처럼 모든 등장에 동일값.
|
|
421
456
|
* @returns HwpxFillResult
|
|
422
457
|
*/
|
|
423
|
-
declare function fillHwpx(hwpxBuffer: ArrayBuffer, values: Record<string,
|
|
458
|
+
declare function fillHwpx(hwpxBuffer: ArrayBuffer, values: Record<string, FillValue>): Promise<HwpxFillResult>;
|
|
424
459
|
|
|
425
460
|
/**
|
|
426
461
|
* 공문서(公文書) 모드 — 한국 행정 공문서 표준 서식 렌더링 로직
|
|
@@ -458,6 +493,14 @@ interface GongmunOptions {
|
|
|
458
493
|
};
|
|
459
494
|
/** 문서 제목(첫 h1)을 가운데 정렬. 기본 true (행정기관명·보고서 제목) */
|
|
460
495
|
centerTitle?: boolean;
|
|
496
|
+
/**
|
|
497
|
+
* 문단별 자동 장평 — 한두 글자(짧은 꼬리)만 다음 줄로 넘어가는 문단의 장평을
|
|
498
|
+
* 95→90%까지 자동 축소해 한 줄에 담는다(공무원 실무 관행의 자동화).
|
|
499
|
+
* false로 끄거나 minRatio(기본 90)로 하한 조정. 기본 켜짐.
|
|
500
|
+
*/
|
|
501
|
+
autoFit?: boolean | {
|
|
502
|
+
minRatio?: number;
|
|
503
|
+
};
|
|
461
504
|
}
|
|
462
505
|
/** 프리셋 별칭(한글/영문) → 내부 preset 키. CLI·라이브러리 공용 */
|
|
463
506
|
declare const PRESET_ALIAS: Record<string, GongmunPreset>;
|
|
@@ -509,6 +552,73 @@ interface MarkdownToHwpxOptions {
|
|
|
509
552
|
*/
|
|
510
553
|
declare function markdownToHwpx(markdown: string, options?: MarkdownToHwpxOptions): Promise<ArrayBuffer>;
|
|
511
554
|
|
|
555
|
+
/**
|
|
556
|
+
* 한글 조판 텍스트 폭 계산 — 함초롬바탕(HCR Batang) 실측 advance 테이블
|
|
557
|
+
*
|
|
558
|
+
* 공문서 표준 본문 글꼴인 함초롬바탕 정품 TTF(한컴 공개 배포)의 hmtx advance를
|
|
559
|
+
* upem=1000 기준으로 추출한 값이다. Bold도 advance가 Regular와 완전히 동일함을
|
|
560
|
+
* 전수 확인했다(한컴이 굵기 간 폭을 통일해 제작). 한글 음절 11,172자 전수 = 970,
|
|
561
|
+
* 한자 = 1000, 전각형·원문자·도형·화살표·단위기호 = 970으로 균일하다.
|
|
562
|
+
*
|
|
563
|
+
* 단위: em×1000. 실제 폭(HWPUNIT) = w/1000 × charPr.height × ratio(장평)/100.
|
|
564
|
+
* (1em = 글자크기 = charPr.height HWPUNIT — 1pt = 100 HWPUNIT이므로)
|
|
565
|
+
*
|
|
566
|
+
* 공백: HWP는 charPr useFontSpace=0(기본)일 때 글꼴의 space advance(0.30em) 대신
|
|
567
|
+
* 반각 고정폭(0.50em)을 쓴다 — kordoc 생성 문서는 모두 useFontSpace=0이므로
|
|
568
|
+
* 기본 SPACE_EM=500. (글꼴값을 쓰려면 measure 옵션 fontSpace로 300 지정)
|
|
569
|
+
*
|
|
570
|
+
* 다른 글꼴(맑은 고딕 등)도 한글=전각 균일·숫자≈0.55em의 동일 부류 구조라
|
|
571
|
+
* 이 테이블로 근사한다(오차 수 % 이내 — 공문서 본문은 어차피 함초롬바탕 관행).
|
|
572
|
+
*/
|
|
573
|
+
/** 코드포인트의 advance(em×1000). 미상 문자는 CJK권 970 / 라틴권 550 폴백 */
|
|
574
|
+
declare function charWidthEm1000(cp: number): number;
|
|
575
|
+
/** HWP 공백 폭(em×1000) — useFontSpace=0(기본): 반각 고정 500 / =1: 글꼴값 300 */
|
|
576
|
+
declare const SPACE_EM_FIXED = 500;
|
|
577
|
+
declare const SPACE_EM_FONT = 300;
|
|
578
|
+
interface MeasureOptions {
|
|
579
|
+
/** 공백 폭(em×1000). 기본 SPACE_EM_FIXED(500) = useFontSpace 0 */
|
|
580
|
+
spaceEm?: number;
|
|
581
|
+
/** 자간(charPr spacing %) — 글자폭의 %가 문자마다 추가 */
|
|
582
|
+
spacingPct?: number;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* 텍스트 폭(HWPUNIT). height=charPr height(pt×100), ratioPct=장평 %.
|
|
586
|
+
* 결과는 float — 호출부에서 비교 시 ±0.5 HWPUNIT 오차 허용 권장.
|
|
587
|
+
*/
|
|
588
|
+
declare function measureTextWidth(text: string, height: number, ratioPct: number, opts?: MeasureOptions): number;
|
|
589
|
+
type WrapMode = "keep" | "charAll";
|
|
590
|
+
interface WrapResult {
|
|
591
|
+
/** 줄 수 */
|
|
592
|
+
lines: number;
|
|
593
|
+
/** 각 줄의 시작 오프셋(UTF-16) — [0, …] */
|
|
594
|
+
starts: number[];
|
|
595
|
+
/** 마지막 줄 텍스트 폭(HWPUNIT) */
|
|
596
|
+
lastLineWidth: number;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* 문단 줄바꿈 시뮬레이션.
|
|
600
|
+
* mode 'keep' = breakNonLatinWord=KEEP_WORD(어절 단위, 공문서 모드·Windows 한글),
|
|
601
|
+
* mode 'charAll' = 글자 단위(BREAK_WORD·macOS 한글·전자결재 변환기의 실동작).
|
|
602
|
+
* 한 어절이 줄보다 길면 keep에서도 글자 단위로 강제 분해(한컴 동일).
|
|
603
|
+
*
|
|
604
|
+
* @param text 문단 전체 텍스트(항목 부호 포함)
|
|
605
|
+
* @param firstWidth 첫 줄 가용 폭(HWPUNIT)
|
|
606
|
+
* @param contWidth 둘째 줄부터 가용 폭(HWPUNIT) — 내어쓰기 반영
|
|
607
|
+
* @param height charPr height (pt×100)
|
|
608
|
+
* @param ratioPct 장평 %
|
|
609
|
+
*/
|
|
610
|
+
declare function simulateWrap(text: string, firstWidth: number, contWidth: number, height: number, ratioPct: number, mode?: WrapMode, opts?: MeasureOptions): WrapResult;
|
|
611
|
+
/** @deprecated simulateWrap(text, …, 'keep') 별칭 — 하위 호환 */
|
|
612
|
+
declare function simulateWrapKeepWord(text: string, firstWidth: number, contWidth: number, height: number, ratioPct: number, opts?: MeasureOptions): WrapResult;
|
|
613
|
+
/**
|
|
614
|
+
* 한두 글자(짧은 꼬리)가 다음 줄로 넘어간 문단을 장평 축소로 한 줄 줄일 수 있는지
|
|
615
|
+
* 탐색. baseRatio에서 줄 수 N≥2일 때 r=baseRatio-1…minRatio를 내려가며 처음으로
|
|
616
|
+
* 줄 수가 줄어드는(가장 큰) r을 반환. 불가능하면 null.
|
|
617
|
+
* (실무 관행: 공무원이 문단 장평을 95→92 등으로 줄여 orphan을 위로 당기는 조작의 자동화.
|
|
618
|
+
* keep 모드로 판정 — 글자 단위 조판은 항상 keep 이하의 줄 수라 함께 만족된다.)
|
|
619
|
+
*/
|
|
620
|
+
declare function fitRatioForFewerLines(text: string, firstWidth: number, contWidth: number, height: number, baseRatio: number, minRatio: number, opts?: MeasureOptions): number | null;
|
|
621
|
+
|
|
512
622
|
/**
|
|
513
623
|
* HWPX 라운드트립 소스맵 — section XML 문자열에서 문단/표 셀의 문자 범위를 추적.
|
|
514
624
|
*
|
|
@@ -558,6 +668,11 @@ interface ScanCell {
|
|
|
558
668
|
paragraphs: ScanParagraph[];
|
|
559
669
|
/** 셀 내부 중첩표 (문서 순서) */
|
|
560
670
|
tables: ScanTable[];
|
|
671
|
+
/** <hp:cellAddr> 태그 범위 (자기닫힘=태그 전체, 펼친형=여는 태그) — rowAddr 재작성용 */
|
|
672
|
+
addrTagRange?: {
|
|
673
|
+
start: number;
|
|
674
|
+
end: number;
|
|
675
|
+
};
|
|
561
676
|
}
|
|
562
677
|
/** 스캔된 표 */
|
|
563
678
|
interface ScanTable {
|
|
@@ -567,6 +682,11 @@ interface ScanTable {
|
|
|
567
682
|
topLevel: boolean;
|
|
568
683
|
/** 비어있지 않은 행들 (tr 순서) */
|
|
569
684
|
rows: ScanCell[][];
|
|
685
|
+
/** rows[i]의 <hp:tr>...</hp:tr> XML 범위 (행 추가/삭제 splice용, rows와 정렬) */
|
|
686
|
+
rowRanges: {
|
|
687
|
+
start: number;
|
|
688
|
+
end: number;
|
|
689
|
+
}[];
|
|
570
690
|
/** 앵커 좌표 → 셀 ("r,c") */
|
|
571
691
|
cellByAnchor: Map<string, ScanCell>;
|
|
572
692
|
}
|
|
@@ -632,9 +752,11 @@ declare function applySplices(xml: string, splices: SpliceEdit[]): string;
|
|
|
632
752
|
* 스타일·이미지·표 구조·설정은 1바이트도 건드리지 않는다 (section XML 외
|
|
633
753
|
* ZIP 엔트리는 원본 바이트 그대로, 변경 문단도 run 구조·charPr 보존).
|
|
634
754
|
*
|
|
635
|
-
* 지원: 문단/헤딩 텍스트 수정, 표 셀 텍스트 수정 (GFM·HTML·1x1·1열 표)
|
|
636
|
-
*
|
|
637
|
-
*
|
|
755
|
+
* 지원: 문단/헤딩 텍스트 수정, 표 셀 텍스트 수정 (GFM·HTML·1x1·1열 표),
|
|
756
|
+
* 문단 → GFM 표 인플레이스 변환 (v3.5 — table-insert.ts),
|
|
757
|
+
* GFM/HTML 표 행 추가/삭제 (v3.7 — table-rows.ts, 병합 교차·개체 포함 행은 skip).
|
|
758
|
+
* 미지원(graceful skip): 블록 추가/삭제/순서 변경, 표 열/병합 변경,
|
|
759
|
+
* 캡션·각주·머리말/꼬리말·이미지 변경. skipped[]에 사유와 함께 보고된다.
|
|
638
760
|
*/
|
|
639
761
|
|
|
640
762
|
/**
|
|
@@ -907,6 +1029,6 @@ interface FillFormOutput {
|
|
|
907
1029
|
* console.log(result.output) // 채워진 마크다운
|
|
908
1030
|
* ```
|
|
909
1031
|
*/
|
|
910
|
-
declare function fillForm(input: string | ArrayBuffer | Buffer, values: Record<string,
|
|
1032
|
+
declare function fillForm(input: string | ArrayBuffer | Buffer, values: Record<string, FillValue>, outputFormat?: FillOutputFormat): Promise<FillFormOutput>;
|
|
911
1033
|
|
|
912
|
-
export { type BlockCapability, type BlockCapabilityInfo, type BlockDiff, type BlockEdit, type BlockSourceRef, type BoundingBox, type CellCapability, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type DocumentQualitySummary, type ErrorCode, type ExtractedImage, type FileType, type FillFormOutput, type FillOutputFormat, type FillResult, type FormField, type FormFieldSchema, type FormFieldType, type FormResult, type FormSchemaResult, type GongmunFont, type GongmunNumbering, type GongmunOptions, type GongmunPreset, type GongmunPresetInput, type HwpxFillResult, HwpxSession, type HwpxTheme, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type MarkdownToHwpxOptions, type OcrProvider, type OutlineItem, PRESET_ALIAS, type PageMargin, type PageQuality, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type PatchOptions, type PatchResult, type PatchSkip, type PrintOptions, type PrintPreset, type ScanCell, type ScanParaKind, type ScanParagraph, type ScanTable, type SectionScan, type SpliceEdit, type TRange, VERSION, type WarningCode, type WatchOptions, applySplices, blocksToMarkdown, blocksToPdf, buildParagraphSplices, buildRangeSplices, compare, detectFormat, detectOle2Format, detectZipFormat, diffBlocks, extractFormFields, extractFormSchema, fillForm, fillFormFields, fillHwpx, inferFieldType, isHwpxFile, isLabelCell, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToPdf, normalizeGongmunPreset, openHwpxDocument, parse, parseDocx, parseHwp, parseHwp3, parseHwpml, parseHwpx, parsePdf, parseXls, parseXlsx, patchHwp, patchHwpx, patchHwpxBlocks, renderHtml, scanSectionXml };
|
|
1034
|
+
export { type BlockCapability, type BlockCapabilityInfo, type BlockDiff, type BlockEdit, type BlockSourceRef, type BoundingBox, type CellCapability, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type DocumentQualitySummary, type ErrorCode, type ExtractedImage, type FileType, type FillFormOutput, type FillOutputFormat, type FillResult, type FillValue, type FormField, type FormFieldSchema, type FormFieldType, type FormResult, type FormSchemaResult, type GongmunFont, type GongmunNumbering, type GongmunOptions, type GongmunPreset, type GongmunPresetInput, type HwpxFillResult, HwpxSession, type HwpxTheme, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type MarkdownToHwpxOptions, type MeasureOptions, type OcrProvider, type OutlineItem, PRESET_ALIAS, type PageMargin, type PageQuality, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type PatchOptions, type PatchResult, type PatchSkip, type PrintOptions, type PrintPreset, SPACE_EM_FIXED, SPACE_EM_FONT, type ScanCell, type ScanParaKind, type ScanParagraph, type ScanTable, type SectionScan, type SpliceEdit, type TRange, VERSION, ValueCursor, type WarningCode, type WatchOptions, type WrapMode, type WrapResult, applySplices, blocksToMarkdown, blocksToPdf, buildParagraphSplices, buildRangeSplices, charWidthEm1000, compare, detectFormat, detectOle2Format, detectZipFormat, diffBlocks, extractFormFields, extractFormSchema, fillForm, fillFormFields, fillHwpx, fitRatioForFewerLines, inferFieldType, isHwpxFile, isLabelCell, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToPdf, measureTextWidth, normalizeGongmunPreset, openHwpxDocument, parse, parseDocx, parseHwp, parseHwp3, parseHwpml, parseHwpx, parsePdf, parseXls, parseXlsx, patchHwp, patchHwpx, patchHwpxBlocks, renderHtml, scanSectionXml, simulateWrap, simulateWrapKeepWord };
|
package/dist/index.d.ts
CHANGED
|
@@ -254,6 +254,11 @@ interface PatchSkip {
|
|
|
254
254
|
before?: string;
|
|
255
255
|
/** 편집 쪽 내용 요약 (최대 80자) */
|
|
256
256
|
after?: string;
|
|
257
|
+
/**
|
|
258
|
+
* 부분 적용 표시 — 변경이 적용은 됐지만(applied 계상) 편집 원형 그대로는
|
|
259
|
+
* 아님 (예: 셀 내 줄 추가를 마지막 문단에 병합). 완전 미적용 skip과 구분.
|
|
260
|
+
*/
|
|
261
|
+
partial?: boolean;
|
|
257
262
|
}
|
|
258
263
|
/** patchHwpx 옵션 */
|
|
259
264
|
interface PatchOptions {
|
|
@@ -308,6 +313,32 @@ interface WatchOptions {
|
|
|
308
313
|
silent?: boolean;
|
|
309
314
|
}
|
|
310
315
|
|
|
316
|
+
/** 양식 필드 매칭 공용 유틸 — filler.ts, filler-hwpx.ts에서 공유 */
|
|
317
|
+
/**
|
|
318
|
+
* 채울 값 — 문자열이면 같은 라벨 모든 등장에 동일값(단일 양식),
|
|
319
|
+
* 배열이면 등장 순서대로 하나씩 소진(2~30장 반복 양식·명부형 표).
|
|
320
|
+
*/
|
|
321
|
+
type FillValue = string | string[];
|
|
322
|
+
/**
|
|
323
|
+
* 다중값 커서 — 라벨별 값 소비 상태를 추적한다.
|
|
324
|
+
* 스칼라 값은 무한 반복(기존 동작), 배열 값은 적용 순서대로 소진되며
|
|
325
|
+
* 다 쓰면 available=false가 되어 이후 등장은 채우지 않는다.
|
|
326
|
+
*/
|
|
327
|
+
declare class ValueCursor {
|
|
328
|
+
private values;
|
|
329
|
+
private nextIdx;
|
|
330
|
+
constructor(values: Map<string, FillValue>);
|
|
331
|
+
keys(): IterableIterator<string>;
|
|
332
|
+
has(key: string): boolean;
|
|
333
|
+
isArray(key: string): boolean;
|
|
334
|
+
/** 남은 값이 있으면 true (스칼라는 항상 true) */
|
|
335
|
+
available(key: string): boolean;
|
|
336
|
+
/** 현재 값 미리보기 (소진 없음) */
|
|
337
|
+
peek(key: string): string | undefined;
|
|
338
|
+
/** 값 소비 — 배열이면 커서 전진, 소진 시 undefined */
|
|
339
|
+
consume(key: string): string | undefined;
|
|
340
|
+
}
|
|
341
|
+
|
|
311
342
|
/** 문서 비교 엔진 — IR 레벨 블록 비교로 신구대조표 생성 */
|
|
312
343
|
|
|
313
344
|
/**
|
|
@@ -366,6 +397,8 @@ interface FillResult {
|
|
|
366
397
|
*
|
|
367
398
|
* @param blocks 원본 IRBlock[] (변경하지 않음 — deep clone)
|
|
368
399
|
* @param values 채울 값 맵 (라벨 → 새 값). 라벨은 접두사 매칭 지원.
|
|
400
|
+
* 값이 배열이면 같은 라벨의 등장 순서대로 하나씩 소진(반복 양식·명부형 표),
|
|
401
|
+
* 문자열이면 모든 등장에 동일값.
|
|
369
402
|
* @returns FillResult
|
|
370
403
|
*
|
|
371
404
|
* @example
|
|
@@ -379,7 +412,7 @@ interface FillResult {
|
|
|
379
412
|
* })
|
|
380
413
|
* ```
|
|
381
414
|
*/
|
|
382
|
-
declare function fillFormFields(blocks: IRBlock[], values: Record<string,
|
|
415
|
+
declare function fillFormFields(blocks: IRBlock[], values: Record<string, FillValue>): FillResult;
|
|
383
416
|
|
|
384
417
|
/**
|
|
385
418
|
* HWPX 원본 서식 유지 채우기 — section XML 오프셋 splice (v3.1, 바이트 보존)
|
|
@@ -417,10 +450,12 @@ interface HwpxFillResult {
|
|
|
417
450
|
* HWPX 원본을 직접 수정하여 서식 필드를 채움 — 스타일 100% 보존.
|
|
418
451
|
*
|
|
419
452
|
* @param hwpxBuffer 원본 HWPX 파일 버퍼
|
|
420
|
-
* @param values 채울 값 맵 (라벨 → 값)
|
|
453
|
+
* @param values 채울 값 맵 (라벨 → 값). 값이 배열이면 같은 라벨의 등장 순서대로
|
|
454
|
+
* 하나씩 소진된다 — 2~30장 반복 양식·명부형 표(헤더+여러 데이터 행) 채우기용.
|
|
455
|
+
* 문자열이면 기존처럼 모든 등장에 동일값.
|
|
421
456
|
* @returns HwpxFillResult
|
|
422
457
|
*/
|
|
423
|
-
declare function fillHwpx(hwpxBuffer: ArrayBuffer, values: Record<string,
|
|
458
|
+
declare function fillHwpx(hwpxBuffer: ArrayBuffer, values: Record<string, FillValue>): Promise<HwpxFillResult>;
|
|
424
459
|
|
|
425
460
|
/**
|
|
426
461
|
* 공문서(公文書) 모드 — 한국 행정 공문서 표준 서식 렌더링 로직
|
|
@@ -458,6 +493,14 @@ interface GongmunOptions {
|
|
|
458
493
|
};
|
|
459
494
|
/** 문서 제목(첫 h1)을 가운데 정렬. 기본 true (행정기관명·보고서 제목) */
|
|
460
495
|
centerTitle?: boolean;
|
|
496
|
+
/**
|
|
497
|
+
* 문단별 자동 장평 — 한두 글자(짧은 꼬리)만 다음 줄로 넘어가는 문단의 장평을
|
|
498
|
+
* 95→90%까지 자동 축소해 한 줄에 담는다(공무원 실무 관행의 자동화).
|
|
499
|
+
* false로 끄거나 minRatio(기본 90)로 하한 조정. 기본 켜짐.
|
|
500
|
+
*/
|
|
501
|
+
autoFit?: boolean | {
|
|
502
|
+
minRatio?: number;
|
|
503
|
+
};
|
|
461
504
|
}
|
|
462
505
|
/** 프리셋 별칭(한글/영문) → 내부 preset 키. CLI·라이브러리 공용 */
|
|
463
506
|
declare const PRESET_ALIAS: Record<string, GongmunPreset>;
|
|
@@ -509,6 +552,73 @@ interface MarkdownToHwpxOptions {
|
|
|
509
552
|
*/
|
|
510
553
|
declare function markdownToHwpx(markdown: string, options?: MarkdownToHwpxOptions): Promise<ArrayBuffer>;
|
|
511
554
|
|
|
555
|
+
/**
|
|
556
|
+
* 한글 조판 텍스트 폭 계산 — 함초롬바탕(HCR Batang) 실측 advance 테이블
|
|
557
|
+
*
|
|
558
|
+
* 공문서 표준 본문 글꼴인 함초롬바탕 정품 TTF(한컴 공개 배포)의 hmtx advance를
|
|
559
|
+
* upem=1000 기준으로 추출한 값이다. Bold도 advance가 Regular와 완전히 동일함을
|
|
560
|
+
* 전수 확인했다(한컴이 굵기 간 폭을 통일해 제작). 한글 음절 11,172자 전수 = 970,
|
|
561
|
+
* 한자 = 1000, 전각형·원문자·도형·화살표·단위기호 = 970으로 균일하다.
|
|
562
|
+
*
|
|
563
|
+
* 단위: em×1000. 실제 폭(HWPUNIT) = w/1000 × charPr.height × ratio(장평)/100.
|
|
564
|
+
* (1em = 글자크기 = charPr.height HWPUNIT — 1pt = 100 HWPUNIT이므로)
|
|
565
|
+
*
|
|
566
|
+
* 공백: HWP는 charPr useFontSpace=0(기본)일 때 글꼴의 space advance(0.30em) 대신
|
|
567
|
+
* 반각 고정폭(0.50em)을 쓴다 — kordoc 생성 문서는 모두 useFontSpace=0이므로
|
|
568
|
+
* 기본 SPACE_EM=500. (글꼴값을 쓰려면 measure 옵션 fontSpace로 300 지정)
|
|
569
|
+
*
|
|
570
|
+
* 다른 글꼴(맑은 고딕 등)도 한글=전각 균일·숫자≈0.55em의 동일 부류 구조라
|
|
571
|
+
* 이 테이블로 근사한다(오차 수 % 이내 — 공문서 본문은 어차피 함초롬바탕 관행).
|
|
572
|
+
*/
|
|
573
|
+
/** 코드포인트의 advance(em×1000). 미상 문자는 CJK권 970 / 라틴권 550 폴백 */
|
|
574
|
+
declare function charWidthEm1000(cp: number): number;
|
|
575
|
+
/** HWP 공백 폭(em×1000) — useFontSpace=0(기본): 반각 고정 500 / =1: 글꼴값 300 */
|
|
576
|
+
declare const SPACE_EM_FIXED = 500;
|
|
577
|
+
declare const SPACE_EM_FONT = 300;
|
|
578
|
+
interface MeasureOptions {
|
|
579
|
+
/** 공백 폭(em×1000). 기본 SPACE_EM_FIXED(500) = useFontSpace 0 */
|
|
580
|
+
spaceEm?: number;
|
|
581
|
+
/** 자간(charPr spacing %) — 글자폭의 %가 문자마다 추가 */
|
|
582
|
+
spacingPct?: number;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* 텍스트 폭(HWPUNIT). height=charPr height(pt×100), ratioPct=장평 %.
|
|
586
|
+
* 결과는 float — 호출부에서 비교 시 ±0.5 HWPUNIT 오차 허용 권장.
|
|
587
|
+
*/
|
|
588
|
+
declare function measureTextWidth(text: string, height: number, ratioPct: number, opts?: MeasureOptions): number;
|
|
589
|
+
type WrapMode = "keep" | "charAll";
|
|
590
|
+
interface WrapResult {
|
|
591
|
+
/** 줄 수 */
|
|
592
|
+
lines: number;
|
|
593
|
+
/** 각 줄의 시작 오프셋(UTF-16) — [0, …] */
|
|
594
|
+
starts: number[];
|
|
595
|
+
/** 마지막 줄 텍스트 폭(HWPUNIT) */
|
|
596
|
+
lastLineWidth: number;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* 문단 줄바꿈 시뮬레이션.
|
|
600
|
+
* mode 'keep' = breakNonLatinWord=KEEP_WORD(어절 단위, 공문서 모드·Windows 한글),
|
|
601
|
+
* mode 'charAll' = 글자 단위(BREAK_WORD·macOS 한글·전자결재 변환기의 실동작).
|
|
602
|
+
* 한 어절이 줄보다 길면 keep에서도 글자 단위로 강제 분해(한컴 동일).
|
|
603
|
+
*
|
|
604
|
+
* @param text 문단 전체 텍스트(항목 부호 포함)
|
|
605
|
+
* @param firstWidth 첫 줄 가용 폭(HWPUNIT)
|
|
606
|
+
* @param contWidth 둘째 줄부터 가용 폭(HWPUNIT) — 내어쓰기 반영
|
|
607
|
+
* @param height charPr height (pt×100)
|
|
608
|
+
* @param ratioPct 장평 %
|
|
609
|
+
*/
|
|
610
|
+
declare function simulateWrap(text: string, firstWidth: number, contWidth: number, height: number, ratioPct: number, mode?: WrapMode, opts?: MeasureOptions): WrapResult;
|
|
611
|
+
/** @deprecated simulateWrap(text, …, 'keep') 별칭 — 하위 호환 */
|
|
612
|
+
declare function simulateWrapKeepWord(text: string, firstWidth: number, contWidth: number, height: number, ratioPct: number, opts?: MeasureOptions): WrapResult;
|
|
613
|
+
/**
|
|
614
|
+
* 한두 글자(짧은 꼬리)가 다음 줄로 넘어간 문단을 장평 축소로 한 줄 줄일 수 있는지
|
|
615
|
+
* 탐색. baseRatio에서 줄 수 N≥2일 때 r=baseRatio-1…minRatio를 내려가며 처음으로
|
|
616
|
+
* 줄 수가 줄어드는(가장 큰) r을 반환. 불가능하면 null.
|
|
617
|
+
* (실무 관행: 공무원이 문단 장평을 95→92 등으로 줄여 orphan을 위로 당기는 조작의 자동화.
|
|
618
|
+
* keep 모드로 판정 — 글자 단위 조판은 항상 keep 이하의 줄 수라 함께 만족된다.)
|
|
619
|
+
*/
|
|
620
|
+
declare function fitRatioForFewerLines(text: string, firstWidth: number, contWidth: number, height: number, baseRatio: number, minRatio: number, opts?: MeasureOptions): number | null;
|
|
621
|
+
|
|
512
622
|
/**
|
|
513
623
|
* HWPX 라운드트립 소스맵 — section XML 문자열에서 문단/표 셀의 문자 범위를 추적.
|
|
514
624
|
*
|
|
@@ -558,6 +668,11 @@ interface ScanCell {
|
|
|
558
668
|
paragraphs: ScanParagraph[];
|
|
559
669
|
/** 셀 내부 중첩표 (문서 순서) */
|
|
560
670
|
tables: ScanTable[];
|
|
671
|
+
/** <hp:cellAddr> 태그 범위 (자기닫힘=태그 전체, 펼친형=여는 태그) — rowAddr 재작성용 */
|
|
672
|
+
addrTagRange?: {
|
|
673
|
+
start: number;
|
|
674
|
+
end: number;
|
|
675
|
+
};
|
|
561
676
|
}
|
|
562
677
|
/** 스캔된 표 */
|
|
563
678
|
interface ScanTable {
|
|
@@ -567,6 +682,11 @@ interface ScanTable {
|
|
|
567
682
|
topLevel: boolean;
|
|
568
683
|
/** 비어있지 않은 행들 (tr 순서) */
|
|
569
684
|
rows: ScanCell[][];
|
|
685
|
+
/** rows[i]의 <hp:tr>...</hp:tr> XML 범위 (행 추가/삭제 splice용, rows와 정렬) */
|
|
686
|
+
rowRanges: {
|
|
687
|
+
start: number;
|
|
688
|
+
end: number;
|
|
689
|
+
}[];
|
|
570
690
|
/** 앵커 좌표 → 셀 ("r,c") */
|
|
571
691
|
cellByAnchor: Map<string, ScanCell>;
|
|
572
692
|
}
|
|
@@ -632,9 +752,11 @@ declare function applySplices(xml: string, splices: SpliceEdit[]): string;
|
|
|
632
752
|
* 스타일·이미지·표 구조·설정은 1바이트도 건드리지 않는다 (section XML 외
|
|
633
753
|
* ZIP 엔트리는 원본 바이트 그대로, 변경 문단도 run 구조·charPr 보존).
|
|
634
754
|
*
|
|
635
|
-
* 지원: 문단/헤딩 텍스트 수정, 표 셀 텍스트 수정 (GFM·HTML·1x1·1열 표)
|
|
636
|
-
*
|
|
637
|
-
*
|
|
755
|
+
* 지원: 문단/헤딩 텍스트 수정, 표 셀 텍스트 수정 (GFM·HTML·1x1·1열 표),
|
|
756
|
+
* 문단 → GFM 표 인플레이스 변환 (v3.5 — table-insert.ts),
|
|
757
|
+
* GFM/HTML 표 행 추가/삭제 (v3.7 — table-rows.ts, 병합 교차·개체 포함 행은 skip).
|
|
758
|
+
* 미지원(graceful skip): 블록 추가/삭제/순서 변경, 표 열/병합 변경,
|
|
759
|
+
* 캡션·각주·머리말/꼬리말·이미지 변경. skipped[]에 사유와 함께 보고된다.
|
|
638
760
|
*/
|
|
639
761
|
|
|
640
762
|
/**
|
|
@@ -907,6 +1029,6 @@ interface FillFormOutput {
|
|
|
907
1029
|
* console.log(result.output) // 채워진 마크다운
|
|
908
1030
|
* ```
|
|
909
1031
|
*/
|
|
910
|
-
declare function fillForm(input: string | ArrayBuffer | Buffer, values: Record<string,
|
|
1032
|
+
declare function fillForm(input: string | ArrayBuffer | Buffer, values: Record<string, FillValue>, outputFormat?: FillOutputFormat): Promise<FillFormOutput>;
|
|
911
1033
|
|
|
912
|
-
export { type BlockCapability, type BlockCapabilityInfo, type BlockDiff, type BlockEdit, type BlockSourceRef, type BoundingBox, type CellCapability, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type DocumentQualitySummary, type ErrorCode, type ExtractedImage, type FileType, type FillFormOutput, type FillOutputFormat, type FillResult, type FormField, type FormFieldSchema, type FormFieldType, type FormResult, type FormSchemaResult, type GongmunFont, type GongmunNumbering, type GongmunOptions, type GongmunPreset, type GongmunPresetInput, type HwpxFillResult, HwpxSession, type HwpxTheme, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type MarkdownToHwpxOptions, type OcrProvider, type OutlineItem, PRESET_ALIAS, type PageMargin, type PageQuality, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type PatchOptions, type PatchResult, type PatchSkip, type PrintOptions, type PrintPreset, type ScanCell, type ScanParaKind, type ScanParagraph, type ScanTable, type SectionScan, type SpliceEdit, type TRange, VERSION, type WarningCode, type WatchOptions, applySplices, blocksToMarkdown, blocksToPdf, buildParagraphSplices, buildRangeSplices, compare, detectFormat, detectOle2Format, detectZipFormat, diffBlocks, extractFormFields, extractFormSchema, fillForm, fillFormFields, fillHwpx, inferFieldType, isHwpxFile, isLabelCell, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToPdf, normalizeGongmunPreset, openHwpxDocument, parse, parseDocx, parseHwp, parseHwp3, parseHwpml, parseHwpx, parsePdf, parseXls, parseXlsx, patchHwp, patchHwpx, patchHwpxBlocks, renderHtml, scanSectionXml };
|
|
1034
|
+
export { type BlockCapability, type BlockCapabilityInfo, type BlockDiff, type BlockEdit, type BlockSourceRef, type BoundingBox, type CellCapability, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type DocumentQualitySummary, type ErrorCode, type ExtractedImage, type FileType, type FillFormOutput, type FillOutputFormat, type FillResult, type FillValue, type FormField, type FormFieldSchema, type FormFieldType, type FormResult, type FormSchemaResult, type GongmunFont, type GongmunNumbering, type GongmunOptions, type GongmunPreset, type GongmunPresetInput, type HwpxFillResult, HwpxSession, type HwpxTheme, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type MarkdownToHwpxOptions, type MeasureOptions, type OcrProvider, type OutlineItem, PRESET_ALIAS, type PageMargin, type PageQuality, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type PatchOptions, type PatchResult, type PatchSkip, type PrintOptions, type PrintPreset, SPACE_EM_FIXED, SPACE_EM_FONT, type ScanCell, type ScanParaKind, type ScanParagraph, type ScanTable, type SectionScan, type SpliceEdit, type TRange, VERSION, ValueCursor, type WarningCode, type WatchOptions, type WrapMode, type WrapResult, applySplices, blocksToMarkdown, blocksToPdf, buildParagraphSplices, buildRangeSplices, charWidthEm1000, compare, detectFormat, detectOle2Format, detectZipFormat, diffBlocks, extractFormFields, extractFormSchema, fillForm, fillFormFields, fillHwpx, fitRatioForFewerLines, inferFieldType, isHwpxFile, isLabelCell, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToPdf, measureTextWidth, normalizeGongmunPreset, openHwpxDocument, parse, parseDocx, parseHwp, parseHwp3, parseHwpml, parseHwpx, parsePdf, parseXls, parseXlsx, patchHwp, patchHwpx, patchHwpxBlocks, renderHtml, scanSectionXml, simulateWrap, simulateWrapKeepWord };
|