Skip to content

Commit

Permalink
Can now change schema for current document
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew MacDonald committed Mar 31, 2015
1 parent e78274b commit cb4e9ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/js/dialogs/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ return function(writer, config) {
}
settings.showStructBrackets = $('#showstructbrackets').prop('checked');

// TODO add handling for schemaChanged
w.schemaManager.schemaId = $('select[name="schema"]', $settingsDialog).val();
w.event('schemaChanged').publish(w.schemaManager.schemaId);
var schemaId = $('select[name="schema"]', $settingsDialog).val();

w.event('schemaChanged').publish(schemaId);

var styles = {
fontSize: settings.fontSize,
Expand Down
4 changes: 4 additions & 0 deletions src/js/modules/structureTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ return function(config) {
});
treeRef.delete_node('#cwrc_tree_root');
var rootNode = $('[_tag="'+w.root+'"]', w.editor.getBody());
if (rootNode.length === 0) {
// fallback if schema/root has changed
rootNode = $('[_tag]', w.editor.getBody()).first();
}
var rootData = _processNode(rootNode, 0);
if (rootData != null) {
rootData.li_attr.id = 'cwrc_tree_root';
Expand Down
5 changes: 5 additions & 0 deletions src/js/schema/schemaManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ return function(writer, config) {
}
};

w.event('schemaChanged').subscribe(function(schemaId) {
w.schemaManager.schemaId = schemaId;
w.schemaManager.loadSchema(schemaId, false, true, function() {});
});

return sm;
};

Expand Down

0 comments on commit cb4e9ba

Please sign in to comment.