mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
daa7f2e781
refs https://github.com/TryGhost/Team/issues/973 - added `@showCreate` option to `<GhInputWithSelect>` that enables the create option without having to pass a function in `@showCreateWhen` - fixed autofocus not focusing input element in `<GhInputWithSelect>` when `autofocus="true"` isn't enough by itself - updated `selectOrCreate` in `<GhInputWithSelect>` to trigger `onChange` if it's passed in rather than `onInput` - swapped input in labs snippet input to `<GhInputWithSelect>` - added actions for updating a snippet when an existing snippet is selected - added action to editor control for saving an updated snippet
120 lines
4.1 KiB
Handlebars
120 lines
4.1 KiB
Handlebars
<div class="koenig-editor__editor-wrapper" data-kg="editor-wrapper">
|
|
<div class="koenig-editor__editor" data-kg="editor"></div>
|
|
</div>
|
|
|
|
{{!-- pop-up markup toolbar is shown when there's a selection --}}
|
|
<KoenigToolbar
|
|
@editor={{this.editor}}
|
|
@editorRange={{this.selectedRange}}
|
|
@activeMarkupTagNames={{this.activeMarkupTagNames}}
|
|
@activeSectionTagNames={{this.activeSectionTagNames}}
|
|
@toggleMarkup={{action "toggleMarkup"}}
|
|
@toggleSection={{action "toggleSection"}}
|
|
@toggleHeaderSection={{action "toggleHeaderSection"}}
|
|
@editLink={{action "editLink"}}
|
|
@addSnippet={{this.addSnippetIfPossible}}
|
|
/>
|
|
|
|
{{!-- pop-up link hover toolbar --}}
|
|
<KoenigLinkToolbar
|
|
@editor={{this.editor}}
|
|
@container={{this.element}}
|
|
@linkRange={{this.linkRange}}
|
|
@selectedRange={{this.selectedRange}}
|
|
@editLink={{action "editLink"}}
|
|
/>
|
|
|
|
{{!-- pop-up link editing toolbar --}}
|
|
{{#if this.linkRange}}
|
|
<KoenigLinkInput
|
|
@editor={{this.editor}}
|
|
@linkRange={{this.linkRange}}
|
|
@linkRect={{this.linkRect}}
|
|
@selectedRange={{this.selectedRange}}
|
|
@cancel={{action "cancelEditLink"}}
|
|
/>
|
|
{{/if}}
|
|
|
|
{{!-- pop-up snippet editing toolbar --}}
|
|
{{#if this.snippetRange}}
|
|
{{#if (feature "snippetReplacements")}}
|
|
<KoenigSnippetInputLabs
|
|
@editor={{this.editor}}
|
|
@snippetRange={{this.snippetRange}}
|
|
@snippetRect={{this.snippetRect}}
|
|
@snippets={{@snippets}}
|
|
@save={{@saveSnippet}}
|
|
@update={{@updateSnippet}}
|
|
@cancel={{this.cancelAddSnippet}}
|
|
/>
|
|
{{else}}
|
|
<KoenigSnippetInput
|
|
@editor={{this.editor}}
|
|
@snippetRange={{this.snippetRange}}
|
|
@snippetRect={{this.snippetRect}}
|
|
@save={{@saveSnippet}}
|
|
@cancel={{this.cancelAddSnippet}}
|
|
/>
|
|
{{/if}}
|
|
{{/if}}
|
|
|
|
{{!-- (+) icon and pop-up menu --}}
|
|
<KoenigPlusMenu
|
|
@editor={{this.editor}}
|
|
@editorRange={{this.selectedRange}}
|
|
@snippets={{this.snippets}}
|
|
@deleteSnippet={{this.deleteSnippet}}
|
|
@replaceWithCardSection={{action "replaceWithCardSection"}}
|
|
@replaceWithPost={{action "replaceWithPost"}}
|
|
/>
|
|
|
|
{{!-- slash menu popup --}}
|
|
<KoenigSlashMenu
|
|
@editor={{this.editor}}
|
|
@editorRange={{this.selectedRange}}
|
|
@snippets={{this.snippets}}
|
|
@deleteSnippet={{this.deleteSnippet}}
|
|
@replaceWithCardSection={{action "replaceWithCardSection"}}
|
|
@replaceWithPost={{action "replaceWithPost"}}
|
|
/>
|
|
|
|
{{!-- all component cards wormholed into the editor canvas --}}
|
|
{{#each this.componentCards as |card|}}
|
|
{{#in-element card.destinationElement}}
|
|
{{component card.componentName
|
|
editor=this.editor
|
|
postModel=card.postModel
|
|
cardName=card.cardName
|
|
payload=card.payload
|
|
env=card.env
|
|
options=card.options
|
|
headerOffset=this.headerOffset
|
|
saveCard=(action card.env.save)
|
|
cancelCard=(action card.env.cancel)
|
|
removeCard=(action card.env.remove)
|
|
isSelected=card.isSelected
|
|
isEditing=card.isEditing
|
|
selectCard=(action "selectCard" card)
|
|
deselectCard=(action "deselectCard" card)
|
|
editCard=(action "editCard" card)
|
|
deleteCard=(action "deleteCard" card)
|
|
saveAsSnippet=(if this.saveCardAsSnippetIfPossible (fn this.saveCardAsSnippetIfPossible card))
|
|
moveCursorToPrevSection=(action "moveCursorToPrevSection" card)
|
|
moveCursorToNextSection=(action "moveCursorToNextSection" card)
|
|
addParagraphAfterCard=(action "addParagraphAfterCard" card)
|
|
registerComponent=(action (mut card.component))
|
|
}}
|
|
{{/in-element}}
|
|
{{/each}}
|
|
|
|
{{!-- all component atoms wormholed into the editor canvas --}}
|
|
{{#each this.componentAtoms as |atom|}}
|
|
{{#in-element atom.destinationElement}}
|
|
{{component atom.componentName
|
|
editor=this.editor
|
|
atom=atom
|
|
saveAtom=(fn atom.env.save atom.env.value atom.env.payload)
|
|
registerComponent=(action (mut atom.component))
|
|
}}
|
|
{{/in-element}}
|
|
{{/each}} |