本文整理汇总了TypeScript中brace.edit函数的典型用法代码示例。如果您正苦于以下问题:TypeScript edit函数的具体用法?TypeScript edit怎么用?TypeScript edit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edit函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1:
response.text().then(text => {
this.scriptContainer.nativeElement.innerHTML = text;
this.editor = ace.edit(this.scriptContainer.nativeElement);
this.editor.setReadOnly(true);
this.editor.getSession().setMode('ace/mode/javascript');
this.changeDetector.detectChanges();
});
开发者ID:m-sc,项目名称:yamcs,代码行数:7,代码来源:ScriptViewer.ts
示例2: function
link: function (scope, element, attrs, ctrl) {
const editor = ace.edit('json-editor');
editor.getSession().setMode('ace/mode/json');
editor.setTheme('ace/theme/dawn');
editor.setShowPrintMargin(false);
timesketchApi.getCurrentQuery(scope.sketchId, scope.query, scope.filter, scope.queryDsl)
.success(function (data) {
let currentQueryDsl = data['objects'][0];
// If there is no current query create a generic query.
if (!currentQueryDsl) {
currentQueryDsl = {
'query': {
'filtered': {
'query': {
'query_string': {
'query': scope.query}}}},
'sort': {
'datetime': 'asc'},
};
}
scope.queryDsl = currentQueryDsl;
editor.setValue(JSON.stringify(currentQueryDsl, null, '\t'), -1);
editor.focus();
});
scope.executeQuery = function () {
scope.queryDsl = editor.getValue();
ctrl.search(scope.query, scope.filter, scope.queryDsl);
};
scope.clearEditor = function () {
scope.queryDsl = '';
editor.setValue('');
};
},
开发者ID:Onager,项目名称:timesketch,代码行数:36,代码来源:json-editor.directive.ts
示例3: link
function link(scope: any, elem: any, attrs: any) {
// Options
const langMode = attrs.mode || DEFAULT_MODE;
const maxLines = attrs.maxLines || DEFAULT_MAX_LINES;
const showGutter = attrs.showGutter !== undefined;
const tabSize = attrs.tabSize || DEFAULT_TAB_SIZE;
const behavioursEnabled = attrs.behavioursEnabled ? attrs.behavioursEnabled === 'true' : DEFAULT_BEHAVIORS;
const snippetsEnabled = attrs.snippetsEnabled ? attrs.snippetsEnabled === 'true' : DEFAULT_SNIPPETS;
// Initialize editor
const aceElem = elem.get(0);
const codeEditor = ace.edit(aceElem);
const editorSession = codeEditor.getSession();
const editorOptions = {
maxLines: maxLines,
showGutter: showGutter,
tabSize: tabSize,
behavioursEnabled: behavioursEnabled,
highlightActiveLine: false,
showPrintMargin: false,
autoScrollEditorIntoView: true, // this is needed if editor is inside scrollable page
};
// Set options
codeEditor.setOptions(editorOptions);
// disable depreacation warning
codeEditor.$blockScrolling = Infinity;
// Padding hacks
(codeEditor.renderer as any).setScrollMargin(10, 10);
codeEditor.renderer.setPadding(10);
setThemeMode();
setLangMode(langMode);
setEditorContent(scope.content);
// Add classes
elem.addClass('gf-code-editor');
const textarea = elem.find('textarea');
textarea.addClass('gf-form-input');
if (scope.codeEditorFocus) {
setTimeout(() => {
textarea.focus();
const domEl = textarea[0];
if (domEl.setSelectionRange) {
const pos = textarea.val().length * 2;
domEl.setSelectionRange(pos, pos);
}
}, 100);
}
// Event handlers
editorSession.on('change', e => {
scope.$apply(() => {
const newValue = codeEditor.getValue();
scope.content = newValue;
});
});
// Sync with outer scope - update editor content if model has been changed from outside of directive.
scope.$watch('content', (newValue: any, oldValue: any) => {
const editorValue = codeEditor.getValue();
if (newValue !== editorValue && newValue !== oldValue) {
scope.$$postDigest(() => {
setEditorContent(newValue);
});
}
});
codeEditor.on('blur', () => {
scope.onChange();
});
scope.$on('$destroy', () => {
codeEditor.destroy();
});
// Keybindings
codeEditor.commands.addCommand({
name: 'executeQuery',
bindKey: { win: 'Ctrl-Enter', mac: 'Command-Enter' },
exec: () => {
scope.onChange();
},
});
function setLangMode(lang: string) {
ace.acequire('ace/ext/language_tools');
codeEditor.setOptions({
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
enableSnippets: snippetsEnabled,
});
if (scope.getCompleter()) {
// make copy of array as ace seems to share completers array between instances
const anyEditor = codeEditor as any;
anyEditor.completers = anyEditor.completers.slice();
anyEditor.completers.push(scope.getCompleter());
//.........这里部分代码省略.........
开发者ID:grafana,项目名称:grafana,代码行数:101,代码来源:code_editor.ts
注:本文中的brace.edit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论