@x-plat/design-system 0.19.0 → 0.21.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.
Files changed (296) hide show
  1. package/dist/chunk-2EGVOUGV.cjs +93 -0
  2. package/dist/chunk-2T3BVV7R.js +0 -0
  3. package/dist/chunk-3FYYFDKQ.js +159 -0
  4. package/dist/chunk-3M3GFSHJ.js +67 -0
  5. package/dist/chunk-3WBHUFOA.cjs +48 -0
  6. package/dist/chunk-3XYYZQR5.cjs +22 -0
  7. package/dist/chunk-4EF7NVAL.js +67 -0
  8. package/dist/chunk-4ISERXK2.cjs +1 -0
  9. package/dist/chunk-4KYHHJ6Z.cjs +250 -0
  10. package/dist/chunk-4NSRDRXC.cjs +70 -0
  11. package/dist/chunk-4OXMRSVE.cjs +99 -0
  12. package/dist/chunk-55EPYLXN.js +30 -0
  13. package/dist/chunk-5CE3ADO5.js +254 -0
  14. package/dist/chunk-5F6Y2JD6.cjs +1 -0
  15. package/dist/chunk-5FMTMXSP.cjs +127 -0
  16. package/dist/chunk-5POCKDDY.js +36 -0
  17. package/dist/chunk-5VDI56BV.js +33 -0
  18. package/dist/chunk-5WLBUPSK.js +77 -0
  19. package/dist/chunk-5WNNWQHD.cjs +272 -0
  20. package/dist/chunk-66STZB6I.cjs +404 -0
  21. package/dist/chunk-6AIKCZN7.js +1455 -0
  22. package/dist/chunk-6IUJJUVP.js +18 -0
  23. package/dist/chunk-6P2B3ZGP.js +79 -0
  24. package/dist/chunk-764ILIDG.cjs +22 -0
  25. package/dist/chunk-7B44DWC4.js +0 -0
  26. package/dist/chunk-7BE6ETFY.js +18 -0
  27. package/dist/chunk-7BSUS5A4.js +97 -0
  28. package/dist/chunk-7RPWCDEW.cjs +20 -0
  29. package/dist/chunk-7ULXHGLO.cjs +77 -0
  30. package/dist/chunk-7YOI5XOW.js +55 -0
  31. package/dist/chunk-AFVTM5CP.js +0 -0
  32. package/dist/chunk-AN2WSL3B.cjs +1 -0
  33. package/dist/chunk-AT5Y5GLS.cjs +118 -0
  34. package/dist/chunk-AWPO2FI7.js +404 -0
  35. package/dist/chunk-BGXHIDUR.js +103 -0
  36. package/dist/chunk-BPZXL5TP.js +99 -0
  37. package/dist/chunk-BRTS5GWV.js +275 -0
  38. package/dist/chunk-BS3MLZCK.cjs +97 -0
  39. package/dist/chunk-BSPYYE2U.js +36 -0
  40. package/dist/chunk-BWJAEB42.js +48 -0
  41. package/dist/chunk-C4RMTISI.cjs +18 -0
  42. package/dist/chunk-C6M4XVR7.cjs +36 -0
  43. package/dist/chunk-CGC4D5MP.cjs +89 -0
  44. package/dist/chunk-CIRQYSQW.js +70 -0
  45. package/dist/chunk-CLOTWJNP.cjs +310 -0
  46. package/dist/chunk-CS7ZY35M.cjs +49 -0
  47. package/dist/chunk-CUV4RLDE.js +89 -0
  48. package/dist/chunk-CZAMLFSE.cjs +275 -0
  49. package/dist/chunk-D7QZLJ3Z.cjs +18 -0
  50. package/dist/chunk-DMSAAZ3M.cjs +92 -0
  51. package/dist/chunk-DUIZC7VJ.cjs +36 -0
  52. package/dist/chunk-DVBF4BDH.js +43 -0
  53. package/dist/chunk-EETYMP6K.cjs +584 -0
  54. package/dist/chunk-EFQL7JPX.js +0 -0
  55. package/dist/chunk-EFU7IAF5.cjs +12 -0
  56. package/dist/chunk-F3M2H5EX.cjs +79 -0
  57. package/dist/chunk-F436V2SX.cjs +254 -0
  58. package/dist/chunk-F664X2OY.js +250 -0
  59. package/dist/chunk-FF7ELUQW.cjs +1 -0
  60. package/dist/chunk-G3HE4S3Q.cjs +296 -0
  61. package/dist/chunk-GOPD5KUK.js +23 -0
  62. package/dist/chunk-GYTB24V6.cjs +107 -0
  63. package/dist/chunk-GZ657SGO.js +310 -0
  64. package/dist/chunk-H2QN65L6.cjs +1 -0
  65. package/dist/chunk-H6WUT7CK.js +22 -0
  66. package/dist/chunk-H76OQ75T.js +49 -0
  67. package/dist/chunk-HA3XONYI.js +18 -0
  68. package/dist/chunk-HF3UFXEU.js +296 -0
  69. package/dist/chunk-HGA47QVV.cjs +55 -0
  70. package/dist/chunk-HHPPAMXF.cjs +674 -0
  71. package/dist/chunk-HLV2XIE2.cjs +385 -0
  72. package/dist/chunk-HNQGIL45.cjs +96 -0
  73. package/dist/chunk-HQ37R7T3.js +53 -0
  74. package/dist/chunk-HXUGW4RR.js +187 -0
  75. package/dist/chunk-HYPRLWD3.js +272 -0
  76. package/dist/chunk-I7TLJUTP.cjs +6 -0
  77. package/dist/chunk-ICTWDTKC.cjs +1 -0
  78. package/dist/chunk-IPYKHDP4.cjs +187 -0
  79. package/dist/chunk-IRKREQ2X.cjs +18 -0
  80. package/dist/chunk-IVJJBMRY.js +92 -0
  81. package/dist/chunk-JPVIVOFG.js +26 -0
  82. package/dist/chunk-JYNBNSNF.js +151 -0
  83. package/dist/chunk-JZC3BXAC.js +93 -0
  84. package/dist/chunk-K5XPQWXN.cjs +92 -0
  85. package/dist/chunk-KQ3GOMHL.js +31 -0
  86. package/dist/chunk-KUJH72U6.cjs +159 -0
  87. package/dist/chunk-KVUXLC6M.cjs +479 -0
  88. package/dist/chunk-KZOJN57Q.js +19 -0
  89. package/dist/chunk-L3XPL4NP.cjs +53 -0
  90. package/dist/chunk-LOEMSXYB.js +0 -0
  91. package/dist/chunk-LU4KBPNG.cjs +23 -0
  92. package/dist/chunk-MWWWPQDB.js +26 -0
  93. package/dist/chunk-NCBB3WUJ.js +562 -0
  94. package/dist/chunk-NGCZTZST.cjs +562 -0
  95. package/dist/chunk-NSDKALIS.cjs +67 -0
  96. package/dist/chunk-NZHCRLNB.cjs +26 -0
  97. package/dist/chunk-OL4NANHB.js +0 -0
  98. package/dist/chunk-OTJRNKLR.js +96 -0
  99. package/dist/chunk-OWWFKTSK.js +0 -0
  100. package/dist/chunk-P2E3PB62.cjs +99 -0
  101. package/dist/chunk-P2QVFR7S.js +20 -0
  102. package/dist/chunk-P6ZGIYY7.cjs +18 -0
  103. package/dist/chunk-PFGSJJRY.cjs +19 -0
  104. package/dist/chunk-PNIUW7AJ.cjs +32 -0
  105. package/dist/chunk-Q2M2ONGO.js +70 -0
  106. package/dist/chunk-Q4PGP5KE.cjs +562 -0
  107. package/dist/chunk-QAI2YQPY.cjs +51 -0
  108. package/dist/chunk-QCD7UEZ3.cjs +59 -0
  109. package/dist/chunk-QEZ4R3SK.js +6 -0
  110. package/dist/chunk-QKDCPM2D.cjs +23 -0
  111. package/dist/chunk-QRGG3V7W.cjs +59 -0
  112. package/dist/chunk-QURIHUEC.js +107 -0
  113. package/dist/chunk-QY742LWN.js +30 -0
  114. package/dist/chunk-QYMRGYTN.js +127 -0
  115. package/dist/chunk-RLKJ2RZG.js +23 -0
  116. package/dist/chunk-RRR5BUOM.cjs +30 -0
  117. package/dist/chunk-RU3FCVXM.cjs +1 -0
  118. package/dist/chunk-RYTDVTV2.js +32 -0
  119. package/dist/chunk-RYYGUYDE.js +92 -0
  120. package/dist/chunk-SGLP4U3Y.cjs +67 -0
  121. package/dist/chunk-SJC543ZK.js +71 -0
  122. package/dist/chunk-SLYQK4SC.js +20 -0
  123. package/dist/chunk-SMLCOMLS.js +2888 -0
  124. package/dist/chunk-SNMOPLMH.cjs +372 -0
  125. package/dist/chunk-TRJUJYW7.cjs +151 -0
  126. package/dist/chunk-TTY5PE3P.js +30 -0
  127. package/dist/chunk-TXARYG3J.js +22 -0
  128. package/dist/chunk-TYXJU4EF.js +18 -0
  129. package/dist/chunk-U3PC7FYZ.cjs +26 -0
  130. package/dist/chunk-U67JM2WL.cjs +34 -0
  131. package/dist/chunk-UARGO5UG.js +59 -0
  132. package/dist/chunk-UCYE3H3F.cjs +43 -0
  133. package/dist/chunk-UGEGN35F.js +118 -0
  134. package/dist/chunk-UHUA3GQC.cjs +30 -0
  135. package/dist/chunk-UJQN477L.js +59 -0
  136. package/dist/chunk-UMX7DTFZ.cjs +70 -0
  137. package/dist/chunk-UT42P54P.js +372 -0
  138. package/dist/chunk-V76ZRGHQ.cjs +1 -0
  139. package/dist/chunk-VCIK366Y.cjs +1455 -0
  140. package/dist/chunk-VMA74ABT.cjs +137 -0
  141. package/dist/chunk-VSA62N2O.js +12 -0
  142. package/dist/chunk-WDAFLVQK.js +479 -0
  143. package/dist/chunk-WHMLMAMO.js +674 -0
  144. package/dist/chunk-WNBLKKLM.js +0 -0
  145. package/dist/chunk-WQ2GY7F3.js +46 -0
  146. package/dist/chunk-WRLCCK3M.cjs +30 -0
  147. package/dist/chunk-WVCZIOLY.js +562 -0
  148. package/dist/chunk-WZLGJQLW.js +385 -0
  149. package/dist/chunk-XB6FEBK6.js +34 -0
  150. package/dist/chunk-XMERDSRE.js +75 -0
  151. package/dist/chunk-XMLFKZYY.js +137 -0
  152. package/dist/chunk-XMM52J3T.js +584 -0
  153. package/dist/chunk-XZ7C5CGB.cjs +103 -0
  154. package/dist/chunk-YGFBAOKX.js +51 -0
  155. package/dist/chunk-YIN552MF.cjs +20 -0
  156. package/dist/chunk-YLC42E65.cjs +31 -0
  157. package/dist/chunk-YOTXRYJL.cjs +46 -0
  158. package/dist/chunk-ZAUGJZK7.js +99 -0
  159. package/dist/chunk-ZIZOQTDG.cjs +75 -0
  160. package/dist/chunk-ZMSV5VZI.cjs +2888 -0
  161. package/dist/chunk-ZN6MLZAE.cjs +71 -0
  162. package/dist/chunk-ZNCT6HXA.cjs +33 -0
  163. package/dist/components/Accordion/index.cjs +5 -1036
  164. package/dist/components/Accordion/index.js +5 -999
  165. package/dist/components/Alert/index.cjs +4 -69
  166. package/dist/components/Alert/index.js +4 -42
  167. package/dist/components/AutoResizeTextArea/index.cjs +6 -260
  168. package/dist/components/AutoResizeTextArea/index.js +6 -223
  169. package/dist/components/Avatar/index.cjs +4 -65
  170. package/dist/components/Avatar/index.js +4 -38
  171. package/dist/components/Badge/index.cjs +6 -69
  172. package/dist/components/Badge/index.js +5 -40
  173. package/dist/components/Box/index.cjs +4 -58
  174. package/dist/components/Box/index.js +4 -31
  175. package/dist/components/Breadcrumb/index.cjs +4 -42
  176. package/dist/components/Breadcrumb/index.js +3 -14
  177. package/dist/components/Button/index.cjs +5 -65
  178. package/dist/components/Button/index.js +5 -38
  179. package/dist/components/Calendar/index.cjs +6 -1317
  180. package/dist/components/Calendar/index.js +10 -1281
  181. package/dist/components/CardTab/index.cjs +4 -120
  182. package/dist/components/CardTab/index.js +4 -83
  183. package/dist/components/Chart/index.cjs +5 -708
  184. package/dist/components/Chart/index.js +4 -670
  185. package/dist/components/ChatInput/index.cjs +9 -390
  186. package/dist/components/ChatInput/index.js +9 -353
  187. package/dist/components/CheckBox/index.cjs +20 -1125
  188. package/dist/components/CheckBox/index.js +17 -1095
  189. package/dist/components/Chip/index.cjs +5 -55
  190. package/dist/components/Chip/index.js +5 -28
  191. package/dist/components/DatePicker/index.cjs +16 -2136
  192. package/dist/components/DatePicker/index.js +19 -2099
  193. package/dist/components/Divider/index.cjs +4 -58
  194. package/dist/components/Divider/index.js +4 -31
  195. package/dist/components/Drawer/index.cjs +5 -190
  196. package/dist/components/Drawer/index.js +5 -153
  197. package/dist/components/Dropdown/index.cjs +7 -375
  198. package/dist/components/Dropdown/index.js +7 -338
  199. package/dist/components/Editor/index.cjs +6 -1486
  200. package/dist/components/Editor/index.css +53 -0
  201. package/dist/components/Editor/index.d.cts +13 -0
  202. package/dist/components/Editor/index.d.ts +13 -0
  203. package/dist/components/Editor/index.js +6 -1453
  204. package/dist/components/EmptyState/index.cjs +4 -42
  205. package/dist/components/EmptyState/index.js +3 -14
  206. package/dist/components/FieldMessage/index.cjs +7 -182
  207. package/dist/components/FieldMessage/index.js +8 -154
  208. package/dist/components/FileUpload/index.cjs +7 -1171
  209. package/dist/components/FileUpload/index.js +7 -1134
  210. package/dist/components/HtmlTypeWriter/index.cjs +3 -171
  211. package/dist/components/HtmlTypeWriter/index.js +3 -133
  212. package/dist/components/IconButton/index.cjs +4 -65
  213. package/dist/components/IconButton/index.js +4 -38
  214. package/dist/components/ImageSelector/index.cjs +8 -1214
  215. package/dist/components/ImageSelector/index.js +8 -1177
  216. package/dist/components/Input/index.cjs +7 -429
  217. package/dist/components/Input/index.js +8 -392
  218. package/dist/components/Link/index.cjs +4 -61
  219. package/dist/components/Link/index.js +4 -34
  220. package/dist/components/LinkButton/index.cjs +5 -61
  221. package/dist/components/LinkButton/index.js +5 -34
  222. package/dist/components/Modal/index.cjs +5 -190
  223. package/dist/components/Modal/index.js +5 -153
  224. package/dist/components/NotificationBadge/index.cjs +5 -68
  225. package/dist/components/NotificationBadge/index.js +5 -40
  226. package/dist/components/Pagination/index.cjs +6 -1034
  227. package/dist/components/Pagination/index.js +6 -1007
  228. package/dist/components/PopOver/index.cjs +7 -363
  229. package/dist/components/PopOver/index.js +7 -326
  230. package/dist/components/Progress/index.cjs +5 -84
  231. package/dist/components/Progress/index.js +5 -57
  232. package/dist/components/Radio/index.cjs +7 -274
  233. package/dist/components/Radio/index.js +8 -237
  234. package/dist/components/Select/index.cjs +10 -1577
  235. package/dist/components/Select/index.js +11 -1540
  236. package/dist/components/Skeleton/index.cjs +4 -71
  237. package/dist/components/Skeleton/index.js +4 -44
  238. package/dist/components/Spinner/index.cjs +5 -88
  239. package/dist/components/Spinner/index.js +5 -61
  240. package/dist/components/Stat/index.cjs +5 -81
  241. package/dist/components/Stat/index.js +5 -54
  242. package/dist/components/Steps/index.cjs +7 -968
  243. package/dist/components/Steps/index.js +7 -941
  244. package/dist/components/Swiper/index.cjs +4 -357
  245. package/dist/components/Swiper/index.js +4 -320
  246. package/dist/components/Switch/index.cjs +7 -252
  247. package/dist/components/Switch/index.js +7 -215
  248. package/dist/components/Tab/index.cjs +4 -144
  249. package/dist/components/Tab/index.js +4 -107
  250. package/dist/components/Table/index.cjs +4 -310
  251. package/dist/components/Table/index.css +31 -5
  252. package/dist/components/Table/index.js +8 -273
  253. package/dist/components/Tag/index.cjs +6 -969
  254. package/dist/components/Tag/index.js +6 -942
  255. package/dist/components/TextArea/index.cjs +6 -229
  256. package/dist/components/TextArea/index.js +6 -192
  257. package/dist/components/TimePicker/index.cjs +9 -579
  258. package/dist/components/TimePicker/index.js +9 -542
  259. package/dist/components/Toast/index.cjs +5 -146
  260. package/dist/components/Toast/index.js +5 -108
  261. package/dist/components/ToggleChip/index.cjs +5 -66
  262. package/dist/components/ToggleChip/index.js +5 -39
  263. package/dist/components/Tooltip/index.cjs +6 -204
  264. package/dist/components/Tooltip/index.js +6 -167
  265. package/dist/components/Tour/index.cjs +6 -414
  266. package/dist/components/Tour/index.js +6 -377
  267. package/dist/components/Video/index.cjs +7 -796
  268. package/dist/components/Video/index.js +7 -759
  269. package/dist/components/index.cjs +140 -8315
  270. package/dist/components/index.css +31 -5
  271. package/dist/components/index.js +190 -8261
  272. package/dist/index.cjs +903 -13291
  273. package/dist/index.css +31 -5
  274. package/dist/index.js +524 -12499
  275. package/dist/layout/Grid/FullGrid/index.cjs +4 -46
  276. package/dist/layout/Grid/FullGrid/index.js +3 -18
  277. package/dist/layout/Grid/FullScreen/index.cjs +4 -46
  278. package/dist/layout/Grid/FullScreen/index.js +3 -18
  279. package/dist/layout/Grid/Item/index.cjs +5 -68
  280. package/dist/layout/Grid/Item/index.js +5 -41
  281. package/dist/layout/Grid/index.cjs +14 -109
  282. package/dist/layout/Grid/index.js +14 -79
  283. package/dist/layout/Header/index.cjs +4 -44
  284. package/dist/layout/Header/index.js +3 -16
  285. package/dist/layout/Layout/index.cjs +4 -42
  286. package/dist/layout/Layout/index.js +3 -14
  287. package/dist/layout/SideBar/index.cjs +6 -96
  288. package/dist/layout/SideBar/index.js +6 -57
  289. package/dist/layout/index.cjs +38 -209
  290. package/dist/layout/index.js +27 -153
  291. package/dist/tokens/index.cjs +627 -6119
  292. package/dist/tokens/index.js +324 -5489
  293. package/guidelines/components/editor.md +3 -0
  294. package/guidelines/components/table.md +23 -0
  295. package/guidelines/setup.md +7 -0
  296. package/package.json +6 -3
