mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:39:05 +08:00
fix: 修复schema编辑复制组件时样式冲突问题
This commit is contained in:
parent
054e564bcd
commit
1504d3978c
@ -71,7 +71,7 @@ const codeErrorWarning = debounce(e => {
|
|||||||
export interface AMisCodeEditorProps {
|
export interface AMisCodeEditorProps {
|
||||||
value: any;
|
value: any;
|
||||||
onChange: (value: any, diff: any) => void;
|
onChange: (value: any, diff: any) => void;
|
||||||
onPaste?: () => void;
|
onPaste?: (e: any) => void;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
$schemaUrl?: string;
|
$schemaUrl?: string;
|
||||||
$schema?: string;
|
$schema?: string;
|
||||||
|
@ -5,9 +5,20 @@ import AMisCodeEditor from './AMisCodeEditor';
|
|||||||
|
|
||||||
export default class CodeEditorPanel extends React.Component<PanelProps> {
|
export default class CodeEditorPanel extends React.Component<PanelProps> {
|
||||||
@autobind
|
@autobind
|
||||||
handleCodePaste() {
|
handleCodePaste(e: any) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.props.manager.patchSchema(true);
|
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);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
* @param id
|
||||||
|
Loading…
Reference in New Issue
Block a user