mt-block-editor-block 1.3.0-alpha.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Block.d.ts CHANGED
@@ -20,5 +20,5 @@ export interface NewFromHtmlOptions {
20
20
  export interface SerializeOptions {
21
21
  editor: Editor;
22
22
  }
23
- declare const _default: typeof import("./index").Block;
23
+ declare const _default: typeof import(".").Block;
24
24
  export default _default;
package/Block.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = window.MTBlockEditor.Block;
2
+ exports.__esModule = true;
3
+ exports["default"] = window.MTBlockEditor.Block;
package/Component.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.__esModule = true;
3
3
  exports.DialogFooter = exports.DialogBody = exports.DialogHeader = exports.Dialog = exports.EditorMode = exports.BlockLabel = exports.BlockSetupCommon = exports.BlockSetup = exports.BlockConfigPanel = exports.BlockToolbarButton = exports.BlockToolbar = exports.BlockIframePreview = void 0;
4
4
  var _a = window.MTBlockEditor.Component, BlockIframePreview = _a.BlockIframePreview, BlockToolbar = _a.BlockToolbar, BlockToolbarButton = _a.BlockToolbarButton, BlockConfigPanel = _a.BlockConfigPanel, BlockSetup = _a.BlockSetup, BlockSetupCommon = _a.BlockSetupCommon, BlockLabel = _a.BlockLabel, EditorMode = _a.EditorMode, Dialog = _a.Dialog, DialogHeader = _a.DialogHeader, DialogBody = _a.DialogBody, DialogFooter = _a.DialogFooter;
5
5
  exports.BlockIframePreview = BlockIframePreview;
package/Context.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.__esModule = true;
3
3
  exports.useBlocksContext = exports.BlocksContext = exports.useEditorContext = exports.EditorContext = void 0;
4
4
  var _a = window.MTBlockEditor.Context, EditorContext = _a.EditorContext, useEditorContext = _a.useEditorContext, BlocksContext = _a.BlocksContext, useBlocksContext = _a.useBlocksContext;
5
5
  exports.EditorContext = EditorContext;
package/Hook.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.__esModule = true;
3
3
  exports.useCommands = void 0;
4
4
  var useCommands = window.MTBlockEditor.Hook.useCommands;
5
5
  exports.useCommands = useCommands;
package/React.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  declare const React: import(".").Map;
2
- declare const useState: any, useEffect: any, useRef: any, useCallback: any;
3
- export { React as default, useState, useEffect, useRef, useCallback };
2
+ declare const useState: any, useEffect: any, useRef: any;
3
+ export { React as default, useState, useEffect, useRef };
package/React.js CHANGED
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useCallback = exports.useRef = exports.useEffect = exports.useState = exports.default = void 0;
2
+ exports.__esModule = true;
3
+ exports.useRef = exports.useEffect = exports.useState = exports["default"] = void 0;
4
4
  var React = window.MTBlockEditor.React;
5
- exports.default = React;
6
- var useState = React.useState, useEffect = React.useEffect, useRef = React.useRef, useCallback = React.useCallback;
5
+ exports["default"] = React;
6
+ var useState = React.useState, useEffect = React.useEffect, useRef = React.useRef;
7
7
  exports.useState = useState;
8
8
  exports.useEffect = useEffect;
9
9
  exports.useRef = useRef;
10
- exports.useCallback = useCallback;
package/decorator.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.__esModule = true;
3
3
  exports.blockProperty = void 0;
4
4
  var blockProperty = window.MTBlockEditor.decorator.blockProperty;
5
5
  exports.blockProperty = blockProperty;
@@ -0,0 +1,24 @@
1
+ import { Editor } from "./index";
2
+ export interface Metadata {
3
+ [key: string]: any;
4
+ }
5
+ export interface EditorOptions {
6
+ focus: boolean;
7
+ focusBlock?: boolean;
8
+ canRemove?: boolean;
9
+ }
10
+ export interface NewOptions {
11
+ editor: Editor;
12
+ event: Event;
13
+ }
14
+ export interface NewFromHtmlOptions {
15
+ html: string;
16
+ node: Element;
17
+ factory: any;
18
+ meta: Metadata;
19
+ }
20
+ export interface SerializeOptions {
21
+ editor: Editor;
22
+ }
23
+ declare const _default: typeof import("./index").Block;
24
+ export default _default;
package/dist/Block.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = window.MTBlockEditor.Block;
@@ -0,0 +1,2 @@
1
+ declare const BlockIframePreview: any, BlockToolbar: any, BlockToolbarButton: any, BlockConfigPanel: any, BlockSetup: any, BlockSetupCommon: any, BlockLabel: any, EditorMode: any, Dialog: any, DialogHeader: any, DialogBody: any, DialogFooter: any;
2
+ export { BlockIframePreview, BlockToolbar, BlockToolbarButton, BlockConfigPanel, BlockSetup, BlockSetupCommon, BlockLabel, EditorMode, Dialog, DialogHeader, DialogBody, DialogFooter, };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DialogFooter = exports.DialogBody = exports.DialogHeader = exports.Dialog = exports.EditorMode = exports.BlockLabel = exports.BlockSetupCommon = exports.BlockSetup = exports.BlockConfigPanel = exports.BlockToolbarButton = exports.BlockToolbar = exports.BlockIframePreview = void 0;
4
+ var _a = window.MTBlockEditor.Component, BlockIframePreview = _a.BlockIframePreview, BlockToolbar = _a.BlockToolbar, BlockToolbarButton = _a.BlockToolbarButton, BlockConfigPanel = _a.BlockConfigPanel, BlockSetup = _a.BlockSetup, BlockSetupCommon = _a.BlockSetupCommon, BlockLabel = _a.BlockLabel, EditorMode = _a.EditorMode, Dialog = _a.Dialog, DialogHeader = _a.DialogHeader, DialogBody = _a.DialogBody, DialogFooter = _a.DialogFooter;
5
+ exports.BlockIframePreview = BlockIframePreview;
6
+ exports.BlockToolbar = BlockToolbar;
7
+ exports.BlockToolbarButton = BlockToolbarButton;
8
+ exports.BlockConfigPanel = BlockConfigPanel;
9
+ exports.BlockSetup = BlockSetup;
10
+ exports.BlockSetupCommon = BlockSetupCommon;
11
+ exports.BlockLabel = BlockLabel;
12
+ exports.EditorMode = EditorMode;
13
+ exports.Dialog = Dialog;
14
+ exports.DialogHeader = DialogHeader;
15
+ exports.DialogBody = DialogBody;
16
+ exports.DialogFooter = DialogFooter;
@@ -0,0 +1,2 @@
1
+ declare const EditorContext: any, useEditorContext: any, BlocksContext: any, useBlocksContext: any;
2
+ export { EditorContext, useEditorContext, BlocksContext, useBlocksContext };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useBlocksContext = exports.BlocksContext = exports.useEditorContext = exports.EditorContext = void 0;
4
+ var _a = window.MTBlockEditor.Context, EditorContext = _a.EditorContext, useEditorContext = _a.useEditorContext, BlocksContext = _a.BlocksContext, useBlocksContext = _a.useBlocksContext;
5
+ exports.EditorContext = EditorContext;
6
+ exports.useEditorContext = useEditorContext;
7
+ exports.BlocksContext = BlocksContext;
8
+ exports.useBlocksContext = useBlocksContext;
package/dist/Hook.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const useCommands: any;
2
+ export { useCommands };
package/dist/Hook.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCommands = void 0;
4
+ var useCommands = window.MTBlockEditor.Hook.useCommands;
5
+ exports.useCommands = useCommands;
@@ -0,0 +1,3 @@
1
+ declare const React: import(".").Map;
2
+ declare const useState: any, useEffect: any, useRef: any, useCallback: any;
3
+ export { React as default, useState, useEffect, useRef, useCallback };
package/dist/React.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCallback = exports.useRef = exports.useEffect = exports.useState = exports.default = void 0;
4
+ var React = window.MTBlockEditor.React;
5
+ exports.default = React;
6
+ var useState = React.useState, useEffect = React.useEffect, useRef = React.useRef, useCallback = React.useCallback;
7
+ exports.useState = useState;
8
+ exports.useEffect = useEffect;
9
+ exports.useRef = useRef;
10
+ exports.useCallback = useCallback;
@@ -0,0 +1,2 @@
1
+ declare const blockProperty: any;
2
+ export { blockProperty };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.blockProperty = void 0;
4
+ var blockProperty = window.MTBlockEditor.decorator.blockProperty;
5
+ exports.blockProperty = blockProperty;
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const i18n: import("i18next").i18n;
2
+ export default i18n;
package/dist/i18n.js ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var i18n = window.MTBlockEditor.i18n;
4
+ exports.default = i18n;
package/dist/icon.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const edit: any, link: any;
2
+ export { edit, link };
package/dist/icon.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.link = exports.edit = void 0;
4
+ var _a = window.MTBlockEditor.icon, edit = _a.edit, link = _a.link;
5
+ exports.edit = edit;
6
+ exports.link = link;
@@ -0,0 +1,166 @@
1
+ import type { JSX } from "react";
2
+ import type * as React from "react";
3
+ import { i18n, InitOptions as InitOptionsI18n } from "i18next";
4
+
5
+ interface Map {
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ [key: string]: any;
8
+ }
9
+
10
+ export interface Metadata {
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ [key: string]: any;
13
+ }
14
+
15
+ export interface EditorOptions {
16
+ id: string;
17
+ mode: string;
18
+ stylesheets: string[];
19
+ rootClassName?: string;
20
+ rootAttributes?: Record<string, string>;
21
+ panelBlockTypes?: string[];
22
+ shortcutBlockTypes?: string[];
23
+ block: Metadata;
24
+ i18n: InitOptionsI18n;
25
+ }
26
+
27
+ export interface BoilerplateBlockOptions {
28
+ typeId: string;
29
+ className: string;
30
+ rootBlock?: string | null;
31
+ label: string;
32
+ icon?: string;
33
+ iconString?: string;
34
+ html: string;
35
+ canRemoveBlock: boolean;
36
+ panelBlockTypes?: string[];
37
+ shortcutBlockTypes?: string[];
38
+ shouldBeCompiled: boolean;
39
+ previewHeader: string;
40
+ }
41
+
42
+ export interface SerializeOptions {
43
+ editor: Editor;
44
+ }
45
+
46
+ interface SetFocusedIdsOptions {
47
+ forceUpdate: boolean;
48
+ }
49
+
50
+ type SetFocusedIds = (ids: string[], opts?: SetFocusedIdsOptions) => void;
51
+
52
+ interface EditorContextProps {
53
+ editor: Editor;
54
+ setFocusedIds: SetFocusedIds;
55
+ getFocusedIds: () => string[];
56
+ }
57
+
58
+ export interface EditHistoryHandlers {
59
+ id: symbol;
60
+ merge?: (a: EditHistory, b: EditHistory) => EditHistory | undefined | null;
61
+ undo: (history: EditHistory, props: EditorContextProps) => void;
62
+ redo: (history: EditHistory, props: EditorContextProps) => void;
63
+ }
64
+
65
+ export interface EditHistory {
66
+ block: Block;
67
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
+ data: any;
69
+ group?: number | undefined;
70
+ handlers: EditHistoryHandlers;
71
+ }
72
+
73
+ export class EditManager {
74
+ public unload(): void;
75
+ public canUndo(): boolean;
76
+ public canRedo(): boolean;
77
+ public add(history: EditHistory): void;
78
+ public undo(props: EditorContextProps, group?: number): void;
79
+ public redo(props: EditorContextProps, group?: number): void;
80
+ public generateGroup(): number;
81
+ public beginGrouping(): void;
82
+ public endGrouping(): void;
83
+ }
84
+
85
+ export class Editor {
86
+ public id: string;
87
+ public opts: EditorOptions;
88
+ public serialize(): Promise<void>;
89
+ public editManager: EditManager;
90
+
91
+ /** Definitions from eventemitter */
92
+ static prefixed: string | boolean;
93
+ public eventNames(): any;
94
+ public listeners(event: any): any[];
95
+ public listenerCount(event: any): number;
96
+ public emit(event: any, ...args: any): boolean;
97
+ public on(event: any, fn: any, context?: any): this;
98
+ public addListener(event: any, fn: any, context?: any): this;
99
+ public once(event: any, fn: any, context?: any): this;
100
+ public removeListener(
101
+ event: any,
102
+ fn?: any,
103
+ context?: any,
104
+ once?: boolean
105
+ ): this;
106
+ public off(event: any, fn?: any, context?: any, once?: boolean): this;
107
+ public removeAllListeners(event?: any): this;
108
+ }
109
+
110
+ export class Block {
111
+ public static typeId: string;
112
+ public static label: string;
113
+ public static icon: string;
114
+ public static selectable: boolean;
115
+ public static shouldBeCompiled: boolean;
116
+ public id: string;
117
+ public compiledHtml: string | undefined;
118
+ public placeholderLabel(): string;
119
+ public placeholder(): JSX.Element;
120
+ public metadata(): Metadata | null;
121
+ public metadataByOwnKeys(opts?: { keys?: string[] }): Metadata | null;
122
+ public keysForSetup(): string[];
123
+ public compile(opts: SerializeOptions): Promise<void>;
124
+ }
125
+
126
+ export class EditorUtil {
127
+ public static version: string;
128
+ public static i18n: i18n;
129
+ public static Component: Map;
130
+ public static decorator: Map;
131
+ public static icon: Map;
132
+ public static util: Map;
133
+ public static React: Map;
134
+ public static jsxRuntime: {
135
+ jsx: (type: any, props: any, key?: React.Key) => any;
136
+ jsxs: (type: any, props: any, key?: React.Key) => any;
137
+ jsxDEV?: (
138
+ type: any,
139
+ props: any,
140
+ key?: React.Key,
141
+ isStatic?: boolean,
142
+ source?: any,
143
+ self?: any
144
+ ) => any;
145
+ Fragment: typeof React.Fragment;
146
+ };
147
+ public static Context: Map;
148
+ public static Hook: Map;
149
+ public static Block: typeof Block;
150
+ public static apply(opts: EditorOptions): Promise<Editor>;
151
+ public static get({ id }: { id: string }): Editor | undefined;
152
+ public static unload({ id }: { id: string }): Promise<void>;
153
+ public static serialize(): Promise<void>;
154
+ public static registerBlockType(block: typeof Block): void;
155
+ public static createBoilerplateBlock(
156
+ opts: BoilerplateBlockOptions
157
+ ): typeof Block;
158
+ public static isSupportedEnvironment(): boolean;
159
+ }
160
+
161
+ declare global {
162
+ interface Window {
163
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
164
+ MTBlockEditor: typeof EditorUtil;
165
+ }
166
+ }
@@ -0,0 +1,9 @@
1
+ import type * as React from "react";
2
+ export interface JSXSource {
3
+ fileName?: string | undefined;
4
+ lineNumber?: number | undefined;
5
+ columnNumber?: number | undefined;
6
+ }
7
+ export declare const jsxDEV: (type: React.ElementType, props: unknown, key: React.Key | undefined, isStatic: boolean, source?: JSXSource, self?: unknown) => React.ReactElement;
8
+ export declare const Fragment: typeof React.Fragment;
9
+ export type { JSX } from "react";
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Fragment = exports.jsxDEV = void 0;
4
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
4
  var jsxRuntime = window.MTBlockEditor.jsxRuntime;
6
5
  exports.jsxDEV = jsxRuntime.jsxDEV || jsxRuntime.jsx;
7
6
  exports.Fragment = jsxRuntime.Fragment;
@@ -0,0 +1,5 @@
1
+ import type * as React from "react";
2
+ export declare const jsx: (type: React.ElementType, props: unknown, key?: React.Key) => React.ReactElement;
3
+ export declare const jsxs: (type: React.ElementType, props: unknown, key?: React.Key) => React.ReactElement;
4
+ export declare const Fragment: typeof React.Fragment;
5
+ export type { JSX } from "react";
package/dist/util.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const nl2br: any, sanitize: any, isIos: any, isTouchDevice: any, focusIfIos: any;
2
+ export { nl2br, sanitize, isIos, isTouchDevice, focusIfIos };
package/dist/util.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.focusIfIos = exports.isTouchDevice = exports.isIos = exports.sanitize = exports.nl2br = void 0;
4
+ var _a = window.MTBlockEditor.util, nl2br = _a.nl2br, sanitize = _a.sanitize, isIos = _a.isIos, isTouchDevice = _a.isTouchDevice, focusIfIos = _a.focusIfIos;
5
+ exports.nl2br = nl2br;
6
+ exports.sanitize = sanitize;
7
+ exports.isIos = isIos;
8
+ exports.isTouchDevice = isTouchDevice;
9
+ exports.focusIfIos = focusIfIos;
package/hooks.js ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var useEditorUtil = window.MTBlockEditor.hooks.useEditorUtil;
4
+ exports.useEditorUtil = useEditorUtil;
package/i18n.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.__esModule = true;
3
3
  var i18n = window.MTBlockEditor.i18n;
4
- exports.default = i18n;
4
+ exports["default"] = i18n;
package/icon.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.__esModule = true;
3
3
  exports.link = exports.edit = void 0;
4
4
  var _a = window.MTBlockEditor.icon, edit = _a.edit, link = _a.link;
5
5
  exports.edit = edit;
package/icons.js ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ var edit = window.MTBlockEditor.icons.edit;
4
+ exports.edit = edit;
package/index.d.ts ADDED
@@ -0,0 +1,154 @@
1
+ import { i18n, InitOptions as InitOptionsI18n } from "i18next";
2
+
3
+ interface Map {
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ [key: string]: any;
6
+ }
7
+
8
+ export interface Metadata {
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ [key: string]: any;
11
+ }
12
+
13
+ export interface EditorOptions {
14
+ id: string;
15
+ mode: string;
16
+ stylesheets: string[];
17
+ rootClassName?: string;
18
+ rootAttributes?: Record<string, string>;
19
+ panelBlockTypes?: string[];
20
+ shortcutBlockTypes?: string[];
21
+ block: Metadata;
22
+ i18n: InitOptionsI18n;
23
+ }
24
+
25
+ export interface BoilerplateBlockOptions {
26
+ typeId: string;
27
+ className: string;
28
+ rootBlock?: string | null;
29
+ label: string;
30
+ icon?: string;
31
+ iconString?: string;
32
+ html: string;
33
+ canRemoveBlock: boolean;
34
+ panelBlockTypes?: string[];
35
+ shortcutBlockTypes?: string[];
36
+ shouldBeCompiled: boolean;
37
+ previewHeader: string;
38
+ }
39
+
40
+ export interface SerializeOptions {
41
+ editor: Editor;
42
+ }
43
+
44
+ interface SetFocusedIdOptions {
45
+ forceUpdate: boolean;
46
+ }
47
+
48
+ type SetFocusedId = (
49
+ id: string | null,
50
+ opts?: SetFocusedIdOptions
51
+ ) => void;
52
+
53
+ interface EditorContextProps {
54
+ editor: Editor;
55
+ setFocusedId: SetFocusedId;
56
+ getFocusedId: () => string | null;
57
+ }
58
+
59
+ export interface EditHistoryHandlers {
60
+ id: symbol;
61
+ merge?: (a: EditHistory, b: EditHistory) => EditHistory | undefined | null;
62
+ undo: (history: EditHistory, props: EditorContextProps) => void;
63
+ redo: (history: EditHistory, props: EditorContextProps) => void;
64
+ }
65
+
66
+ export interface EditHistory {
67
+ block: Block;
68
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
+ data: any;
70
+ group?: number | undefined;
71
+ handlers: EditHistoryHandlers;
72
+ }
73
+
74
+ export class EditManager {
75
+ public unload(): void;
76
+ public canUndo(): boolean;
77
+ public canRedo(): boolean;
78
+ public add(history: EditHistory): void;
79
+ public undo(props: EditorContextProps, group?: number): void;
80
+ public redo(props: EditorContextProps, group?: number): void;
81
+ public generateGroup(): number;
82
+ public beginGrouping(): void;
83
+ public endGrouping(): void;
84
+ }
85
+
86
+ export class Editor {
87
+ public id: string;
88
+ public opts: EditorOptions;
89
+ public serialize(): Promise<void>;
90
+ public editManager: EditManager;
91
+
92
+ /** Definitions from eventemitter */
93
+ static prefixed: string | boolean;
94
+ public eventNames(): any;
95
+ public listeners(event: any): any[];
96
+ public listenerCount(event: any): number;
97
+ public emit(event: any, ...args: any): boolean;
98
+ public on(event: any, fn: any, context?: any): this;
99
+ public addListener(event: any, fn: any, context?: any): this;
100
+ public once(event: any, fn: any, context?: any): this;
101
+ public removeListener(
102
+ event: any,
103
+ fn?: any,
104
+ context?: any,
105
+ once?: boolean
106
+ ): this;
107
+ public off(event: any, fn?: any, context?: any, once?: boolean): this;
108
+ public removeAllListeners(event?: any): this;
109
+ }
110
+
111
+ export class Block {
112
+ public static typeId: string;
113
+ public static label: string;
114
+ public static icon: string;
115
+ public static selectable: boolean;
116
+ public static shouldBeCompiled: boolean;
117
+ public id: string;
118
+ public compiledHtml: string;
119
+ public placeholderLabel(): string;
120
+ public placeholder(): JSX.Element;
121
+ public metadata(): Metadata | null;
122
+ public metadataByOwnKeys(opts?: { keys?: string[] }): Metadata | null;
123
+ public keysForSetup(): string[];
124
+ public compile(opts: SerializeOptions): Promise<void>;
125
+ }
126
+
127
+ export class EditorUtil {
128
+ public static version: string;
129
+ public static i18n: i18n;
130
+ public static Component: Map;
131
+ public static decorator: Map;
132
+ public static icon: Map;
133
+ public static util: Map;
134
+ public static React: Map;
135
+ public static Context: Map;
136
+ public static Hook: Map;
137
+ public static Block: typeof Block;
138
+ public static apply(opts: EditorOptions): Promise<Editor>;
139
+ public static get({ id }: { id: string }): Editor | undefined;
140
+ public static unload({ id }: { id: string }): Promise<void>;
141
+ public static serialize(): Promise<void>;
142
+ public static registerBlockType(block: typeof Block): void;
143
+ public static createBoilerplateBlock(
144
+ opts: BoilerplateBlockOptions
145
+ ): typeof Block;
146
+ public static isSupportedEnvironment(): boolean;
147
+ }
148
+
149
+ declare global {
150
+ interface Window {
151
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
152
+ MTBlockEditor: typeof EditorUtil;
153
+ }
154
+ }
package/index.js ADDED
File without changes
package/package.json CHANGED
@@ -1,25 +1,61 @@
1
1
  {
2
2
  "name": "mt-block-editor-block",
3
- "version": "1.3.0-alpha.1",
3
+ "version": "1.3.0",
4
4
  "description": "This package helps you define custom block types.",
5
- "main": "index.js",
6
- "types": "index.d.ts",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "types": "./index.d.ts",
10
- "default": "./index.js"
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./Block": {
13
+ "types": "./dist/Block.d.ts",
14
+ "default": "./dist/Block.js"
15
+ },
16
+ "./Component": {
17
+ "types": "./dist/Component.d.ts",
18
+ "default": "./dist/Component.js"
19
+ },
20
+ "./Context": {
21
+ "types": "./dist/Context.d.ts",
22
+ "default": "./dist/Context.js"
23
+ },
24
+ "./decorator": {
25
+ "types": "./dist/decorator.d.ts",
26
+ "default": "./dist/decorator.js"
27
+ },
28
+ "./Hook": {
29
+ "types": "./dist/Hook.d.ts",
30
+ "default": "./dist/Hook.js"
31
+ },
32
+ "./i18n": {
33
+ "types": "./dist/i18n.d.ts",
34
+ "default": "./dist/i18n.js"
35
+ },
36
+ "./icon": {
37
+ "types": "./dist/icon.d.ts",
38
+ "default": "./dist/icon.js"
39
+ },
40
+ "./React": {
41
+ "types": "./dist/React.d.ts",
42
+ "default": "./dist/React.js"
43
+ },
44
+ "./util": {
45
+ "types": "./dist/util.d.ts",
46
+ "default": "./dist/util.js"
11
47
  },
12
48
  "./jsx-runtime": {
13
- "types": "./jsx-runtime.d.ts",
14
- "default": "./jsx-runtime.js"
49
+ "types": "./dist/jsx-runtime.d.ts",
50
+ "default": "./dist/jsx-runtime.js"
15
51
  },
16
52
  "./jsx-dev-runtime": {
17
- "types": "./jsx-dev-runtime.d.ts",
18
- "default": "./jsx-dev-runtime.js"
53
+ "types": "./dist/jsx-dev-runtime.d.ts",
54
+ "default": "./dist/jsx-dev-runtime.js"
19
55
  }
20
56
  },
