Pārlūkot izejas kodu

Use relative URLs for the custom emoji images

That way, they can be relative to the `assets_path` setting.
JC Brand 11 mēneši atpakaļ
vecāks
revīzija
4fbb6e15ca

+ 2 - 1
docs/source/configuration.rst

@@ -1682,7 +1682,8 @@ XMPP servers.
 assets_path
 -----------
 
-* Default: ``'/dist/'`` or the `publicPath <https://webpack.js.org/guides/public-path/>`_ value as configured in the relevant Webpack configuration.
+* Default: ``'/dist/'`` or the `publicPath <https://webpack.js.org/guides/public-path/>`_
+  value as configured in the relevant Webpack configuration.
 
 Since version 5.0.0, Converse serves a smaller bundle by extracting various
 resources (for example emojis and translations) into separate files (aka

+ 2 - 2
src/headless/plugins/emoji/emoji.json

@@ -1,7 +1,7 @@
 {
 "custom": {
-":converse:":{"sn":":converse:","url":"/dist/images/custom_emojis/converse.png","c":"custom"},
-":xmpp:":{"sn":":xmpp:","url":"/dist/images/custom_emojis/xmpp.png","c":"custom"}
+":converse:":{"sn":":converse:","url":"./images/custom_emojis/converse.png","c":"custom"},
+":xmpp:":{"sn":":xmpp:","url":"./images/custom_emojis/xmpp.png","c":"custom"}
 },
 "smileys": {
 ":smiley:":{"sn":":smiley:","cp":"1f603","sns":[],"c":"smileys"},

+ 0 - 1
src/headless/plugins/emoji/plugin.js

@@ -101,7 +101,6 @@ converse.plugins.add('converse-emoji', {
                         const json = await api.hook('loadEmojis', {}, module.default);
                         converse.emojis.json = json;
 
-                        
                         converse.emojis.by_sn = Object.keys(json).reduce(
                             (result, cat) => Object.assign(result, json[cat]),
                             {}

+ 2 - 1
src/shared/chat/utils.js

@@ -208,12 +208,13 @@ export function getEmojiMarkup (data, options={unicode_only: false, add_title_wr
     } else if (options.unicode_only) {
         return shortname;
     } else {
+        const { url } = converse.emojis.by_sn[shortname];
         return html`<img class="emoji"
             loading="lazy"
             draggable="false"
             title="${shortname}"
             alt="${shortname}"
-            src="${converse.emojis.by_sn[shortname].url}">`;
+            src="${url.startsWith('.') ? `${api.settings.get('assets_path')}/${url}` : url}">`;
     }
 }