컴포저 뷰에서 조리된 아이템을 장식하지 않나요?

사용자가 사용자 정의 사용자 필드에서 지정하는 키워드가 포함된 게시글을 차단하는 테마 컴포넌트를 개발 중입니다.

차단/표시 기능은 정상적으로 작동하지만, 작성자 뷰에서 타이핑할 때 미리보기 영역에도 적용되고 있습니다. 작성자 미리보기에서 api.decorateCookedElement가 실행되지 않도록 막을 수 있는 방법이 있을까요? 아래는 현재까지 정상적으로 작동하는 코드입니다.

<script type="text/discourse-plugin" version="0.8">
let currentUser = api.getCurrentUser();

if (currentUser) {
    api.container.lookup('store:main').find('user', currentUser.username).then((user) => {
        let blocklist = user.user_fields[1];

        const blocked = blocklist.split(",").map(function(item) {
            return item.trim();
        });
        
        api.decorateCookedElement(
            elem => {
                let textContent = elem.textContent;
                let result = "";
                if (blocked.find(text => textContent.includes(text))) {
                    const found = blocked.filter(text => textContent.includes(text));
                    if (found.length >= 2) {
                        const last = found.pop();
                        result = found.join(', ') + ' and ' + last;
                    } else {
                        result = found.join(', ');
                    }
                    const children = elem.childNodes;
                    const newNode = document.createElement("a");
                    const textNode = document.createTextNode("Blocked for containing " + result + ".");
                    newNode.classList.add("block-notice")
                    newNode.appendChild(textNode);
                    newNode.onclick = function() { showComment(this); };
                    
                    elem.insertBefore(newNode, elem.children[0]);
                    for (let index = 0; index < children.length; ++index) {
                        children[index].classList.add("blocker-blocked")
                    }
                    newNode.classList.remove("blocker-blocked");
                }
            },
            {"id": "blocker-blocked"}
        );
        
    });
}

function showComment(elem) {
    const cooked = elem.parentNode;
    elem.remove();
    const children = cooked.childNodes;
    for (let index = 0; index < children.length; ++index) {
        children[index].classList.remove("blocker-blocked")
    }
}
</script>

안녕하세요,

onlyStream을 추가하면 됩니다. 다른 토픽에서 가져온 예시를 보여드릴게요. :slightly_smiling_face:

완벽합니다, 링크 감사합니다!