Would be possible to use this with custom emojis?
As we provide support from our community, it would be nice to add our logo before mentioning one of the staff
This component is kind of a super basic template on finding content in a post and appending something to it. There’s probably a way to grab existing emojis, but I don’t know it off the top of my head.
What would work is replacing the header.html file in the component with this, which would just append an image after a mention instead (that image could be a little logo).
<script type="text/discourse-plugin" version="0.8.18">
$.expr[":"].contains = $.expr.createPseudo(function(arg) { // make case insensitive
return function( elem ) {
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});
let emoji = {};
settings.username_emoji.split('|').forEach(pair => {
let split = pair.split(",");
emoji[split[0].toLowerCase()] = split[1];
});
$.each(emoji, function (key, value){
api.decorateCooked($elem => $elem.find("a.mention:contains(" + key + ")").append("<img src='" + value + "'>").addClass("with-image"));
});
</script>
멘션 옆 아이콘으로 사용자 정의 SVG도 사용할 수 있는 기능을 원했습니다. 길디드(Guilded)에서 스태프에게 적용되는 것을 본 적이 있는데, 제가 원했지만 아직 사용할 수 없었던 기능이었죠. 디스코urses를 좋아하게 된 또 다른 이유는, 개발자가 추가하기를 바라면서 기다리는 대신, 실제로 작동할 수 있는 것을 직접 조립해 볼 수 있다는 점입니다.
그래서 다음과 같은 해결책을 직접 만들어 보았습니다. 이 방식은 완벽하지 않으며, 업로드하는 SVG에 svg로 시작하는 SCSS 변수가 필요할 가능성이 높지만, 지금은 저에게 충분히 잘 작동하는 것 같습니다
누군가 이 코드를 가져가서 더 발전시키거나, 더 화려하게 개선한다면 감사하겠습니다!
개선할 수 있는 부분
모든 SVG 아이콘에서 작동하도록 만들기: 즉, svg로 시작하지 않는 디스코urses의 모든 아이콘과 업로드된 아이콘 모두에서 작동하도록 하는 것.
코드 정리.
스타일링 개선: CSS를 작동하도록 직접 조립한 것이므로 모든 상황에서 작동하지 않을 수 있습니다.
어쨌든, 감정적 자기방어(Emotional Self-Defense)를 위한 사용자 정의 아이콘을 스태프 멘션 아이콘으로 사용한 멘션의 예시는 다음과 같습니다:
제가 추가한 코드는 다음과 같습니다:
header.html
// SVG 아이콘을 옵션으로 추가 (assets에 포함되어 있고 업로드된 경우에만)
// 모든 assets의 객체를 생성하고, data-emoji 속성이 asset 변수 이름과 일치하는 링크를 찾아 해당 URL을 추가
// 객체를 키 배열로 변환
const keys = Object.keys(settings.theme_uploads);
// 모든 키 출력
console.log(keys);
// 객체 반복
keys.forEach((key, index) => {
console.log(`${key}: ${settings.theme_uploads[key]}`);
api.decorateCooked($elem => {
var url = settings.theme_uploads[key];
console.log("key: " + key);
console.log("index: " + index);
console.log("url: " + url);
console.log(JSON.stringify(settings.theme_uploads));
$elem
.find("a[data-emoji^='" + key + "']")
.css("--svg-icon", "url('" + url + "')");
}
);
});
Github 링크는 Discourse 저장소로 리디렉션되며, all-the-themes 저장소의 official.txt 파일에 목록에 포함되어 있습니다. OP(원문)의 링크를 업데이트할 수 있을까요? 그렇게 하면 해당 저장소의 update_from_meta 스크립트가 이 컴포넌트를 공식 컴포넌트라고 인식할 수 있고, third-party 파일에 추가하려는 시도를 하지 않을 것입니다. 이 컴포넌트는 이전 업데이트에서 실수로 추가된 후 12월에 third-party.txt에서 제거되었습니다. 저장소 URL을 변경하면 이러한 문제가 다시 발생하는 것을 방지할 수 있을 것입니다.
추가로, official 태그와 공식 컴포넌트의 일반적인 요소를 갖춘 첫 번째 게시물이 있으면 좋겠습니다.