packages/embed-plugin-utilities/src/insert.js
async function saveEmbedData(opts, pluginOptions) {
  const { regex } = pluginOptions
  let options = extend({}, opts)

  if (isAnchorTagApplied(options, { regex })) {
    await stringReplaceAsync(
      options.result,
      anchorRegex,
      async (match, url, index) => {
        if (!isMatchPresent(regex, match, true)) return match
        saveServiceName(options, pluginOptions, match)
        options = await pushEmbedContent(url, options, pluginOptions, index)
        return match
      }
    )
  } else {
    options = pushEmbedContent(options.result, options, pluginOptions)
  }

  return options
}
async function saveEmbedData(opts, pluginOptions) {
  const { regex } = pluginOptions
  let options = extend({}, opts)

  if (isAnchorTagApplied(options, { regex })) {
    await stringReplaceAsync(
      options.result,
      anchorRegex,
      async (match, url, index) => {
        if (!isMatchPresent(regex, match, true)) return match
        saveServiceName(options, pluginOptions, match)
        options = await pushEmbedContent(url, options, pluginOptions, index)
        return match
      }
    )
  } else {
    options = pushEmbedContent(options.result, options, pluginOptions)
  }

  return options
}
async function saveEmbedData ( opts , pluginOptions ) { const { regex } = pluginOptions let options = extend ( { } , opts ) if ( isAnchorTagApplied ( options , { regex } ) ) { await stringReplaceAsync ( options . result , anchorRegex , async ( match , url , index ) => { if ( ! isMatchPresent ( regex , match , true ) ) return match saveServiceName ( options , pluginOptions , match ) options = await pushEmbedContent ( url , options , pluginOptions , index ) return match } ) } else { options = pushEmbedContent ( options . result , options , pluginOptions ) } return options }
Save the embed code into an array that can be added later to the end of original string
@param opts
@param pluginOptions
Save the embed code into an array that can be added later to the end of original string