From 63cef1023c201224ccd8db27a7bc0b492376d4c4 Mon Sep 17 00:00:00 2001 From: Maksim Ivanov Date: Thu, 8 Jun 2023 17:27:07 +0300 Subject: [PATCH] feat(addon-doc): upgrade `ngx-highlightjs` (#4608) --- package-lock.json | 249 +++++++----------- .../code/tests/code.component.spec.ts | 36 +-- .../components/code/tests/highlight.spec.ts | 128 +++++++++ projects/addon-doc/package.json | 5 +- 4 files changed, 252 insertions(+), 166 deletions(-) create mode 100644 projects/addon-doc/components/code/tests/highlight.spec.ts diff --git a/package-lock.json b/package-lock.json index 83a2c5c0b293..fe21c85c979a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1667,9 +1667,9 @@ } }, "node_modules/@babel/plugin-proposal-private-property-in-object": { - "version": "7.21.10", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.10.tgz", - "integrity": "sha512-3YybmT8FN4sZFXp0kTr9Gbu90wAIhC3feNung+qcRQ1wALGoSHgOz1c+fR3ZLGZ0LXqIpYmtE6Faua6tMDarUg==", + "version": "7.21.11", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.11.tgz", + "integrity": "sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw==", "dev": true, "dependencies": { "@babel/helper-annotate-as-pure": "^7.18.6", @@ -3722,9 +3722,9 @@ "dev": true }, "node_modules/@cspell/dict-companies": { - "version": "3.0.13", - "resolved": "https://registry.npmjs.org/@cspell/dict-companies/-/dict-companies-3.0.13.tgz", - "integrity": "sha512-7fYRZOaa2fBGXdIessWYT0/L28k4Vj3V+xE5ZMog58mY4Yrp7lAkArIga0xgi4fYqMupPkOjOTeALAqWWzEgVA==", + "version": "3.0.14", + "resolved": "https://registry.npmjs.org/@cspell/dict-companies/-/dict-companies-3.0.14.tgz", + "integrity": "sha512-mVNJqi6CAAeD8osGqxbozGAkmG9mZ8rMvUnmR1z2LmS4jxGBEDjYcHj7ii5buoP3G5gWnLBtYP+2ehp+5zuwDw==", "dev": true }, "node_modules/@cspell/dict-cpp": { @@ -3914,9 +3914,9 @@ "dev": true }, "node_modules/@cspell/dict-python": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@cspell/dict-python/-/dict-python-4.0.6.tgz", - "integrity": "sha512-24AhYyTZdOTLqkoiwXlEZrqEHkOwmePWQqRc9YigV9X69EtzBMrdMhYBvkJCVnQZD2ckT05U3A36YFYaxZ39Pg==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/@cspell/dict-python/-/dict-python-4.0.7.tgz", + "integrity": "sha512-Oxg21WYiOVRlEOyEAW90eeaAcUE9qAqmkqI/7LRvTS3iKgE6HuUHFj5Bozh+8Q/UYFxGepxdcn1ikUUpgjKMdQ==", "dev": true }, "node_modules/@cspell/dict-r": { @@ -3956,9 +3956,9 @@ "dev": true }, "node_modules/@cspell/dict-software-terms": { - "version": "3.1.11", - "resolved": "https://registry.npmjs.org/@cspell/dict-software-terms/-/dict-software-terms-3.1.11.tgz", - "integrity": "sha512-3T8Q90YtkHTO49gEI8ALQhOt5Ae1MpUzeo8s0THVXmE0tXfD24ASgdiKcKiAjjokJAj4Bs9Lkb4NcaBhXq5+rw==", + "version": "3.1.12", + "resolved": "https://registry.npmjs.org/@cspell/dict-software-terms/-/dict-software-terms-3.1.12.tgz", + "integrity": "sha512-pnUtrsWgozGimBk6xSeGvInFcB8p1C30flUdBddD5k3bGWHsd33M8g+F8lTxwtYLyXkEaFFPSfQ9ljj+9exWYQ==", "dev": true }, "node_modules/@cspell/dict-sql": { @@ -7435,9 +7435,9 @@ } }, "node_modules/@nrwl/webpack/node_modules/html-entities": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.3.tgz", - "integrity": "sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==", + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.5.tgz", + "integrity": "sha512-72TJlcMkYsEJASa/3HnX7VT59htM7iSHbH59NSZbtc+22Ap0Txnlx91sfeB+/A7wNZg7UxtZdhAW4y+/jimrdg==", "dev": true }, "node_modules/@nrwl/webpack/node_modules/iconv-lite": { @@ -10948,15 +10948,15 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.59.8", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.8.tgz", - "integrity": "sha512-JDMOmhXteJ4WVKOiHXGCoB96ADWg9q7efPWHRViT/f09bA8XOMLAVHHju3l0MkZnG1izaWXYmgvQcUjTRcpShQ==", + "version": "5.59.9", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.9.tgz", + "integrity": "sha512-4uQIBq1ffXd2YvF7MAvehWKW3zVv/w+mSfRAu+8cKbfj3nwzyqJLNcZJpQ/WZ1HLbJDiowwmQ6NO+63nCA+fqA==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.4.0", - "@typescript-eslint/scope-manager": "5.59.8", - "@typescript-eslint/type-utils": "5.59.8", - "@typescript-eslint/utils": "5.59.8", + "@typescript-eslint/scope-manager": "5.59.9", + "@typescript-eslint/type-utils": "5.59.9", + "@typescript-eslint/utils": "5.59.9", "debug": "^4.3.4", "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", @@ -10982,13 +10982,13 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/type-utils": { - "version": "5.59.8", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.8.tgz", - "integrity": "sha512-+5M518uEIHFBy3FnyqZUF3BMP+AXnYn4oyH8RF012+e7/msMY98FhGL5SrN29NQ9xDgvqCgYnsOiKp1VjZ/fpA==", + "version": "5.59.9", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.59.9.tgz", + "integrity": "sha512-ksEsT0/mEHg9e3qZu98AlSrONAQtrSTljL3ow9CGej8eRo7pe+yaC/mvTjptp23Xo/xIf2mLZKC6KPv4Sji26Q==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "5.59.8", - "@typescript-eslint/utils": "5.59.8", + "@typescript-eslint/typescript-estree": "5.59.9", + "@typescript-eslint/utils": "5.59.9", "debug": "^4.3.4", "tsutils": "^3.21.0" }, @@ -11009,17 +11009,17 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils": { - "version": "5.59.8", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.8.tgz", - "integrity": "sha512-Tr65630KysnNn9f9G7ROF3w1b5/7f6QVCJ+WK9nhIocWmx9F+TmCAcglF26Vm7z8KCTwoKcNEBZrhlklla3CKg==", + "version": "5.59.9", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.9.tgz", + "integrity": "sha512-1PuMYsju/38I5Ggblaeb98TOoUvjhRvLpLa1DoTOFaLWqaXl/1iQ1eGurTXgBY58NUdtfTXKP5xBq7q9NDaLKg==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.59.8", - "@typescript-eslint/types": "5.59.8", - "@typescript-eslint/typescript-estree": "5.59.8", + "@typescript-eslint/scope-manager": "5.59.9", + "@typescript-eslint/types": "5.59.9", + "@typescript-eslint/typescript-estree": "5.59.9", "eslint-scope": "^5.1.1", "semver": "^7.3.7" }, @@ -11107,12 +11107,12 @@ "dev": true }, "node_modules/@typescript-eslint/experimental-utils": { - "version": "5.59.8", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-5.59.8.tgz", - "integrity": "sha512-jAf+hihtd0G2RLB9x796+3i8D0L5T5xjftuPpJ82RLsPNHdzGXmbZNNftQ558h90ogc45DD8/W3OrxmdSO5Nng==", + "version": "5.59.9", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-5.59.9.tgz", + "integrity": "sha512-eZTK/Ci0QAqNc/q2MqMwI2+QI5ZI9HM12FcfGwbEvKif5ev/CIIYLmrlckvgPrC8XSbl39HtErR5NJiQkRkvWg==", "dev": true, "dependencies": { - "@typescript-eslint/utils": "5.59.8" + "@typescript-eslint/utils": "5.59.9" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -11126,17 +11126,17 @@ } }, "node_modules/@typescript-eslint/experimental-utils/node_modules/@typescript-eslint/utils": { - "version": "5.59.8", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.8.tgz", - "integrity": "sha512-Tr65630KysnNn9f9G7ROF3w1b5/7f6QVCJ+WK9nhIocWmx9F+TmCAcglF26Vm7z8KCTwoKcNEBZrhlklla3CKg==", + "version": "5.59.9", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.59.9.tgz", + "integrity": "sha512-1PuMYsju/38I5Ggblaeb98TOoUvjhRvLpLa1DoTOFaLWqaXl/1iQ1eGurTXgBY58NUdtfTXKP5xBq7q9NDaLKg==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@types/json-schema": "^7.0.9", "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.59.8", - "@typescript-eslint/types": "5.59.8", - "@typescript-eslint/typescript-estree": "5.59.8", + "@typescript-eslint/scope-manager": "5.59.9", + "@typescript-eslint/types": "5.59.9", + "@typescript-eslint/typescript-estree": "5.59.9", "eslint-scope": "^5.1.1", "semver": "^7.3.7" }, @@ -11207,14 +11207,14 @@ "dev": true }, "node_modules/@typescript-eslint/parser": { - "version": "5.59.8", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.8.tgz", - "integrity": "sha512-AnR19RjJcpjoeGojmwZtCwBX/RidqDZtzcbG3xHrmz0aHHoOcbWnpDllenRDmDvsV0RQ6+tbb09/kyc+UT9Orw==", + "version": "5.59.9", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.9.tgz", + "integrity": "sha512-FsPkRvBtcLQ/eVK1ivDiNYBjn3TGJdXy2fhXX+rc7czWl4ARwnpArwbihSOHI2Peg9WbtGHrbThfBUkZZGTtvQ==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.59.8", - "@typescript-eslint/types": "5.59.8", - "@typescript-eslint/typescript-estree": "5.59.8", + "@typescript-eslint/scope-manager": "5.59.9", + "@typescript-eslint/types": "5.59.9", + "@typescript-eslint/typescript-estree": "5.59.9", "debug": "^4.3.4" }, "engines": { @@ -11251,13 +11251,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.59.8", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.8.tgz", - "integrity": "sha512-/w08ndCYI8gxGf+9zKf1vtx/16y8MHrZs5/tnjHhMLNSixuNcJavSX4wAiPf4aS5x41Es9YPCn44MIe4cxIlig==", + "version": "5.59.9", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.9.tgz", + "integrity": "sha512-8RA+E+w78z1+2dzvK/tGZ2cpGigBZ58VMEHDZtpE1v+LLjzrYGc8mMaTONSxKyEkz3IuXFM0IqYiGHlCsmlZxQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.59.8", - "@typescript-eslint/visitor-keys": "5.59.8" + "@typescript-eslint/types": "5.59.9", + "@typescript-eslint/visitor-keys": "5.59.9" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -11402,9 +11402,9 @@ "dev": true }, "node_modules/@typescript-eslint/types": { - "version": "5.59.8", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.8.tgz", - "integrity": "sha512-+uWuOhBTj/L6awoWIg0BlWy0u9TyFpCHrAuQ5bNfxDaZ1Ppb3mx6tUigc74LHcbHpOHuOTOJrBoAnhdHdaea1w==", + "version": "5.59.9", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.9.tgz", + "integrity": "sha512-uW8H5NRgTVneSVTfiCVffBb8AbwWSKg7qcA4Ot3JI3MPCJGsB4Db4BhvAODIIYE5mNj7Q+VJkK7JxmRhk2Lyjw==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -11415,13 +11415,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.59.8", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.8.tgz", - "integrity": "sha512-Jy/lPSDJGNow14vYu6IrW790p7HIf/SOV1Bb6lZ7NUkLc2iB2Z9elESmsaUtLw8kVqogSbtLH9tut5GCX1RLDg==", + "version": "5.59.9", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.9.tgz", + "integrity": "sha512-pmM0/VQ7kUhd1QyIxgS+aRvMgw+ZljB3eDb+jYyp6d2bC0mQWLzUDF+DLwCTkQ3tlNyVsvZRXjFyV0LkU/aXjA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.59.8", - "@typescript-eslint/visitor-keys": "5.59.8", + "@typescript-eslint/types": "5.59.9", + "@typescript-eslint/visitor-keys": "5.59.9", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -11664,12 +11664,12 @@ "dev": true }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.59.8", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.8.tgz", - "integrity": "sha512-pJhi2ms0x0xgloT7xYabil3SGGlojNNKjK/q6dB3Ey0uJLMjK2UDGJvHieiyJVW/7C3KI+Z4Q3pEHkm4ejA+xQ==", + "version": "5.59.9", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.9.tgz", + "integrity": "sha512-bT7s0td97KMaLwpEBckbzj/YohnvXtqbe2XgqNvTl6RJVakY5mvENOTPvw5u66nljfZxthESpDozs86U+oLY8Q==", "dev": true, "dependencies": { - "@typescript-eslint/types": "5.59.8", + "@typescript-eslint/types": "5.59.9", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -14299,9 +14299,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001494", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001494.tgz", - "integrity": "sha512-sY2B5Qyl46ZzfYDegrl8GBCzdawSLT4ThM9b9F+aDYUrAG2zCOyMbd2Tq34mS1g4ZKBfjRlzOohQMxx28x6wJg==", + "version": "1.0.30001495", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001495.tgz", + "integrity": "sha512-F6x5IEuigtUfU5ZMQK2jsy5JqUUlEFRVZq8bO2a+ysq5K7jD6PPc9YXZj78xDNS3uNchesp1Jw47YXEqr+Viyg==", "funding": [ { "type": "opencollective", @@ -18848,9 +18848,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.419", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.419.tgz", - "integrity": "sha512-jdie3RiEgygvDTyS2sgjq71B36q2cDSBfPlwzUyuOrfYTNoYWyBxxjGJV/HAu3A2hB0Y+HesvCVkVAFoCKwCSw==" + "version": "1.4.423", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.423.tgz", + "integrity": "sha512-y4A7YfQcDGPAeSWM1IuoWzXpg9RY1nwHzHSwRtCSQFp9FgAVDgdWlFf0RbdWfLWQ2WUI+bddUgk5RgTjqRE6FQ==" }, "node_modules/ember-rfc176-data": { "version": "0.3.18", @@ -25762,9 +25762,9 @@ } }, "node_modules/jest-environment-jsdom/node_modules/tough-cookie": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz", - "integrity": "sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz", + "integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==", "dev": true, "dependencies": { "psl": "^1.1.33", @@ -27596,9 +27596,9 @@ } }, "node_modules/jsdom/node_modules/tough-cookie": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz", - "integrity": "sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz", + "integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==", "dependencies": { "psl": "^1.1.33", "punycode": "^2.1.1", @@ -28036,9 +28036,9 @@ } }, "node_modules/linkify-it": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", - "integrity": "sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-4.0.1.tgz", + "integrity": "sha512-C7bfi1UZmoj8+PQx22XyeXCuBlokoyWQL5pWSP+EI6nzRylyThouddufc2c1NDIcP9k5agmN9fLpA7VNJfIiqw==", "dependencies": { "uc.micro": "^1.0.1" } @@ -29068,13 +29068,13 @@ } }, "node_modules/markdown-it": { - "version": "12.3.2", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.2.tgz", - "integrity": "sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg==", + "version": "13.0.1", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-13.0.1.tgz", + "integrity": "sha512-lTlxriVoy2criHP0JKRhO2VDG9c2ypWCsT237eDiLqi09rmbKoUetyGHq2uOIRoRS//kfoJckS0eUzzkDR+k2Q==", "dependencies": { "argparse": "^2.0.1", - "entities": "~2.1.0", - "linkify-it": "^3.0.1", + "entities": "~3.0.1", + "linkify-it": "^4.0.1", "mdurl": "^1.0.1", "uc.micro": "^1.0.5" }, @@ -29088,9 +29088,12 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, "node_modules/markdown-it/node_modules/entities": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", - "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-3.0.1.tgz", + "integrity": "sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q==", + "engines": { + "node": ">=0.12" + }, "funding": { "url": "https://github.com/fb55/entities?sponsor=1" } @@ -30028,28 +30031,20 @@ } }, "node_modules/ngx-highlightjs": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/ngx-highlightjs/-/ngx-highlightjs-4.1.4.tgz", - "integrity": "sha512-yh5p8J+mUNHMm5kQM1CAyRdLT2KiW631l/Rky+rkxwT6NZHG80yImWXZt7RG3heTQzd1wDOWMQ8JznF3KeUv5g==", + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/ngx-highlightjs/-/ngx-highlightjs-6.1.3.tgz", + "integrity": "sha512-QF91hKhD75HpuJOgCGL3M7UyZommAqIgzubpZN2/At7OqBZ3G6NX9n/r6ksezSur34wjYOYQunNJhIvsXQzu6Q==", "dependencies": { - "highlight.js": "^10.0.0", + "highlight.js": "^11.0.0", "highlightjs-line-numbers.js": "^2.8.0", "tslib": "^2.0.0" }, "peerDependencies": { - "@angular/common": ">=8.0.0", - "@angular/core": ">=8.0.0", + "@angular/common": ">=13.0.0", + "@angular/core": ">=13.0.0", "rxjs": ">=6.0.0" } }, - "node_modules/ngx-highlightjs/node_modules/highlight.js": { - "version": "10.7.3", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz", - "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==", - "engines": { - "node": "*" - } - }, "node_modules/ngx-markdown": { "version": "10.1.1", "resolved": "https://registry.npmjs.org/ngx-markdown/-/ngx-markdown-10.1.1.tgz", @@ -34757,45 +34752,6 @@ "prosemirror-model": "^1.0.0" } }, - "node_modules/prosemirror-markdown/node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" - }, - "node_modules/prosemirror-markdown/node_modules/entities": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/entities/-/entities-3.0.1.tgz", - "integrity": "sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q==", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/prosemirror-markdown/node_modules/linkify-it": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-4.0.1.tgz", - "integrity": "sha512-C7bfi1UZmoj8+PQx22XyeXCuBlokoyWQL5pWSP+EI6nzRylyThouddufc2c1NDIcP9k5agmN9fLpA7VNJfIiqw==", - "dependencies": { - "uc.micro": "^1.0.1" - } - }, - "node_modules/prosemirror-markdown/node_modules/markdown-it": { - "version": "13.0.1", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-13.0.1.tgz", - "integrity": "sha512-lTlxriVoy2criHP0JKRhO2VDG9c2ypWCsT237eDiLqi09rmbKoUetyGHq2uOIRoRS//kfoJckS0eUzzkDR+k2Q==", - "dependencies": { - "argparse": "^2.0.1", - "entities": "~3.0.1", - "linkify-it": "^4.0.1", - "mdurl": "^1.0.1", - "uc.micro": "^1.0.5" - }, - "bin": { - "markdown-it": "bin/markdown-it.js" - } - }, "node_modules/prosemirror-menu": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/prosemirror-menu/-/prosemirror-menu-1.2.2.tgz", @@ -40291,9 +40247,9 @@ } }, "node_modules/w3c-keyname": { - "version": "2.2.7", - "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.7.tgz", - "integrity": "sha512-XB8aa62d4rrVfoZYQaYNy3fy+z4nrfy2ooea3/0BnBzXW0tSdZ+lRgjzBZhk0La0H6h8fVyYCxx/qkQcAIuvfg==" + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz", + "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==" }, "node_modules/w3c-xmlserializer": { "version": "2.0.0", @@ -42006,9 +41962,8 @@ "license": "Apache-2.0", "dependencies": { "@angular-devkit/schematics": "12.2.18", - "highlight.js": "11.8.0", - "markdown-it": "12.3.2", - "ngx-highlightjs": "4.1.4", + "markdown-it": "13.0.1", + "ngx-highlightjs": "6.1.3", "schematics-utilities": "1.1.3" }, "devDependencies": { diff --git a/projects/addon-doc/components/code/tests/code.component.spec.ts b/projects/addon-doc/components/code/tests/code.component.spec.ts index 9c1c7625ae72..8bceab8d0fcf 100644 --- a/projects/addon-doc/components/code/tests/code.component.spec.ts +++ b/projects/addon-doc/components/code/tests/code.component.spec.ts @@ -1,13 +1,14 @@ -import {ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {TuiDocCodeComponent} from '@taiga-ui/addon-doc'; +import {configureTestSuite} from '@taiga-ui/testing'; import {HIGHLIGHT_OPTIONS, HighlightModule} from 'ngx-highlightjs'; describe(`TuiDocCodeComponent`, () => { let component: TuiDocCodeComponent; let fixture: ComponentFixture; - beforeEach(async () => { - await TestBed.configureTestingModule({ + configureTestSuite(() => { + TestBed.configureTestingModule({ declarations: [TuiDocCodeComponent], imports: [HighlightModule], providers: [ @@ -24,7 +25,7 @@ describe(`TuiDocCodeComponent`, () => { }, }, ], - }).compileComponents(); + }); }); beforeEach(() => { @@ -47,41 +48,44 @@ describe(`TuiDocCodeComponent`, () => { expect(component.hasFilename).toBeTruthy(); }); - it(`should sync load simple text and process the code when the code input is set`, fakeAsync(() => { + it(`should sync load simple text and process the code when the code input is set`, async () => { component.code = `const a = 5;`; + fixture.detectChanges(); - waitHighlightJsParseContent(); + await waitHighlightJsParseContent(); expect(fixture.nativeElement.querySelector(`.t-code`)?.innerHTML).toEqual( `const a = 5;`, ); - })); + }); - it(`should async load simple text and process the code when the code input is set`, fakeAsync(() => { + it(`should async load simple text and process the code when the code input is set`, async () => { component.code = Promise.resolve({default: `const a = 10;`}); + fixture.detectChanges(); - waitHighlightJsParseContent(); + await waitHighlightJsParseContent(); expect(fixture.nativeElement.querySelector(`.t-code`)?.innerHTML).toEqual( `const a = 10;`, ); - })); + }); - it(`should async load markdown code and process the code when the code input is set`, fakeAsync(() => { + it(`should async load markdown code and process the code when the code input is set`, async () => { component.code = Promise.resolve({ default: `\`\`\`ts\nconst a = 15;\n\`\`\``, // markdown }); + fixture.detectChanges(); - waitHighlightJsParseContent(); + await waitHighlightJsParseContent(); expect(fixture.nativeElement.querySelector(`.t-code`)?.innerHTML).toEqual( `const a = 15;`, ); - })); + }); - function waitHighlightJsParseContent(): void { - tick(100); + async function waitHighlightJsParseContent(): Promise { + await fixture?.whenStable(); fixture.detectChanges(); - tick(100); + await new Promise(resolve => setTimeout(resolve, 100)); } }); diff --git a/projects/addon-doc/components/code/tests/highlight.spec.ts b/projects/addon-doc/components/code/tests/highlight.spec.ts new file mode 100644 index 000000000000..f420be2dd278 --- /dev/null +++ b/projects/addon-doc/components/code/tests/highlight.spec.ts @@ -0,0 +1,128 @@ +import {Component, DebugElement, Input} from '@angular/core'; +import { + ComponentFixture, + fakeAsync, + TestBed, + tick, + waitForAsync, +} from '@angular/core/testing'; +import {By} from '@angular/platform-browser'; +import hljs from 'highlight.js'; +import {Highlight, HighlightLibrary, HighlightLoader} from 'ngx-highlightjs'; +import {BehaviorSubject} from 'rxjs'; + +describe(`Highlight Directive`, () => { + let highlightedCode: string | undefined; + let component: TestHighlightComponent; + let directiveElement: DebugElement; + let directiveInstance: Highlight; + let fixture: ComponentFixture; + let loader: HighlightLoader; + const testJsCode = `console.log("test")`; + const testHtmlCode = `
`; + + @Component({ + template: ` + + `, + }) + class TestHighlightComponent { + @Input() + code?: string | null; + } + + beforeEach(waitForAsync(async () => { + await TestBed.configureTestingModule({ + declarations: [Highlight, TestHighlightComponent], + providers: [ + { + provide: HighlightLoader, + useValue: { + ready: new BehaviorSubject(hljs), + }, + }, + ], + }).compileComponents(); + + loader = TestBed.inject(HighlightLoader); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TestHighlightComponent); + component = fixture.componentInstance; + directiveElement = fixture.debugElement.query(By.directive(Highlight)); + directiveInstance = directiveElement.injector.get(Highlight); + fixture.detectChanges(); + }); + + it(`should create highlight directive`, () => { + expect(directiveInstance).not.toBeNull(); + }); + + it(`should add hljs class`, () => { + expect(directiveElement.nativeElement.classList.contains(`hljs`)).toBeTruthy(); + }); + + it(`should highlight given text`, fakeAsync(() => { + component.code = testJsCode; + fixture.detectChanges(); + loader.ready.subscribe((lib: HighlightLibrary) => { + highlightedCode = lib.highlightAuto( + testJsCode, + // note: enable auto detect language mode + null as unknown as string[], + ).value; + }); + tick(500); + expect(directiveElement.nativeElement.innerHTML).toBe(highlightedCode); + })); + + it(`should reset text if empty string was passed`, () => { + component.code = ``; + fixture.detectChanges(); + expect(directiveElement.nativeElement.innerHTML).toBe(``); + }); + + it(`should not highlight if code is undefined`, () => { + jest.spyOn(directiveInstance, `highlightElement`); + component.code = null; + fixture.detectChanges(); + expect(directiveInstance.highlightElement).not.toHaveBeenCalled(); + }); + + it(`should highlight given text and highlight another text when change`, fakeAsync(() => { + component.code = testJsCode; + fixture.detectChanges(); + loader.ready.subscribe((lib: HighlightLibrary) => { + highlightedCode = lib.highlightAuto( + testJsCode, + // note: enable auto detect language mode + null as unknown as string[], + ).value; + }); + tick(500); + expect(directiveElement.nativeElement.innerHTML).toBe(highlightedCode); + + component.code = testHtmlCode; + fixture.detectChanges(); + loader.ready.subscribe((lib: HighlightLibrary) => { + highlightedCode = lib.highlightAuto( + testHtmlCode, + // note: enable auto detect language mode + null as unknown as string[], + ).value; + }); + tick(500); + expect(directiveElement.nativeElement.innerHTML).toBe(highlightedCode); + + component.code = ``; + fixture.detectChanges(); + tick(300); + expect(directiveElement.nativeElement.innerHTML).toBe(``); + + component.code = null; + fixture.detectChanges(); + tick(300); + expect(directiveElement.nativeElement.innerHTML).toBe(``); + })); +}); diff --git a/projects/addon-doc/package.json b/projects/addon-doc/package.json index 6a7b1cfb9baf..638afc8db9bb 100644 --- a/projects/addon-doc/package.json +++ b/projects/addon-doc/package.json @@ -15,9 +15,8 @@ "license": "Apache-2.0", "dependencies": { "@angular-devkit/schematics": "12.2.18", - "highlight.js": "11.8.0", - "markdown-it": "12.3.2", - "ngx-highlightjs": "4.1.4", + "markdown-it": "13.0.1", + "ngx-highlightjs": "6.1.3", "schematics-utilities": "1.1.3" }, "devDependencies": {