Creates an instance of UmbCodeEditor. You should instantiate this class through the UmbCodeEditorHost
interface and that should happen when inside DOM nodes of the host container are available, otherwise the editor will not be able to initialize, for example in lit firstUpdated
lifecycle hook. It will make host emit change and input events when the value of the editor changes.
Optional
options: CodeEditorConstructorOptionsThe monaco editor object. This is the actual monaco editor object. It is exposed for advanced usage, but mind the fact that editor might be swapped in the future for a different library, so use on your own responsibility. For more information see monaco editor API.
Provides the current model of the editor. For advanced usage. Bare in mind that in case of the monaco library being swapped in the future, this might not be available. For more information see monaco editor model API.
Provides the current position of the cursor.
Provides positions of all the secondary cursors.
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in ยง 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
Optional
options: boolean | AddEventListenerOptionsCallback method called when context is resolved.
Reference to the created Context Consumer Controller instance
Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Looks for a string or matching strings in the editor and returns the ranges of the found strings. Can use regex, case sensitive and more. If you want regex set the isRegex to true in the options.
Optional
searchOptions: CodeEditorSearchOptions = ...{UmbCodeEditorRange[]}
A Promise with the reference to the Context Api Instance
Provides the current positions of the cursor or multiple cursors.
{(UmbCodeEditorCursorPosition | null)}
Provides the current selections of the editor.
{UmbCodeEditorSelection[]}
Returns the value of the editor for a given range.
{string}
Inserts text at a given position.
An Observable to observe from.
Optional
callback: ObserverCallback<SpecificT>Callback method called when data is changed.
Optional
controllerAlias: null | UmbControllerAliasDefine an explicit controller alias. If not defined then one will be generated based on the callback function. If null is parsed no controller alias will be given.
Reference to the created Observer Controller instance.
Runs callback on change of cursor position. Gives as parameter the new position.
Runs callback on change of cursor selection. Gives as parameter the new selection.
The API instance to be exposed.
Reference to the created Context Provider Controller instance
Removes the event listener in target's event listener list with the same type, callback, and options.
Optional
options: boolean | EventListenerOptionsUpdates the options of the editor. This is useful for updating the options after the editor has been created.
This is a wrapper class for the monaco editor. It exposes some of the monaco editor API. It also handles the creation of the monaco editor. It allows access to the entire monaco editor object through
monacoEditor
property, but mind the fact that editor might be swapped in the future for a different library, so use on your own responsibility. Through the UmbCodeEditorHost interface it can be used in a custom element. By using monaco library directly you can access the entire monaco API along with code completions, actions etc. This class creates some level of abstraction over the monaco editor. It only provides basic functionality, that should be enough for most of the use cases and should be possible to implement with any code editor library.Current issues: shadow DOM related issues #3217 currently fixed by a hack , razor syntax highlight UmbCodeEditor