codex-team / codex-team/editor.js
How do I assign data from an Ajax request to data
- Dominant language
- TypeScript
- Stars
- 31.9k
- Forks
- 2.2k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
l just **tried** editor.js development, but **l can't assign data of the Editor**. I want to **assign the data from the Ajax request to data of the Editor**. How do I solve the problem of **asynchronous requests** The problem like this:
```
import { defineComponent, onMounted, ref } from 'vue';
import EditorJS from '@editorjs/editorjs';
import List from '@editorjs/list';
import Headers from '@editorjs/header/dist/bundle.js';
import axios from "axios";
import {message} from "ant-design-vue";
export default defineComponent({
name:'AdminEbook',
setup(){
const blocks=ref();
const handleQuery=async ()=>{
await axios.get("/blog/list",{
params:{
page:1,
size:10,
}
}).then((response)=>{
const data=response.data;
if(data.success) {
blocks.value=data.content.list;
//editor.blocks=blocks.value;
console.log("block::",editor)
}else {
message.error(data.message);
}
});
};
const editor=new EditorJS({
holder:'editorjs',
tools:{
header: {
class: Headers,
inlineToolbar: ['marker', 'link'],
config: {
placeholder: 'Header'
},
shortcut: 'CMD+SHIFT+H'
},
list: {
class: List,
inlineToolbar: true
}
},
data: blocks.value,
onReady:function (){
handleQuery();
console.log('bbbb',blocks.value);
},
onChange:function (api,event){
console.log('something changed',event);
}
})
onMounted(()=>{
handleQuery();
})
return {
editor,
handleQuery,
blocks
}
}
})
```
I would be **gratefu**l if you had **documentation** developed in conjunction with **Vue** and **editor.js**
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.