Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

2.4 KB
Raw Blame
{{ define "campaign-content" -}}
{{- $root := .Root -}}
{{- $c := $root.Data.Campaign -}}
{{- $canManage := .CanManage -}}
{{- $canSend := .CanSend -}}
<div class="page-content content editor">
	<fieldset class="card editor-box">
		<!-- <legend>{{ $root.L.T "globals.fields.content" }}</legend> -->
		<div class="editor-body" :class="{ 'is-loading': showEditorSpinner }" @editor-ready="editorReady = true" @campaign-save.window="onSave" @campaign-preview.window="onPreviewContent" @richtext-media="onEditorMedia($event)" @richtext-attachment="onPasteAttachment($event.detail)" @visual-media="onEditorMedia($event)" @editor-change="form.body = $event.detail.body; form.body_source = $event.detail.source">
			<template x-if="contentReady && form.content_type === 'richtext'">
				{{ template "richtext-editor" dict "Root" $root "Body" $c.Body "Attachments" true "Disabled" (not (or (eq $c.Status "draft") (eq $c.Status "scheduled") (eq $c.Status "paused"))) }}
			</template>
			<template x-if="contentReady && form.content_type === 'html'">
				<code-editor lang="html" @input="form.body = $event.target.value"><textarea>{{ $c.Body }}</textarea></code-editor>
			</template>
			<template x-if="contentReady && form.content_type === 'markdown'">
				<code-editor lang="markdown" @input="form.body = $event.target.value"><textarea>{{ $c.Body }}</textarea></code-editor>
			</template>
			<template x-if="contentReady && form.content_type === 'plain'">
				<textarea class="plain-editor m-0" name="content" x-model="form.body" :disabled="!canEdit"></textarea>
			</template>
			<template x-if="contentReady && form.content_type === 'visual'">
				<visual-editor base="{{ URI "/admin/static/email-builder" }}" @editor-change="form.body = $event.detail.body; form.body_source = $event.detail.source"><textarea>{{ $c.BodySource.String }}</textarea></visual-editor>
			</template>
		</div>
	</fieldset>

	<template x-if="canEdit && form.content_type !== 'plain'">
		<fieldset class="card">
			<legend>{{ $root.L.T "campaigns.addAltText" }}</legend>
			<input type="checkbox" role="switch" :checked="form.altbody !== null" @change="$event.target.checked ? onAddAltBody() : onRemoveAltBody()" :disabled="!canEdit" />

			<template x-if="form.altbody !== null">
				<div data-field>
					<textarea rows="10" aria-label="{{ $root.L.T "campaigns.addAltText" }}" x-model="form.altbody" :disabled="!canEdit"></textarea>
				</div>
			</template>
		</fieldset>
	</template>
</div>
{{- end }}