SW-Text-编辑器字段不以config字段为单位

发布于 2025-01-22 16:00:13 字数 1242 浏览 5 评论 0原文

我正在尝试将Wysiwyg字段添加给我的CMS元素作为配置字段的SW-Text-Edtior组件,但根本没有显示。如果我尝试一个SW-Text-Field而不是SW-Text-编辑器组件,则确实会显示。如果我缺少某些内容,我似乎在文档中找不到它。

我的代码: config/sw-cms-el-config-collapse.html.twig

{% block sw_cms_element_collapse_config %}
    <sw-text-editor
        v-model="blockContent"
        :allow-inline-data-mapping="true"
        sanitize-input
            @element-update="onElementUpdate">
    </sw-text-field>
{% endblock %}

config/index.js

import template from './sw-cms-el-config-collapse.html.twig';

Shopware.Component.register('sw-cms-el-config-collapse', {
    template,

    mixins: ['cms-element'],

    computed: {
        blockContent: {
            get() {
                return this.element.config.blockContent.value;
            },
            set(value) {
                this.element.config.blockContent.value = value;
            },
        },
    },

    created() {
        this.createdComponent();
    },

    methods: {
        createdComponent() {
            this.initElementConfig('s7-collapse');
        },

        onElementUpdate(element) {
            this.emitChanges(element);
        },
    },
});

I'm trying to add an wysiwyg field with the sw-text-edtior component for my cms-element as an config field, but it doesn't show up at all. If I try an sw-text-field instead of an sw-text-editor component it does show up. I can't seem to find it in the docs if I am missing something.

My code:
config/sw-cms-el-config-collapse.html.twig

{% block sw_cms_element_collapse_config %}
    <sw-text-editor
        v-model="blockContent"
        :allow-inline-data-mapping="true"
        sanitize-input
            @element-update="onElementUpdate">
    </sw-text-field>
{% endblock %}

config/index.js

import template from './sw-cms-el-config-collapse.html.twig';

Shopware.Component.register('sw-cms-el-config-collapse', {
    template,

    mixins: ['cms-element'],

    computed: {
        blockContent: {
            get() {
                return this.element.config.blockContent.value;
            },
            set(value) {
                this.element.config.blockContent.value = value;
            },
        },
    },

    created() {
        this.createdComponent();
    },

    methods: {
        createdComponent() {
            this.initElementConfig('s7-collapse');
        },

        onElementUpdate(element) {
            this.emitChanges(element);
        },
    },
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘香 2025-01-29 16:00:13

更改此信息:

<sw-text-editor
    v-model="blockContent"
    :allow-inline-data-mapping="true"
    sanitize-input
        @element-update="onElementUpdate">
</sw-text-field>

对此:

<sw-text-editor
    v-model="blockContent"
    :allow-inline-data-mapping="true"
    sanitize-input
        @element-update="onElementUpdate">
</sw-text-field>

您使用“ SW-Text-editor”的开放标签,但您可以使用“ SW-Text-Field”关闭。

或者您查看基本组件:
https://github.com/shopware/shopware/blob/ab564a66dbaa112dfa20099881a718a80813c482/src/Administration/Resources/app/administration/src/module/sw-cms/ elements/text/component/sw-cms-el-text.html.twig#l10

在这里:

<sw-text-editor
    v-else
    v-model:value="element.config.content.value"
    :disabled="disabled"
    :vertical-align="element.config.verticalAlign.value"
    :allow-inline-data-mapping="true"
    :is-inline-edit="true"
    sanitize-input
    sanitize-field-name="app_cms_block.template"
    enable-transparent-background
    @blur="onBlur"
    @update:value="onInput"
/>

Change this:

<sw-text-editor
    v-model="blockContent"
    :allow-inline-data-mapping="true"
    sanitize-input
        @element-update="onElementUpdate">
</sw-text-field>

to this:

<sw-text-editor
    v-model="blockContent"
    :allow-inline-data-mapping="true"
    sanitize-input
        @element-update="onElementUpdate">
</sw-text-field>

you use the open tag of "sw-text-editor" but you close with "sw-text-field".

Or you look at the base components:
https://github.com/shopware/shopware/blob/ab564a66dbaa112dfa20099881a718a80813c482/src/Administration/Resources/app/administration/src/module/sw-cms/elements/text/component/sw-cms-el-text.html.twig#L10

Here:

<sw-text-editor
    v-else
    v-model:value="element.config.content.value"
    :disabled="disabled"
    :vertical-align="element.config.verticalAlign.value"
    :allow-inline-data-mapping="true"
    :is-inline-edit="true"
    sanitize-input
    sanitize-field-name="app_cms_block.template"
    enable-transparent-background
    @blur="onBlur"
    @update:value="onInput"
/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文