fix: fix createInstance bugs
This commit is contained in:
parent
1fbf1b64d9
commit
a04e057119
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kevisual/codemirror",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"description": "",
|
||||
"main": "dist/editor.js",
|
||||
"privite": false,
|
||||
|
@ -10,7 +10,7 @@ let editor: EditorView = null;
|
||||
*/
|
||||
const createEditorInstance = (el?: HTMLDivElement) => {
|
||||
if (editor && el) {
|
||||
editor.dom.appendChild(el);
|
||||
el.appendChild(editor.dom);
|
||||
return editor;
|
||||
} else if (editor) {
|
||||
return editor;
|
||||
@ -19,6 +19,7 @@ const createEditorInstance = (el?: HTMLDivElement) => {
|
||||
extensions: [basicSetup, json()],
|
||||
parent: el || document.body,
|
||||
});
|
||||
editor.dom.style.height = '100%';
|
||||
return editor;
|
||||
};
|
||||
|
||||
@ -28,10 +29,12 @@ const createEditorInstance = (el?: HTMLDivElement) => {
|
||||
* @returns
|
||||
*/
|
||||
export const createEditor = (el: HTMLDivElement) => {
|
||||
return new EditorView({
|
||||
const editor = new EditorView({
|
||||
extensions: [basicSetup, json()],
|
||||
parent: el || document.body,
|
||||
});
|
||||
editor.dom.style.height = '100%';
|
||||
return editor;
|
||||
};
|
||||
|
||||
export { editor, createEditorInstance };
|
||||
|
@ -14,7 +14,7 @@ type CreateOpts = {
|
||||
*/
|
||||
const createEditorInstance = (el?: HTMLDivElement, opts?: CreateOpts) => {
|
||||
if (editor && el) {
|
||||
editor.dom.appendChild(el);
|
||||
el.appendChild(editor.dom);
|
||||
return editor;
|
||||
} else if (editor) {
|
||||
return editor;
|
||||
@ -24,6 +24,7 @@ const createEditorInstance = (el?: HTMLDivElement, opts?: CreateOpts) => {
|
||||
extensions: [basicSetup, javascript({ jsx, typescript })],
|
||||
parent: el || document.body,
|
||||
});
|
||||
editor.dom.style.height = '100%';
|
||||
return editor;
|
||||
};
|
||||
|
||||
@ -33,10 +34,12 @@ const createEditorInstance = (el?: HTMLDivElement, opts?: CreateOpts) => {
|
||||
* @returns
|
||||
*/
|
||||
export const createEditor = (el: HTMLDivElement, opts?: CreateOpts) => {
|
||||
return new EditorView({
|
||||
const editor = new EditorView({
|
||||
extensions: [basicSetup, javascript({ jsx: opts?.jsx, typescript: opts?.typescript })],
|
||||
parent: el || document.body,
|
||||
});
|
||||
editor.dom.style.height = '100%';
|
||||
return editor;
|
||||
};
|
||||
|
||||
export { editor, createEditorInstance };
|
||||
|
@ -36,6 +36,7 @@ export type DefaultStyle<T> = {
|
||||
} & T;
|
||||
|
||||
export class Modal<T = any, U = KV> {
|
||||
static rootClassName = '#ui-modal-list';
|
||||
root: HTMLDivElement;
|
||||
id: string;
|
||||
modalElement?: HTMLDivElement;
|
||||
|
Loading…
x
Reference in New Issue
Block a user