ckEditor5踩坑(1)

1.插入媒体

const config = {
 mediaEmbed: {
    previewsInData: true,
    providers: [
      {
        // A URL regexp or an array of URL regexps:
        // url: /^example\.com\/media\/(\w+)/,
        name: 'allow-all',
        url: /^.+/,    //适配所有url
        html: match => {
          // Array.prototype.slice.call(match)
          // console.log(match)
          // console.log(match['input'])
          const id = match['input']
          // match.map(item => {
          //   console.log(item)
          // })
          // console.log(id)
          return (
            '<div style="position: relative; padding-bottom: 100%; height: 0; padding-bottom: 30%;">' +
              `<iframe src="${id}" ` +
                'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" ' +
                'frameborder="0" allowtransparency="true" allow="encrypted-media"' + 'allow="autoplay; encrypted-media">' +
              '</iframe>' +
            '</div>'
          )
        }
      }
    ]
  },
}

2.插入超链接

const config = {
  link: {
    addTargetToExternalLinks: true
  }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容