@@ -0,0 +1,1455 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+ var _chunkHGA47QVVcjs = require('./chunk-HGA47QVV.cjs');
5
+
6
+
7
+ var _chunkPFGSJJRYcjs = require('./chunk-PFGSJJRY.cjs');
8
+
9
+ // src/components/Editor/Editor.tsx
10
+ var _react = require('react'); var _react2 = _interopRequireDefault(_react);
11
+
12
+ // src/components/Editor/highlight.ts
13
+ var CODE_LANGUAGES = [
14
+ { value: "plain", label: "\uC5C6\uC74C" },
15
+ { value: "javascript", label: "JavaScript" },
16
+ { value: "typescript", label: "TypeScript" },
17
+ { value: "json", label: "JSON" },
18
+ { value: "html", label: "HTML" },
19
+ { value: "css", label: "CSS" },
20
+ { value: "python", label: "Python" },
21
+ { value: "sql", label: "SQL" },
22
+ { value: "bash", label: "Bash" }
23
+ ];
24
+ var KEYWORDS = {
25
+ plain: [],
26
+ javascript: "const let var function return if else for while class new this import export from default async await try catch throw typeof instanceof null undefined true false break continue switch case do delete in of yield".split(" "),
27
+ typescript: "const let var function return if else for while class new this import export from default async await try catch throw typeof instanceof null undefined true false break continue switch case do delete in of yield interface type enum implements extends public private protected readonly as satisfies keyof infer never unknown any".split(" "),
28
+ json: ["true", "false", "null"],
29
+ html: [],
30
+ css: [],
31
+ python: "def class return if elif else for while import from as try except finally raise with lambda None True False and or not in is pass break continue global nonlocal yield async await".split(" "),
32
+ sql: "SELECT FROM WHERE INSERT INTO VALUES UPDATE SET DELETE CREATE TABLE ALTER DROP JOIN LEFT RIGHT INNER OUTER ON GROUP BY ORDER HAVING LIMIT OFFSET AS AND OR NOT NULL DISTINCT UNION INDEX PRIMARY KEY FOREIGN REFERENCES DEFAULT".split(" "),
33
+ bash: "if then else fi for while do done case esac function return export local echo cd ls rm cp mv mkdir sudo source set unset exit".split(" ")
34
+ };
35
+ var LINE_COMMENT = {
36
+ javascript: "//",
37
+ typescript: "//",
38
+ css: "",
39
+ python: "#",
40
+ sql: "--",
41
+ bash: "#"
42
+ };
43
+ var escape = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
44
+ var wrap = (cls, text) => `<span class="tok-${cls}">${escape(text)}</span>`;
45
+ var highlight = (code, lang) => {
46
+ if (lang === "plain" || !code) return escape(code);
47
+ const keywords = new Set(KEYWORDS[lang]);
48
+ const lineComment = LINE_COMMENT[lang];
49
+ const caseInsensitive = lang === "sql";
50
+ let out = "";
51
+ let i = 0;
52
+ while (i < code.length) {
53
+ const rest = code.slice(i);
54
+ if ((lang === "javascript" || lang === "typescript" || lang === "css") && rest.startsWith("/*")) {
55
+ const end = code.indexOf("*/", i + 2);
56
+ const stop = end === -1 ? code.length : end + 2;
57
+ out += wrap("comment", code.slice(i, stop));
58
+ i = stop;
59
+ continue;
60
+ }
61
+ if (lineComment && rest.startsWith(lineComment)) {
62
+ const nl = code.indexOf("\n", i);
63
+ const stop = nl === -1 ? code.length : nl;
64
+ out += wrap("comment", code.slice(i, stop));
65
+ i = stop;
66
+ continue;
67
+ }
68
+ const q = rest[0];
69
+ if (q === '"' || q === "'" || q === "`") {
70
+ let j = 1;
71
+ while (j < rest.length) {
72
+ if (rest[j] === "\\") {
73
+ j += 2;
74
+ continue;
75
+ }
76
+ if (rest[j] === q) {
77
+ j += 1;
78
+ break;
79
+ }
80
+ if (rest[j] === "\n" && q !== "`") break;
81
+ j += 1;
82
+ }
83
+ out += wrap("string", rest.slice(0, j));
84
+ i += j;
85
+ continue;
86
+ }
87
+ const num = /^\d+(\.\d+)?/.exec(rest);
88
+ if (num && !/[\w$]/.test(_nullishCoalesce(code[i - 1], () => ( "")))) {
89
+ out += wrap("number", num[0]);
90
+ i += num[0].length;
91
+ continue;
92
+ }
93
+ const word = /^[A-Za-z_$][\w$]*/.exec(rest);
94
+ if (word) {
95
+ const w = word[0];
96
+ const hit = caseInsensitive ? keywords.has(w.toUpperCase()) : keywords.has(w);
97
+ out += hit ? wrap("keyword", w) : escape(w);
98
+ i += w.length;
99
+ continue;
100
+ }
101
+ if (lang === "html" && rest.startsWith("<")) {
102
+ const tag = /^<\/?[A-Za-z][\w-]*/.exec(rest);
103
+ if (tag) {
104
+ out += wrap("keyword", tag[0]);
105
+ i += tag[0].length;
106
+ continue;
107
+ }
108
+ }
109
+ out += escape(code[i]);
110
+ i += 1;
111
+ }
112
+ return out;
113
+ };
114
+
115
+ // src/components/Editor/Editor.tsx
116
+ var _jsxruntime = require('react/jsx-runtime');
117
+ var DEFAULT_TOOLBAR = [
118
+ "bold",
119
+ "italic",
120
+ "underline",
121
+ "strikethrough",
122
+ "code",
123
+ "heading-1",
124
+ "heading-2",
125
+ "heading-3",
126
+ "list",
127
+ "ordered-list",
128
+ "blockquote",
129
+ "code-block",
130
+ "link",
131
+ "image",
132
+ "divider",
133
+ "checklist",
134
+ "table",
135
+ "align-left",
136
+ "align-center",
137
+ "align-right",
138
+ "highlight",
139
+ "superscript",
140
+ "subscript",
141
+ "clear-format",
142
+ "undo",
143
+ "redo"
144
+ ];
145
+ var ALLOWED_TAGS = /* @__PURE__ */ new Set([
146
+ "p",
147
+ "br",
148
+ "h1",
149
+ "h2",
150
+ "h3",
151
+ "h4",
152
+ "h5",
153
+ "h6",
154
+ "ul",
155
+ "ol",
156
+ "li",
157
+ "blockquote",
158
+ "pre",
159
+ "code",
160
+ "strong",
161
+ "b",
162
+ "em",
163
+ "i",
164
+ "u",
165
+ "s",
166
+ "strike",
167
+ "del",
168
+ "a",
169
+ "img",
170
+ "hr",
171
+ "span",
172
+ "div",
173
+ "sub",
174
+ "sup",
175
+ "mark",
176
+ "table",
177
+ "thead",
178
+ "tbody",
179
+ "tr",
180
+ "th",
181
+ "td"
182
+ ]);
183
+ var ALLOWED_ATTRS = {
184
+ a: ["href", "target", "rel"],
185
+ img: ["src", "alt", "width"],
186
+ // 정렬·체크리스트는 클래스로만 표현한다. style 을 열면 붙여넣기로 아무 CSS 나 들어온다
187
+ p: ["class"],
188
+ h1: ["class"],
189
+ h2: ["class"],
190
+ h3: ["class"],
191
+ h4: ["class"],
192
+ h5: ["class"],
193
+ h6: ["class"],
194
+ ul: ["class"],
195
+ ol: ["class"],
196
+ li: ["class", "data-checked"],
197
+ blockquote: ["class"],
198
+ div: ["class"],
199
+ span: ["class"],
200
+ pre: ["class"],
201
+ code: ["class"],
202
+ mark: ["class"],
203
+ table: ["class"],
204
+ td: ["class"],
205
+ th: ["class"],
206
+ tr: ["class"]
207
+ };
208
+ var DROP_WITH_CONTENT = /* @__PURE__ */ new Set([
209
+ "script",
210
+ "style",
211
+ "noscript",
212
+ "iframe",
213
+ "object",
214
+ "embed",
215
+ "template"
216
+ ]);
217
+ var sanitizeHtml = (input) => {
218
+ const doc = new DOMParser().parseFromString(`<div>${input}</div>`, "text/html");
219
+ const root = doc.body.firstElementChild;
220
+ if (!root) return "";
221
+ const walk = (node) => {
222
+ const children = Array.from(node.children);
223
+ for (const child of children) {
224
+ const tag = child.tagName.toLowerCase();
225
+ if (DROP_WITH_CONTENT.has(tag)) {
226
+ node.removeChild(child);
227
+ continue;
228
+ }
229
+ if (!ALLOWED_TAGS.has(tag)) {
230
+ while (child.firstChild) node.insertBefore(child.firstChild, child);
231
+ node.removeChild(child);
232
+ continue;
233
+ }
234
+ const allowed = ALLOWED_ATTRS[tag] || [];
235
+ for (const attr of Array.from(child.attributes)) {
236
+ if (!allowed.includes(attr.name)) {
237
+ child.removeAttribute(attr.name);
238
+ }
239
+ if (attr.name === "href" || attr.name === "src") {
240
+ const val = attr.value.trim().toLowerCase();
241
+ if (val.startsWith("javascript:") || val.startsWith("data:text/html")) {
242
+ child.removeAttribute(attr.name);
243
+ }
244
+ }
245
+ }
246
+ walk(child);
247
+ }
248
+ };
249
+ walk(root);
250
+ return root.innerHTML;
251
+ };
252
+ var escapeHtml = (text) => {
253
+ const div = document.createElement("div");
254
+ div.textContent = text;
255
+ return div.innerHTML.replace(/\n/g, "<br>");
256
+ };
257
+ var SLASH_ITEMS = [
258
+ { key: "paragraph", label: "\uB2E8\uB77D", hint: "\uAE30\uBCF8 \uD14D\uC2A4\uD2B8" },
259
+ { key: "heading-1", label: "\uC81C\uBAA9 1", hint: "\uAC00\uC7A5 \uD070 \uC81C\uBAA9" },
260
+ { key: "heading-2", label: "\uC81C\uBAA9 2", hint: "" },
261
+ { key: "heading-3", label: "\uC81C\uBAA9 3", hint: "" },
262
+ { key: "list", label: "\uAE00\uBA38\uB9AC \uAE30\uD638 \uBAA9\uB85D", hint: "\u2022 \uD56D\uBAA9" },
263
+ { key: "ordered-list", label: "\uBC88\uD638 \uB9E4\uAE30\uAE30 \uBAA9\uB85D", hint: "1. \uD56D\uBAA9" },
264
+ { key: "blockquote", label: "\uC778\uC6A9", hint: "" },
265
+ { key: "code-block", label: "\uCF54\uB4DC \uBE14\uB85D", hint: "" },
266
+ { key: "divider", label: "\uAD6C\uBD84\uC120", hint: "\u2500" },
267
+ { key: "image", label: "\uC774\uBBF8\uC9C0", hint: "" }
268
+ ];
269
+ var Editor = (props) => {
270
+ const {
271
+ value = "",
272
+ onChange,
273
+ placeholder = "\uB0B4\uC6A9\uC744 \uC785\uB825\uD558\uC138\uC694",
274
+ readOnly = false,
275
+ toolbar = DEFAULT_TOOLBAR,
276
+ enableSlashCommand = true,
277
+ enableMarkdownShortcuts = true,
278
+ onImageUpload,
279
+ minHeight = 200,
280
+ label,
281
+ required = false,
282
+ validations
283
+ } = props;
284
+ const labelId = _react2.default.useId();
285
+ const editorRef = _react2.default.useRef(null);
286
+ const lastRangeRef = _react2.default.useRef(null);
287
+ const composingRef = _react2.default.useRef(false);
288
+ const [isFocused, setIsFocused] = _react2.default.useState(false);
289
+ const [isEmpty, setIsEmpty] = _react2.default.useState(!value);
290
+ const [activeFormats, setActiveFormats] = _react2.default.useState(/* @__PURE__ */ new Set());
291
+ const [slashOpen, setSlashOpen] = _react2.default.useState(false);
292
+ const [slashFilter, setSlashFilter] = _react2.default.useState("");
293
+ const [slashIdx, setSlashIdx] = _react2.default.useState(0);
294
+ const [slashPos, setSlashPos] = _react2.default.useState({ top: 0, left: 0 });
295
+ const slashStartRangeRef = _react2.default.useRef(null);
296
+ const [linkOpen, setLinkOpen] = _react2.default.useState(false);
297
+ const [linkValue, setLinkValue] = _react2.default.useState("");
298
+ const [linkPos, setLinkPos] = _react2.default.useState({ top: 0, left: 0 });
299
+ const lastEmittedRef = _react2.default.useRef(null);
300
+ _react2.default.useEffect(() => {
301
+ const el = editorRef.current;
302
+ if (!el) return;
303
+ if (value === lastEmittedRef.current) return;
304
+ if (el.innerHTML === value) return;
305
+ el.innerHTML = sanitizeHtml(value || "");
306
+ if (!el.firstChild) el.innerHTML = "<p><br></p>";
307
+ lastEmittedRef.current = null;
308
+ historyRef.current = [{ html: el.innerHTML, caret: 0 }];
309
+ historyIdxRef.current = 0;
310
+ updateEmpty();
311
+ }, [value]);
312
+ const updateEmpty = () => {
313
+ const el = editorRef.current;
314
+ if (!el) return;
315
+ const text = el.textContent || "";
316
+ const childCount = el.children.length;
317
+ setIsEmpty(text.length === 0 && childCount <= 1);
318
+ };
319
+ const saveSelection = () => {
320
+ const sel = window.getSelection();
321
+ if (sel && sel.rangeCount > 0 && _optionalChain([editorRef, 'access', _ => _.current, 'optionalAccess', _2 => _2.contains, 'call', _3 => _3(sel.anchorNode)])) {
322
+ lastRangeRef.current = sel.getRangeAt(0).cloneRange();
323
+ }
324
+ };
325
+ const restoreSelection = () => {
326
+ const range = lastRangeRef.current;
327
+ if (!range) return;
328
+ if (!_optionalChain([editorRef, 'access', _4 => _4.current, 'optionalAccess', _5 => _5.contains, 'call', _6 => _6(range.startContainer)])) {
329
+ lastRangeRef.current = null;
330
+ return;
331
+ }
332
+ const sel = window.getSelection();
333
+ try {
334
+ _optionalChain([sel, 'optionalAccess', _7 => _7.removeAllRanges, 'call', _8 => _8()]);
335
+ _optionalChain([sel, 'optionalAccess', _9 => _9.addRange, 'call', _10 => _10(range)]);
336
+ } catch (e2) {
337
+ lastRangeRef.current = null;
338
+ }
339
+ };
340
+ const updateActiveFormats = () => {
341
+ if (!editorRef.current) return;
342
+ const sel = window.getSelection();
343
+ if (!sel || !editorRef.current.contains(sel.anchorNode)) return;
344
+ const next = /* @__PURE__ */ new Set();
345
+ try {
346
+ if (document.queryCommandState("bold")) next.add("bold");
347
+ if (document.queryCommandState("italic")) next.add("italic");
348
+ if (document.queryCommandState("underline")) next.add("underline");
349
+ if (document.queryCommandState("strikethrough")) next.add("strikethrough");
350
+ if (document.queryCommandState("insertUnorderedList")) next.add("list");
351
+ if (document.queryCommandState("insertOrderedList")) next.add("ordered-list");
352
+ const block = String(document.queryCommandValue("formatBlock") || "").toLowerCase();
353
+ if (block) next.add(`block:${block}`);
354
+ if (document.queryCommandState("superscript")) next.add("superscript");
355
+ if (document.queryCommandState("subscript")) next.add("subscript");
356
+ } catch (e3) {
357
+ }
358
+ try {
359
+ const blockEl = currentBlock();
360
+ if (_optionalChain([blockEl, 'optionalAccess', _11 => _11.classList, 'access', _12 => _12.contains, 'call', _13 => _13("align-center")])) next.add("align:center");
361
+ else if (_optionalChain([blockEl, 'optionalAccess', _14 => _14.classList, 'access', _15 => _15.contains, 'call', _16 => _16("align-right")])) next.add("align:right");
362
+ else if (blockEl) next.add("align:left");
363
+ if (_optionalChain([blockEl, 'optionalAccess', _17 => _17.closest, 'call', _18 => _18("mark")])) next.add("highlight");
364
+ if (_optionalChain([blockEl, 'optionalAccess', _19 => _19.closest, 'call', _20 => _20("ul.checklist")])) next.add("checklist");
365
+ } catch (e4) {
366
+ }
367
+ setActiveFormats(next);
368
+ };
369
+ const exec = (cmd, val) => {
370
+ document.execCommand(cmd, false, val);
371
+ _optionalChain([editorRef, 'access', _21 => _21.current, 'optionalAccess', _22 => _22.focus, 'call', _23 => _23()]);
372
+ updateActiveFormats();
373
+ handleInput();
374
+ };
375
+ const setBlock = (tag) => {
376
+ exec("formatBlock", tag);
377
+ };
378
+ const toggleBlock = (tag) => {
379
+ const current = String(document.queryCommandValue("formatBlock") || "").toLowerCase();
380
+ setBlock(current === tag ? "p" : tag);
381
+ };
382
+ const historyRef = _react2.default.useRef([]);
383
+ const historyIdxRef = _react2.default.useRef(-1);
384
+ const lastPushAtRef = _react2.default.useRef(0);
385
+ const isRestoringRef = _react2.default.useRef(false);
386
+ const caretOffset = (rootEl) => {
387
+ const el = _nullishCoalesce(rootEl, () => ( editorRef.current));
388
+ const sel = window.getSelection();
389
+ if (!el || !sel || sel.rangeCount === 0 || !el.contains(sel.anchorNode)) return 0;
390
+ const range = sel.getRangeAt(0).cloneRange();
391
+ range.selectNodeContents(el);
392
+ range.setEnd(sel.getRangeAt(0).endContainer, sel.getRangeAt(0).endOffset);
393
+ return range.toString().length;
394
+ };
395
+ const setCaretOffset = (offset, rootEl) => {
396
+ const el = _nullishCoalesce(rootEl, () => ( editorRef.current));
397
+ if (!el) return;
398
+ const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);
399
+ let remaining = offset;
400
+ let node = null;
401
+ while (node = walker.nextNode()) {
402
+ const len = _nullishCoalesce(_optionalChain([node, 'access', _24 => _24.textContent, 'optionalAccess', _25 => _25.length]), () => ( 0));
403
+ if (remaining <= len) {
404
+ const range = document.createRange();
405
+ range.setStart(node, remaining);
406
+ range.collapse(true);
407
+ const sel = window.getSelection();
408
+ _optionalChain([sel, 'optionalAccess', _26 => _26.removeAllRanges, 'call', _27 => _27()]);
409
+ _optionalChain([sel, 'optionalAccess', _28 => _28.addRange, 'call', _29 => _29(range)]);
410
+ return;
411
+ }
412
+ remaining -= len;
413
+ }
414
+ placeCaretAtEnd(el);
415
+ };
416
+ const pushHistory = (force = false) => {
417
+ const el = editorRef.current;
418
+ if (!el || isRestoringRef.current) return;
419
+ const html = el.innerHTML;
420
+ const hist = historyRef.current;
421
+ const cur = hist[historyIdxRef.current];
422
+ if (cur && cur.html === html) return;
423
+ const now = Date.now();
424
+ const coalesce = !force && cur && now - lastPushAtRef.current < 500;
425
+ lastPushAtRef.current = now;
426
+ if (coalesce) {
427
+ hist[historyIdxRef.current] = { html, caret: caretOffset() };
428
+ return;
429
+ }
430
+ hist.length = historyIdxRef.current + 1;
431
+ hist.push({ html, caret: caretOffset() });
432
+ if (hist.length > 200) hist.shift();
433
+ historyIdxRef.current = hist.length - 1;
434
+ };
435
+ const applySnapshot = (snap) => {
436
+ const el = editorRef.current;
437
+ if (!el) return;
438
+ isRestoringRef.current = true;
439
+ el.innerHTML = snap.html;
440
+ setCaretOffset(snap.caret);
441
+ isRestoringRef.current = false;
442
+ lastEmittedRef.current = el.innerHTML;
443
+ _optionalChain([onChange, 'optionalCall', _30 => _30(el.innerHTML)]);
444
+ updateEmpty();
445
+ updateActiveFormats();
446
+ };
447
+ const undo = () => {
448
+ pushHistory(true);
449
+ if (historyIdxRef.current <= 0) return;
450
+ historyIdxRef.current -= 1;
451
+ applySnapshot(historyRef.current[historyIdxRef.current]);
452
+ };
453
+ const redo = () => {
454
+ if (historyIdxRef.current >= historyRef.current.length - 1) return;
455
+ historyIdxRef.current += 1;
456
+ applySnapshot(historyRef.current[historyIdxRef.current]);
457
+ };
458
+ const langOf = (pre) => {
459
+ const cls = Array.from(pre.classList).find((c) => c.startsWith("lang-"));
460
+ return _nullishCoalesce(_optionalChain([cls, 'optionalAccess', _31 => _31.slice, 'call', _32 => _32(5)]), () => ( "plain"));
461
+ };
462
+ const [codeLang, setCodeLang] = _react2.default.useState("plain");
463
+ const highlightRafRef = _react2.default.useRef(0);
464
+ const rehighlight = (pre) => {
465
+ if (composingRef.current) return;
466
+ const code = pre.querySelector("code");
467
+ if (!code) return;
468
+ const lang = langOf(pre);
469
+ const text = code.textContent || "";
470
+ const next = highlight(text, lang);
471
+ if (code.innerHTML === next) return;
472
+ const caret = caretOffset(code);
473
+ isRestoringRef.current = true;
474
+ code.innerHTML = next;
475
+ setCaretOffset(caret, code);
476
+ isRestoringRef.current = false;
477
+ };
478
+ const scheduleHighlight = () => {
479
+ const pre = closestPre();
480
+ if (!pre) return;
481
+ cancelAnimationFrame(highlightRafRef.current);
482
+ highlightRafRef.current = requestAnimationFrame(() => rehighlight(pre));
483
+ };
484
+ const changeCodeLang = (lang) => {
485
+ const pre = closestPre();
486
+ if (!pre) return;
487
+ pushHistory(true);
488
+ Array.from(pre.classList).filter((c) => c.startsWith("lang-")).forEach((c) => pre.classList.remove(c));
489
+ if (lang !== "plain") pre.classList.add(`lang-${lang}`);
490
+ setCodeLang(lang);
491
+ rehighlight(pre);
492
+ handleInput();
493
+ };
494
+ const closestPre = () => {
495
+ const sel = window.getSelection();
496
+ const node = _optionalChain([sel, 'optionalAccess', _33 => _33.anchorNode]);
497
+ if (!node || !_optionalChain([editorRef, 'access', _34 => _34.current, 'optionalAccess', _35 => _35.contains, 'call', _36 => _36(node)])) return null;
498
+ const el = node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement;
499
+ return _nullishCoalesce(_optionalChain([el, 'optionalAccess', _37 => _37.closest, 'call', _38 => _38("pre")]), () => ( null));
500
+ };
501
+ const insertCodeBlock = () => {
502
+ pushHistory(true);
503
+ const el = editorRef.current;
504
+ const sel = window.getSelection();
505
+ if (!el || !sel || sel.rangeCount === 0) return;
506
+ const existing = closestPre();
507
+ if (existing) {
508
+ const p = document.createElement("p");
509
+ p.textContent = existing.textContent || "";
510
+ if (!p.textContent) p.innerHTML = "<br>";
511
+ existing.replaceWith(p);
512
+ placeCaretAtEnd(p);
513
+ handleInput();
514
+ return;
515
+ }
516
+ const range = sel.getRangeAt(0);
517
+ const frag = range.cloneContents();
518
+ const holder = document.createElement("div");
519
+ holder.appendChild(frag);
520
+ const BLOCK = /^(p|div|h[1-6]|li|blockquote|pre|tr)$/i;
521
+ const linesOf = (node) => {
522
+ const out = [];
523
+ let cur = "";
524
+ for (const child of Array.from(node.childNodes)) {
525
+ if (child.nodeType === Node.TEXT_NODE) {
526
+ cur += child.textContent || "";
527
+ } else if (child.nodeName === "BR") {
528
+ out.push(cur);
529
+ cur = "";
530
+ } else if (BLOCK.test(child.nodeName)) {
531
+ if (cur) {
532
+ out.push(cur);
533
+ cur = "";
534
+ }
535
+ const sub = linesOf(child);
536
+ out.push(...sub.length > 0 ? sub : [""]);
537
+ } else {
538
+ cur += linesOf(child).join("\n");
539
+ }
540
+ }
541
+ if (cur) out.push(cur);
542
+ return out;
543
+ };
544
+ const text = linesOf(holder).join("\n").replace(/\n+$/, "");
545
+ const pre = document.createElement("pre");
546
+ const code = document.createElement("code");
547
+ code.textContent = text || "";
548
+ pre.appendChild(code);
549
+ range.deleteContents();
550
+ range.insertNode(pre);
551
+ ensureParagraphAfter(pre);
552
+ placeCaretAtEnd(code);
553
+ handleInput();
554
+ };
555
+ const insertTextAtCaret = (text) => {
556
+ const sel = window.getSelection();
557
+ if (!sel || sel.rangeCount === 0) return;
558
+ const range = sel.getRangeAt(0);
559
+ range.deleteContents();
560
+ const node = document.createTextNode(text);
561
+ range.insertNode(node);
562
+ range.setStartAfter(node);
563
+ range.collapse(true);
564
+ sel.removeAllRanges();
565
+ sel.addRange(range);
566
+ handleInput();
567
+ };
568
+ const ensureParagraphAfter = (node) => {
569
+ const next = node.nextElementSibling;
570
+ if (next && next.tagName === "P") return;
571
+ const p = document.createElement("p");
572
+ p.innerHTML = "<br>";
573
+ node.after(p);
574
+ };
575
+ const placeCaretAtEnd = (node) => {
576
+ const sel = window.getSelection();
577
+ if (!sel) return;
578
+ const r = document.createRange();
579
+ r.selectNodeContents(node);
580
+ r.collapse(false);
581
+ sel.removeAllRanges();
582
+ sel.addRange(r);
583
+ _optionalChain([editorRef, 'access', _39 => _39.current, 'optionalAccess', _40 => _40.focus, 'call', _41 => _41()]);
584
+ };
585
+ const clearFormat = () => {
586
+ exec("removeFormat");
587
+ exec("unlink");
588
+ setBlock("p");
589
+ };
590
+ const indentList = (outdent) => {
591
+ exec(outdent ? "outdent" : "indent");
592
+ };
593
+ const inListItem = () => {
594
+ const sel = window.getSelection();
595
+ const node = _optionalChain([sel, 'optionalAccess', _42 => _42.anchorNode]);
596
+ if (!node || !_optionalChain([editorRef, 'access', _43 => _43.current, 'optionalAccess', _44 => _44.contains, 'call', _45 => _45(node)])) return false;
597
+ const el = node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement;
598
+ return !!_optionalChain([el, 'optionalAccess', _46 => _46.closest, 'call', _47 => _47("li")]);
599
+ };
600
+ const currentBlock = () => {
601
+ const sel = window.getSelection();
602
+ const node = _optionalChain([sel, 'optionalAccess', _48 => _48.anchorNode]);
603
+ const root = editorRef.current;
604
+ if (!node || !_optionalChain([root, 'optionalAccess', _49 => _49.contains, 'call', _50 => _50(node)])) return null;
605
+ let el = node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement;
606
+ while (el && el !== root && !/^(P|H[1-6]|LI|BLOCKQUOTE|PRE|DIV|TD|TH)$/.test(el.tagName)) {
607
+ el = el.parentElement;
608
+ }
609
+ return el && el !== root ? el : null;
610
+ };
611
+ const setAlign = (align) => {
612
+ const block = currentBlock();
613
+ if (!block) return;
614
+ pushHistory(true);
615
+ block.classList.remove("align-left", "align-center", "align-right");
616
+ if (align !== "left") block.classList.add(`align-${align}`);
617
+ handleInput();
618
+ };
619
+ const toggleChecklist = () => {
620
+ pushHistory(true);
621
+ const block = currentBlock();
622
+ const list = _optionalChain([block, 'optionalAccess', _51 => _51.closest, 'call', _52 => _52("ul")]);
623
+ if (_optionalChain([list, 'optionalAccess', _53 => _53.classList, 'access', _54 => _54.contains, 'call', _55 => _55("checklist")])) {
624
+ list.classList.remove("checklist");
625
+ list.querySelectorAll("li").forEach((li) => li.removeAttribute("data-checked"));
626
+ handleInput();
627
+ return;
628
+ }
629
+ if (list) {
630
+ list.classList.add("checklist");
631
+ list.querySelectorAll("li").forEach((li) => li.setAttribute("data-checked", "false"));
632
+ handleInput();
633
+ return;
634
+ }
635
+ exec("insertUnorderedList");
636
+ const made = _optionalChain([currentBlock, 'call', _56 => _56(), 'optionalAccess', _57 => _57.closest, 'call', _58 => _58("ul")]);
637
+ if (made) {
638
+ made.classList.add("checklist");
639
+ made.querySelectorAll("li").forEach((li) => li.setAttribute("data-checked", "false"));
640
+ }
641
+ handleInput();
642
+ };
643
+ const handleEditorClick = (e) => {
644
+ if (readOnly) return;
645
+ const target = e.target;
646
+ const li = _optionalChain([target, 'access', _59 => _59.closest, 'optionalCall', _60 => _60("li")]);
647
+ if (!li || !li.closest("ul.checklist")) return;
648
+ const rect = li.getBoundingClientRect();
649
+ if (e.clientX - rect.left > 20) return;
650
+ e.preventDefault();
651
+ pushHistory(true);
652
+ li.setAttribute("data-checked", li.getAttribute("data-checked") === "true" ? "false" : "true");
653
+ handleInput();
654
+ };
655
+ const toggleHighlight = () => {
656
+ const sel = window.getSelection();
657
+ if (!sel || sel.rangeCount === 0 || sel.isCollapsed) return;
658
+ pushHistory(true);
659
+ const range = sel.getRangeAt(0);
660
+ const node = sel.anchorNode;
661
+ const el = _optionalChain([node, 'optionalAccess', _61 => _61.nodeType]) === Node.ELEMENT_NODE ? node : _optionalChain([node, 'optionalAccess', _62 => _62.parentElement]);
662
+ const existing = _optionalChain([el, 'optionalAccess', _63 => _63.closest, 'call', _64 => _64("mark")]);
663
+ if (existing) {
664
+ const parent = existing.parentNode;
665
+ while (existing.firstChild) _optionalChain([parent, 'optionalAccess', _65 => _65.insertBefore, 'call', _66 => _66(existing.firstChild, existing)]);
666
+ _optionalChain([parent, 'optionalAccess', _67 => _67.removeChild, 'call', _68 => _68(existing)]);
667
+ handleInput();
668
+ return;
669
+ }
670
+ const mark = document.createElement("mark");
671
+ try {
672
+ range.surroundContents(mark);
673
+ } catch (e5) {
674
+ const frag = range.extractContents();
675
+ mark.appendChild(frag);
676
+ range.insertNode(mark);
677
+ }
678
+ handleInput();
679
+ };
680
+ const insertTable = (cols = 3, rows = 2) => {
681
+ const sel = window.getSelection();
682
+ if (!sel || sel.rangeCount === 0) return;
683
+ pushHistory(true);
684
+ const table = document.createElement("table");
685
+ const thead = document.createElement("thead");
686
+ const headRow = document.createElement("tr");
687
+ for (let c = 0; c < cols; c++) {
688
+ const th = document.createElement("th");
689
+ th.innerHTML = "<br>";
690
+ headRow.appendChild(th);
691
+ }
692
+ thead.appendChild(headRow);
693
+ table.appendChild(thead);
694
+ const tbody = document.createElement("tbody");
695
+ for (let r = 0; r < rows; r++) {
696
+ const tr = document.createElement("tr");
697
+ for (let c = 0; c < cols; c++) {
698
+ const td = document.createElement("td");
699
+ td.innerHTML = "<br>";
700
+ tr.appendChild(td);
701
+ }
702
+ tbody.appendChild(tr);
703
+ }
704
+ table.appendChild(tbody);
705
+ const range = sel.getRangeAt(0);
706
+ range.deleteContents();
707
+ range.insertNode(table);
708
+ ensureParagraphAfter(table);
709
+ const first = table.querySelector("th");
710
+ if (first) placeCaretAtEnd(first);
711
+ handleInput();
712
+ };
713
+ const moveTableCell = (backwards) => {
714
+ const block = currentBlock();
715
+ const cell = _optionalChain([block, 'optionalAccess', _69 => _69.closest, 'call', _70 => _70("td, th")]);
716
+ if (!cell) return false;
717
+ const table = cell.closest("table");
718
+ if (!table) return false;
719
+ const cells = Array.from(table.querySelectorAll("td, th"));
720
+ const i = cells.indexOf(cell);
721
+ const next = cells[i + (backwards ? -1 : 1)];
722
+ if (next) {
723
+ placeCaretAtEnd(next);
724
+ return true;
725
+ }
726
+ if (!backwards) {
727
+ pushHistory(true);
728
+ const lastRow = _optionalChain([table, 'access', _71 => _71.querySelector, 'call', _72 => _72("tbody"), 'optionalAccess', _73 => _73.lastElementChild]);
729
+ if (lastRow) {
730
+ const tr = document.createElement("tr");
731
+ for (let c = 0; c < lastRow.children.length; c++) {
732
+ const td = document.createElement("td");
733
+ td.innerHTML = "<br>";
734
+ tr.appendChild(td);
735
+ }
736
+ lastRow.after(tr);
737
+ placeCaretAtEnd(tr.firstElementChild);
738
+ handleInput();
739
+ return true;
740
+ }
741
+ }
742
+ return false;
743
+ };
744
+ const insertDivider = () => {
745
+ pushHistory(true);
746
+ exec("insertHorizontalRule");
747
+ const el = editorRef.current;
748
+ if (el && _optionalChain([el, 'access', _74 => _74.lastElementChild, 'optionalAccess', _75 => _75.tagName]) === "HR") {
749
+ const p = document.createElement("p");
750
+ p.innerHTML = "<br>";
751
+ el.appendChild(p);
752
+ handleInput();
753
+ }
754
+ };
755
+ const insertImageByUrl = (url) => {
756
+ if (!url) return;
757
+ exec("insertImage", url);
758
+ };
759
+ const triggerImageUpload = async () => {
760
+ if (!onImageUpload) {
761
+ const url = window.prompt("\uC774\uBBF8\uC9C0 URL");
762
+ if (url) {
763
+ restoreSelection();
764
+ insertImageByUrl(url);
765
+ }
766
+ return;
767
+ }
768
+ const input = document.createElement("input");
769
+ input.type = "file";
770
+ input.accept = "image/*";
771
+ input.onchange = async () => {
772
+ const file = _optionalChain([input, 'access', _76 => _76.files, 'optionalAccess', _77 => _77[0]]);
773
+ if (!file) return;
774
+ try {
775
+ const url = await onImageUpload(file);
776
+ restoreSelection();
777
+ insertImageByUrl(url);
778
+ } catch (err) {
779
+ console.error("\uC774\uBBF8\uC9C0 \uC5C5\uB85C\uB4DC \uC2E4\uD328:", err);
780
+ }
781
+ };
782
+ input.click();
783
+ };
784
+ const openSlashMenu = () => {
785
+ if (!enableSlashCommand) return;
786
+ const sel = window.getSelection();
787
+ if (!sel || sel.rangeCount === 0) return;
788
+ const range = sel.getRangeAt(0);
789
+ slashStartRangeRef.current = range.cloneRange();
790
+ const rect = range.getBoundingClientRect();
791
+ const editorEl = editorRef.current;
792
+ if (!editorEl) return;
793
+ const editorRect = editorEl.getBoundingClientRect();
794
+ setSlashPos({
795
+ top: rect.bottom - editorRect.top + 4,
796
+ left: rect.left - editorRect.left
797
+ });
798
+ setSlashFilter("");
799
+ setSlashIdx(0);
800
+ setSlashOpen(true);
801
+ };
802
+ const closeSlashMenu = () => {
803
+ setSlashOpen(false);
804
+ setSlashFilter("");
805
+ setSlashIdx(0);
806
+ slashStartRangeRef.current = null;
807
+ };
808
+ const filteredSlashItems = _react2.default.useMemo(() => {
809
+ if (!slashFilter) return SLASH_ITEMS;
810
+ const f = slashFilter.toLowerCase();
811
+ return SLASH_ITEMS.filter((it) => it.label.toLowerCase().includes(f) || it.key.includes(f));
812
+ }, [slashFilter]);
813
+ const removeSlashTrigger = () => {
814
+ const sel = window.getSelection();
815
+ if (!sel || sel.rangeCount === 0) return;
816
+ const range = sel.getRangeAt(0);
817
+ const node = range.startContainer;
818
+ if (node.nodeType === Node.TEXT_NODE) {
819
+ const text = node.textContent || "";
820
+ const idx = text.lastIndexOf("/");
821
+ if (idx >= 0) {
822
+ node.textContent = text.slice(0, idx) + text.slice(range.startOffset);
823
+ const newRange = document.createRange();
824
+ newRange.setStart(node, idx);
825
+ newRange.collapse(true);
826
+ sel.removeAllRanges();
827
+ sel.addRange(newRange);
828
+ }
829
+ }
830
+ };
831
+ const applySlashItem = (item) => {
832
+ removeSlashTrigger();
833
+ closeSlashMenu();
834
+ switch (item.key) {
835
+ case "paragraph":
836
+ setBlock("p");
837
+ break;
838
+ case "heading-1":
839
+ toggleBlock("h1");
840
+ break;
841
+ case "heading-2":
842
+ toggleBlock("h2");
843
+ break;
844
+ case "heading-3":
845
+ toggleBlock("h3");
846
+ break;
847
+ case "list":
848
+ exec("insertUnorderedList");
849
+ break;
850
+ case "ordered-list":
851
+ exec("insertOrderedList");
852
+ break;
853
+ case "blockquote":
854
+ setBlock("blockquote");
855
+ break;
856
+ case "code-block":
857
+ insertCodeBlock();
858
+ break;
859
+ case "divider":
860
+ insertDivider();
861
+ break;
862
+ case "image":
863
+ triggerImageUpload();
864
+ break;
865
+ default:
866
+ break;
867
+ }
868
+ };
869
+ const openLinkEditor = () => {
870
+ saveSelection();
871
+ const sel = window.getSelection();
872
+ if (!sel || sel.rangeCount === 0) return;
873
+ const range = sel.getRangeAt(0);
874
+ const rect = range.getBoundingClientRect();
875
+ const editorEl2 = editorRef.current;
876
+ if (!editorEl2) return;
877
+ const editorRect = editorEl2.getBoundingClientRect();
878
+ setLinkPos({
879
+ top: rect.bottom - editorRect.top + 4,
880
+ left: rect.left - editorRect.left
881
+ });
882
+ const anchor = _optionalChain([sel, 'access', _78 => _78.anchorNode, 'optionalAccess', _79 => _79.parentElement, 'optionalAccess', _80 => _80.closest, 'call', _81 => _81("a")]);
883
+ setLinkValue(_optionalChain([anchor, 'optionalAccess', _82 => _82.getAttribute, 'call', _83 => _83("href")]) || "");
884
+ setLinkOpen(true);
885
+ };
886
+ const applyLink = () => {
887
+ restoreSelection();
888
+ if (linkValue) {
889
+ exec("createLink", linkValue);
890
+ const sel = window.getSelection();
891
+ const anchor = _optionalChain([sel, 'optionalAccess', _84 => _84.anchorNode, 'optionalAccess', _85 => _85.parentElement, 'optionalAccess', _86 => _86.closest, 'call', _87 => _87("a")]);
892
+ if (anchor) {
893
+ anchor.setAttribute("target", "_blank");
894
+ anchor.setAttribute("rel", "noopener noreferrer");
895
+ }
896
+ } else {
897
+ exec("unlink");
898
+ }
899
+ setLinkOpen(false);
900
+ };
901
+ const tryMarkdownShortcut = () => {
902
+ if (!enableMarkdownShortcuts) return false;
903
+ const sel = window.getSelection();
904
+ if (!sel || sel.rangeCount === 0) return false;
905
+ const range = sel.getRangeAt(0);
906
+ const node = range.startContainer;
907
+ if (node.nodeType !== Node.TEXT_NODE) return false;
908
+ const text = (node.textContent || "").slice(0, range.startOffset);
909
+ const patterns = [
910
+ [/^###$/, () => setBlock("h3")],
911
+ [/^##$/, () => setBlock("h2")],
912
+ [/^#$/, () => setBlock("h1")],
913
+ [/^-$/, () => exec("insertUnorderedList")],
914
+ [/^\*$/, () => exec("insertUnorderedList")],
915
+ [/^1\.$/, () => exec("insertOrderedList")],
916
+ [/^>$/, () => setBlock("blockquote")]
917
+ ];
918
+ for (const [re, fn] of patterns) {
919
+ if (re.test(text)) {
920
+ node.textContent = (node.textContent || "").slice(range.startOffset);
921
+ const newRange = document.createRange();
922
+ newRange.setStart(node, 0);
923
+ newRange.collapse(true);
924
+ sel.removeAllRanges();
925
+ sel.addRange(newRange);
926
+ fn();
927
+ return true;
928
+ }
929
+ }
930
+ return false;
931
+ };
932
+ const handleInput = () => {
933
+ if (composingRef.current) return;
934
+ const el = editorRef.current;
935
+ if (!el) return;
936
+ const html = el.innerHTML;
937
+ lastEmittedRef.current = html;
938
+ pushHistory();
939
+ scheduleHighlight();
940
+ _optionalChain([onChange, 'optionalCall', _88 => _88(html)]);
941
+ updateEmpty();
942
+ updateActiveFormats();
943
+ if (slashOpen) {
944
+ const sel = window.getSelection();
945
+ if (sel && sel.rangeCount > 0) {
946
+ const range = sel.getRangeAt(0);
947
+ const node = range.startContainer;
948
+ if (node.nodeType === Node.TEXT_NODE) {
949
+ const text = node.textContent || "";
950
+ const lastSlash = text.lastIndexOf("/", range.startOffset - 1);
951
+ if (lastSlash >= 0) {
952
+ const filter = text.slice(lastSlash + 1, range.startOffset);
953
+ if (filter.includes(" ") || filter.includes("\n")) {
954
+ closeSlashMenu();
955
+ } else {
956
+ setSlashFilter(filter);
957
+ setSlashIdx(0);
958
+ }
959
+ } else {
960
+ closeSlashMenu();
961
+ }
962
+ }
963
+ }
964
+ }
965
+ };
966
+ const handleKeyDown = (e) => {
967
+ if (readOnly) return;
968
+ if (composingRef.current || e.nativeEvent.isComposing || e.keyCode === 229) return;
969
+ const pre = closestPre();
970
+ if (pre && !slashOpen) {
971
+ if (e.key === "Enter" && !e.shiftKey) {
972
+ const text = pre.textContent || "";
973
+ if (text.endsWith("\n\n")) {
974
+ e.preventDefault();
975
+ const code = _nullishCoalesce(pre.querySelector("code"), () => ( pre));
976
+ code.textContent = text.replace(/\n\n$/, "");
977
+ ensureParagraphAfter(pre);
978
+ const next = pre.nextElementSibling;
979
+ if (next) placeCaretAtEnd(next);
980
+ handleInput();
981
+ return;
982
+ }
983
+ e.preventDefault();
984
+ insertTextAtCaret("\n");
985
+ return;
986
+ }
987
+ if (e.key === "Tab") {
988
+ e.preventDefault();
989
+ insertTextAtCaret(" ");
990
+ return;
991
+ }
992
+ }
993
+ if (e.key === "Tab" && moveTableCell(e.shiftKey)) {
994
+ e.preventDefault();
995
+ return;
996
+ }
997
+ if (e.key === "Tab" && inListItem()) {
998
+ e.preventDefault();
999
+ indentList(e.shiftKey);
1000
+ return;
1001
+ }
1002
+ if (slashOpen) {
1003
+ if (e.key === "ArrowDown") {
1004
+ e.preventDefault();
1005
+ setSlashIdx((i) => Math.min(i + 1, filteredSlashItems.length - 1));
1006
+ return;
1007
+ }
1008
+ if (e.key === "ArrowUp") {
1009
+ e.preventDefault();
1010
+ setSlashIdx((i) => Math.max(i - 1, 0));
1011
+ return;
1012
+ }
1013
+ if (e.key === "Enter") {
1014
+ e.preventDefault();
1015
+ const item = filteredSlashItems[slashIdx];
1016
+ if (item) applySlashItem(item);
1017
+ return;
1018
+ }
1019
+ if (e.key === "Escape") {
1020
+ e.preventDefault();
1021
+ closeSlashMenu();
1022
+ return;
1023
+ }
1024
+ }
1025
+ if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "z") {
1026
+ e.preventDefault();
1027
+ if (e.shiftKey) redo();
1028
+ else undo();
1029
+ return;
1030
+ }
1031
+ if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key.toLowerCase() === "v") {
1032
+ plainPasteRef.current = true;
1033
+ return;
1034
+ }
1035
+ if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "y") {
1036
+ e.preventDefault();
1037
+ redo();
1038
+ return;
1039
+ }
1040
+ if ((e.metaKey || e.ctrlKey) && !e.shiftKey && !e.altKey) {
1041
+ const k = e.key.toLowerCase();
1042
+ if (k === "b") {
1043
+ e.preventDefault();
1044
+ exec("bold");
1045
+ return;
1046
+ }
1047
+ if (k === "i") {
1048
+ e.preventDefault();
1049
+ exec("italic");
1050
+ return;
1051
+ }
1052
+ if (k === "u") {
1053
+ e.preventDefault();
1054
+ exec("underline");
1055
+ return;
1056
+ }
1057
+ if (k === "k") {
1058
+ e.preventDefault();
1059
+ openLinkEditor();
1060
+ return;
1061
+ }
1062
+ }
1063
+ if (pre) return;
1064
+ if (enableSlashCommand && e.key === "/") {
1065
+ setTimeout(openSlashMenu, 0);
1066
+ }
1067
+ if (enableMarkdownShortcuts && e.key === " ") {
1068
+ if (tryMarkdownShortcut()) {
1069
+ e.preventDefault();
1070
+ }
1071
+ }
1072
+ };
1073
+ const plainPasteRef = _react2.default.useRef(false);
1074
+ const handlePaste = (e) => {
1075
+ if (readOnly) return;
1076
+ e.preventDefault();
1077
+ const text = e.clipboardData.getData("text/plain");
1078
+ if (plainPasteRef.current) {
1079
+ plainPasteRef.current = false;
1080
+ insertTextAtCaret(text);
1081
+ return;
1082
+ }
1083
+ if (closestPre()) {
1084
+ insertTextAtCaret(text);
1085
+ return;
1086
+ }
1087
+ const html = e.clipboardData.getData("text/html");
1088
+ const clean = html ? sanitizeHtml(html) : escapeHtml(text);
1089
+ document.execCommand("insertHTML", false, clean);
1090
+ handleInput();
1091
+ };
1092
+ const handleCompositionStart = () => {
1093
+ composingRef.current = true;
1094
+ };
1095
+ const handleCompositionEnd = () => {
1096
+ composingRef.current = false;
1097
+ handleInput();
1098
+ };
1099
+ const handleFocus = () => {
1100
+ setIsFocused(true);
1101
+ updateActiveFormats();
1102
+ };
1103
+ const handleBlur = () => {
1104
+ setIsFocused(false);
1105
+ saveSelection();
1106
+ };
1107
+ const handleSelectionUpdate = () => {
1108
+ updateActiveFormats();
1109
+ const pre = closestPre();
1110
+ setCodeLang(pre ? langOf(pre) : "plain");
1111
+ };
1112
+ const onToolbarAction = (item) => {
1113
+ if (closestPre() && !["code-block", "undo", "redo"].includes(item)) return;
1114
+ switch (item) {
1115
+ case "bold":
1116
+ exec("bold");
1117
+ break;
1118
+ case "italic":
1119
+ exec("italic");
1120
+ break;
1121
+ case "underline":
1122
+ exec("underline");
1123
+ break;
1124
+ case "strikethrough":
1125
+ exec("strikethrough");
1126
+ break;
1127
+ case "code": {
1128
+ const sel = window.getSelection();
1129
+ if (!sel || sel.rangeCount === 0 || sel.isCollapsed) return;
1130
+ const range = sel.getRangeAt(0);
1131
+ const code = document.createElement("code");
1132
+ try {
1133
+ range.surroundContents(code);
1134
+ } catch (e6) {
1135
+ const frag = range.extractContents();
1136
+ code.appendChild(frag);
1137
+ range.insertNode(code);
1138
+ }
1139
+ handleInput();
1140
+ break;
1141
+ }
1142
+ case "heading-1":
1143
+ toggleBlock("h1");
1144
+ break;
1145
+ case "heading-2":
1146
+ toggleBlock("h2");
1147
+ break;
1148
+ case "heading-3":
1149
+ toggleBlock("h3");
1150
+ break;
1151
+ case "list":
1152
+ exec("insertUnorderedList");
1153
+ break;
1154
+ case "ordered-list":
1155
+ exec("insertOrderedList");
1156
+ break;
1157
+ case "blockquote":
1158
+ setBlock("blockquote");
1159
+ break;
1160
+ case "code-block":
1161
+ insertCodeBlock();
1162
+ break;
1163
+ case "link":
1164
+ openLinkEditor();
1165
+ break;
1166
+ case "image":
1167
+ triggerImageUpload();
1168
+ break;
1169
+ case "divider":
1170
+ insertDivider();
1171
+ break;
1172
+ case "checklist":
1173
+ toggleChecklist();
1174
+ break;
1175
+ case "align-left":
1176
+ setAlign("left");
1177
+ break;
1178
+ case "align-center":
1179
+ setAlign("center");
1180
+ break;
1181
+ case "align-right":
1182
+ setAlign("right");
1183
+ break;
1184
+ case "highlight":
1185
+ toggleHighlight();
1186
+ break;
1187
+ case "superscript":
1188
+ exec("superscript");
1189
+ break;
1190
+ case "subscript":
1191
+ exec("subscript");
1192
+ break;
1193
+ case "table":
1194
+ insertTable();
1195
+ break;
1196
+ case "clear-format":
1197
+ clearFormat();
1198
+ break;
1199
+ case "undo":
1200
+ undo();
1201
+ break;
1202
+ case "redo":
1203
+ redo();
1204
+ break;
1205
+ }
1206
+ };
1207
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHGA47QVVcjs.Field, { label, required, labelId, validations, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunkPFGSJJRYcjs.clsx_default.call(void 0, "lib-xplat-editor", isFocused && "focused", readOnly && "readonly"), children: [
1208
+ !readOnly && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1209
+ EditorToolbar,
1210
+ {
1211
+ items: toolbar,
1212
+ active: activeFormats,
1213
+ onAction: onToolbarAction,
1214
+ codeLang,
1215
+ inCodeBlock: activeFormats.has("block:pre"),
1216
+ onCodeLangChange: changeCodeLang
1217
+ }
1218
+ ),
1219
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "lib-xplat-editor__content", style: { minHeight }, children: [
1220
+ isEmpty && !isFocused && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "lib-xplat-editor__placeholder", children: placeholder }),
1221
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1222
+ "div",
1223
+ {
1224
+ ref: editorRef,
1225
+ contentEditable: !readOnly,
1226
+ suppressContentEditableWarning: true,
1227
+ role: "textbox",
1228
+ "aria-multiline": "true",
1229
+ "aria-readonly": readOnly || void 0,
1230
+ "aria-labelledby": label ? labelId : void 0,
1231
+ "aria-label": label ? void 0 : placeholder,
1232
+ "aria-invalid": _chunkHGA47QVVcjs.hasError.call(void 0, validations) || void 0,
1233
+ className: "lib-xplat-editor__editable",
1234
+ onInput: handleInput,
1235
+ onKeyDown: handleKeyDown,
1236
+ onClick: handleEditorClick,
1237
+ onKeyUp: handleSelectionUpdate,
1238
+ onMouseUp: handleSelectionUpdate,
1239
+ onPaste: handlePaste,
1240
+ onCompositionStart: handleCompositionStart,
1241
+ onCompositionEnd: handleCompositionEnd,
1242
+ onFocus: handleFocus,
1243
+ onBlur: handleBlur,
1244
+ spellCheck: true
1245
+ }
1246
+ ),
1247
+ slashOpen && filteredSlashItems.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1248
+ SlashMenu,
1249
+ {
1250
+ position: slashPos,
1251
+ items: filteredSlashItems,
1252
+ activeIndex: slashIdx,
1253
+ onSelect: applySlashItem,
1254
+ onClose: closeSlashMenu
1255
+ }
1256
+ ),
1257
+ linkOpen && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1258
+ LinkPopover,
1259
+ {
1260
+ position: linkPos,
1261
+ value: linkValue,
1262
+ onChange: setLinkValue,
1263
+ onConfirm: applyLink,
1264
+ onClose: () => setLinkOpen(false)
1265
+ }
1266
+ )
1267
+ ] })
1268
+ ] }) });
1269
+ };
1270
+ Editor.displayName = "Editor";
1271
+ var Editor_default = Editor;
1272
+ var TOOLBAR_LABEL = {
1273
+ bold: "B",
1274
+ italic: "I",
1275
+ underline: "U",
1276
+ strikethrough: "S",
1277
+ code: "<>",
1278
+ "heading-1": "H1",
1279
+ "heading-2": "H2",
1280
+ "heading-3": "H3",
1281
+ list: "\u2022",
1282
+ "ordered-list": "1.",
1283
+ blockquote: "\u275D",
1284
+ "code-block": "[ ]",
1285
+ link: "\u{1F517}",
1286
+ image: "\u{1F5BC}",
1287
+ divider: "\u2014",
1288
+ checklist: "\u2611",
1289
+ "align-left": "\u21E4",
1290
+ "align-center": "\u2194",
1291
+ "align-right": "\u21E5",
1292
+ highlight: "\u{1F58D}",
1293
+ superscript: "x\xB2",
1294
+ subscript: "x\u2082",
1295
+ table: "\u25A6",
1296
+ "clear-format": "\u232B",
1297
+ undo: "\u21B6",
1298
+ redo: "\u21B7"
1299
+ };
1300
+ var TOOLBAR_TITLE = {
1301
+ bold: "\uAD75\uAC8C (\u2318B)",
1302
+ italic: "\uAE30\uC6B8\uC784 (\u2318I)",
1303
+ underline: "\uBC11\uC904 (\u2318U)",
1304
+ strikethrough: "\uCDE8\uC18C\uC120",
1305
+ code: "\uC778\uB77C\uC778 \uCF54\uB4DC",
1306
+ "heading-1": "\uC81C\uBAA9 1",
1307
+ "heading-2": "\uC81C\uBAA9 2",
1308
+ "heading-3": "\uC81C\uBAA9 3",
1309
+ list: "\uAE00\uBA38\uB9AC \uAE30\uD638 \uBAA9\uB85D",
1310
+ "ordered-list": "\uBC88\uD638 \uB9E4\uAE30\uAE30 \uBAA9\uB85D",
1311
+ blockquote: "\uC778\uC6A9",
1312
+ "code-block": "\uCF54\uB4DC \uBE14\uB85D",
1313
+ link: "\uB9C1\uD06C (\u2318K)",
1314
+ image: "\uC774\uBBF8\uC9C0",
1315
+ divider: "\uAD6C\uBD84\uC120",
1316
+ checklist: "\uCCB4\uD06C\uB9AC\uC2A4\uD2B8",
1317
+ "align-left": "\uC67C\uCABD \uC815\uB82C",
1318
+ "align-center": "\uAC00\uC6B4\uB370 \uC815\uB82C",
1319
+ "align-right": "\uC624\uB978\uCABD \uC815\uB82C",
1320
+ highlight: "\uD615\uAD11\uD39C",
1321
+ superscript: "\uC704 \uCCA8\uC790",
1322
+ subscript: "\uC544\uB798 \uCCA8\uC790",
1323
+ table: "\uD45C \uC0BD\uC785",
1324
+ "clear-format": "\uC11C\uC2DD \uC9C0\uC6B0\uAE30",
1325
+ undo: "\uB418\uB3CC\uB9AC\uAE30 (\u2318Z)",
1326
+ redo: "\uB2E4\uC2DC\uD558\uAE30 (\u2318\u21E7Z)"
1327
+ };
1328
+ var isActive = (item, active) => {
1329
+ if (item === "heading-1") return active.has("block:h1");
1330
+ if (item === "heading-2") return active.has("block:h2");
1331
+ if (item === "heading-3") return active.has("block:h3");
1332
+ if (item === "blockquote") return active.has("block:blockquote");
1333
+ if (item === "code-block") return active.has("block:pre");
1334
+ if (item === "align-left") return active.has("align:left");
1335
+ if (item === "align-center") return active.has("align:center");
1336
+ if (item === "align-right") return active.has("align:right");
1337
+ return active.has(item);
1338
+ };
1339
+ var EditorToolbar = ({
1340
+ items,
1341
+ active,
1342
+ onAction,
1343
+ codeLang,
1344
+ inCodeBlock,
1345
+ onCodeLangChange
1346
+ }) => {
1347
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "lib-xplat-editor__toolbar", children: [
1348
+ items.map((item) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1349
+ "button",
1350
+ {
1351
+ type: "button",
1352
+ className: _chunkPFGSJJRYcjs.clsx_default.call(void 0, "lib-xplat-editor__toolbar-btn", isActive(item, active) && "active"),
1353
+ title: TOOLBAR_TITLE[item],
1354
+ onMouseDown: (e) => {
1355
+ e.preventDefault();
1356
+ onAction(item);
1357
+ },
1358
+ children: TOOLBAR_LABEL[item]
1359
+ },
1360
+ item
1361
+ )),
1362
+ inCodeBlock && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1363
+ "select",
1364
+ {
1365
+ className: "lib-xplat-editor__lang",
1366
+ value: codeLang,
1367
+ "aria-label": "\uCF54\uB4DC \uC5B8\uC5B4",
1368
+ onMouseDown: (e) => e.stopPropagation(),
1369
+ onChange: (e) => onCodeLangChange(e.target.value),
1370
+ children: CODE_LANGUAGES.map((l) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: l.value, children: l.label }, l.value))
1371
+ }
1372
+ )
1373
+ ] });
1374
+ };
1375
+ var SlashMenu = ({ position, items, activeIndex, onSelect, onClose }) => {
1376
+ _react2.default.useEffect(() => {
1377
+ const handleClickOutside = (e) => {
1378
+ const target = e.target;
1379
+ const menu = document.querySelector(".lib-xplat-editor__slash-menu");
1380
+ if (menu && !menu.contains(target)) onClose();
1381
+ };
1382
+ window.addEventListener("mousedown", handleClickOutside);
1383
+ return () => window.removeEventListener("mousedown", handleClickOutside);
1384
+ }, [onClose]);
1385
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1386
+ "div",
1387
+ {
1388
+ className: "lib-xplat-editor__slash-menu",
1389
+ style: { top: position.top, left: position.left },
1390
+ children: items.map((item, i) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1391
+ "button",
1392
+ {
1393
+ type: "button",
1394
+ className: _chunkPFGSJJRYcjs.clsx_default.call(void 0, "lib-xplat-editor__slash-item", i === activeIndex && "active"),
1395
+ onMouseDown: (e) => {
1396
+ e.preventDefault();
1397
+ onSelect(item);
1398
+ },
1399
+ children: [
1400
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "label", children: item.label }),
1401
+ item.hint && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "hint", children: item.hint })
1402
+ ]
1403
+ },
1404
+ item.key
1405
+ ))
1406
+ }
1407
+ );
1408
+ };
1409
+ var LinkPopover = ({ position, value, onChange, onConfirm, onClose }) => {
1410
+ const inputRef = _react2.default.useRef(null);
1411
+ _react2.default.useEffect(() => {
1412
+ _optionalChain([inputRef, 'access', _89 => _89.current, 'optionalAccess', _90 => _90.focus, 'call', _91 => _91()]);
1413
+ }, []);
1414
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1415
+ "div",
1416
+ {
1417
+ className: "lib-xplat-editor__link-popover",
1418
+ style: { top: position.top, left: position.left },
1419
+ children: [
1420
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1421
+ "input",
1422
+ {
1423
+ ref: inputRef,
1424
+ type: "url",
1425
+ placeholder: "https://",
1426
+ value,
1427
+ onChange: (e) => onChange(e.target.value),
1428
+ onKeyDown: (e) => {
1429
+ if (e.key === "Enter") {
1430
+ e.preventDefault();
1431
+ onConfirm();
1432
+ }
1433
+ if (e.key === "Escape") {
1434
+ e.preventDefault();
1435
+ onClose();
1436
+ }
1437
+ }
1438
+ }
1439
+ ),
1440
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", onMouseDown: (e) => {
1441
+ e.preventDefault();
1442
+ onConfirm();
1443
+ }, children: "\uC801\uC6A9" }),
1444
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", onMouseDown: (e) => {
1445
+ e.preventDefault();
1446
+ onClose();
1447
+ }, children: "\uCDE8\uC18C" })
1448
+ ]
1449
+ }
1450
+ );
1451
+ };
1452
+
1453
+
1454
+
1455
+ exports.Editor_default = Editor_default;