Skip to content

[QUESTION] How can i save a selected component in editor to database and use it for the next time? #4390

Answered by artf
trandoancuong195 asked this question in Q&A
Discussion options

You must be logged in to vote

Probably the best approach would be to store the component as JSON

const cmpJson = JSON.parse(JSON.stringify(editor.getSelected()));
// ...save the component

and reuse it later in a block

// ...load the saved component
editor.Blocks.add('saved-component-ID', {
    label: 'Saved component',
    content: cmpJson,
});

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@trandoancuong195
Comment options

Answer selected by trandoancuong195
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants