Coder Social home page Coder Social logo

wangeditor-plugin-link-card's People

Contributors

wangfupeng1988 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

wangeditor-plugin-link-card's Issues

请问作者大大 parseElemsHtml如果需要异步返回 应该怎么做呢?

我需求在第二次打开编辑框的时候 还原链接到卡片状态
我在保存的时候 不是保存的卡片dom 而是保存的是a标签

// elem-to-html.ts
const html = `<div data-w-e-type="link-card" data-linkText="${linkText}" data-url="${url}"><a href="${url}" target="_blank">${linkText}</a></div>`
return html

在第二次打开的时候重新请求接口还原卡片状态

// parse-elem-html.ts

const parseHtml = (
  elem: DOMElement,
): SlateElement => {
  const linkText = elem.getAttribute('data-linkText') || ''
  const url = elem.getAttribute('data-url') || ''

  let str = {
    url,
    "reqTime": Date.now()
  }
  cardInfo(str).then((res: any) => {
    return {
      type: 'link-card',
      linkText,
      url,
      cardData: res,
      children: [{ text: '' }], // void node 必须有一个空白 text
    } as LinkCardElement
  }).catch(res => {
    return {
      type: 'link-card',
      linkText,
      url,
      cardData: undefined,
      children: [{ text: '' }], // void node 必须有一个空白 text
    } as LinkCardElement
  })
}

我这么做会有异步问题 请问我应该怎么处理这个异步问题?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.