복사 아이콘으로 콘텐츠 복사

Custom Wizards 플러그인을 사용하여 페이지를 만들 때, 플러그인이 제공하는 변수들의 출력을 복사하고 싶습니다. 이를 메시지 내용 내에서 무작위로 선택된 영역이라고 생각할 수 있습니다. 복사할 콘텐츠에 사용자 정의 CSS 선택자를 지정할 수 있습니다.

https://github.com/keegangeorge/discourse-copy-post/blob/main/javascripts/discourse/widgets/copy-widget.js

  click(attrs) {
    const copyButton = attrs.currentTarget.activeElement;
    const rawCooked = this.attrs.attrs.cooked;
    const cookedText = this.attrs.attrs.cooked.replace(/<p>(.*)<\/p>/g, "$1\n");
    let postContents = cookedText.replace(/(<([^>]+)>)/gi, "");

    if (settings.copy_raw_html) {
      postContents = rawCooked;
    }

const rawCooked = this.attrs.attrs.cooked;

선택자가 여기에 있습니다. 전체 cooked 대신 cooked div 내의 마지막 p 태그 또는 그 직전 p 태그를 대상으로 하고 싶습니다. 가능하다면 각각을 개별적으로 대상으로 지정하고, 복사 아이콘을 해당 문단 바로 옆에 배치하고 싶습니다.