使用 api.onToolbarCreate 添加图片标签

如果我在 api.onToolbarCreate 中有以下内容:

perform: (e) => {
  e.applySurround(
    `[wrap="Carousel" autoplay=${settings.autoplay}]\n`,
    "\n[/wrap]",
    "image_carousel_placeholder"
  );
}

并且我的 image_carousel_placeholder 设置如下:

image_carousel_placeholder:
  type: upload
  default: "placeholder_image"

它会添加图像的 URL,而不是 <img> 标签或 markdown ![] 等效项。我该如何处理?我想避免将设置作为字符串输入实际的 <img> 标签。这可能吗?

我真傻。我完全错过了上面那行 I18n.translations[currentLocale].js.composer.image_carousel_placeholder
现在:

I18n.translations[currentLocale].js.composer.image_carousel_placeholder = `\u003cimg src=\"${settings.image_carousel_placeholder}\" height=\"200\" width=\"300\" /\u003e`;

这样效果多了。

1 个赞