From 348a6bf70d0f4766e57f0a3d0425b9222feccf62 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 9 Jul 2023 13:06:13 +0200 Subject: [PATCH] Always pass 6-digit hex color to monaco (#25780) (#25782) Backport https://github.com/go-gitea/gitea/pull/25780, clean cherry-pick. Monaco can not deal with color formats other than 6-digit hex, so we convert the colors for it via new [`tinycolor2`](https://github.com/bgrins/TinyColor) dependency (5kB minzipped). Also, with the addition of the module, we can replace the existing `hexToRGBColor` usage, I verified it is compatible with the current tests before removing the function. Fixes: https://github.com/go-gitea/gitea/issues/25770 --- package-lock.json | 6 +++++ package.json | 1 + web_src/js/components/ContextPopup.vue | 5 ++-- web_src/js/features/codeeditor.js | 36 ++++++++++++++------------ web_src/js/features/repo-projects.js | 5 ++-- web_src/js/utils/color.js | 21 --------------- web_src/js/utils/color.test.js | 14 +--------- 7 files changed, 33 insertions(+), 55 deletions(-) diff --git a/package-lock.json b/package-lock.json index d19195e372899..a10225b3360c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,6 +42,7 @@ "sortablejs": "1.15.0", "swagger-ui-dist": "5.0.0", "throttle-debounce": "5.0.0", + "tinycolor2": "1.6.0", "tippy.js": "6.3.7", "tributejs": "5.1.3", "uint8-to-base64": "0.2.0", @@ -10085,6 +10086,11 @@ "integrity": "sha512-kRwSG8Zx4tjF9ZiyH4bhaebu+EDz1BOx9hOigYHlUW4xxI/wKIUQUqo018UlU4ar6ATPBsaMrdbKZ+tmPdohFA==", "dev": true }, + "node_modules/tinycolor2": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz", + "integrity": "sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==" + }, "node_modules/tinypool": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-0.5.0.tgz", diff --git a/package.json b/package.json index 08c54c27c7359..fe3f0691a991a 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "sortablejs": "1.15.0", "swagger-ui-dist": "5.0.0", "throttle-debounce": "5.0.0", + "tinycolor2": "1.6.0", "tippy.js": "6.3.7", "tributejs": "5.1.3", "uint8-to-base64": "0.2.0", diff --git a/web_src/js/components/ContextPopup.vue b/web_src/js/components/ContextPopup.vue index 420c271fcccee..b6852655f6c4b 100644 --- a/web_src/js/components/ContextPopup.vue +++ b/web_src/js/components/ContextPopup.vue @@ -26,7 +26,8 @@