| 9 | |
| 10 | @customElement('code-editor') |
| 11 | export class CodeEditor extends LitElement { |
| 12 | @property({ |
| 13 | type: String, |
| 14 | }) |
| 15 | startText: Lazy<string>; |
| 16 | @property({ type: String }) copyText = 'Copy Manifest'; |
| 17 | @property({ type: String}) editorStateType: string = 'json'; |
| 18 | @property({ type: Boolean }) readOnly = false; |
| 19 | |
| 20 | @state() |
| 21 | editorState: Lazy<EditorState>; |
| 22 | |
| 23 | @state() editorView: Lazy<EditorView>; |
| 24 | |
| 25 | @state() editorId: string; |
| 26 | |
| 27 | @state() editorEmitter = emitter; |
| 28 | |
| 29 | @state() copied = false; |
| 30 | |
| 31 | protected static editorIdGenerator = increment(); |
| 32 | |
| 33 | static get styles() { |
| 34 | return [ |
| 35 | css` |
| 36 | |
| 37 | :host { |
| 38 | position: relative; |
| 39 | } |
| 40 | |
| 41 | sl-button::part(base) { |
| 42 | --sl-button-font-size-medium: 14px; |
| 43 | } |
| 44 | |
| 45 | #copy-block { |
| 46 | display: flex; |
| 47 | justify-content: flex-end; |
| 48 | margin-bottom: 10px; |
| 49 | position: sticky; |
| 50 | top: 0; |
| 51 | z-index: 1; |
| 52 | } |
| 53 | |
| 54 | .editor-container { |
| 55 | font-size: 14px; |
| 56 | } |
| 57 | `, |
| 58 | ]; |
| 59 | } |
| 60 | |
| 61 | constructor() { |
| 62 | super(); |
| 63 | |
| 64 | this.editorId = `editor-${CodeEditor.editorIdGenerator.next().value}`; |
| 65 | |
| 66 | this.editorEmitter.addEventListener( |
| 67 | CodeEditorEvents.sync, |
| 68 | (event: Event) => { |
nothing calls this directly
no test coverage detected