open-vault/ui/app/templates/components/json-editor.hbs
Arnav Palnitkar 1d26f056bc
Updated code mirror component for consistency (#11500)
* Updated code mirror component for consistency

- Hide gutters, line number and selection while read only
- Show toolbar with copy functionality for all instances

* Moved toolbar and actions to json editor component

* Updated form-field-from-model template

* Added test for toolbar
2021-05-06 09:59:15 -07:00

32 lines
1.1 KiB
Handlebars

{{#if showToolbar }}
<div data-test-component="json-editor-toolbar">
<Toolbar>
<label class="is-label" data-test-component="json-editor-title">
{{title}}
{{#if subTitle }}
<span class="is-size-9 is-lowercase has-text-grey">({{ subTitle }})</span>
{{/if}}
</label>
<ToolbarActions>
{{yield}}
<div class="toolbar-separator"></div>
<CopyButton class="button is-transparent" @clipboardText={{value}}
@buttonType="button" @success={{action (set-flash-message 'Data copied!')}}>
<Icon @glyph="copy-action" aria-label="Copy" />
</CopyButton>
</ToolbarActions>
</Toolbar>
</div>
{{/if}}
{{ivy-codemirror
data-test-component="json-editor"
value=value
options=options
valueUpdated=(action "updateValue")
onFocusOut=(action "onFocus")
}}
{{#if helpText }}
<div class="box is-shadowless is-fullwidth has-short-padding">
<p class="sub-text">{{ helpText }}</p>
</div>
{{/if}}