From 671209663995cef45ba2452abcf79da20547bf0c Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Tue, 17 Nov 2026 09:56:19 +0900 Subject: [PATCH] =?UTF-8?q?261117=5F02=5FENH:=20kri-editor=EB=A5=BC=20KriU?= =?UTF-8?q?iRegistry=20=EC=B5=9C=EC=8B=A0=EB=B3=B8=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=9E=AC=EC=84=A4=EC=B9=98(LMS=C2=B7MMS=20=EB=B6=84=EB=A6=AC,?= =?UTF-8?q?=20UTF-8=20=EB=B0=94=EC=9D=B4=ED=8A=B8=20=EA=B3=84=EC=82=B0,=20?= =?UTF-8?q?lint=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 319 +++++++++--------- package.json | 14 +- .../kri-editor/KriEditorHtmlOnly.tsx | 1 - src/components/kri-editor/KriEditorSms.tsx | 41 ++- .../kri-editor/KriEditorWysiwyg.tsx | 136 +++++--- .../kri-editor/hooks/useImageMapOverlay.ts | 48 +++ src/components/kri-editor/types.ts | 7 +- .../kri-editor/utils/imageMapOverlay.ts | 112 ++++++ 8 files changed, 466 insertions(+), 212 deletions(-) create mode 100644 src/components/kri-editor/hooks/useImageMapOverlay.ts create mode 100644 src/components/kri-editor/utils/imageMapOverlay.ts diff --git a/package-lock.json b/package-lock.json index 93d75dc..6e555df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "@dnd-kit/core": "^6.3.1", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", - "@kri/common": "^0.19.1", + "@kri/common": "^0.20.0", "@tanstack/react-query": "latest", "@tanstack/react-table": "^8.21.3", "@tiptap/extension-color": "^3.31.4", @@ -30,26 +30,24 @@ "@tiptap/react": "^3.31.4", "@tiptap/starter-kit": "^3.31.4", "class-variance-authority": "latest", - "clsx": "latest", "cmdk": "^1.1.1", - "cn": "^0.4.0", + "cn": "0.5.2", "d3-cloud": "^1.2.9", "date-fns": "^4.4.0", - "dompurify": "^3.4.16", + "dompurify": "^3.4.18", "echarts": "^6.1.0", "echarts-for-react": "^3.0.6", "embla-carousel-react": "^8.6.0", "jotai": "latest", "lucide-react": "latest", - "next": "~16.4.1", + "next": "~16.4.6", "prettier": "^3.9.10", "radix-ui": "^1.8.0", "react": "latest", "react-day-picker": "^10.0.2", "react-dom": "latest", "server-only": "latest", - "sonner": "latest", - "tailwind-merge": "latest" + "sonner": "latest" }, "devDependencies": { "@tailwindcss/postcss": "latest", @@ -59,7 +57,7 @@ "@types/react-dom": "latest", "babel-plugin-react-compiler": "latest", "eslint": "^9", - "eslint-config-next": "~16.4.1", + "eslint-config-next": "~16.4.6", "playwright": "^1.64.1", "tailwindcss": "latest", "tw-animate-css": "latest", @@ -1160,6 +1158,13 @@ "url": "https://opencollective.com/libvips" } }, + "node_modules/@isaacs/nonrecursive-glob-match": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.1.0.tgz", + "integrity": "sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.13", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", @@ -1211,14 +1216,13 @@ } }, "node_modules/@kri/common": { - "version": "0.19.1", - "resolved": "https://gitea.kric.com/api/packages/KRi/npm/%40kri%2Fcommon/-/0.19.1/common-0.19.1.tgz", - "integrity": "sha512-AbCeomCvzF3CoogRNvM2eBT3AgL0SR5a3PS1W4MHh0W9gs/J5Fkt44/uXRc2ouiyT1xhjOmOwp9JJSp1vDVRnQ==", + "version": "0.20.0", + "resolved": "https://gitea.kric.com/api/packages/KRi/npm/%40kri%2Fcommon/-/0.20.0/common-0.20.0.tgz", + "integrity": "sha512-v6pLvFxePWmdSqG5cK63XwFNrmu4aiZQ1WprKktKVz9CQLpKAKPauQ2mvlQkSn70HXRaJmdwQXUpZHQBFZoE0Q==", "license": "UNLICENSED", "dependencies": { - "clsx": "^2.1.1", - "crypto-js": "^4.2.0", - "tailwind-merge": "^3.4.0" + "cn": "0.5.2", + "crypto-js": "^4.2.0" }, "peerDependencies": { "@tanstack/react-query": ">=5 <6", @@ -1260,15 +1264,15 @@ } }, "node_modules/@next/env": { - "version": "16.4.3", - "resolved": "https://registry.npmjs.org/@next/env/-/env-16.4.3.tgz", - "integrity": "sha512-a7tz1QCcWWkwC/rPJcPMJk/UNRu9CFhDd3OHYE5hddbJrs8BqRTalxI6GlKCWEGzRLHN+S/B7a4PAHCtm25aBQ==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/env/-/env-16.4.6.tgz", + "integrity": "sha512-SunBjJ6t+oBtecS3dTjdVuMhUogP5wD/vrGL5EVuQYM1iS4O5ilL51HkiJ3sPjMzRHiCChvr4dbaSJbR7F3lxA==", "license": "MIT" }, "node_modules/@next/eslint-plugin-next": { - "version": "16.4.3", - "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-16.4.3.tgz", - "integrity": "sha512-oxuC06wt/71h6ACYCV9GbKOfnf5a7VlRe/p80YHTut15TNgDEmynDnaq8t/xhy5rlvk7dhItIPs6H3rvIM4kyw==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-16.4.6.tgz", + "integrity": "sha512-HdqERVOafOD8JaUSAkwf9aSu/1rsHlkN8C5GcXYBH3C/z1MxBhZFxB5rz/xqMMRiIj7r9tIv8OCLQ9JWUxCvWA==", "dev": true, "license": "MIT", "dependencies": { @@ -1309,9 +1313,9 @@ } }, "node_modules/@next/swc-darwin-arm64": { - "version": "16.4.3", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.4.3.tgz", - "integrity": "sha512-4yq5EXBt+VDtAZwTyfijaFp5D2C5oz3Ikw5a2kiX2K9nw72vrZX2q5UuAlkPtUMO1tQz6JTKpaKWjS7OOefTDQ==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.4.6.tgz", + "integrity": "sha512-kJ4VVZkley17xKaJx72QN2IBqjrj7zenCQZaUF0l9ShS/1Mt2kW4+Z5KGG6vgr3L/J562xTOizVyM1iA/u5nlg==", "cpu": [ "arm64" ], @@ -1325,9 +1329,9 @@ } }, "node_modules/@next/swc-darwin-x64": { - "version": "16.4.3", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.4.3.tgz", - "integrity": "sha512-1Rvkn/LUhnEF8WxnRkOrqGhbwXui1bkWFxONKIbN+r7C+9KHDSZ+iUoj4CzymVMWUyZIyx9szcb9+kbKhD500A==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.4.6.tgz", + "integrity": "sha512-eIPGZIqC+8JKaeZmvnCANJQF4xWkkHqSnAAajtFxgwDMAOnCgxNvP52SeWZ41PyVwoe+Le/NQuZSaQ8j7YshSA==", "cpu": [ "x64" ], @@ -1341,12 +1345,15 @@ } }, "node_modules/@next/swc-linux-arm64-gnu": { - "version": "16.4.3", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.4.3.tgz", - "integrity": "sha512-dCKpXErGg3abUM6t5JTJV/ottVBTStJB5lRJTbgdUdQaQ+jNHiK56Hsc0YAEg/rinSh42hYG3HWiYmEMdilnxg==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.4.6.tgz", + "integrity": "sha512-9nI6O8vvczH2D9ZNdMGqb/3NuT15T9ksOZnAmx9/gjF2cOi74+xxyf1Hk96uIMfm14c9y6wHeBq6SH8g6udvcA==", "cpu": [ "arm64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1357,12 +1364,15 @@ } }, "node_modules/@next/swc-linux-arm64-musl": { - "version": "16.4.3", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.4.3.tgz", - "integrity": "sha512-WwYbhWkhYBvBtib1K4W0kL8MW2snBD2A5b3SN4vPpqalZbZs5+bQ1yzAdepVoOqrFfEW3dmREy4Zs1MrWcrFbw==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.4.6.tgz", + "integrity": "sha512-7/qPhTxDp2ScluOJOhLuhWmlA17o1yZ0SIgpISBCpBxXgtnK4+KGywBpFkfLPiU1rnSM1faFGzYkH6i7JdTrqA==", "cpu": [ "arm64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -1373,12 +1383,15 @@ } }, "node_modules/@next/swc-linux-x64-gnu": { - "version": "16.4.3", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.4.3.tgz", - "integrity": "sha512-QymWvfUwDEC5/lpJOsxX5VAbyoR2D13+2Jsjz4be7gT4LPqEgdpkeLIR/HFfCLgKzoMhpJbp6I/JnogyNZHcaA==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.4.6.tgz", + "integrity": "sha512-oOpbNa8XOW1qCGd9VvzC4fbkkRxEls7/WI6tz+YHC0xRA7KpV1U7DrAnCPjzVyOk/karzWEepCOcTIDmwK8FwQ==", "cpu": [ "x64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -1389,12 +1402,15 @@ } }, "node_modules/@next/swc-linux-x64-musl": { - "version": "16.4.3", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.4.3.tgz", - "integrity": "sha512-Vmjd9D7DpA4Vv3cUlr82QWgJD/BQZmns801vtC5VWHg6jCIA4a5vMKpQnfrM2pyCrp2eV0ENdUg4PlN3bAc2Yw==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.4.6.tgz", + "integrity": "sha512-aM8CZ+OR2EwXaAYw7KGkW2GDmNDsLBIRe1MMRZCJPTdw/xhTD0IMUVO4sf3KqrzuRouGzwwLZn34+gFeVXiUQA==", "cpu": [ "x64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -1405,9 +1421,9 @@ } }, "node_modules/@next/swc-win32-arm64-msvc": { - "version": "16.4.3", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.4.3.tgz", - "integrity": "sha512-lG1pPdPLk7gTyGb00n5JIMLdBJgjb+UEhSdZvFbhUMg0DyC6z4B7RnpSKF9VCd4imkLObVbXOFA0kFCpw7yFow==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.4.6.tgz", + "integrity": "sha512-U0p7/tEtqvHX2crhd841CDwKtp5CFkKXVjOhmfccR3Pvp64sj8KBwRqsvltqLOwVBbj0NtkxwXSDpEHYGbxeXQ==", "cpu": [ "arm64" ], @@ -1421,9 +1437,9 @@ } }, "node_modules/@next/swc-win32-x64-msvc": { - "version": "16.4.3", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.4.3.tgz", - "integrity": "sha512-NmQC9RkJdnPXRaMxtkCzobB3teVjqF33oSOnwDfi+XYGWWYpt+xlGK3mtktSKLbdjwaWbJu2OkkMiRFGUUncKg==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.4.6.tgz", + "integrity": "sha512-3ZG15/5WIdlTQsIEvc9sPTTSL5XFrlLklIKmfF4fwsDnoAhu6NcBDXsk3mbGxNyo6aVLEGex+fHCv2MahY7a9g==", "cpu": [ "x64" ], @@ -3998,17 +4014,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.71.1.tgz", - "integrity": "sha512-nNlBf6HuotqMgZvSkWD5hNdemiBIxQ2NmrlgfcUIeZRs+BbakjscCQRq/Hb74EFVnFiSWWdL12JruqwBy3ERDw==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.73.0.tgz", + "integrity": "sha512-UkygMFer53Yzn29MCYFTHf34hGXf5KJhiDWfIm1tXtXRrym1CS6l5H9Y3yCtPWChpC0/f93H88gdj8tN0dd4kw==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.12.2", - "@typescript-eslint/scope-manager": "8.71.1", - "@typescript-eslint/type-utils": "8.71.1", - "@typescript-eslint/utils": "8.71.1", - "@typescript-eslint/visitor-keys": "8.71.1", + "@typescript-eslint/scope-manager": "8.73.0", + "@typescript-eslint/type-utils": "8.73.0", + "@typescript-eslint/utils": "8.73.0", + "@typescript-eslint/visitor-keys": "8.73.0", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.5.0" @@ -4021,15 +4037,15 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.71.1", + "@typescript-eslint/parser": "^8.73.0", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.1.0" } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { - "version": "7.0.12", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.12.tgz", - "integrity": "sha512-/8UvqAPU9DGTI9k4mxtf49U37Isfwr8Uts96+SBHIkFxPJnHS0Ew4f00sM4Scd8V8EjM0jUNtVDdv1kPdt35lg==", + "version": "7.0.14", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.14.tgz", + "integrity": "sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ==", "dev": true, "license": "MIT", "engines": { @@ -4037,16 +4053,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.71.1.tgz", - "integrity": "sha512-oM/5sAqz/l1v/zYK1qTOPrn2+JIrBGC1V6uNYucRO5gh6eT9vWJ/RhPbGE59byvZEUQ4VP6XkLBaS5Jti5jpvw==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.73.0.tgz", + "integrity": "sha512-AuL45bVcmssHfZ3Di3cs9Q0l4gBm4ZFVrJOQEE7VpqW+PVgQaEwSwazz4TVIiFabXkk6U51EprYDwqw+HR8ePw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.71.1", - "@typescript-eslint/types": "8.71.1", - "@typescript-eslint/typescript-estree": "8.71.1", - "@typescript-eslint/visitor-keys": "8.71.1", + "@typescript-eslint/scope-manager": "8.73.0", + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/typescript-estree": "8.73.0", + "@typescript-eslint/visitor-keys": "8.73.0", "debug": "^4.4.3" }, "engines": { @@ -4062,14 +4078,14 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.71.1.tgz", - "integrity": "sha512-Oijc9RUsohHjncg6iGi7gCtjnEjYt9FWv9u6ygK8uKcHK5eLjLAkqERQ9BaytbpceOFdk6kifPCS/zAZE+A99g==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.73.0.tgz", + "integrity": "sha512-/pEf8Rc4Mjk+qJnY0uO1+Gadeal8uv50xpuic+srG2vIVatA0XxvWMUeMtFvs6OCHqftiQ7/+qH4aehG5stzIA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.71.1", - "@typescript-eslint/types": "^8.71.1", + "@typescript-eslint/tsconfig-utils": "^8.73.0", + "@typescript-eslint/types": "^8.73.0", "debug": "^4.4.3" }, "engines": { @@ -4084,14 +4100,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.71.1.tgz", - "integrity": "sha512-1YUDZXdTnXLlob03SFHBipdyMBsDVm7zoSz0ytTJ39dk5J1TgsTK03VlR/dLXG/RLLUrPcYbD4rp23BmHxHP0w==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.73.0.tgz", + "integrity": "sha512-/TjD738Iq2rzj5z0ixVOi+TsvgjAzZPLPaH1yWdDBytR/HTR5gMpyYWZeCe5WTQZLwk3ho8AV7U3muoQCRtXBQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.71.1", - "@typescript-eslint/visitor-keys": "8.71.1" + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/visitor-keys": "8.73.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -4102,9 +4118,9 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.71.1.tgz", - "integrity": "sha512-oTvkml5SxXhgg+WWKhod5qWQICDXtOB+/Hi9VdPKFAANJ2b7YOgMffgvzXuqog7R6A/JtrzRf128dsxummyWhg==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.73.0.tgz", + "integrity": "sha512-lmtCFOfYaJfpqZywGuXi4FpNtE+NQ+YLe3T0K9rtEDcW8ZuGWvfI++pj8r05sYMI8vWT2CYK4rWyedmD6Rp4og==", "dev": true, "license": "MIT", "engines": { @@ -4119,15 +4135,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.71.1.tgz", - "integrity": "sha512-kH3t3jZCYv2PZSBEWPKTariLrCaoF1CLoPitYFBJOhAGEwWnSRAtGEifrfrpBa4K9JlwWNZotgA5w3/wLSk/FQ==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.73.0.tgz", + "integrity": "sha512-MOC9i4xy1F7KcDde7Ip8jf1SrRiALb2Km4UWxGNjUE2YlhjIEo1ayE27GHIwIQyfWuHTmEonQT14uyurlyC6aA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.71.1", - "@typescript-eslint/typescript-estree": "8.71.1", - "@typescript-eslint/utils": "8.71.1", + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/typescript-estree": "8.73.0", + "@typescript-eslint/utils": "8.73.0", "debug": "^4.4.3", "ts-api-utils": "^2.5.0" }, @@ -4144,9 +4160,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.71.1.tgz", - "integrity": "sha512-ybYnPTUwg3VQQOFEiBPLs8Jxl1ry2vXdn1kVKguomBbvxpetdu3MKTNDqFNUrlG8ylP9MpZosmXMFYlGQHk1oQ==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.73.0.tgz", + "integrity": "sha512-O/1ytYzflF16QDKXx4/qOXg1IuZp+n7hr9t+S0nv7N/2Tl8rJiNCshztV1gcSUvHbPtoX3+zmNbtSAyVbzxVfw==", "dev": true, "license": "MIT", "engines": { @@ -4158,18 +4174,18 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.71.1.tgz", - "integrity": "sha512-pSKSEK1JJpHs6KiKVtABCE4iJK5d7FLFzDXQNBQ2oRY7LEd3UwOt3TZemTgu9syTIf56dJWlTn/pdmrO9oKUXQ==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.73.0.tgz", + "integrity": "sha512-InjlBkSdWceIwIBWSwS3ENUp+i0O02PGX3Zv2wnihWJC1WDVGvG7mTHuf8b57uAaITj94d6tRPDH+sUEtXdRQQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.71.1", - "@typescript-eslint/tsconfig-utils": "8.71.1", - "@typescript-eslint/types": "8.71.1", - "@typescript-eslint/visitor-keys": "8.71.1", + "@typescript-eslint/project-service": "8.73.0", + "@typescript-eslint/tsconfig-utils": "8.73.0", + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/visitor-keys": "8.73.0", "debug": "^4.4.3", - "minimatch": "^10.2.2", + "minimatch": "^11.0.1", "semver": "^7.7.3", "tinyglobby": "^0.2.15", "ts-api-utils": "^2.5.0" @@ -4182,7 +4198,13 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { + "@typescript/native": "npm:typescript@>=7.1.0-dev.20261009.1 || >=7.1.0-beta <7.1.0-dev", "typescript": ">=4.8.4 <6.1.0" + }, + "peerDependenciesMeta": { + "@typescript/native": { + "optional": true + } } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/balanced-match": { @@ -4196,9 +4218,9 @@ } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", "dev": true, "license": "MIT", "dependencies": { @@ -4209,25 +4231,26 @@ } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { - "version": "10.2.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", - "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "version": "11.0.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.9.tgz", + "integrity": "sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { - "brace-expansion": "^5.0.8" + "@isaacs/nonrecursive-glob-match": "^1.1.0", + "brace-expansion": "^5.0.12" }, "engines": { - "node": "18 || 20 || >=22" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "dev": true, "license": "ISC", "bin": { @@ -4238,16 +4261,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.71.1.tgz", - "integrity": "sha512-CBjT6gfAz3DW2j9Q4moFnqt208Aq+506sVGXfpRcyAeqn0EpayL0mjdWoCO2t3RC7GewNrFxdeehuEaPg6DMzQ==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.73.0.tgz", + "integrity": "sha512-j2SVJJvVkXdUL0WcEzo4vEH1mO1vIi8KlVukcYA2MgMZvYN2LlZR4PmsW+GTSxSW24j6Q/EP7+MOifLtg5hmsA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", - "@typescript-eslint/scope-manager": "8.71.1", - "@typescript-eslint/types": "8.71.1", - "@typescript-eslint/typescript-estree": "8.71.1" + "@typescript-eslint/scope-manager": "8.73.0", + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/typescript-estree": "8.73.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -4262,13 +4285,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.71.1.tgz", - "integrity": "sha512-0GxiUGqMU0qXJt58cBsiG3DP8lUmBaFo2vChtUX+CT7PnR3v/VGLLrzVP4K9r1lNiZXjHYefMBbPunplr09v6w==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.73.0.tgz", + "integrity": "sha512-k4lsFVpRZICbltkIEEH4hZRkwXkqDF1GHBpClKQOHQY+RkoZAAuyc1ci3I6p+CB6v3U4jaHIUshc4RzzQXZWLg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.71.1", + "@typescript-eslint/types": "8.73.0", "eslint-visitor-keys": "^5.0.0" }, "engines": { @@ -5142,15 +5165,15 @@ } }, "node_modules/cn": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/cn/-/cn-0.4.0.tgz", - "integrity": "sha512-qOAeUhPwPzBxx6jaeQdo646XIKliKHc2j1ZF7Ngb1o0pJZKH5gq8FkA0aVdUdPFUDXNXyUCXpCtoJISo6dhizg==", + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/cn/-/cn-0.5.2.tgz", + "integrity": "sha512-wm10E6iuJ37rALOw3D+3cfaXXZSLNMh2uxpQn3dNICqfJM59yXqgbA9/9Iiz155j5kYNLdK6WreNdW3NQtx3OQ==", "license": "MIT", "bin": { "cn": "bin/cn.mjs" }, "engines": { - "node": ">=20" + "node": ">=22" } }, "node_modules/color-convert": { @@ -5392,9 +5415,9 @@ } }, "node_modules/dompurify": { - "version": "3.4.16", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.16.tgz", - "integrity": "sha512-sqo+pNp3qRhCIpbgRi1y8Tgk27Bo2Ry7w0dC1NBeNTdZChWjz9Xb/KOoZbRP/R6pQZ80Qw8YhXw13hWWBbMRnQ==", + "version": "3.4.18", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.18.tgz", + "integrity": "sha512-ofe3wI/uNm68HInABYFJYqQxRw1EaKAjNdrFVKqjUY+UZurvNd2L/HuQe097s/4RivWiZyP6tT7aoT8atjfhwg==", "license": "(MPL-2.0 OR Apache-2.0)", "optionalDependencies": { "@types/trusted-types": "^2.0.7" @@ -5785,13 +5808,13 @@ } }, "node_modules/eslint-config-next": { - "version": "16.4.3", - "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-16.4.3.tgz", - "integrity": "sha512-j9IqBma6abp800frdUURaizYMgXOK+jNGyq6CsYcM9AxpSJs5D/TgMNGeAmRUilZvA7g9V1Tr71gNg9/SVTuMQ==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-16.4.6.tgz", + "integrity": "sha512-IBGGrVf9E6pL0NGL0hmeicVGeSyv1VEzIWq6IecDqkw+YFByhEtDJS9u1r6s6a1VxK6rssh69KyNFQUgfaacqw==", "dev": true, "license": "MIT", "dependencies": { - "@next/eslint-plugin-next": "16.4.3", + "@next/eslint-plugin-next": "16.4.6", "eslint-import-resolver-node": "^0.3.6", "eslint-import-resolver-typescript": "^3.5.2", "eslint-plugin-import": "^2.32.0", @@ -7723,12 +7746,12 @@ "license": "MIT" }, "node_modules/next": { - "version": "16.4.3", - "resolved": "https://registry.npmjs.org/next/-/next-16.4.3.tgz", - "integrity": "sha512-OqxKTGi9u80FydydsMNYNjnuje9Au+kvHlt2GZ//ftdpDHm1dxKqAaENoOOTX5wKzn+9vaKUNIfZeyZUuLhCnA==", + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/next/-/next-16.4.6.tgz", + "integrity": "sha512-QZJiYhaZLJMo2KpkQGQIwvmd79WVsAWeYIU554a8d7zArS3si/IRy3lBNV/rtYhE70oLwdLYhPAXLPx8HwcwtA==", "license": "MIT", "dependencies": { - "@next/env": "16.4.3", + "@next/env": "16.4.6", "@swc/helpers": "0.5.23", "baseline-browser-mapping": "^2.9.19", "caniuse-lite": "^1.0.30001579", @@ -7742,14 +7765,14 @@ "node": ">=20.9.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "16.4.3", - "@next/swc-darwin-x64": "16.4.3", - "@next/swc-linux-arm64-gnu": "16.4.3", - "@next/swc-linux-arm64-musl": "16.4.3", - "@next/swc-linux-x64-gnu": "16.4.3", - "@next/swc-linux-x64-musl": "16.4.3", - "@next/swc-win32-arm64-msvc": "16.4.3", - "@next/swc-win32-x64-msvc": "16.4.3", + "@next/swc-darwin-arm64": "16.4.6", + "@next/swc-darwin-x64": "16.4.6", + "@next/swc-linux-arm64-gnu": "16.4.6", + "@next/swc-linux-arm64-musl": "16.4.6", + "@next/swc-linux-x64-gnu": "16.4.6", + "@next/swc-linux-x64-musl": "16.4.6", + "@next/swc-win32-arm64-msvc": "16.4.6", + "@next/swc-win32-x64-msvc": "16.4.6", "sharp": "^0.35.5" }, "peerDependencies": { @@ -9219,16 +9242,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/tailwind-merge": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.7.0.tgz", - "integrity": "sha512-XPPUyAc+cvspz3lHTcR/QgPfW2A0lv/xQNIjX3HGhLR+Nq2lHaLq5MtTesHn8GUr3W3DguT2KT5x3NVgRtYwmA==", - "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/dcastil" - } - }, "node_modules/tailwindcss": { "version": "4.3.3", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.3.tgz", @@ -9471,16 +9484,16 @@ } }, "node_modules/typescript-eslint": { - "version": "8.71.1", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.71.1.tgz", - "integrity": "sha512-oiNVPC3/NbV1FpaHU07l8O6ynqG9v4PAiW2WvTrAmZdR0f2HI/gE668ElMLCK7Xbsu5k2fK5C4fXNiq05j7/nQ==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.73.0.tgz", + "integrity": "sha512-+EnKy9rkYPun4l+kG2bDuYWQ6y1tGVgdR/tY1U9AC6h21CjEwOoc7gsjwe0FXB8uWFzk4QiCFbuRWgX758PiAg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.71.1", - "@typescript-eslint/parser": "8.71.1", - "@typescript-eslint/typescript-estree": "8.71.1", - "@typescript-eslint/utils": "8.71.1" + "@typescript-eslint/eslint-plugin": "8.73.0", + "@typescript-eslint/parser": "8.73.0", + "@typescript-eslint/typescript-estree": "8.73.0", + "@typescript-eslint/utils": "8.73.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" diff --git a/package.json b/package.json index 3e28256..4f3d89b 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@dnd-kit/core": "^6.3.1", "@dnd-kit/sortable": "^10.0.0", "@dnd-kit/utilities": "^3.2.2", - "@kri/common": "^0.19.1", + "@kri/common": "^0.20.0", "@tanstack/react-query": "latest", "@tanstack/react-table": "^8.21.3", "@tiptap/extension-color": "^3.31.4", @@ -32,26 +32,24 @@ "@tiptap/react": "^3.31.4", "@tiptap/starter-kit": "^3.31.4", "class-variance-authority": "latest", - "clsx": "latest", "cmdk": "^1.1.1", - "cn": "^0.4.0", + "cn": "0.5.2", "d3-cloud": "^1.2.9", "date-fns": "^4.4.0", - "dompurify": "^3.4.16", + "dompurify": "^3.4.18", "echarts": "^6.1.0", "echarts-for-react": "^3.0.6", "embla-carousel-react": "^8.6.0", "jotai": "latest", "lucide-react": "latest", - "next": "~16.4.1", + "next": "~16.4.6", "prettier": "^3.9.10", "radix-ui": "^1.8.0", "react": "latest", "react-day-picker": "^10.0.2", "react-dom": "latest", "server-only": "latest", - "sonner": "latest", - "tailwind-merge": "latest" + "sonner": "latest" }, "devDependencies": { "@tailwindcss/postcss": "latest", @@ -61,7 +59,7 @@ "@types/react-dom": "latest", "babel-plugin-react-compiler": "latest", "eslint": "^9", - "eslint-config-next": "~16.4.1", + "eslint-config-next": "~16.4.6", "playwright": "^1.64.1", "tailwindcss": "latest", "tw-animate-css": "latest", diff --git a/src/components/kri-editor/KriEditorHtmlOnly.tsx b/src/components/kri-editor/KriEditorHtmlOnly.tsx index 0e4c845..edecbd2 100644 --- a/src/components/kri-editor/KriEditorHtmlOnly.tsx +++ b/src/components/kri-editor/KriEditorHtmlOnly.tsx @@ -65,7 +65,6 @@ export function KriEditorHtmlOnly({ React.useEffect(() => { applyExternalValue(value || '') // 최초 마운트 시 1회만 실행 — 이후 value 변경은 아래 effect가 처리한다. - // eslint-disable-next-line react-hooks/exhaustive-deps }, []) React.useEffect(() => { diff --git a/src/components/kri-editor/KriEditorSms.tsx b/src/components/kri-editor/KriEditorSms.tsx index 0b40870..6688e4a 100644 --- a/src/components/kri-editor/KriEditorSms.tsx +++ b/src/components/kri-editor/KriEditorSms.tsx @@ -8,8 +8,23 @@ import { useTextareaInsert } from './hooks/useTextareaInsert' type SmsEditorProps = Omit & { mode: 'sms' } +type SmsMessageType = 'SMS' | 'LMS' | 'MMS' + function calculateBytes(value: string): number { - return Array.from(value).reduce((total, character) => total + (character.charCodeAt(0) > 127 ? 2 : 1), 0) + return new TextEncoder().encode(value).byteLength +} + +// 첨부파일이 있으면 MMS, 제목이 있거나 smsMaxBytes 이상이면 LMS, 나머지는 SMS로 미리보기 판정한다. +function getSmsMessageType(hasAttachment: boolean, byteSize: number, smsMaxBytes: number, title: string): SmsMessageType { + if (hasAttachment) return 'MMS' + if (byteSize >= smsMaxBytes || Boolean(title)) return 'LMS' + return 'SMS' +} + +function getTextareaMinHeight(hasImages: boolean, hasTitle: boolean): string { + if (hasImages) return '160px' + if (hasTitle) return '320px' + return '360px' } export function KriEditorSms({ @@ -29,18 +44,30 @@ export function KriEditorSms({ smsPreviewSuffix = '', smsHasAttachment = false, smsImages = [], + smsFrameClassName, }: SmsEditorProps) { const [text, setText] = React.useState(value || '') const textareaRef = React.useRef(null) const latestTextRef = React.useRef(text) - const lastTypeRef = React.useRef<'SMS' | 'LMS' | null>(null) + const lastTypeRef = React.useRef(null) const { scheduleChange, flushChange } = useDebouncedChange(onChange, debounceMs) const textareaInsert = useTextareaInsert(textareaRef) const previewText = smsPreviewSuffix ? `${text}\n${smsPreviewSuffix}` : text const byteSize = React.useMemo(() => calculateBytes(previewText), [previewText]) - const messageType: 'SMS' | 'LMS' = byteSize > smsMaxBytes || Boolean(smsTitle) || smsHasAttachment ? 'LMS' : 'SMS' + const messageType = getSmsMessageType(smsHasAttachment, byteSize, smsMaxBytes, smsTitle) const maxBytes = messageType === 'SMS' ? smsMaxBytes : lmsMaxBytes + function getBadgeColor(): string { + switch (messageType) { + case 'SMS': + return 'bg-red-500' + case 'LMS': + return 'bg-blue-500' + case 'MMS': + return 'bg-green-500' + } + } + const commitText = React.useCallback((next: string, immediate = false) => { setText(next) latestTextRef.current = next @@ -84,13 +111,13 @@ export function KriEditorSms({ return (
{label ?
{label}
: null} -
+
{byteSize}/{maxBytes}byte - - {messageType === 'LMS' ? 'LMS/MMS' : 'SMS'} + + {messageType}
0 ? 'overflow-y-auto' : 'overflow-hidden')}> @@ -115,7 +142,7 @@ export function KriEditorSms({ onBlur={() => flushChange(latestTextRef.current)} placeholder={placeholder} readOnly={isSmsReadOnly} - style={{ minHeight: smsImages.length > 0 ? '160px' : smsTitle ? '320px' : '360px' }} + style={{ minHeight: getTextareaMinHeight(smsImages.length > 0, Boolean(smsTitle)) }} {...textareaInsert.bindSelectionHandlers} /> {smsPreviewSuffix ? ( diff --git a/src/components/kri-editor/KriEditorWysiwyg.tsx b/src/components/kri-editor/KriEditorWysiwyg.tsx index 97b5225..33a70a6 100644 --- a/src/components/kri-editor/KriEditorWysiwyg.tsx +++ b/src/components/kri-editor/KriEditorWysiwyg.tsx @@ -35,9 +35,62 @@ import { applyLinkPreviewClass, KRI_EDITOR_LINK_CLASS } from "./utils/linkPrevie import { Toolbar } from "./toolbar/Toolbar"; import { useDebouncedChange } from "./hooks/useDebouncedChange"; import { useTextareaInsert } from "./hooks/useTextareaInsert"; +import { useImageMapOverlay } from "./hooks/useImageMapOverlay"; type ViewMode = "wysiwyg" | "html"; +type ToolbarEndSlotProps = Pick & { + editor: Editor; + command: KriEditorCommand; + view: ViewMode; +}; + +// command는 ref를 사용하는 함수 묶음이라, 렌더 중 외부 함수에 직접 넘기면 React Compiler가 +// ref 접근으로 판단한다. 별도 컴포넌트의 props로 전달해 렌더 범위를 분리한다(동작 동일). +function ToolbarEndSlot({ renderToolbarEnd, editor, command, view }: Readonly) { + return <>{renderToolbarEnd?.({ editor, command, view })}; +} + +// 주입된 정제 함수가 우선이고, 없으면 sanitizeHtml 옵션에 따라 기본 정제기를 사용한다. +function sanitizeEditorHtml( + html: string, + htmlSanitizer: KriEditorProps["htmlSanitizer"], + sanitizeEnabled: boolean, + allowedCustomHtml: KriEditorProps["allowedCustomHtml"], +): string { + if (htmlSanitizer) return htmlSanitizer(html); + if (sanitizeEnabled) return sanitizeHtml(html, allowedCustomHtml); + return html; +} + +function writeHtmlDraft( + draftRef: { current: string }, + textareaRef: { current: HTMLTextAreaElement | null }, + html: string, +): void { + draftRef.current = html; + if (textareaRef.current) textareaRef.current.value = html; +} + +// 외부에서 본문이 변경된 경우에만 기존 editor 문서를 갱신한다. +function syncEditorContent(editor: Editor, value: string, optimisticHtml: string): void { + // 빈 문자열("")은 ProseMirror 스키마상 유효한 문서가 아니라 setContent가 조용히 실패해 + // 이전 템플릿 본문이 그대로 남는 문제가 있었음 -> 빈 값은 빈 문단으로 정규화해서 비교/설정. + const normalizedValue = value || "

"; + if (normalizedValue === editor.getHTML() || normalizedValue === optimisticHtml) return; + + editor.commands.setContent(normalizedValue, { + emitUpdate: false, + parseOptions: { preserveWhitespace: "full" }, + }); + + // resize가 활성화된 TipTap 이미지 NodeView는 노드의 src 변경을 기존 DOM에 반영하지 않는다. + // editor 전체 대신 NodeView만 다시 생성해 이미지를 갱신하고 편집 포커스는 유지한다. + if (normalizedValue.includes(") { const { label, @@ -114,6 +167,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) { const { scheduleChange, flushChange, optimisticHtmlRef } = useDebouncedChange(onChange, debounceMs); const fileRef = useRef(null); + const previewContainerRef = useRef(null); const htmlTextareaRef = useRef(null); const htmlTi = useTextareaInsert(htmlTextareaRef); const { insertText: insertTextareaText } = htmlTi; @@ -132,6 +186,9 @@ export function KriEditorWysiwyg(props: KriEditorProps) { }, [view]); const htmlDraftRef = useRef(value ?? ""); + // HTML textarea는 비제어 컴포넌트다. 렌더 중 ref를 읽지 않도록, HTML 보기로 전환하는 시점의 + // 초안을 state로 보관해 textarea가 마운트될 때의 초기값(defaultValue)으로만 사용한다. + const [htmlTextareaSeed, setHtmlTextareaSeed] = useState(value ?? ""); const canImageUpload = Boolean(onImageUpload); const selectionRef = useRef<{ from: number; to: number } | null>(null); @@ -469,6 +526,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) { if (viewRef.current === "wysiwyg") { const raw = editor.getHTML(); htmlDraftRef.current = raw; + setHtmlTextareaSeed(raw); setView("html"); // WYSIWYG에서 막 넘어온, 사용자가 직접 타이핑하지 않은 HTML이므로 @@ -490,14 +548,12 @@ export function KriEditorWysiwyg(props: KriEditorProps) { toast.message(compatibility.reason ?? "현재 HTML은 WYSIWYG로 전환할 수 없습니다."); return; } - const safe = htmlSanitizer - ? htmlSanitizer(raw) - : sanitizeHtmlOpt ? sanitizeHtml(raw, allowedCustomHtml) : raw; + const safe = sanitizeEditorHtml(raw, htmlSanitizer, sanitizeHtmlOpt, allowedCustomHtml); editor.commands.setContent(safe, { emitUpdate: false, parseOptions: { preserveWhitespace: "full" } }); flushChange(preserveEmptyParagraphs(editor.getHTML())); setView("wysiwyg"); - }, [allowedCustomHtml, editor, flushChange, getCompatibility, htmlSanitizer, sanitizeHtmlOpt]); + }, [allowedCustomHtml, editor, flushChange, getCompatibility, htmlSanitizer, sanitizeHtmlOpt, setView, setPreviewSource, setHtmlTextareaSeed]); const formatHtmlView = useCallback(async () => { try { @@ -510,7 +566,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) { toast.error("HTML 정렬에 실패했습니다."); console.error(err); } - }, [scheduleChange]); + }, [scheduleChange, setPreviewSource]); useEffect(() => { if (!editor) return; @@ -542,46 +598,28 @@ export function KriEditorWysiwyg(props: KriEditorProps) { useEffect(() => { setPreviewSource(value ?? ""); - if (!editor) return; - if (value == null) return; + if (!editor || value == null) return; - const compatibility = getCompatibility(value); - if (showHtmlToggle && !compatibility.compatible) { - htmlDraftRef.current = value; - if (htmlTextareaRef.current) htmlTextareaRef.current.value = value; + // WYSIWYG로 손실 없이 편집할 수 없는 값은 HTML 보기로 전환해 원문을 유지한다. + if (showHtmlToggle && !getCompatibility(value).compatible) { + writeHtmlDraft(htmlDraftRef, htmlTextareaRef, value); if (viewRef.current !== "html") { viewRef.current = "html"; + setHtmlTextareaSeed(value); setView("html"); } return; } if (viewRef.current === "html") { - if (getWysiwygCompatibility && value !== optimisticHtmlRef.current && value !== htmlDraftRef.current) { - htmlDraftRef.current = value; - if (htmlTextareaRef.current) htmlTextareaRef.current.value = value; + const isExternalChange = value !== optimisticHtmlRef.current && value !== htmlDraftRef.current; + if (getWysiwygCompatibility && isExternalChange) { + writeHtmlDraft(htmlDraftRef, htmlTextareaRef, value); } return; } - // 빈 문자열("")은 ProseMirror 스키마상 유효한 문서가 아니라 setContent가 조용히 실패해 - // 이전 템플릿 본문이 그대로 남는 문제가 있었음 -> 빈 값은 빈 문단으로 정규화해서 비교/설정. - const normalizedValue = value || "

"; - const current = editor.getHTML(); - - if (normalizedValue !== current && normalizedValue !== optimisticHtmlRef.current) { - // 외부에서 본문이 변경된 경우에만 기존 editor 문서를 갱신한다. - editor.commands.setContent(normalizedValue, { - emitUpdate: false, - parseOptions: {preserveWhitespace: "full"}, - }); - - // resize가 활성화된 TipTap 이미지 NodeView는 노드의 src 변경을 기존 DOM에 반영하지 않는다. - // editor 전체 대신 NodeView만 다시 생성해 이미지를 갱신하고 편집 포커스는 유지한다. - if (normalizedValue.includes(" { @@ -646,13 +684,14 @@ export function KriEditorWysiwyg(props: KriEditorProps) { const previewHtml = useMemo(() => { const preserved = preserveEmptyParagraphs(previewSource); - const sanitized = htmlSanitizer - ? htmlSanitizer(preserved) - : sanitizeHtmlOpt ? sanitizeHtml(preserved, allowedCustomHtml) : preserved; + const sanitized = sanitizeEditorHtml(preserved, htmlSanitizer, sanitizeHtmlOpt, allowedCustomHtml); const withLinkStyle = applyLinkPreviewClass(sanitized); return transformPreviewHtml ? transformPreviewHtml(withLinkStyle) : withLinkStyle; }, [allowedCustomHtml, htmlSanitizer, previewSource, sanitizeHtmlOpt, transformPreviewHtml]); + // 이미지맵을 사용할 때만 미리보기에 영역을 표시한다. + const imageMapOverlayBoxes = useImageMapOverlay(previewContainerRef, previewHtml, enableImageMap && showPreview); + const wysiwygCompatibility = useMemo( () => getCompatibility(view === "html" ? previewSource : (editor?.getHTML() ?? previewSource)), [editor, getCompatibility, previewSource, view], @@ -700,7 +739,11 @@ export function KriEditorWysiwyg(props: KriEditorProps) { onAddRow={addRow} onAddColumn={addColumn} onDeleteTable={deleteTable} - customContent={props.renderToolbarEnd?.({ editor, command, view })} + customContent={ + props.renderToolbarEnd ? ( + + ) : undefined + } />
) : null} @@ -714,7 +757,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) {