2020-01-16 18:14:03 +03:00
|
|
|
<KoenigCard
|
|
|
|
@tagName="figure"
|
|
|
|
@class={{concat (kg-style "media-card") " " (kg-style "breakout" size=this.payload.cardWidth) " flex flex-column"}}
|
|
|
|
@isSelected={{this.isSelected}}
|
|
|
|
@isEditing={{this.isEditing}}
|
|
|
|
@selectCard={{action this.selectCard}}
|
|
|
|
@deselectCard={{action this.deselectCard}}
|
|
|
|
@editCard={{action this.editCard}}
|
2020-10-21 14:16:04 +03:00
|
|
|
@saveAsSnippet={{this.saveAsSnippet}}
|
2020-01-16 18:14:03 +03:00
|
|
|
@toolbar={{this.toolbar}}
|
|
|
|
@hasEditMode={{false}}
|
|
|
|
@addParagraphAfterCard={{this.addParagraphAfterCard}}
|
|
|
|
@moveCursorToPrevSection={{this.moveCursorToPrevSection}}
|
|
|
|
@moveCursorToNextSection={{this.moveCursorToNextSection}}
|
|
|
|
@editor={{this.editor}}
|
2018-06-12 20:08:27 +03:00
|
|
|
as |card|
|
2020-01-16 18:14:03 +03:00
|
|
|
>
|
|
|
|
<GhUploader
|
|
|
|
@files={{this.files}}
|
|
|
|
@accept={{this.imageMimeTypes}}
|
|
|
|
@extensions={{this.imageExtensions}}
|
|
|
|
@onStart={{action "setPreviewSrc"}}
|
|
|
|
@onComplete={{action "updateSrc"}}
|
|
|
|
@onFailed={{action "resetSrcs"}}
|
2018-02-22 23:41:40 +03:00
|
|
|
as |uploader|
|
2020-01-16 18:14:03 +03:00
|
|
|
>
|
|
|
|
<div class="relative{{unless (or this.previewSrc this.payload.src) " bg-whitegrey-l2"}}">
|
|
|
|
{{#if (or this.previewSrc this.payload.src)}}
|
|
|
|
<img src={{or this.previewSrc this.payload.src}} class="{{kg-style this.kgImgStyle sidebar=this.ui.hasSideNav}}" alt={{this.payload.alt}}>
|
|
|
|
{{#if this.isDraggedOver}}
|
2018-06-20 14:34:30 +03:00
|
|
|
<div class="absolute absolute--fill flex items-center bg-black-60 pe-none">
|
|
|
|
<span class="db center sans-serif fw7 f7 white">
|
|
|
|
Drop to replace image
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
{{/if}}
|
2018-02-22 23:41:40 +03:00
|
|
|
{{/if}}
|
|
|
|
|
2020-01-16 18:14:03 +03:00
|
|
|
{{#if (or uploader.errors uploader.isUploading (not this.payload.src))}}
|
|
|
|
<div class="relative miw-100 flex items-center {{if (not this.previewSrc this.payload.src) "kg-media-placeholder ba b--whitegrey" "absolute absolute--fill bg-white-50"}}">
|
2018-02-22 23:41:40 +03:00
|
|
|
{{#if uploader.errors}}
|
|
|
|
<span class="db absolute top-0 right-0 left-0 pl2 pr2 bg-red white sans-serif f7">
|
|
|
|
{{uploader.errors.firstObject.message}}
|
|
|
|
</span>
|
|
|
|
{{/if}}
|
|
|
|
|
2020-01-16 18:14:03 +03:00
|
|
|
{{#if this.isDraggedOver}}
|
2018-06-20 14:34:30 +03:00
|
|
|
<span class="db center sans-serif fw7 f7 middarkgrey">
|
|
|
|
Drop it like it's hot 🔥
|
|
|
|
</span>
|
|
|
|
{{else if uploader.isUploading}}
|
2018-02-22 23:41:40 +03:00
|
|
|
{{uploader.progressBar}}
|
2020-01-16 18:14:03 +03:00
|
|
|
{{else if (not this.previewSrc this.payload.src)}}
|
2019-03-07 17:37:03 +03:00
|
|
|
<button class="flex flex-column items-center center sans-serif fw4 f7 middarkgrey pa16 pt14 pb14 kg-image-button" onclick={{action "triggerFileDialog"}}>
|
|
|
|
{{svg-jar this.placeholder class="kg-placeholder-image"}}
|
2018-06-11 14:28:37 +03:00
|
|
|
<span class="mt2 midgrey">Click to select an image</span>
|
2018-02-22 23:41:40 +03:00
|
|
|
</button>
|
|
|
|
{{/if}}
|
|
|
|
</div>
|
|
|
|
{{/if}}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div style="display:none">
|
2020-01-16 18:14:03 +03:00
|
|
|
<GhFileInput @multiple={{false}} @action={{uploader.setFiles}} @accept={{this.imageMimeTypes}} />
|
2018-02-22 23:41:40 +03:00
|
|
|
</div>
|
2020-01-16 18:14:03 +03:00
|
|
|
</GhUploader>
|
2018-02-22 23:41:40 +03:00
|
|
|
|
2020-01-16 18:14:03 +03:00
|
|
|
{{#if (or this.isSelected (clean-basic-html this.payload.caption))}}
|
2019-07-23 20:13:41 +03:00
|
|
|
{{#if this.isEditingAlt}}
|
2020-01-16 18:14:03 +03:00
|
|
|
<card.AltInput
|
2019-07-23 20:13:41 +03:00
|
|
|
@alt={{this.payload.alt}}
|
|
|
|
@update={{this.updateAlt}}
|
|
|
|
@placeholder="Type alt text for image (optional)" />
|
|
|
|
{{else}}
|
2020-01-16 18:14:03 +03:00
|
|
|
<card.CaptionInput
|
|
|
|
@caption={{this.payload.caption}}
|
2019-07-23 20:13:41 +03:00
|
|
|
@update={{this.updateCaption}}
|
|
|
|
@placeholder="Type caption for image (optional)" />
|
|
|
|
{{/if}}
|
|
|
|
|
2020-01-16 18:14:03 +03:00
|
|
|
{{#if this.isSelected}}
|
2019-07-23 20:13:41 +03:00
|
|
|
<button
|
|
|
|
title="Toggle between editing alt text and caption"
|
2020-08-27 16:21:11 +03:00
|
|
|
class="absolute right-0 bottom-0 ma2 pl1 pr1 ba br3 f8 sans-serif fw4 lh-title tracked-2 {{if this.isEditingAlt "bg-blue b--blue white" "bg-white b--midlightgrey midlightgrey"}}"
|
2019-07-23 20:13:41 +03:00
|
|
|
{{on "click" this.toggleAltEditing passive=true}}
|
|
|
|
>
|
|
|
|
Alt
|
|
|
|
</button>
|
|
|
|
{{/if}}
|
2018-02-22 23:41:40 +03:00
|
|
|
{{/if}}
|
2018-08-09 19:55:11 +03:00
|
|
|
|
2020-01-16 18:14:03 +03:00
|
|
|
{{#if this.imageSelector}}
|
|
|
|
{{component this.imageSelector
|
|
|
|
searchTerm=this.payload.searchTerm
|
2018-08-09 19:55:11 +03:00
|
|
|
select=(action "selectFromImageSelector")
|
|
|
|
close=(action "closeImageSelector")}}
|
|
|
|
{{/if}}
|
2020-01-16 18:14:03 +03:00
|
|
|
</KoenigCard>
|
2021-02-17 01:01:46 +03:00
|
|
|
|
|
|
|
{{#if this.isEditingLink}}
|
|
|
|
<KoenigLinkInput
|
|
|
|
@source="direct"
|
|
|
|
@href={{this.payload.href}}
|
|
|
|
@linkRect={{this.linkRect}}
|
|
|
|
@update={{action "updateHref"}}
|
|
|
|
@cancel={{action "cancelEditLink"}}
|
|
|
|
/>
|
|
|
|
{{/if}}
|