当使用 Custom Wizards 插件创建页面时,我想复制插件提供的变量的输出。因此,我们可以将其视为消息内容中随机选择的区域。我可以为要复制的内容分配自定义 CSS 选择器。
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 div 中的最后一个 p 标签或倒数第二个 p 标签,而不是整个 cooked。如果可能的话,我想单独定位它们,并将复制图标放在段落旁边。