How to get the type of pluginViews properties

class Hub implements PluginSpec {

    view(eView) {
        return new LinkPlugin(eView);
    }

    props: EditorProps = {
        handleKeyDown: (view, event) => {
            const {state} = view;
            const {selection} = state;
            const {from, to} = selection;

            console.log(view)
        {
    }
}

I took a log of handleKeyDown’s view.

i fond pluginViews properties

Since I am using typescript, I want to use the property, but there is no related information even when I search, so I am using the any type. How can I get the type of pluginviews?

const linkPlugin = ((view as any).pluginViews)[0] as LinkPlugin;

That’s not part of the public interface, so its type is not in the type definitions, and you should not be touching it. (Exploring the interface through devtools is not generally a good idea for JS libraries, since you’ll just end up finding private interfaces that aren’t documented and might change between versions. Rely on the docs instead.)

1 Like

Thank you for quick response.

Is there a separate way to access the PluginView when hadleKeyDown occurs without using the pluginViews property?

Below is how I currently implement the plugin.

class LinkPlugin implements Plugin {
    spec: PluginSpec<any, any> = {
        view: (view) => new LinkPluginView(view)
    }

    getState(state: EditorState<any>) {
        return state;
    }

    props: EditorProps<Plugin<any, any>, any> = {
        handleKeyDown: (view, event) => {
            const linkPlugin = ((view as any).pluginViews)[0] as LinkPluginView;
            linkPlugin.create(view);
            return false
        }
    }
}

Oh, I solved it by just importing the LinkPluginView contents into the LinkPlugin class.