amis icon indicating copy to clipboard operation
amis copied to clipboard

如何给已有组件增加一个可配置的属性

Open niceHou opened this issue 1 year ago • 1 comments

实现场景:

希望能在已有的“代码编辑器”组件的属性配置面板上增加一个size属性,用户可配 md / xl / xxl等。

存在的问题:

1、继承了CodeEditorControlPlugin 2、重写了panelBodyCreator 但还是不生效,现在属性面板显示的依然是原本组件的配置。 跟源码发现,registerEditorPlugin这个没问题,我的plugin注册进去了。但是选中“代码编辑器”组件的时候,发现取的plugin还是CodeEditorControlPlugin,而不是我重写的。 请问现在是否支持这种场景呢

当前方案:

麻烦帮忙看看是哪里有问题哇

import { registerEditorPlugin, getSchemaTpl, BaseEventContext } from 'amis-editor-core';
import { CodeEditorControlPlugin } from 'amis-editor/lib/plugin/Form/CodeEditor';

export class CodeEditorPlugin extends CodeEditorControlPlugin {
    static id = 'CodeEditorPlugin';
    static priority = 9999;

    rendererName = 'editor';
    $schema = "/schemas/EditorControlSchema.json";

    name = '代码编辑器dd';
    isBaseComponent = true;
    panelJustify = true;

    panelBodyCreator = (context: BaseEventContext) => {
        debugger
        return getSchemaTpl('tabs', [
            {
                title: '属性1',
                body: getSchemaTpl(
                    'collapseGroup',
                    [
                        {
                            title: '基本1',
                            body: [{
                                label: '默认值1',
                                name: 'value1',
                                type: 'input-text'
                              }]
                        }
                    ]
                )
            }
        ]);
    };

}

registerEditorPlugin(CodeEditorPlugin);

niceHou avatar Jul 08 '24 10:07 niceHou

兄弟,问题解决了吗

hugo8680 avatar Aug 07 '24 12:08 hugo8680