kordoc 2.2.3 → 2.2.4
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/{chunk-AIG7SDWU.js → chunk-SY2RFVLW.js} +1051 -149
- package/dist/chunk-SY2RFVLW.js.map +1 -0
- package/dist/cli.js +149 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +799 -238
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +97 -7
- package/dist/index.d.ts +97 -7
- package/dist/index.js +795 -238
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +126 -6
- package/dist/mcp.js.map +1 -1
- package/dist/{watch-H672QAW2.js → watch-5P7DJ3HG.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-AIG7SDWU.js.map +0 -1
- /package/dist/{watch-H672QAW2.js.map → watch-5P7DJ3HG.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -227,12 +227,70 @@ declare function diffBlocks(blocksA: IRBlock[], blocksB: IRBlock[]): DiffResult;
|
|
|
227
227
|
|
|
228
228
|
/** 양식(서식) 필드 인식 — 테이블 기반 label-value 패턴 매칭 */
|
|
229
229
|
|
|
230
|
+
/** 라벨처럼 보이는 셀인지 판별 */
|
|
231
|
+
declare function isLabelCell(text: string): boolean;
|
|
230
232
|
/**
|
|
231
233
|
* IRBlock[]에서 양식 필드를 인식하여 추출.
|
|
232
234
|
* 테이블의 label-value 패턴을 감지.
|
|
233
235
|
*/
|
|
234
236
|
declare function extractFormFields(blocks: IRBlock[]): FormResult;
|
|
235
237
|
|
|
238
|
+
/** 양식 서식 필드 값 채우기 — IRBlock[] 기반 in-place 교체 */
|
|
239
|
+
|
|
240
|
+
/** 필드 채우기 결과 */
|
|
241
|
+
interface FillResult {
|
|
242
|
+
/** 값이 교체된 IRBlock[] */
|
|
243
|
+
blocks: IRBlock[];
|
|
244
|
+
/** 실제 채워진 필드 목록 */
|
|
245
|
+
filled: FormField[];
|
|
246
|
+
/** 매칭 실패한 라벨 (입력에는 있지만 서식에서 못 찾은 것) */
|
|
247
|
+
unmatched: string[];
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* IRBlock[]에서 양식 필드를 찾아 값을 교체.
|
|
251
|
+
*
|
|
252
|
+
* @param blocks 원본 IRBlock[] (변경하지 않음 — deep clone)
|
|
253
|
+
* @param values 채울 값 맵 (라벨 → 새 값). 라벨은 접두사 매칭 지원.
|
|
254
|
+
* @returns FillResult
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* const result = await parse("신청서.hwp")
|
|
259
|
+
* if (!result.success) throw new Error(result.error)
|
|
260
|
+
* const { blocks, filled } = fillFormFields(result.blocks, {
|
|
261
|
+
* "성명": "홍길동",
|
|
262
|
+
* "전화번호": "010-1234-5678",
|
|
263
|
+
* "주소": "서울시 강남구",
|
|
264
|
+
* })
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
declare function fillFormFields(blocks: IRBlock[], values: Record<string, string>): FillResult;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* HWPX 원본 서식 유지 채우기 — ZIP 내 section XML 직접 수정
|
|
271
|
+
*
|
|
272
|
+
* IRBlock 중간 표현을 거치지 않고, 원본 HWPX ZIP의 section XML에서
|
|
273
|
+
* 테이블 셀 텍스트(<hp:t>)만 교체하여 모든 스타일을 보존합니다.
|
|
274
|
+
*/
|
|
275
|
+
|
|
276
|
+
/** 채우기 결과 */
|
|
277
|
+
interface HwpxFillResult {
|
|
278
|
+
/** 채워진 HWPX 바이너리 */
|
|
279
|
+
buffer: ArrayBuffer;
|
|
280
|
+
/** 실제 채워진 필드 목록 */
|
|
281
|
+
filled: FormField[];
|
|
282
|
+
/** 매칭 실패한 라벨 */
|
|
283
|
+
unmatched: string[];
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* HWPX 원본을 직접 수정하여 서식 필드를 채움 — 스타일 100% 보존.
|
|
287
|
+
*
|
|
288
|
+
* @param hwpxBuffer 원본 HWPX 파일 버퍼
|
|
289
|
+
* @param values 채울 값 맵 (라벨 → 값)
|
|
290
|
+
* @returns HwpxFillResult
|
|
291
|
+
*/
|
|
292
|
+
declare function fillHwpx(hwpxBuffer: ArrayBuffer, values: Record<string, string>): Promise<HwpxFillResult>;
|
|
293
|
+
|
|
236
294
|
/**
|
|
237
295
|
* Markdown → HWPX 역변환
|
|
238
296
|
*
|
|
@@ -270,12 +328,6 @@ declare function blocksToMarkdown(blocks: IRBlock[]): string;
|
|
|
270
328
|
/** kordoc 공용 유틸리티 */
|
|
271
329
|
declare const VERSION: string;
|
|
272
330
|
|
|
273
|
-
/**
|
|
274
|
-
* kordoc — 모두 파싱해버리겠다
|
|
275
|
-
*
|
|
276
|
-
* HWP, HWPX, PDF → Markdown 변환 통합 라이브러리
|
|
277
|
-
*/
|
|
278
|
-
|
|
279
331
|
/**
|
|
280
332
|
* 파일 버퍼를 자동 감지하여 Markdown으로 변환
|
|
281
333
|
*
|
|
@@ -299,5 +351,43 @@ declare function parsePdf(buffer: ArrayBuffer, options?: ParseOptions): Promise<
|
|
|
299
351
|
declare function parseXlsx(buffer: ArrayBuffer, options?: ParseOptions): Promise<ParseResult>;
|
|
300
352
|
/** DOCX 파일을 Markdown으로 변환 */
|
|
301
353
|
declare function parseDocx(buffer: ArrayBuffer, options?: ParseOptions): Promise<ParseResult>;
|
|
354
|
+
/**
|
|
355
|
+
* 서식 채우기 출력 포맷
|
|
356
|
+
* - "markdown": 마크다운 텍스트
|
|
357
|
+
* - "hwpx": 새로 생성한 HWPX (스타일 초기화)
|
|
358
|
+
* - "hwpx-preserve": 원본 HWPX ZIP 직접 수정 (스타일 100% 보존, HWPX 입력만 가능)
|
|
359
|
+
*/
|
|
360
|
+
type FillOutputFormat = "markdown" | "hwpx" | "hwpx-preserve";
|
|
361
|
+
/** 서식 채우기 결과 */
|
|
362
|
+
interface FillFormOutput {
|
|
363
|
+
/** 채워진 문서 (markdown: string, hwpx/hwpx-preserve: ArrayBuffer) */
|
|
364
|
+
output: string | ArrayBuffer;
|
|
365
|
+
/** 출력 포맷 */
|
|
366
|
+
format: FillOutputFormat;
|
|
367
|
+
/** 채우기 상세 — filled 필드 목록 + unmatched 라벨 */
|
|
368
|
+
fill: {
|
|
369
|
+
filled: FormField[];
|
|
370
|
+
unmatched: string[];
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* 서식 문서를 파싱하여 필드를 채우고, 원하는 포맷으로 출력.
|
|
375
|
+
*
|
|
376
|
+
* - "hwpx-preserve": HWPX 입력 → 원본 ZIP XML 직접 수정 (테두리/폰트/병합 등 100% 보존)
|
|
377
|
+
* - "hwpx": 아무 포맷 → IRBlock → Markdown → HWPX 생성 (스타일 초기화됨)
|
|
378
|
+
* - "markdown": 아무 포맷 → IRBlock → Markdown
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```ts
|
|
382
|
+
* // HWPX 원본 스타일 보존 채우기
|
|
383
|
+
* const result = await fillForm("신청서.hwpx", { "성명": "홍길동" }, "hwpx-preserve")
|
|
384
|
+
* writeFileSync("결과.hwpx", Buffer.from(result.output as ArrayBuffer))
|
|
385
|
+
*
|
|
386
|
+
* // 아무 포맷 → 마크다운 채우기
|
|
387
|
+
* const result = await fillForm("신청서.hwp", { "성명": "홍길동" })
|
|
388
|
+
* console.log(result.output) // 채워진 마크다운
|
|
389
|
+
* ```
|
|
390
|
+
*/
|
|
391
|
+
declare function fillForm(input: string | ArrayBuffer | Buffer, values: Record<string, string>, outputFormat?: FillOutputFormat): Promise<FillFormOutput>;
|
|
302
392
|
|
|
303
|
-
export { type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type ErrorCode, type ExtractedImage, type FileType, type FormField, type FormResult, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, detectFormat, detectZipFormat, diffBlocks, extractFormFields, isHwpxFile, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, parse, parseDocx, parseHwp, parseHwpx, parsePdf, parseXlsx };
|
|
393
|
+
export { type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type ErrorCode, type ExtractedImage, type FileType, type FillFormOutput, type FillOutputFormat, type FillResult, type FormField, type FormResult, type HwpxFillResult, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, detectFormat, detectZipFormat, diffBlocks, extractFormFields, fillForm, fillFormFields, fillHwpx, isHwpxFile, isLabelCell, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, parse, parseDocx, parseHwp, parseHwpx, parsePdf, parseXlsx };
|
package/dist/index.d.ts
CHANGED
|
@@ -227,12 +227,70 @@ declare function diffBlocks(blocksA: IRBlock[], blocksB: IRBlock[]): DiffResult;
|
|
|
227
227
|
|
|
228
228
|
/** 양식(서식) 필드 인식 — 테이블 기반 label-value 패턴 매칭 */
|
|
229
229
|
|
|
230
|
+
/** 라벨처럼 보이는 셀인지 판별 */
|
|
231
|
+
declare function isLabelCell(text: string): boolean;
|
|
230
232
|
/**
|
|
231
233
|
* IRBlock[]에서 양식 필드를 인식하여 추출.
|
|
232
234
|
* 테이블의 label-value 패턴을 감지.
|
|
233
235
|
*/
|
|
234
236
|
declare function extractFormFields(blocks: IRBlock[]): FormResult;
|
|
235
237
|
|
|
238
|
+
/** 양식 서식 필드 값 채우기 — IRBlock[] 기반 in-place 교체 */
|
|
239
|
+
|
|
240
|
+
/** 필드 채우기 결과 */
|
|
241
|
+
interface FillResult {
|
|
242
|
+
/** 값이 교체된 IRBlock[] */
|
|
243
|
+
blocks: IRBlock[];
|
|
244
|
+
/** 실제 채워진 필드 목록 */
|
|
245
|
+
filled: FormField[];
|
|
246
|
+
/** 매칭 실패한 라벨 (입력에는 있지만 서식에서 못 찾은 것) */
|
|
247
|
+
unmatched: string[];
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* IRBlock[]에서 양식 필드를 찾아 값을 교체.
|
|
251
|
+
*
|
|
252
|
+
* @param blocks 원본 IRBlock[] (변경하지 않음 — deep clone)
|
|
253
|
+
* @param values 채울 값 맵 (라벨 → 새 값). 라벨은 접두사 매칭 지원.
|
|
254
|
+
* @returns FillResult
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* const result = await parse("신청서.hwp")
|
|
259
|
+
* if (!result.success) throw new Error(result.error)
|
|
260
|
+
* const { blocks, filled } = fillFormFields(result.blocks, {
|
|
261
|
+
* "성명": "홍길동",
|
|
262
|
+
* "전화번호": "010-1234-5678",
|
|
263
|
+
* "주소": "서울시 강남구",
|
|
264
|
+
* })
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
declare function fillFormFields(blocks: IRBlock[], values: Record<string, string>): FillResult;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* HWPX 원본 서식 유지 채우기 — ZIP 내 section XML 직접 수정
|
|
271
|
+
*
|
|
272
|
+
* IRBlock 중간 표현을 거치지 않고, 원본 HWPX ZIP의 section XML에서
|
|
273
|
+
* 테이블 셀 텍스트(<hp:t>)만 교체하여 모든 스타일을 보존합니다.
|
|
274
|
+
*/
|
|
275
|
+
|
|
276
|
+
/** 채우기 결과 */
|
|
277
|
+
interface HwpxFillResult {
|
|
278
|
+
/** 채워진 HWPX 바이너리 */
|
|
279
|
+
buffer: ArrayBuffer;
|
|
280
|
+
/** 실제 채워진 필드 목록 */
|
|
281
|
+
filled: FormField[];
|
|
282
|
+
/** 매칭 실패한 라벨 */
|
|
283
|
+
unmatched: string[];
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* HWPX 원본을 직접 수정하여 서식 필드를 채움 — 스타일 100% 보존.
|
|
287
|
+
*
|
|
288
|
+
* @param hwpxBuffer 원본 HWPX 파일 버퍼
|
|
289
|
+
* @param values 채울 값 맵 (라벨 → 값)
|
|
290
|
+
* @returns HwpxFillResult
|
|
291
|
+
*/
|
|
292
|
+
declare function fillHwpx(hwpxBuffer: ArrayBuffer, values: Record<string, string>): Promise<HwpxFillResult>;
|
|
293
|
+
|
|
236
294
|
/**
|
|
237
295
|
* Markdown → HWPX 역변환
|
|
238
296
|
*
|
|
@@ -270,12 +328,6 @@ declare function blocksToMarkdown(blocks: IRBlock[]): string;
|
|
|
270
328
|
/** kordoc 공용 유틸리티 */
|
|
271
329
|
declare const VERSION: string;
|
|
272
330
|
|
|
273
|
-
/**
|
|
274
|
-
* kordoc — 모두 파싱해버리겠다
|
|
275
|
-
*
|
|
276
|
-
* HWP, HWPX, PDF → Markdown 변환 통합 라이브러리
|
|
277
|
-
*/
|
|
278
|
-
|
|
279
331
|
/**
|
|
280
332
|
* 파일 버퍼를 자동 감지하여 Markdown으로 변환
|
|
281
333
|
*
|
|
@@ -299,5 +351,43 @@ declare function parsePdf(buffer: ArrayBuffer, options?: ParseOptions): Promise<
|
|
|
299
351
|
declare function parseXlsx(buffer: ArrayBuffer, options?: ParseOptions): Promise<ParseResult>;
|
|
300
352
|
/** DOCX 파일을 Markdown으로 변환 */
|
|
301
353
|
declare function parseDocx(buffer: ArrayBuffer, options?: ParseOptions): Promise<ParseResult>;
|
|
354
|
+
/**
|
|
355
|
+
* 서식 채우기 출력 포맷
|
|
356
|
+
* - "markdown": 마크다운 텍스트
|
|
357
|
+
* - "hwpx": 새로 생성한 HWPX (스타일 초기화)
|
|
358
|
+
* - "hwpx-preserve": 원본 HWPX ZIP 직접 수정 (스타일 100% 보존, HWPX 입력만 가능)
|
|
359
|
+
*/
|
|
360
|
+
type FillOutputFormat = "markdown" | "hwpx" | "hwpx-preserve";
|
|
361
|
+
/** 서식 채우기 결과 */
|
|
362
|
+
interface FillFormOutput {
|
|
363
|
+
/** 채워진 문서 (markdown: string, hwpx/hwpx-preserve: ArrayBuffer) */
|
|
364
|
+
output: string | ArrayBuffer;
|
|
365
|
+
/** 출력 포맷 */
|
|
366
|
+
format: FillOutputFormat;
|
|
367
|
+
/** 채우기 상세 — filled 필드 목록 + unmatched 라벨 */
|
|
368
|
+
fill: {
|
|
369
|
+
filled: FormField[];
|
|
370
|
+
unmatched: string[];
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* 서식 문서를 파싱하여 필드를 채우고, 원하는 포맷으로 출력.
|
|
375
|
+
*
|
|
376
|
+
* - "hwpx-preserve": HWPX 입력 → 원본 ZIP XML 직접 수정 (테두리/폰트/병합 등 100% 보존)
|
|
377
|
+
* - "hwpx": 아무 포맷 → IRBlock → Markdown → HWPX 생성 (스타일 초기화됨)
|
|
378
|
+
* - "markdown": 아무 포맷 → IRBlock → Markdown
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```ts
|
|
382
|
+
* // HWPX 원본 스타일 보존 채우기
|
|
383
|
+
* const result = await fillForm("신청서.hwpx", { "성명": "홍길동" }, "hwpx-preserve")
|
|
384
|
+
* writeFileSync("결과.hwpx", Buffer.from(result.output as ArrayBuffer))
|
|
385
|
+
*
|
|
386
|
+
* // 아무 포맷 → 마크다운 채우기
|
|
387
|
+
* const result = await fillForm("신청서.hwp", { "성명": "홍길동" })
|
|
388
|
+
* console.log(result.output) // 채워진 마크다운
|
|
389
|
+
* ```
|
|
390
|
+
*/
|
|
391
|
+
declare function fillForm(input: string | ArrayBuffer | Buffer, values: Record<string, string>, outputFormat?: FillOutputFormat): Promise<FillFormOutput>;
|
|
302
392
|
|
|
303
|
-
export { type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type ErrorCode, type ExtractedImage, type FileType, type FormField, type FormResult, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, detectFormat, detectZipFormat, diffBlocks, extractFormFields, isHwpxFile, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, parse, parseDocx, parseHwp, parseHwpx, parsePdf, parseXlsx };
|
|
393
|
+
export { type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type ErrorCode, type ExtractedImage, type FileType, type FillFormOutput, type FillOutputFormat, type FillResult, type FormField, type FormResult, type HwpxFillResult, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, detectFormat, detectZipFormat, diffBlocks, extractFormFields, fillForm, fillFormFields, fillHwpx, isHwpxFile, isLabelCell, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, parse, parseDocx, parseHwp, parseHwpx, parsePdf, parseXlsx };
|