fix: 修复schema编辑复制组件时样式冲突问题

This commit is contained in:
zhangtao07 2024-05-10 17:59:39 +08:00
parent 054e564bcd
commit 1504d3978c
3 changed files with 24 additions and 2 deletions

View File

@ -71,7 +71,7 @@ const codeErrorWarning = debounce(e => {
export interface AMisCodeEditorProps {
value: any;
onChange: (value: any, diff: any) => void;
onPaste?: () => void;
onPaste?: (e: any) => void;
disabled?: boolean;
$schemaUrl?: string;
$schema?: string;

View File

@ -5,9 +5,20 @@ import AMisCodeEditor from './AMisCodeEditor';
export default class CodeEditorPanel extends React.Component<PanelProps> {
@autobind
handleCodePaste() {
handleCodePaste(e: any) {
setTimeout(() => {
this.props.manager.patchSchema(true);
// 检测是否整体粘贴组件如果是的话强制替换ID避免样式bug
if (
e?.languageId === 'json' &&
e.range?.startColumn === 1 &&
e.range?.startLineNumber === 1 &&
e.range?.endColumn === 2 &&
e.range?.endLineNumber > 1
) {
this.props.manager.reGenerateCurrentNodeID();
}
}, 500);
}

View File

@ -1570,6 +1570,17 @@ export class EditorManager {
}
}
/**
* id
*/
reGenerateCurrentNodeID() {
const node = this.store.getNodeById(this.store.activeId);
if (!node) {
return;
}
this.replaceChild(node.id, reGenerateID(node.schema));
}
/**
*
* @param id