0.5.1 • Published 11 months ago

@acrodata/code-editor v0.5.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Code Editor

npm license

CodeMirror 6 wrapper for Angular

Quick links

Documentation | Playground

Installation

npm install @acrodata/code-editor --save

Usage

Code Editor

import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { CodeEditor } from '@acrodata/code-editor';

@Component({
  selector: 'your-app',
  template: `<code-editor [(ngModel)]="value" />`,
  standalone: true,
  imports: [FormsModule, CodeEditor],
})
export class YourAppComponent {
  value = `console.log("Hello world")`;
}

Diff Editor

import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { DiffEditor } from '@acrodata/code-editor';

@Component({
  selector: 'your-app',
  template: `<diff-editor [(ngModel)]="value" />`,
  standalone: true,
  imports: [FormsModule, DiffEditor],
})
export class YourAppComponent {
  value = {
    original: `bar`;
    modified: `foo`;
  }
}

API

Code Editor

NameTypeDefaultDescription
valuestring''The editor's value.
rootDocument | ShadowRootundefinedEditorView's root.
autoFocusbooleanfalseWhether focus on the editor after init.
disabledbooleanfalseWhether the editor is disabled.
readonlybooleanfalseWhether the editor is readonly.
themeThemelightThe editor's theme.
placeholderstring''The editor's placecholder.
indentWithTabbooleanfalseWhether indent with Tab key.
indentUnitstring''Should be a string consisting either entirely of the same whitespace character.
lineWrappingbooleanfalseWhether the editor wraps lines.
highlightWhitespacebooleanfalseWhether highlight the whitespace.
languagesLanguageDescription[][]An array of language descriptions for known language-data.
languagestring''The editor's language. You should set the languages prop at first.
setupSetup'basic'The editor's built-in setup. The value can be set to basic, minimal or null.
extensionsExtension[][]It will be appended to the root extensions.
(change)EventEmitter-Event emitted when the editor's value changes.
(focus)EventEmitter-Event emitted when focus on the editor.
(blur)EventEmitter-Event emitted when the editor has lost focus.

Diff Editor

NameTypeDefaultDescription
setupSetup'basic'The editor's built-in setup. The value can be set to basic, minimal or null.
originalValuestring''The diff-editor's original value.
originalExtensionsExtension[][]The MergeView original config's extensions.
modifiedValuestring''The diff-editor's modified value.
modifiedExtensionsExtension[][]The MergeView modified config's extensions.
orientationOrientationundefinedControls whether editor A or editor B is shown first. Defaults to "a-b".
revertControlsRevertControlsundefinedControls whether revert controls are shown between changed chunks.
renderRevertControlRenderRevertControlundefinedWhen given, this function is called to render the button to revert a chunk.
highlightChangesbooleantrueBy default, the merge view will mark inserted and deleted text in changed chunks.
gutterbooleantrueControls whether a gutter marker is shown next to changed lines.
disabledbooleanfalseWhether the diff-editor is disabled.
collapseUnchanged{ margin?: number; minSize?: number }undefinedWhen given, long stretches of unchanged text are collapsed.
diffConfigDiffConfigundefinedPass options to the diff algorithm.
(originalValueChange)EventEmitter-Event emitted when the editor's original value changes.
(originalFocus)EventEmitter-Event emitted when focus on the original editor.
(originalBlur)EventEmitter-Event emitted when blur on the original editor.
(modifiedValueChange)EventEmitter-Event emitted when the editor's modified value changes.
(modifiedFocus)EventEmitter-Event emitted when focus on the modified editor.
(modifiedBlur)EventEmitter-Event emitted when blur on the modified editor.

License

MIT