-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0547509
commit 6ea4916
Showing
4 changed files
with
60 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/editor-view/properties/editors/string/text-property-editor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { InspectorPropertyModel } from 'data/inspector-data'; | ||
import { PropertyEditor } from '../property-editor'; | ||
|
||
export class TextPropertyEditor extends PropertyEditor<string> { | ||
public static readonly tagName: string = 'phred-text-property-editor'; | ||
private input: HTMLTextAreaElement; | ||
|
||
protected createInnerContent(fieldId: string, _value: string, prop: InspectorPropertyModel) { | ||
const input = this.input = document.createElement('textarea'); | ||
input.id = fieldId; | ||
input.onkeydown = e => { | ||
if (e.ctrlKey && e.code === 'Enter') { | ||
e.preventDefault(); | ||
this.dispatchEvent(new Event('change')); | ||
} | ||
}; | ||
if (prop.data) Object.keys(prop.data).forEach(p => input.setAttribute(p, prop.data[p])); | ||
return input; | ||
} | ||
|
||
public setInternalValue(value: string) { | ||
value = value ?? ''; | ||
this._internalValue = value; | ||
this.input.value = value; | ||
} | ||
|
||
public updateInternalValue(): string { | ||
const value = this.input.value || ''; | ||
this._internalValue = value; | ||
return value; | ||
} | ||
} | ||
|
||
customElements.define(TextPropertyEditor.tagName, TextPropertyEditor); |