21
57
  "scripts": {
22
- "build": "rimraf dist && tsc -d src/*.ts --outDir dist --lib esnext,dom && cpy \"./src/index.d.ts\" \"./src/jsx-runtime.d.ts\" \"./src/jsx-dev-runtime.d.ts\" \"./dist/*\" ./",
58
+ "build": "rimraf dist && tsc -d src/*.ts --outDir dist --lib esnext,dom && cpy \"./src/index.d.ts\" ./dist/ --flat",
23
59
  "test": "echo \"Error: no test specified\" && exit 1"
24
60
  },
25
61
  "author": "",
package/src/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { JSX } from "react";
2
+ import type * as React from "react";
2
3
  import { i18n, InitOptions as InitOptionsI18n } from "i18next";
3
4
 
4
5
  interface Map {
@@ -131,9 +132,17 @@ export class EditorUtil {
131
132
  public static util: Map;
132
133
  public static React: Map;
133
134
  public static jsxRuntime: {
134
- jsx: (type: any, props: any, key?: string) => any;
135
- jsxs: (type: any, props: any, key?: string) => any;
136
- Fragment: symbol;
135
+ jsx: (type: any, props: any, key?: React.Key) => any;
136
+ jsxs: (type: any, props: any, key?: React.Key) => any;
137
+ jsxDEV?: (
138
+ type: any,
139
+ props: any,
140
+ key?: React.Key,
141
+ isStatic?: boolean,
142
+ source?: any,
143
+ self?: any
144
+ ) => any;
145
+ Fragment: typeof React.Fragment;
137
146
  };
138
147
  public static Context: Map;
139
148
  public static Hook: Map;
@@ -1,5 +1,22 @@
1
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
- const jsxRuntime = window.MTBlockEditor.jsxRuntime as any;
1
+ import type * as React from "react";
3
2
 
4
- export const jsxDEV = jsxRuntime.jsxDEV || jsxRuntime.jsx;
5
- export const Fragment = jsxRuntime.Fragment;
3
+ const jsxRuntime = window.MTBlockEditor.jsxRuntime;
4
+
5
+ export interface JSXSource {
6
+ fileName?: string | undefined;
7
+ lineNumber?: number | undefined;
8
+ columnNumber?: number | undefined;
9
+ }
10
+
11
+ export const jsxDEV: (
12
+ type: React.ElementType,
13
+ props: unknown,
14
+ key: React.Key | undefined,
15
+ isStatic: boolean,
16
+ source?: JSXSource,
17
+ self?: unknown
18
+ ) => React.ReactElement = jsxRuntime.jsxDEV || jsxRuntime.jsx;
19
+
20
+ export const Fragment: typeof React.Fragment = jsxRuntime.Fragment;
21
+
22
+ export type { JSX } from "react";
@@ -1,5 +1,19 @@
1
+ import type * as React from "react";
2
+
1
3
  const jsxRuntime = window.MTBlockEditor.jsxRuntime;
2
4
 
3
- export const jsx = jsxRuntime.jsx;
4
- export const jsxs = jsxRuntime.jsxs;
5
- export const Fragment = jsxRuntime.Fragment;
5
+ export const jsx: (
6
+ type: React.ElementType,
7
+ props: unknown,
8
+ key?: React.Key
9
+ ) => React.ReactElement = jsxRuntime.jsx;
10
+
11
+ export const jsxs: (
12
+ type: React.ElementType,
13
+ props: unknown,
14
+ key?: React.Key
15
+ ) => React.ReactElement = jsxRuntime.jsxs;
16
+
17
+ export const Fragment: typeof React.Fragment = jsxRuntime.Fragment;
18
+
19
+ export type { JSX } from "react";
package/util.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.__esModule = true;
3
3
  exports.focusIfIos = exports.isTouchDevice = exports.isIos = exports.sanitize = exports.nl2br = void 0;
4
4
  var _a = window.MTBlockEditor.util, nl2br = _a.nl2br, sanitize = _a.sanitize, isIos = _a.isIos, isTouchDevice = _a.isTouchDevice, focusIfIos = _a.focusIfIos;
5
5
  exports.nl2br = nl2br;
@@ -1,2 +0,0 @@
1
- export declare const jsxDEV: any;
2
- export declare const Fragment: any;
package/jsx-runtime.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export declare const jsx: (type: any, props: any, key?: string) => any;
2
- export declare const jsxs: (type: any, props: any, key?: string) => any;
3
- export declare const Fragment: symbol;
@@ -1,3 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
- export const jsxDEV: (type: any, props: any, key?: string, isStatic?: boolean, source?: any, self?: any) => any;
3
- export const Fragment: symbol;
@@ -1,5 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
- export const jsx: (type: any, props: any, key?: string) => any;
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
- export const jsxs: (type: any, props: any, key?: string) => any;
5
- export const Fragment: symbol;
File without changes