Skip to content

Commit

Permalink
Update assets after render
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Sep 4, 2017
1 parent 0dfa656 commit efa3f19
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
16 changes: 16 additions & 0 deletions index.html
Expand Up @@ -1310,6 +1310,22 @@ <h1 class="heading">Insert title here</h1>
});
*/

var am = editor.AssetManager;

am.addType('svg-icon', {
// `value` is for example the argument passed in `am.add(VALUE);`
isType(value) {
// The condition is intentionally simple
if (value.substring(0, 5) == '<svg ') {
return {
type: 'svg-icon',
svgContent: value
};
}
}
})


// Store and load events
editor.on('storage:load', function(e) {
console.log('LOAD ', e);
Expand Down
9 changes: 7 additions & 2 deletions src/asset_manager/index.js
Expand Up @@ -233,6 +233,7 @@ module.exports = () => {
this.getAll().reset(assets);
}

this.lastLoad = assets;
return assets;
},

Expand Down Expand Up @@ -325,8 +326,12 @@ module.exports = () => {
postRender(editorView) {
c.dropzone && fu.initDropzone(editorView);

// Leave it here for custom types
assets.add(c.assets, {silent: 1});
// Reset assets for custom types
const last = this.lastLoad;
const assets = last.length ? last : c.assets;
const all = this.getAll();
all.reset();
all.add(assets, {silent: 1});
},

/**
Expand Down

0 comments on commit efa3f19

Please sign in to comment.