Support for multiple editors, reorder rules, and use replace all.
This commit is contained in:
parent
1d7c9220ee
commit
5708ef899e
1 changed files with 30 additions and 20 deletions
|
|
@ -297,14 +297,6 @@ var rules = {
|
|||
'meta': {
|
||||
prop: DEFAULT_PROP,
|
||||
replace: [
|
||||
{
|
||||
substr: '<',
|
||||
newSubstr: ' tag start '
|
||||
},
|
||||
{
|
||||
substr: '>',
|
||||
newSubstr: ' tag end '
|
||||
},
|
||||
{
|
||||
substr: '</',
|
||||
newSubstr: ' closing tag '
|
||||
|
|
@ -312,6 +304,14 @@ var rules = {
|
|||
{
|
||||
substr: '/>',
|
||||
newSubstr: ' close tag '
|
||||
},
|
||||
{
|
||||
substr: '<',
|
||||
newSubstr: ' tag start '
|
||||
},
|
||||
{
|
||||
substr: '>',
|
||||
newSubstr: ' tag end '
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -334,7 +334,8 @@ var expand = function(value, replaceRules) {
|
|||
var newValue = value;
|
||||
for (var i = 0; i < replaceRules.length; i++) {
|
||||
var replaceRule = replaceRules[i];
|
||||
newValue = newValue.replace(replaceRule.substr, replaceRule.newSubstr);
|
||||
var regexp = new RegExp(replaceRule.substr, 'g');
|
||||
newValue = newValue.replace(regexp, replaceRule.newSubstr);
|
||||
}
|
||||
return newValue;
|
||||
};
|
||||
|
|
@ -865,34 +866,43 @@ var SHORTCUTS = [
|
|||
}
|
||||
];
|
||||
|
||||
/**
|
||||
* Event handler for focus events.
|
||||
*/
|
||||
var onFocus = function() {
|
||||
cvoxAce.editor = editor;
|
||||
|
||||
/* Set up listeners. */
|
||||
editor.getSession().selection.on('changeCursor', onCursorChange);
|
||||
editor.getSession().on('change', onChange);
|
||||
editor.getSession().on('changeAnnotation', onAnnotationChange);
|
||||
editor.on('changeStatus', onChangeStatus);
|
||||
editor.on('findSearchBox', onFindSearchbox);
|
||||
editor.container.addEventListener('keydown', onKeyDown);
|
||||
|
||||
lastCursor = editor.selection.getCursor();
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize the theme.
|
||||
* @param {Object} editor Editor to use.
|
||||
*/
|
||||
var init = function(editor) {
|
||||
cvoxAce.editor = editor;
|
||||
lastCursor = editor.selection.getCursor();
|
||||
onFocus();
|
||||
|
||||
/* Construct maps. */
|
||||
SHORTCUTS.forEach(function(shortcut) {
|
||||
keyCodeToShortcutMap[shortcut.keyCode] = shortcut;
|
||||
cmdToShortcutMap[shortcut.cmd] = shortcut;
|
||||
});
|
||||
|
||||
/* Set up listeners. */
|
||||
cvoxAce.editor.getSession().selection.on('changeCursor', onCursorChange);
|
||||
cvoxAce.editor.getSession().on('change', onChange);
|
||||
cvoxAce.editor.getSession().on('changeAnnotation', onAnnotationChange);
|
||||
cvoxAce.editor.on('changeStatus', onChangeStatus);
|
||||
cvoxAce.editor.on('findSearchBox', onFindSearchbox);
|
||||
editor.container.addEventListener('keydown', onKeyDown);
|
||||
editor.on('focus', onFocus);
|
||||
|
||||
/* Assume we start in command mode if vim. */
|
||||
if (isVimMode()) {
|
||||
cvox.Api.setKeyEcho(false);
|
||||
}
|
||||
initContextMenu();
|
||||
|
||||
cvoxAce.editor.focus();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue