diff --git a/package.json b/package.json index 30254ed78d..086a1006cf 100644 --- a/package.json +++ b/package.json @@ -167,6 +167,7 @@ "matrix-mock-request": "^1.2.3", "matrix-react-test-utils": "^0.2.3", "matrix-web-i18n": "github:matrix-org/matrix-web-i18n", + "raw-loader": "^4.0.2", "react-test-renderer": "^17.0.2", "rimraf": "^3.0.2", "stylelint": "^13.9.0", diff --git a/src/@types/raw-loader.d.ts b/src/@types/raw-loader.d.ts new file mode 100644 index 0000000000..ee9277c662 --- /dev/null +++ b/src/@types/raw-loader.d.ts @@ -0,0 +1,20 @@ +/* +Copyright 2021 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +declare module '!!raw-loader!*' { + const contents: string; + export = contents; +} diff --git a/src/utils/exportUtils/HtmlExport.tsx b/src/utils/exportUtils/HtmlExport.tsx index 05ce8570da..c27f5b7d12 100644 --- a/src/utils/exportUtils/HtmlExport.tsx +++ b/src/utils/exportUtils/HtmlExport.tsx @@ -31,7 +31,7 @@ import EventTile, { haveTileForEvent } from "../../components/views/rooms/EventT import DateSeparator from "../../components/views/messages/DateSeparator"; import BaseAvatar from "../../components/views/avatars/BaseAvatar"; import exportCSS from "./exportCSS"; -import exportJS from "./exportJS"; +import exportJS from "!!raw-loader!./exportJS"; import exportIcons from "./exportIcons"; import { ExportTypes } from "./exportUtils"; import { IExportOptions } from "./exportUtils"; diff --git a/src/utils/exportUtils/exportIcons.ts b/src/utils/exportUtils/exportIcons.ts index 2a19e9c4d1..865fb08a06 100644 --- a/src/utils/exportUtils/exportIcons.ts +++ b/src/utils/exportUtils/exportIcons.ts @@ -1,15 +1,7 @@ -/* eslint-disable max-len */ +import Trash from "!!raw-loader!../../../res/img/element-icons/trashcan.svg"; +import Attach from "!!raw-loader!../../../res/img/element-icons/room/composer/attach.svg"; + export default { - "trash.svg": ` - - - - - - - `, - "attach.svg": ` - - - `, + "trash.svg": Trash, + "attach.svg": Attach, }; diff --git a/src/utils/exportUtils/exportJS.js b/src/utils/exportUtils/exportJS.js new file mode 100644 index 0000000000..9e58c8b99c --- /dev/null +++ b/src/utils/exportUtils/exportJS.js @@ -0,0 +1,25 @@ +function showToastIfNeeded(replyId) { + const el = document.getElementById(replyId); + if (!el) { + showToast("The message you're looking for wasn't exported"); + return; + } +} + +function showToast(text) { + const el = document.getElementById("snackbar"); + el.innerHTML = text; + el.className = "mx_show"; + setTimeout(() => { + el.className = el.className.replace("mx_show", ""); + }, 2000); +} + +window.onload = () => { + document.querySelectorAll('.mx_reply_anchor').forEach(element => { + element.addEventListener('click', event => { + showToastIfNeeded(event.target.getAttribute("scroll-to")); + }); + }); +}; + diff --git a/src/utils/exportUtils/exportJS.ts b/src/utils/exportUtils/exportJS.ts deleted file mode 100644 index 21b10b50d5..0000000000 --- a/src/utils/exportUtils/exportJS.ts +++ /dev/null @@ -1,27 +0,0 @@ -export default ` -function showToastIfNeeded(replyId){ - let el = document.getElementById(replyId); - if(!el) { - showToast("The message you're looking for wasn't exported"); - return; - }; -} - -function showToast(text) { - let el = document.getElementById("snackbar"); - el.innerHTML = text; - el.className = "mx_show"; - setTimeout(() => { - el.className = el.className.replace("mx_show", ""); - }, 2000); -} - -window.onload = () => { -document.querySelectorAll('.mx_reply_anchor').forEach(element => { - element.addEventListener('click', event => { - showToastIfNeeded(event.target.getAttribute("scroll-to")); - }) -}) -} - -`; diff --git a/yarn.lock b/yarn.lock index dc3bc2ca7b..ea64ed5180 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1531,7 +1531,7 @@ jest-diff "^26.0.0" pretty-format "^26.0.0" -"@types/json-schema@^7.0.7": +"@types/json-schema@^7.0.7", "@types/json-schema@^7.0.8": version "7.0.8" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.8.tgz#edf1bf1dbf4e04413ca8e5b17b3b7d7d54b59818" integrity sha512-YSBPTLTVm2e2OoQIDYx8HaeWJ5tTToLH67kXR7zYNGupXMEHa2++G8k+DczX2cFVgalypqtyZIcU19AFcmOpmg== @@ -1840,7 +1840,12 @@ agent-base@6: dependencies: debug "4" -ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4: +ajv-keywords@^3.5.2: + version "3.5.2" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" + integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== + +ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== @@ -2216,6 +2221,11 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" +big.js@^5.2.2: + version "5.2.2" + resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" + integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== + binary-extensions@^1.0.0: version "1.13.1" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.13.1.tgz#598afe54755b2868a5330d2aff9d4ebb53209b65" @@ -3072,6 +3082,11 @@ emojibase-regex@^5.1.3: resolved "https://registry.yarnpkg.com/emojibase-regex/-/emojibase-regex-5.1.3.tgz#f0ef621ed6ec624becd2326f999fd4ea01b94554" integrity sha512-gT8T9LxLA8VJdI+8KQtyykB9qKzd7WuUL3M2yw6y9tplFeufOUANg3UKVaKUvkMcRNvZsSElWhxcJrx8WPE12g== +emojis-list@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" + integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== + encoding@^0.1.11: version "0.1.13" resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9" @@ -5339,6 +5354,15 @@ linkifyjs@^2.1.9: resolved "https://registry.yarnpkg.com/linkifyjs/-/linkifyjs-2.1.9.tgz#af06e45a2866ff06c4766582590d098a4d584702" integrity sha512-74ivurkK6WHvHFozVaGtQWV38FzBwSTGNmJolEgFp7QgR2bl6ArUWlvT4GcHKbPe1z3nWYi+VUdDZk16zDOVug== +loader-utils@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0" + integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ== + dependencies: + big.js "^5.2.2" + emojis-list "^3.0.0" + json5 "^2.1.2" + locate-path@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" @@ -6445,6 +6469,14 @@ randexp@0.4.6: discontinuous-range "1.0.0" ret "~0.1.10" +raw-loader@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-4.0.2.tgz#1aac6b7d1ad1501e66efdac1522c73e59a584eb6" + integrity sha512-ZnScIV3ag9A4wPX/ZayxL/jZH+euYb6FcUinPcgiQW0+UBtEv0O6Q3lGd3cqJ+GHH+rksEv3Pj99oxJ3u3VIKA== + dependencies: + loader-utils "^2.0.0" + schema-utils "^3.0.0" + re-resizable@^6.9.0: version "6.9.0" resolved "https://registry.yarnpkg.com/re-resizable/-/re-resizable-6.9.0.tgz#9c3059b389ced6ade602234cc5bb1e12d231cd47" @@ -6958,6 +6990,15 @@ scheduler@^0.20.2: loose-envify "^1.1.0" object-assign "^4.1.1" +schema-utils@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.1.tgz#bc74c4b6b6995c1d88f76a8b77bea7219e0c8281" + integrity sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw== + dependencies: + "@types/json-schema" "^7.0.8" + ajv "^6.12.5" + ajv-keywords "^3.5.2" + "semver@2 || 3 || 4 || 5", semver@^5.5.0, semver@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"