{% import '_includes/forms.twig' as forms %} {% import 'codeeditor/codeEditor.twig' as codeEditor %} {% set readOnly = readOnly ?? false %} {% set baseMonacoOptions = { tabSize: 2, showUnused: false, } %} {% if readOnly %} {% set baseMonacoOptions = baseMonacoOptions|merge({ domReadOnly: true, readOnly: true }) %} {% endif %} {% set wrapperClasses = ['monaco-editor-background-frame'] %} {% set baseCodeEditorOptions = {} %} {% embed '_includes/forms/field.twig' with { label: 'Toolbar'|t('ckeditor'), instructions: 'Drag toolbar items into the editor.'|t('ckeditor'), id: 'toolbar', field, errors: field.getErrors('toolbar'), data: {'error-key': 'toolbar'}, } %} {% block input %}
{{ hiddenInput('toolbar', field.toolbar|json_encode) }}
{% endblock %} {% endembed %} {{ forms.field({ label: 'Entry Types'|t('app'), instructions: 'Choose the types of entries that can be created in this field.'|t('app'), id: 'entry-types', name: 'entryTypes[]', values: field.getEntryTypes(), allowOverrides: true, create: true, sortable: true, errors: field.getErrors('entryTypes'), data: {'error-key': 'entryTypes'}, disabled: readOnly, }, 'template:ckeditor/_entry-type-select.twig') }} {{ forms.checkboxSelectField({ label: 'Heading Levels'|t('ckeditor'), instructions: 'Choose which heading levels should be available to this field.'|t('ckeditor'), id: 'heading-levels', name: 'headingLevels', options: [ {label: 'Heading {level}'|t('ckeditor', {level: 1}), value: '1'}, {label: 'Heading {level}'|t('ckeditor', {level: 2}), value: '2'}, {label: 'Heading {level}'|t('ckeditor', {level: 3}), value: '3'}, {label: 'Heading {level}'|t('ckeditor', {level: 4}), value: '4'}, {label: 'Heading {level}'|t('ckeditor', {level: 5}), value: '5'}, {label: 'Heading {level}'|t('ckeditor', {level: 6}), value: '6'}, ], values: field.headingLevels, disabled: readOnly, }) }} {{ forms.checkboxSelectField({ label: 'Advanced Link Fields'|t('ckeditor'), id: 'advanced-link-fields', name: 'advancedLinkFields', showAllOption: false, options: advanceLinkOptions, values: field.advancedLinkFields, sortable: true, disabled: readOnly, }) }} {% embed '_includes/forms/field' with { label: 'Field Limit'|t('app'), instructions: "The maximum number of words or characters the field is allowed to have."|t('ckeditor'), id: 'field-limit', errors: field.getErrors(field.wordLimit ? 'wordLimit' : 'characterLimit') } %} {% import "_includes/forms" as forms %} {% block input %}
{{ forms.text({ id: 'fieldLimit', name: 'fieldLimit', value: field.wordLimit ?? field.characterLimit, size: 3, disabled: readOnly, }) }} {{ forms.select({ id: 'limitUnit', name: 'limitUnit', options: [ { value: 'words', label: 'Words'|t('ckeditor') }, { value: 'chars', label: 'Characters'|t('app') }, ], value: field.characterLimit ? 'chars' : 'words', disabled: readOnly, }) }}
{% endblock %} {% endembed %} {{ forms.lightswitchField({ id: 'show-word-count', name: 'showWordCount', label: 'Show word count'|t('ckeditor'), on: field.showWordCount, disabled: readOnly, }) }}
{{ 'Assets'|t('app') }}
{{ "Advanced"|t('ckeditor') }} {% if not readOnly %} {% js %} (() => { new Craft.AssetsFieldSettings( null, {{ 'availableVolumes'|namespaceInputId|json_encode|raw }}, {{ 'default-upload-location-volume'|namespaceInputId|json_encode|raw }}, null, ); const $volumeSelect = $("#{{ 'default-upload-location-volume'|namespaceInputId }}"); const $subpathContainer = $("#{{ 'default-upload-location-subpath-container'|namespaceInputId }}"); $volumeSelect.on('change', () => { $subpathContainer.toggleClass('hidden', !$volumeSelect.val()); }); })(); {% endjs %} {% script with {type: 'module'} %} const $select = $("#{{ 'entry-types'|namespaceInputId }}"); // the entry type select gets instantiated asynchronously const entryTypeSelect = await (() => { return new Promise(resolve => { const interval = setInterval(() => { const entryTypeSelect = $select.data('componentSelect'); if (entryTypeSelect) { clearInterval(interval); resolve(entryTypeSelect); } }, 100); }); })(); const updateImageField = () => { const entryTypes = Object.values(Garnish.getPostData(entryTypeSelect.$container)); Craft.sendActionRequest('POST', 'ckeditor/field-settings/render-image-field', { data: { namespace: {{ view.getNamespace()|json_encode|raw }}, entryTypes, value: $("#{{ 'image-field'|namespaceInputId }}").val(), }, }).then(({data}) => { $("#{{ 'image-field-field'|namespaceInputId }}").replaceWith(data.html); }); }; entryTypeSelect.on('change', () => updateImageField()); entryTypeSelect.on('applySettings', () => updateImageField()); {% endscript %} {% endif %}