@aeriz/wysiwyg 1.0.2 → 1.0.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.
Files changed (131) hide show
  1. package/README.md +634 -96
  2. package/angular/README.md +112 -0
  3. package/angular/aeriz-editor.directive.ts +243 -0
  4. package/angular/aeriz-wysiwyg.module.ts +14 -0
  5. package/angular/index.ts +5 -0
  6. package/dist/adapters/jquery.cjs +1 -0
  7. package/dist/adapters/jquery.js +91 -0
  8. package/dist/adapters/react.cjs +1 -0
  9. package/dist/adapters/react.js +66 -0
  10. package/dist/adapters/shared.cjs +1 -0
  11. package/dist/adapters/shared.js +87 -0
  12. package/dist/adapters/svelte.cjs +1 -0
  13. package/dist/adapters/svelte.js +29 -0
  14. package/dist/adapters/vue.cjs +1 -0
  15. package/dist/adapters/vue.js +110 -0
  16. package/dist/adapters/vue2.cjs +1 -0
  17. package/dist/adapters/vue2.js +117 -0
  18. package/dist/adapters/wc.cjs +1 -0
  19. package/dist/adapters/wc.js +207 -0
  20. package/dist/aeriz-wysiwyg-adapter.js +169 -0
  21. package/dist/aeriz-wysiwyg-adapter.min.js +1 -0
  22. package/dist/aeriz-wysiwyg-jquery.js +275 -0
  23. package/dist/aeriz-wysiwyg-jquery.min.js +1 -0
  24. package/dist/aeriz-wysiwyg-wc.js +401 -0
  25. package/dist/aeriz-wysiwyg-wc.min.js +1 -0
  26. package/dist/aeriz-wysiwyg.cjs +8759 -0
  27. package/dist/aeriz-wysiwyg.css +587 -163
  28. package/dist/aeriz-wysiwyg.esm.js +4249 -1381
  29. package/dist/aeriz-wysiwyg.esm.min.js +4456 -1995
  30. package/dist/aeriz-wysiwyg.js +4249 -1381
  31. package/dist/aeriz-wysiwyg.min.cjs +56 -0
  32. package/dist/aeriz-wysiwyg.min.css +1 -1
  33. package/dist/aeriz-wysiwyg.min.js +54 -21
  34. package/dist/server.cjs +34 -0
  35. package/dist/server.js +798 -0
  36. package/dist-types/adapters/jquery.d.ts +34 -0
  37. package/dist-types/adapters/jquery.d.ts.map +1 -0
  38. package/dist-types/adapters/react.d.ts +28 -0
  39. package/dist-types/adapters/react.d.ts.map +1 -0
  40. package/dist-types/adapters/shared.d.ts +83 -0
  41. package/dist-types/adapters/shared.d.ts.map +1 -0
  42. package/dist-types/adapters/svelte.d.ts +38 -0
  43. package/dist-types/adapters/svelte.d.ts.map +1 -0
  44. package/dist-types/adapters/vue.d.ts +189 -0
  45. package/dist-types/adapters/vue.d.ts.map +1 -0
  46. package/dist-types/adapters/vue2.d.ts +175 -0
  47. package/dist-types/adapters/vue2.d.ts.map +1 -0
  48. package/dist-types/adapters/wc.d.ts +96 -0
  49. package/dist-types/adapters/wc.d.ts.map +1 -0
  50. package/dist-types/cjs/adapters/jquery.d.cts +34 -0
  51. package/dist-types/cjs/adapters/react.d.cts +28 -0
  52. package/dist-types/cjs/adapters/shared.d.cts +83 -0
  53. package/dist-types/cjs/adapters/svelte.d.cts +38 -0
  54. package/dist-types/cjs/adapters/vue.d.cts +189 -0
  55. package/dist-types/cjs/adapters/vue2.d.cts +175 -0
  56. package/dist-types/cjs/adapters/wc.d.cts +96 -0
  57. package/dist-types/cjs/core/AerizEditor.d.cts +530 -0
  58. package/dist-types/cjs/core/AerizViewer.d.cts +61 -0
  59. package/dist-types/cjs/core/block-meta.d.cts +98 -0
  60. package/dist-types/cjs/core/block-policy.d.cts +43 -0
  61. package/dist-types/cjs/core/blocks.d.cts +411 -0
  62. package/dist-types/cjs/core/fonts.d.cts +60 -0
  63. package/dist-types/cjs/core/highlight.d.cts +44 -0
  64. package/dist-types/cjs/core/history.d.cts +86 -0
  65. package/dist-types/cjs/core/html-mini.d.cts +65 -0
  66. package/dist-types/cjs/core/i18n.d.cts +221 -0
  67. package/dist-types/cjs/core/import-html.d.cts +40 -0
  68. package/dist-types/cjs/core/import-markdown.d.cts +33 -0
  69. package/dist-types/cjs/core/input-rules.d.cts +46 -0
  70. package/dist-types/cjs/core/markdown-export.d.cts +30 -0
  71. package/dist-types/cjs/core/plain-text.d.cts +17 -0
  72. package/dist-types/cjs/core/render-string.d.cts +68 -0
  73. package/dist-types/cjs/core/selection.d.cts +46 -0
  74. package/dist-types/cjs/core/snapshot.d.cts +51 -0
  75. package/dist-types/cjs/core/table-ops.d.cts +30 -0
  76. package/dist-types/cjs/index.d.cts +22 -0
  77. package/dist-types/cjs/server/index.d.cts +37 -0
  78. package/dist-types/cjs/types/index.d.cts +61 -0
  79. package/dist-types/cjs/ui/Toolbar.d.cts +21 -0
  80. package/dist-types/cjs/ui/dialogs.d.cts +74 -0
  81. package/dist-types/cjs/ui/icons.d.cts +2 -0
  82. package/dist-types/cjs/ui/popovers.d.cts +70 -0
  83. package/dist-types/core/AerizEditor.d.ts +210 -17
  84. package/dist-types/core/AerizEditor.d.ts.map +1 -1
  85. package/dist-types/core/AerizViewer.d.ts +16 -4
  86. package/dist-types/core/AerizViewer.d.ts.map +1 -1
  87. package/dist-types/core/block-meta.d.ts +98 -0
  88. package/dist-types/core/block-meta.d.ts.map +1 -0
  89. package/dist-types/core/block-policy.d.ts +43 -0
  90. package/dist-types/core/block-policy.d.ts.map +1 -0
  91. package/dist-types/core/blocks.d.ts +109 -11
  92. package/dist-types/core/blocks.d.ts.map +1 -1
  93. package/dist-types/core/fonts.d.ts +11 -0
  94. package/dist-types/core/fonts.d.ts.map +1 -1
  95. package/dist-types/core/history.d.ts +86 -0
  96. package/dist-types/core/history.d.ts.map +1 -0
  97. package/dist-types/core/html-mini.d.ts +65 -0
  98. package/dist-types/core/html-mini.d.ts.map +1 -0
  99. package/dist-types/core/i18n.d.ts +12 -0
  100. package/dist-types/core/i18n.d.ts.map +1 -1
  101. package/dist-types/core/import-html.d.ts +1 -0
  102. package/dist-types/core/import-html.d.ts.map +1 -1
  103. package/dist-types/core/import-markdown.d.ts +0 -4
  104. package/dist-types/core/import-markdown.d.ts.map +1 -1
  105. package/dist-types/core/input-rules.d.ts +46 -0
  106. package/dist-types/core/input-rules.d.ts.map +1 -0
  107. package/dist-types/core/markdown-export.d.ts +30 -0
  108. package/dist-types/core/markdown-export.d.ts.map +1 -0
  109. package/dist-types/core/plain-text.d.ts +17 -0
  110. package/dist-types/core/plain-text.d.ts.map +1 -0
  111. package/dist-types/core/render-string.d.ts +68 -0
  112. package/dist-types/core/render-string.d.ts.map +1 -0
  113. package/dist-types/core/selection.d.ts +46 -0
  114. package/dist-types/core/selection.d.ts.map +1 -0
  115. package/dist-types/core/snapshot.d.ts +51 -0
  116. package/dist-types/core/snapshot.d.ts.map +1 -0
  117. package/dist-types/core/table-ops.d.ts +30 -0
  118. package/dist-types/core/table-ops.d.ts.map +1 -0
  119. package/dist-types/index.d.ts +21 -10
  120. package/dist-types/index.d.ts.map +1 -1
  121. package/dist-types/server/index.d.ts +37 -0
  122. package/dist-types/server/index.d.ts.map +1 -0
  123. package/dist-types/types/index.d.ts +21 -0
  124. package/dist-types/types/index.d.ts.map +1 -1
  125. package/dist-types/ui/Toolbar.d.ts +1 -1
  126. package/dist-types/ui/Toolbar.d.ts.map +1 -1
  127. package/dist-types/ui/dialogs.d.ts.map +1 -1
  128. package/dist-types/ui/icons.d.ts.map +1 -1
  129. package/dist-types/ui/popovers.d.ts +1 -1
  130. package/dist-types/ui/popovers.d.ts.map +1 -1
  131. package/package.json +213 -58
