mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-05-05 09:46:56 +08:00
parent
449efcc56b
commit
c025508cd7
@ -230,7 +230,7 @@ class Editor extends BaseService {
|
|||||||
if (node?.id) {
|
if (node?.id) {
|
||||||
this.get('stage')
|
this.get('stage')
|
||||||
?.renderer.runtime?.getApp?.()
|
?.renderer.runtime?.getApp?.()
|
||||||
?.emit(
|
.page?.emit(
|
||||||
'editor:select',
|
'editor:select',
|
||||||
{
|
{
|
||||||
node,
|
node,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { useContext, useEffect, useState } from 'react';
|
import React, { useContext, useState } from 'react';
|
||||||
|
|
||||||
import Core from '@tmagic/core';
|
import Core from '@tmagic/core';
|
||||||
import type { MComponent, MNode } from '@tmagic/schema';
|
import type { MComponent, MNode } from '@tmagic/schema';
|
||||||
@ -31,7 +31,7 @@ interface OverlayProps {
|
|||||||
const Overlay: React.FC<OverlayProps> = ({ config }) => {
|
const Overlay: React.FC<OverlayProps> = ({ config }) => {
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
|
|
||||||
const app: Core = useContext(AppContent);
|
const app: Core | undefined = useContext(AppContent);
|
||||||
const node = app?.page?.getNode(config.id);
|
const node = app?.page?.getNode(config.id);
|
||||||
|
|
||||||
if (!app) return null;
|
if (!app) return null;
|
||||||
@ -58,7 +58,7 @@ const Overlay: React.FC<OverlayProps> = ({ config }) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
app?.on('editor:select', (info: any, path: MNode[]) => {
|
app?.page?.on('editor:select', (info: any, path: MNode[]) => {
|
||||||
if (path.find((node: MNode) => node.id === config.id)) {
|
if (path.find((node: MNode) => node.id === config.id)) {
|
||||||
openOverlay();
|
openOverlay();
|
||||||
} else {
|
} else {
|
||||||
|
@ -26,12 +26,12 @@ import AppContent from './AppContent';
|
|||||||
interface UseAppOptions {
|
interface UseAppOptions {
|
||||||
config: MComponent;
|
config: MComponent;
|
||||||
methods?: {
|
methods?: {
|
||||||
string: Function;
|
[key: string]: Function;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ({ config, methods }: UseAppOptions) => {
|
export default ({ config, methods }: UseAppOptions) => {
|
||||||
const app: Core = useContext(AppContent);
|
const app: Core | undefined = useContext(AppContent);
|
||||||
const node = app?.page?.getNode(config.id);
|
const node = app?.page?.getNode(config.id);
|
||||||
const [created, setCreated] = useState(false);
|
const [created, setCreated] = useState(false);
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
app?.on('editor:select', (info, path) => {
|
app?.page?.on('editor:select', (info, path) => {
|
||||||
if (path.find((node: MNode) => node.id === props.config.id)) {
|
if (path.find((node: MNode) => node.id === props.config.id)) {
|
||||||
openOverlay();
|
openOverlay();
|
||||||
} else {
|
} else {
|
||||||
|
@ -43,7 +43,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
app?.on('editor:select', (info, path) => {
|
app?.page?.on('editor:select', (info, path) => {
|
||||||
if (path.find((node: MNode) => node.id === props.config.id)) {
|
if (path.find((node: MNode) => node.id === props.config.id)) {
|
||||||
openOverlay();
|
openOverlay();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user