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