@@ -0,0 +1,68 @@
1
+ /**
2
+ * DOM 없이 `BlockSnapshot[]` → HTML 문자열.
3
+ *
4
+ * `document` / `window` 를 **모듈 최상위에서도, 함수 안에서도** 참조하지 않는다.
5
+ * Cloudflare Workers(workerd) · Node · Deno · Bun 어디서든 그대로 동작한다.
6
+ *
7
+ * ## 보장
8
+ *
9
+ * - **결정적** — 같은 입력이면 항상 같은 문자열. 난수 · 현재 시각 · 순회 순서에
10
+ * 의존하는 값을 쓰지 않는다. 따라서 재렌더 결과의 diff 가 의미를 갖는다.
11
+ * - **멱등** — 같은 스냅샷을 몇 번 렌더해도 결과가 누적되거나 변하지 않는다.
12
+ * - **에디터 전용 마크업 없음** — 리사이즈 핸들 · 정렬 컨트롤 · `contenteditable`
13
+ * 같은 편집 보조 마크업은 출력에 포함되지 않는다.
14
+ *
15
+ * ## 브라우저 렌더 경로와의 관계
16
+ *
17
+ * DOM 경로(`renderBlock`) 와 **같은 결과**를 내는 것이 목표다. 모든 블록은
18
+ * `snapshot.html` 을 그대로 싣고, `html` 이 비어 있을 때만 `attrs` 로 골격을
19
+ * 조립한다 (`AerizViewer` 도 같은 규칙).
20
+ *
21
+ * 원자 블록(이미지 · 유튜브 · 링크 카드 · 파일) 도 예외가 아니다. 예전에는
22
+ * `attrs` 로만 다시 조립했는데, 그러면 `<figcaption>` 처럼 `attrs` 에 없는
23
+ * 사용자 컨텐츠가 **서버 렌더에서만** 사라져 같은 스냅샷이 브라우저와 서버에서
24
+ * 다르게 보였다.
25
+ *
26
+ * 편집 보조 마크업(정렬 컨트롤 · 리사이즈 핸들) 은 1.0.3 부터 `serialize()` 가
27
+ * 애초에 싣지 않지만, 그 이전 데이터를 위해 읽는 쪽에서도 걷어낸다.
28
+ */
29
+ import type { BlockSnapshot } from './blocks.cjs';
30
+ export interface RenderHtmlOptions {
31
+ /**
32
+ * 각 블록에 `data-block-id` 를 남길지. 기본 `true`.
33
+ *
34
+ * 저장된 스냅샷과 렌더된 HTML 을 대조해야 하는 경우(앵커 링크, 코멘트 위치
35
+ * 고정 등) 켜 두고, 순수 발행용 HTML 이면 끈다.
36
+ */
37
+ blockIds?: boolean;
38
+ /**
39
+ * 감싸는 컨테이너.
40
+ * - `'none'` (기본) — 블록들만 이어붙인 조각
41
+ * - `'content'` — `<div class="aeriz-wysiwyg"><div class="aw-content">…`
42
+ * 로 감싼다. 배포된 `aeriz-wysiwyg.min.css` 를 함께 로드하면 에디터와 같은
43
+ * 시각으로 렌더된다 (클래스 기반 스타일링 경로).
44
+ */
45
+ wrapper?: 'none' | 'content';
46
+ /** `wrapper: 'content'` 일 때 컨테이너에 부여할 테마. */
47
+ theme?: 'light' | 'dark';
48
+ }
49
+ /**
50
+ * 스냅샷 배열을 HTML 문자열로 렌더한다.
51
+ *
52
+ * @example
53
+ * // Cloudflare Worker
54
+ * import { renderBlocksToHTML } from '@aeriz/wysiwyg/server';
55
+ *
56
+ * const html = renderBlocksToHTML(post.blocks, { wrapper: 'content' });
57
+ */
58
+ export declare function renderBlocksToHTML(snapshots: readonly BlockSnapshot[], options?: RenderHtmlOptions): string;
59
+ /**
60
+ * 단일 스냅샷을 HTML 문자열로 렌더한다.
61
+ *
62
+ * 스트리밍 · 블록 단위 캐시처럼 블록을 하나씩 렌더하는 호출자를 위해 공개돼
63
+ * 있다. `renderBlocksToHTML` 과 **같은 정규화**를 거쳐야 하므로 여기서도
64
+ * `upgradeSnapshot` 을 적용한다 — 빠뜨리면 모르는 kind 가 exhaustive 분기로
65
+ * 떨어져 빈 문자열이 되고, 블록이 조용히 사라진다.
66
+ */
67
+ export declare function renderBlockToHTML(snapshot: BlockSnapshot, options?: Pick<RenderHtmlOptions, 'blockIds'>): string;
68
+ // (소스맵은 CJS 선언 사본에서 제외됨 — scripts/finalize-types.mjs)
@@ -0,0 +1,46 @@
1
+ /** 문자 오프셋으로 표현한 선택 영역. */
2
+ export interface SelectionOffsets {
3
+ start: number;
4
+ end: number;
5
+ }
6
+ /**
7
+ * `<code>` element 안의 셀렉션을 텍스트 오프셋으로 저장한다.
8
+ * 하이라이트가 innerHTML 을 다시 쓰기 직전에 부른다.
9
+ */
10
+ export declare function saveCodeSelection(codeEl: HTMLElement): SelectionOffsets | null;
11
+ /** {@link saveCodeSelection} 로 저장한 위치에 캐럿을 되돌린다. */
12
+ export declare function restoreCodeSelection(codeEl: HTMLElement, saved: SelectionOffsets): void;
13
+ /**
14
+ * `root` 안의 현재 셀렉션을 문자 오프셋으로 캡처한다.
15
+ * 셀렉션이 `root` 밖이면 null.
16
+ */
17
+ export declare function captureSelectionOffsets(root: HTMLElement): SelectionOffsets | null;
18
+ /**
19
+ * 문자 오프셋으로 저장해 둔 셀렉션을 되살린다.
20
+ * 문서가 짧아져 오프셋이 넘치면 가장 가까운 위치(문서 끝) 에 둔다.
21
+ */
22
+ export declare function restoreSelectionOffsets(root: HTMLElement, saved: SelectionOffsets): void;
23
+ /**
24
+ * 캐럿이 블록의 맨 끝에 있는지.
25
+ *
26
+ * 캐럿 뒤에 남은 **글자**가 없으면 끝으로 본다. 빈 단락의 `<br>` 이나 캐럿
27
+ * 고정용 zero-width 문자는 글자로 치지 않는다 — 사용자 눈에는 아무것도 없는
28
+ * 자리이기 때문이다.
29
+ */
30
+ export declare function isCaretAtBlockEnd(blockEl: HTMLElement): boolean;
31
+ /**
32
+ * 블록 시작부터 캐럿까지의 **보이는 글자**.
33
+ *
34
+ * 마크다운 입력 규칙이 방아쇠(`# ` 등) 를 알아보는 근거다. 노드 구조로
35
+ * 판정하지 않는 이유 — 빈 단락에는 placeholder `<br>` 이 남아 있고 첫 입력의
36
+ * 노드 배치가 브라우저마다 달라서, "첫 텍스트 노드" 같은 조건은 실제
37
+ * 브라우저에서 조용히 빗나간다.
38
+ *
39
+ * 판정에 쓴 Range 를 함께 돌려준다 — 방아쇠를 지우려면 정확히 그 범위가
40
+ * 필요하고, 다시 계산하면 그 사이 캐럿이 움직였을 때 엉뚱한 곳을 지운다.
41
+ */
42
+ export declare function textBeforeCaret(blockEl: HTMLElement): {
43
+ text: string;
44
+ range: Range;
45
+ } | null;
46
+ // (소스맵은 CJS 선언 사본에서 제외됨 — scripts/finalize-types.mjs)
@@ -0,0 +1,51 @@
1
+ /**
2
+ * BlockSnapshot 스키마 버전과 마이그레이션 진입점.
3
+ *
4
+ * 이 모듈은 **DOM 을 전혀 참조하지 않는다**. `document` / `window` 가 없는
5
+ * 런타임(Cloudflare workerd, Node, Deno) 에서 그대로 import 할 수 있어야 하므로
6
+ * blocks.ts 로부터는 타입만 가져온다.
7
+ */
8
+ import type { BlockSnapshot } from './blocks.cjs';
9
+ /**
10
+ * 현재 직렬화 스키마 버전.
11
+ *
12
+ * `serializeBlock()` 은 항상 이 값을 `snapshot.version` 에 기록한다.
13
+ *
14
+ * ## 버전 변경 정책
15
+ *
16
+ * 버전을 올리는 경우 — 저장된 데이터를 그대로 읽으면 **의미가 달라지는** 변경:
17
+ * - `kind` 의 삭제 또는 의미 변경
18
+ * - 기존 `attrs` 필드의 삭제 · 이름 변경 · 타입 변경 · 단위 변경
19
+ * - `html` 필드가 담는 내용의 범위 변경 (예: 인라인 컨텐츠 → 전체 outerHTML)
20
+ *
21
+ * 버전을 올리지 않는 경우 — 구버전 데이터를 그대로 읽어도 안전한 변경:
22
+ * - 새로운 `kind` 추가 (구버전 데이터에는 등장하지 않음)
23
+ * - 새로운 optional `attrs` 필드 추가
24
+ * - 렌더 결과의 시각적 변경 (CSS · 마크업 세부)
25
+ *
26
+ * 버전이 올라가면 {@link upgradeSnapshots} 에 해당 단계의 변환을 추가하고,
27
+ * 이 상수를 올린다. 읽기 경로(`AerizViewer.setBlocks` /
28
+ * `renderBlocksToHTML`) 는 모두 upgrade 를 거치도록 유지한다.
29
+ */
30
+ export declare const SNAPSHOT_VERSION = 1;
31
+ /**
32
+ * 스냅샷의 스키마 버전. `version` 이 없으면 버전 필드 도입 이전 데이터이므로
33
+ * 1 로 간주한다 (1.0.x 까지의 출력이 여기 해당한다).
34
+ */
35
+ export declare function snapshotVersionOf(snapshot: BlockSnapshot): number;
36
+ /**
37
+ * 저장된 스냅샷을 현재 스키마로 정규화한다.
38
+ *
39
+ * 읽기 경로의 단일 관문이다. 지금(v1) 은 실질 변환이 없고 다음만 보정한다.
40
+ * - `version` 누락 → 1 로 채움
41
+ * - 모르는 `kind` → `'unknown'` 으로 강등 (미래 버전으로 저장된 글을 구버전
42
+ * 클라이언트가 열었을 때 렌더가 통째로 깨지는 대신 해당 블록만 원문 유지)
43
+ * - `html` 누락 → 빈 문자열
44
+ *
45
+ * 버전이 올라가면 여기에 단계별 변환(1→2, 2→3 …) 을 순차 적용하는 형태로
46
+ * 확장한다.
47
+ */
48
+ export declare function upgradeSnapshots(input: readonly BlockSnapshot[]): BlockSnapshot[];
49
+ /** 단일 스냅샷 정규화. {@link upgradeSnapshots} 의 단위 연산. */
50
+ export declare function upgradeSnapshot(snapshot: BlockSnapshot): BlockSnapshot;
51
+ // (소스맵은 CJS 선언 사본에서 제외됨 — scripts/finalize-types.mjs)
@@ -0,0 +1,30 @@
1
+ /**
2
+ * 표 셀의 기하와 이동.
3
+ *
4
+ * 표 편집은 "지금 어느 셀인가" 를 계속 되묻는 일이다 — 캐럿이 놓인 셀, 드래그
5
+ * 로 걸친 셀 범위, 마우스가 가장자리에 닿았는지, Tab 을 눌렀을 때 다음 셀.
6
+ * 그 판정들만 여기 모은다. 에디터 인스턴스 상태를 보지 않는 순수 계산이라
7
+ * 따로 두면 표 동작을 고칠 때 에디터 본체를 읽지 않아도 된다.
8
+ *
9
+ * **rowspan / colspan 은 고려하지 않는다.** 이 에디터는 둘 다 만들지 않으며,
10
+ * 병합 셀을 지원하게 되면 여기 있는 인덱스 계산은 전부 다시 짜야 한다.
11
+ */
12
+ /** 임의의 노드에서 가장 가까운 td/th element. 없으면 null. */
13
+ export declare function nearestCell(node: Node): HTMLTableCellElement | null;
14
+ /**
15
+ * 다음 표 셀. 행 끝이면 다음 행의 첫 셀, 표의 마지막 셀이면 **새 행을 만들어**
16
+ * 그 첫 셀을 돌려준다 — Tab 만으로 표를 끝까지 채울 수 있도록.
17
+ */
18
+ export declare function nextTableCell(cell: HTMLTableCellElement, table: HTMLTableElement): HTMLTableCellElement | null;
19
+ /** 이전 표 셀. 첫 셀이면 null. */
20
+ export declare function previousTableCell(cell: HTMLTableCellElement): HTMLTableCellElement | null;
21
+ /**
22
+ * `startCell` 과 `endCell` 을 모서리로 하는 사각 영역의 모든 td/th.
23
+ *
24
+ * thead 와 tbody 가 섞여 있어도 `querySelectorAll('tr')` 의 document order 로
25
+ * 단일 행 인덱스를 매긴다 — 사용자 눈에 보이는 순서와 같다.
26
+ */
27
+ export declare function cellsInRectangle(table: HTMLTableElement, startCell: HTMLTableCellElement, endCell: HTMLTableCellElement): HTMLTableCellElement[];
28
+ /** 셀의 우/하 가장자리에 포인터가 있으면 'right' / 'bottom'. 아니면 null. */
29
+ export declare function detectCellEdge(cell: HTMLTableCellElement, x: number, y: number): 'right' | 'bottom' | null;
30
+ // (소스맵은 CJS 선언 사본에서 제외됨 — scripts/finalize-types.mjs)
@@ -0,0 +1,22 @@
1
+ // (CSS 부수 효과 import 는 타입 선언에서 제거됨 — scripts/strip-css-imports.mjs)
2
+ export { AerizEditor } from './core/AerizEditor.cjs';
3
+ export type { EditorState, EditorStateListener, InlineState, } from './core/AerizEditor.cjs';
4
+ export { AerizViewer } from './core/AerizViewer.cjs';
5
+ export type { ViewerOptions } from './core/AerizViewer.cjs';
6
+ export { ALIGN_CLASS_BY_VALUE, ALL_INLINE_MARKS, BLOCK_ID_ATTR, BLOCK_TYPES, BLOCK_TYPE_BY_KIND, BlockIdRegistry, applyBlockClassNames, applyBlockInlineStyles, assignMissingIds, classifyBlockElement, extractInlineContent, fillInlineContent, findBlockFrom, getBlockLabel, isElementBlank, listBlocks, normalizeContent, placeCaretAtStart, readBlockStyleTheme, renderBlock, renderBlocks, serializeBlock, serializeBlocks, restoreAlignFromClasses, stripEditorOnlyAttrs, stripEditorOnlyNodes, } from './core/blocks.cjs';
7
+ export type { BlockStyleTheme } from './core/blocks.cjs';
8
+ export type { Block, BlockAttrs, BlockAttrsByKind, BlockIdResolver, BlockKind, BlockMatch, BlockSnapshot, BlockType, BlockquoteAttrs, BulletListAttrs, ClassifyResult, CodeBlockAttrs, FileAttrs, HeadingAttrs, HeadingLevel, HrAttrs, ImageAttrs, ImportedHtmlAttrs, InlineMarkName, LinkCardAttrs, OrderedListAttrs, ParagraphAttrs, Snapshot, TableAttrs, UnknownAttrs, YoutubeAttrs, } from './core/blocks.cjs';
9
+ export { getLocale, setLocale, t } from './core/i18n.cjs';
10
+ export type { Locale, Strings } from './core/i18n.cjs';
11
+ export type { EditorOptions, HtmlStyleMode, SerializeHtmlOptions, ToolbarConfig, ToolbarItem, ToolbarItemName, } from './types/index.cjs';
12
+ export { DEFAULT_TOOLBAR } from './types/index.cjs';
13
+ export { SNAPSHOT_VERSION, snapshotVersionOf, upgradeSnapshot, upgradeSnapshots, } from './core/snapshot.cjs';
14
+ export { renderBlockToHTML, renderBlocksToHTML } from './core/render-string.cjs';
15
+ export type { RenderHtmlOptions } from './core/render-string.cjs';
16
+ export { blocksToMarkdown } from './core/markdown-export.cjs';
17
+ export type { MarkdownOptions } from './core/markdown-export.cjs';
18
+ export { blocksToPlainText } from './core/plain-text.cjs';
19
+ export type { PlainTextOptions } from './core/plain-text.cjs';
20
+ export { decodeEntities, escapeAttr, escapeHtml, parseHtmlFragment, serializeNodes, textOf, textWithBlockBreaks, } from './core/html-mini.cjs';
21
+ export type { HtmlElementNode, HtmlNode, HtmlText } from './core/html-mini.cjs';
22
+ // (소스맵은 CJS 선언 사본에서 제외됨 — scripts/finalize-types.mjs)
@@ -0,0 +1,37 @@
1
+ /**
2
+ * `@aeriz/wysiwyg/server` — DOM 없는 런타임용 진입점.
3
+ *
4
+ * 이 모듈은 **CSS 를 import 하지 않으며**, import 그래프 전체가
5
+ * `document` / `window` 를 참조하지 않는다. Cloudflare Workers(workerd) ·
6
+ * Node · Deno · Bun 에서 그대로 쓸 수 있다.
7
+ *
8
+ * 브라우저용 기본 진입점(`@aeriz/wysiwyg`) 은 스타일시트를 부수 효과로
9
+ * 불러오고 에디터/뷰어가 DOM 을 직접 만들기 때문에 서버에서 쓸 수 없다.
10
+ * 저장된 스냅샷을 HTML · 마크다운 · 평문으로 바꾸는 일만 필요하면 여기서
11
+ * 가져오면 된다.
12
+ *
13
+ * @example
14
+ * // Cloudflare Worker — 저장된 글을 HTML 로 재렌더
15
+ * import { renderBlocksToHTML, blocksToPlainText } from '@aeriz/wysiwyg/server';
16
+ *
17
+ * export default {
18
+ * async fetch(req, env) {
19
+ * const post = await env.DB.get('post:1', 'json');
20
+ * return new Response(
21
+ * renderBlocksToHTML(post.blocks, { wrapper: 'content' }),
22
+ * { headers: { 'content-type': 'text/html; charset=utf-8' } },
23
+ * );
24
+ * },
25
+ * };
26
+ */
27
+ export { renderBlockToHTML, renderBlocksToHTML, } from '../core/render-string.cjs';
28
+ export type { RenderHtmlOptions } from '../core/render-string.cjs';
29
+ export { blocksToMarkdown } from '../core/markdown-export.cjs';
30
+ export type { MarkdownOptions } from '../core/markdown-export.cjs';
31
+ export { blocksToPlainText } from '../core/plain-text.cjs';
32
+ export type { PlainTextOptions } from '../core/plain-text.cjs';
33
+ export { SNAPSHOT_VERSION, snapshotVersionOf, upgradeSnapshot, upgradeSnapshots, } from '../core/snapshot.cjs';
34
+ export type { Block, BlockAttrs, BlockAttrsByKind, BlockKind, BlockSnapshot, BlockquoteAttrs, BulletListAttrs, CodeBlockAttrs, FileAttrs, HeadingAttrs, HeadingLevel, HrAttrs, ImageAttrs, ImportedHtmlAttrs, InlineMarkName, LinkCardAttrs, OrderedListAttrs, ParagraphAttrs, Snapshot, TableAttrs, UnknownAttrs, YoutubeAttrs, } from '../core/blocks.cjs';
35
+ export { decodeEntities, escapeAttr, escapeHtml, parseHtmlFragment, serializeNodes, textOf, textWithBlockBreaks, } from '../core/html-mini.cjs';
36
+ export type { HtmlElementNode, HtmlNode, HtmlText } from '../core/html-mini.cjs';
37
+ // (소스맵은 CJS 선언 사본에서 제외됨 — scripts/finalize-types.mjs)
@@ -0,0 +1,61 @@
1
+ export type ToolbarItem = ToolbarItemName | '|';
2
+ export type ToolbarItemName = 'undo' | 'redo' | 'blockType' | 'fontFamily' | 'fontSize' | 'bold' | 'italic' | 'underline' | 'strike' | 'color' | 'backgroundColor' | 'align' | 'cellBg' | 'tableMenu' | 'codeLang' | 'bulletList' | 'orderedList' | 'blockquote' | 'codeBlock' | 'link' | 'image' | 'table' | 'hr' | 'clearFormat';
3
+ export interface ToolbarConfig {
4
+ items: ToolbarItem[];
5
+ sticky?: boolean;
6
+ }
7
+ /**
8
+ * HTML 출력의 스타일 전략.
9
+ *
10
+ * - `'inline'` — 테마 색을 블록 인라인 style 에 베이크. 스타일시트 없이도
11
+ * 에디터와 같은 시각으로 렌더된다 (기본값).
12
+ * - `'class'` — 테마 스타일을 베이크하지 않고 `aw-block-*` / `aw-align-*`
13
+ * 클래스만 남긴다. `style` 속성을 제거하는 서버 sanitizer 를 통과해야 할 때
14
+ * 쓴다. 출력은 `aeriz-wysiwyg.min.css` 가 로드된 페이지의
15
+ * `.aeriz-wysiwyg > .aw-content` 안에 넣는 것을 전제로 한다.
16
+ */
17
+ export type HtmlStyleMode = 'inline' | 'class';
18
+ /** `getHTML()` 호출 단위 옵션. */
19
+ export interface SerializeHtmlOptions {
20
+ /** 스타일 전략. 미지정 시 인스턴스 기본값을 따른다. */
21
+ styles?: HtmlStyleMode;
22
+ }
23
+ export interface EditorOptions {
24
+ element: HTMLElement;
25
+ initialHTML?: string;
26
+ placeholder?: string;
27
+ toolbar?: ToolbarConfig | false;
28
+ theme?: 'light' | 'dark';
29
+ /** UI 언어. 'en' / 'ko' / 'ja' / 'zh'. 기본 'ko'. */
30
+ locale?: 'en' | 'ko' | 'ja' | 'zh';
31
+ /**
32
+ * `getHTML()` 과 `onChange` 가 내보내는 HTML 의 스타일 전략. 기본 `'inline'`.
33
+ * `getHTML({ styles })` 로 호출 단위 재정의 가능.
34
+ */
35
+ htmlStyles?: HtmlStyleMode;
36
+ onChange?: (html: string) => void;
37
+ /**
38
+ * 직접 업로드 핸들러. 우선 적용된다. 미설정 + `imageUploadUrl` 만 있을 때는
39
+ * 에디터가 multipart/form-data 로 그 URL 에 POST 한 응답 JSON 의
40
+ * `url` 필드를 사용한다.
41
+ */
42
+ onImageUpload?: (file: File) => Promise<string>;
43
+ /**
44
+ * 서버 이미지 업로드 API URL. 설정 시 이미지 다이얼로그의 "업로드" 탭이
45
+ * 활성화된다. 미설정 시 업로드 탭은 비활성 + 툴팁 안내.
46
+ */
47
+ imageUploadUrl?: string;
48
+ /**
49
+ * 파일 첨부 직접 업로드 핸들러. 첨부 다이얼로그의 "업로드" 탭에서 사용.
50
+ * 미설정 + `fileUploadUrl` 만 있을 때는 에디터가 multipart/form-data 로
51
+ * POST 한 응답 JSON 의 `url` 필드를 사용한다.
52
+ */
53
+ onFileUpload?: (file: File) => Promise<string>;
54
+ /**
55
+ * 서버 파일 업로드 API URL. 설정 시 파일 첨부 다이얼로그의 "업로드" 탭이
56
+ * 활성화된다. 미설정 시 업로드 탭은 비활성 + 툴팁 안내.
57
+ */
58
+ fileUploadUrl?: string;
59
+ }
60
+ export declare const DEFAULT_TOOLBAR: ToolbarConfig;
61
+ // (소스맵은 CJS 선언 사본에서 제외됨 — scripts/finalize-types.mjs)
@@ -0,0 +1,21 @@
1
+ import type { ToolbarConfig, ToolbarItemName } from '../types/index.cjs';
2
+ export interface ToolbarHandlers {
3
+ onAction: (name: ToolbarItemName, anchor: HTMLElement) => void;
4
+ }
5
+ export declare class Toolbar {
6
+ readonly element: HTMLDivElement;
7
+ private buttons;
8
+ constructor(config: ToolbarConfig, handlers: ToolbarHandlers);
9
+ setActive(name: ToolbarItemName, active: boolean): void;
10
+ setEnabled(name: ToolbarItemName, enabled: boolean): void;
11
+ /** 조건부 항목을 완전히 숨긴다 (display:none). 허용 블록으로 돌아오면 다시 보임. */
12
+ setVisible(name: ToolbarItemName, visible: boolean): void;
13
+ /**
14
+ * 모든 자식 버튼이 숨겨진 그룹을 함께 숨긴다 — `|` 구분자 padding 이 외롭게
15
+ * 남지 않도록. applyToolbarState 에서 visibility 갱신 후 호출.
16
+ */
17
+ syncGroupVisibility(): void;
18
+ private createGroup;
19
+ private createButton;
20
+ }
21
+ // (소스맵은 CJS 선언 사본에서 제외됨 — scripts/finalize-types.mjs)
@@ -0,0 +1,74 @@
1
+ export interface DialogResult {
2
+ confirmed: boolean;
3
+ }
4
+ export interface LinkDialogResult extends DialogResult {
5
+ text?: string;
6
+ href?: string;
7
+ newWindow?: boolean;
8
+ }
9
+ export interface ImageDialogResult extends DialogResult {
10
+ src?: string;
11
+ }
12
+ export interface YouTubeDialogResult extends DialogResult {
13
+ url?: string;
14
+ }
15
+ export interface ImportHtmlDialogResult extends DialogResult {
16
+ /** 사용자가 선택했거나 붙여넣은 원본 HTML 문서 텍스트. */
17
+ html?: string;
18
+ }
19
+ export interface ImportMarkdownDialogResult extends DialogResult {
20
+ /** 사용자가 선택했거나 붙여넣은 원본 Markdown 텍스트. */
21
+ markdown?: string;
22
+ }
23
+ export interface FileAttachmentDialogResult extends DialogResult {
24
+ /** 다운로드 URL — 외부 URL 또는 업로드 API 응답에서 받은 URL. */
25
+ src?: string;
26
+ /** 원본 파일명. download attr 와 표시 라벨에 사용. */
27
+ name?: string;
28
+ /** 바이트 크기 (선택). 파일 업로드/메타에서 알 수 있을 때만. */
29
+ size?: number;
30
+ /** MIME 타입 (선택). 파일 업로드 시에만 알 수 있다. */
31
+ type?: string;
32
+ }
33
+ export interface TableDialogResult extends DialogResult {
34
+ rows?: number;
35
+ cols?: number;
36
+ }
37
+ export declare function openLinkDialog(initial?: {
38
+ text?: string;
39
+ href?: string;
40
+ newWindow?: boolean;
41
+ }, theme?: 'light' | 'dark'): Promise<LinkDialogResult>;
42
+ export declare function openImageDialog(options?: {
43
+ onUpload?: (file: File) => Promise<string>;
44
+ }, theme?: 'light' | 'dark'): Promise<ImageDialogResult>;
45
+ export declare function openTableDialog(theme?: 'light' | 'dark'): Promise<TableDialogResult>;
46
+ /**
47
+ * HTML 파일을 골라 본문에 임포트하기 위한 다이얼로그.
48
+ * 파일 선택(.html / .htm) 또는 textarea 직접 붙여넣기를 모두 지원한다.
49
+ * 확인 시 원본 HTML 문자열을 resolve.
50
+ *
51
+ * 다이얼로그 안에서는 가져오기 동작 자체는 수행하지 않는다 — 호출자가
52
+ * 받은 html 을 importHtmlWithComputedStyles 로 처리한다.
53
+ */
54
+ export declare function openImportHtmlDialog(theme?: 'light' | 'dark'): Promise<ImportHtmlDialogResult>;
55
+ /**
56
+ * Markdown 파일을 골라 본문에 임포트하기 위한 다이얼로그.
57
+ * 파일 선택(.md / .markdown) 또는 textarea 직접 붙여넣기 모두 지원. 확인 시
58
+ * 원본 markdown 문자열을 resolve. 호출자가 받은 markdown 을 markdownToBlocks
59
+ * 으로 처리해 본문에 삽입한다.
60
+ */
61
+ export declare function openMarkdownImportDialog(theme?: 'light' | 'dark'): Promise<ImportMarkdownDialogResult>;
62
+ /**
63
+ * 파일 첨부 다이얼로그. 두 가지 입력 방식:
64
+ * 1) 링크 — 외부 URL + 표시 이름(선택) 입력
65
+ * 2) 업로드 — 사용자가 등록한 onUpload(file) 로 서버 업로드 후 응답 URL 사용
66
+ *
67
+ * 이미지 다이얼로그와 달리 base64 임베드 모드는 의도적으로 제외 — 첨부
68
+ * 파일은 보통 크기가 커서 직렬화 snapshot 비대화의 부작용이 크다.
69
+ */
70
+ export declare function openFileAttachmentDialog(options?: {
71
+ onUpload?: (file: File) => Promise<string>;
72
+ }, theme?: 'light' | 'dark'): Promise<FileAttachmentDialogResult>;
73
+ export declare function openYouTubeDialog(theme?: 'light' | 'dark'): Promise<YouTubeDialogResult>;
74
+ // (소스맵은 CJS 선언 사본에서 제외됨 — scripts/finalize-types.mjs)
@@ -0,0 +1,2 @@
1
+ export declare const icons: Record<string, string>;
2
+ // (소스맵은 CJS 선언 사본에서 제외됨 — scripts/finalize-types.mjs)
@@ -0,0 +1,70 @@
1
+ import type { BlockAttrs, BlockKind } from '../core/blocks.cjs';
2
+ export declare const COLOR_PALETTE: string[];
3
+ export declare function openColorPicker(anchor: HTMLElement, onPick: (color: string | null) => void, recents?: ReadonlyArray<string>): void;
4
+ /**
5
+ * 블록 드롭다운에서 사용자가 고른 항목.
6
+ * - `kind` 가 BlockKind 인 경우 일반 블록 추가/변환
7
+ * - `kind` 가 'importHtml' / 'importMarkdown' 인 경우 외부 가져오기 액션(특수 처리)
8
+ */
9
+ export interface BlockTypeChoice {
10
+ kind: BlockKind | 'importHtml' | 'importMarkdown';
11
+ attrs: BlockAttrs;
12
+ }
13
+ export declare function openBlockTypeDropdown(anchor: HTMLElement, onPick: (choice: BlockTypeChoice) => void): void;
14
+ export declare function openAlignDropdown(anchor: HTMLElement, onPick: (value: 'left' | 'center' | 'right' | 'justify') => void): void;
15
+ export interface FontFamilyChoice {
16
+ id: string;
17
+ label: string;
18
+ stack: string;
19
+ }
20
+ /**
21
+ * 글꼴 선택 드롭다운. 첫 호출 시 모든 글꼴 CSS 를 lazy 로드(Google Fonts +
22
+ * Pretendard CDN), 항목 라벨은 각 글꼴 자신으로 미리보기 렌더한다.
23
+ *
24
+ * - `currentId` 가 지정되면 해당 글꼴 항목에 `aw-popover-item-active` 적용
25
+ * - 선택 시 `onPick(choice)` 호출 + 팝오버 닫힘
26
+ */
27
+ export declare function openFontFamilyDropdown(anchor: HTMLElement, onPick: (choice: FontFamilyChoice) => void, currentId?: string): void;
28
+ export interface CodeLanguageChoice {
29
+ id: string;
30
+ label: string;
31
+ }
32
+ /**
33
+ * 코드 블록의 언어 선택 드롭다운. highlight.ts 의 LANGUAGES 를 그대로 노출.
34
+ *
35
+ * - `currentId` 가 일치하는 항목에 active(✓) 표시
36
+ * - 선택 시 onPick(choice) 호출 + 팝오버 닫힘
37
+ */
38
+ export declare function openCodeLanguageDropdown(anchor: HTMLElement, onPick: (choice: CodeLanguageChoice) => void, currentId?: string): void;
39
+ export type TableMenuAction = 'rowAbove' | 'rowBelow' | 'colLeft' | 'colRight' | 'deleteRow' | 'deleteCol';
40
+ /**
41
+ * 표 편집 드롭다운 — 행/열 추가·삭제. 활성 블록이 table 일 때만 의미가 있어
42
+ * AerizEditor 가 toolbar 'tableMenu' 항목 클릭 시점에 호출.
43
+ */
44
+ export declare function openTableMenuDropdown(anchor: HTMLElement, onPick: (action: TableMenuAction) => void): void;
45
+ export interface FontSizeChoice {
46
+ px: number;
47
+ }
48
+ /**
49
+ * 글자 크기 프리셋 드롭다운. FONT_SIZES 의 px 값을 작은 라벨로 나열.
50
+ *
51
+ * - `currentPx` 가 일치하는 항목에 active 표시
52
+ * - 선택 시 `onPick({ px })` 호출 + 팝오버 닫힘
53
+ */
54
+ export declare function openFontSizeDropdown(anchor: HTMLElement, onPick: (choice: FontSizeChoice) => void, currentPx?: number): void;
55
+ /**
56
+ * 기능 미구현 메뉴 항목용 placeholder 드롭다운.
57
+ * 항목명만 노출하고 "준비 중" 메시지를 보여준다.
58
+ */
59
+ export declare function openComingSoonDropdown(anchor: HTMLElement, label: string): void;
60
+ /**
61
+ * 표 삽입 드롭다운. 모달 대신 anchor 아래에 떠 호버 위치에 따라 2x2 부터
62
+ * 12x12 까지 그리드가 동적으로 늘어난다. 셀을 클릭하면 onPick 호출 + 닫힘,
63
+ * 외부 클릭 / Esc → 취소.
64
+ */
65
+ export interface TableSizeChoice {
66
+ rows: number;
67
+ cols: number;
68
+ }
69
+ export declare function openTableDropdown(anchor: HTMLElement, onPick: (choice: TableSizeChoice) => void): void;
70
+ // (소스맵은 CJS 선언 사본에서 제외됨 — scripts/finalize-types.mjs)