mce 0.1.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/LICENSE +21 -0
- package/README.md +126 -0
- package/dist/components/Auxiliary.vue.d.ts +3 -0
- package/dist/components/Bottombar.vue.d.ts +13 -0
- package/dist/components/ContextMenu.vue.d.ts +25 -0
- package/dist/components/Drawboard.vue.d.ts +58 -0
- package/dist/components/Drawing.vue.d.ts +3 -0
- package/dist/components/Floatbar.vue.d.ts +54 -0
- package/dist/components/Frame.vue.d.ts +11 -0
- package/dist/components/Frames.vue.d.ts +3 -0
- package/dist/components/GoBackSelectedArea.vue.d.ts +3 -0
- package/dist/components/Hover.vue.d.ts +3 -0
- package/dist/components/Rulers.vue.d.ts +8 -0
- package/dist/components/Scrollbars.vue.d.ts +12 -0
- package/dist/components/Selector.vue.d.ts +197 -0
- package/dist/components/Starter.vue.d.ts +3 -0
- package/dist/components/Statusbar.vue.d.ts +3 -0
- package/dist/components/TextEditor.vue.d.ts +6 -0
- package/dist/components/shared/Dialog.vue.d.ts +58 -0
- package/dist/components/shared/Menu.vue.d.ts +71 -0
- package/dist/components/shared/Overlay.vue.d.ts +64 -0
- package/dist/components/shared/Ruler.vue.d.ts +17 -0
- package/dist/components/shared/Scrollbar.vue.d.ts +21 -0
- package/dist/components/shared/Tooltip.vue.d.ts +71 -0
- package/dist/components/shared/Transformable.vue.d.ts +79 -0
- package/dist/composables/editor.d.ts +3 -0
- package/dist/composables/index.d.ts +4 -0
- package/dist/composables/menu.d.ts +7 -0
- package/dist/composables/overlay.d.ts +60 -0
- package/dist/composables/strategy.d.ts +40 -0
- package/dist/editor.d.ts +29 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +5815 -0
- package/dist/indexeddb/IndexeddbProvider.d.ts +31 -0
- package/dist/indexeddb/index.d.ts +1 -0
- package/dist/indexeddb/indexeddb.d.ts +23 -0
- package/dist/models/Doc.d.ts +57 -0
- package/dist/models/Model.d.ts +32 -0
- package/dist/models/Workspace.d.ts +17 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/plugins/0.command.d.ts +27 -0
- package/dist/plugins/0.config/base.d.ts +30 -0
- package/dist/plugins/0.config.d.ts +16 -0
- package/dist/plugins/0.context.d.ts +32 -0
- package/dist/plugins/0.element.d.ts +14 -0
- package/dist/plugins/0.font.d.ts +18 -0
- package/dist/plugins/0.i18n.d.ts +13 -0
- package/dist/plugins/1.frame.d.ts +24 -0
- package/dist/plugins/1.hotkey.d.ts +39 -0
- package/dist/plugins/1.upload.d.ts +13 -0
- package/dist/plugins/2.box.d.ts +20 -0
- package/dist/plugins/2.exporter/0.json.d.ts +10 -0
- package/dist/plugins/2.exporter/image.d.ts +11 -0
- package/dist/plugins/2.exporter/pdf.d.ts +9 -0
- package/dist/plugins/2.exporter/pptx.d.ts +9 -0
- package/dist/plugins/2.exporter/video.d.ts +10 -0
- package/dist/plugins/2.exporter.d.ts +27 -0
- package/dist/plugins/2.loader/0.url.d.ts +2 -0
- package/dist/plugins/2.loader/image.d.ts +2 -0
- package/dist/plugins/2.loader/json.d.ts +2 -0
- package/dist/plugins/2.loader/pptx.d.ts +2 -0
- package/dist/plugins/2.loader/txt.d.ts +2 -0
- package/dist/plugins/2.loader.d.ts +23 -0
- package/dist/plugins/3.view.d.ts +12 -0
- package/dist/plugins/4.0.text.d.ts +11 -0
- package/dist/plugins/4.1.lock.d.ts +20 -0
- package/dist/plugins/4.2.element.d.ts +45 -0
- package/dist/plugins/4.3.frame.d.ts +21 -0
- package/dist/plugins/4.4.doc.d.ts +23 -0
- package/dist/plugins/align.d.ts +16 -0
- package/dist/plugins/arrange.d.ts +19 -0
- package/dist/plugins/auxiliary.d.ts +14 -0
- package/dist/plugins/clipboard.d.ts +22 -0
- package/dist/plugins/flip.d.ts +10 -0
- package/dist/plugins/frame.d.ts +14 -0
- package/dist/plugins/group.d.ts +14 -0
- package/dist/plugins/history.d.ts +21 -0
- package/dist/plugins/import.d.ts +15 -0
- package/dist/plugins/insert/image.d.ts +13 -0
- package/dist/plugins/insert/text.d.ts +14 -0
- package/dist/plugins/menu.d.ts +12 -0
- package/dist/plugins/move.d.ts +20 -0
- package/dist/plugins/new.d.ts +12 -0
- package/dist/plugins/open.d.ts +12 -0
- package/dist/plugins/preference.d.ts +16 -0
- package/dist/plugins/saveAs.d.ts +15 -0
- package/dist/plugins/select.d.ts +20 -0
- package/dist/plugins/snapshot.d.ts +17 -0
- package/dist/plugins/theme.d.ts +8 -0
- package/dist/plugins/ui.d.ts +16 -0
- package/dist/plugins/visibility.d.ts +14 -0
- package/dist/plugins/zoom.d.ts +32 -0
- package/dist/preset-plugins.d.ts +1 -0
- package/dist/sw.d.ts +1 -0
- package/dist/typed-global.d.ts +26 -0
- package/dist/typed-plugins.d.ts +58 -0
- package/dist/types/box.d.ts +9 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/BSTree/BSTree.d.ts +18 -0
- package/dist/utils/BSTree/BSTreeKV.d.ts +210 -0
- package/dist/utils/BSTree/LinkedList.d.ts +179 -0
- package/dist/utils/BSTree/Queue.d.ts +81 -0
- package/dist/utils/BSTree/index.d.ts +1 -0
- package/dist/utils/BSTree/utils.d.ts +47 -0
- package/dist/utils/box.d.ts +7 -0
- package/dist/utils/constants.d.ts +4 -0
- package/dist/utils/create.d.ts +3 -0
- package/dist/utils/helper.d.ts +1 -0
- package/dist/utils/image.d.ts +26 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/propsFactory.d.ts +57 -0
- package/dist/utils/random.d.ts +3 -0
- package/package.json +147 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ObservableEvents } from 'modern-idoc';
|
|
2
|
+
import { Observable } from 'modern-idoc';
|
|
3
|
+
import * as Y from 'yjs';
|
|
4
|
+
export declare const PREFERRED_TRIM_SIZE = 500;
|
|
5
|
+
export declare function fetchUpdates(idbPersistence: IndexeddbProvider, beforeApplyUpdatesCallback?: ((arg0: IDBObjectStore) => void) | undefined, afterApplyUpdatesCallback?: ((arg0: IDBObjectStore) => void) | undefined): Promise<IDBObjectStore>;
|
|
6
|
+
export declare function storeState(idbPersistence: IndexeddbProvider, forceStore?: boolean): Promise<void>;
|
|
7
|
+
export declare const clearDocument: (name: string) => Promise<void>;
|
|
8
|
+
interface IndexeddbProviderEvents extends ObservableEvents {
|
|
9
|
+
synced: [db: IndexeddbProvider];
|
|
10
|
+
}
|
|
11
|
+
export declare class IndexeddbProvider extends Observable<IndexeddbProviderEvents> {
|
|
12
|
+
name: string;
|
|
13
|
+
doc: Y.Doc;
|
|
14
|
+
db: IDBDatabase | null;
|
|
15
|
+
synced: boolean;
|
|
16
|
+
whenSynced: Promise<IndexeddbProvider>;
|
|
17
|
+
_dbref: number;
|
|
18
|
+
_dbsize: number;
|
|
19
|
+
_destroyed: boolean;
|
|
20
|
+
_db: Promise<IDBDatabase>;
|
|
21
|
+
_storeTimeout: number;
|
|
22
|
+
_storeTimeoutId: any;
|
|
23
|
+
_storeUpdate: (update: Uint8Array, origin: any) => void;
|
|
24
|
+
constructor(name: string, doc: Y.Doc);
|
|
25
|
+
destroy(): Promise<void>;
|
|
26
|
+
clearData(): Promise<void>;
|
|
27
|
+
get<T = any>(key: IDBValidKey): Promise<T>;
|
|
28
|
+
set<T = any>(key: IDBValidKey, value: T): Promise<T>;
|
|
29
|
+
del(key: IDBValidKey): Promise<any>;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './IndexeddbProvider';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare function rtop(request: IDBRequest): Promise<any>;
|
|
2
|
+
export declare function openDB(name: string, initDB: (arg0: IDBDatabase) => any): Promise<IDBDatabase>;
|
|
3
|
+
export declare function deleteDB(name: string): Promise<void>;
|
|
4
|
+
export declare function createStores(db: IDBDatabase, definitions: Array<Array<string> | Array<string | IDBObjectStoreParameters | undefined>>): void;
|
|
5
|
+
export declare function transact(db: IDBDatabase, stores: Array<string>, access?: 'readwrite' | 'readonly'): Array<IDBObjectStore>;
|
|
6
|
+
export declare function count(store: IDBObjectStore, range?: IDBKeyRange): Promise<number>;
|
|
7
|
+
export declare function get(store: IDBObjectStore, key: IDBValidKey): Promise<string | number | ArrayBuffer | Date | any[]>;
|
|
8
|
+
export declare function del(store: IDBObjectStore, key: IDBValidKey): Promise<any>;
|
|
9
|
+
export declare function put(store: IDBObjectStore, item: any, key?: IDBValidKey): Promise<any>;
|
|
10
|
+
export declare function add(store: IDBObjectStore, item: any, key: IDBValidKey): Promise<any>;
|
|
11
|
+
export declare function addAutoKey(store: IDBObjectStore, item: any): Promise<number>;
|
|
12
|
+
export declare function getAll(store: IDBObjectStore, range?: IDBKeyRange, limit?: number): Promise<any[]>;
|
|
13
|
+
export declare function getAllKeys(store: IDBObjectStore, range?: IDBKeyRange, limit?: number): Promise<any[]>;
|
|
14
|
+
export declare function queryFirst(store: IDBObjectStore, query: IDBKeyRange | undefined, direction: 'next' | 'prev' | 'nextunique' | 'prevunique'): Promise<any>;
|
|
15
|
+
export declare function getLastKey(store: IDBObjectStore, range?: IDBKeyRange): Promise<any>;
|
|
16
|
+
export declare function getFirstKey(store: IDBObjectStore, range?: IDBKeyRange): Promise<any>;
|
|
17
|
+
export declare function getAllKeysValues(store: IDBObjectStore, range?: IDBKeyRange, limit?: number): Promise<any[]>;
|
|
18
|
+
export declare function iterate(store: IDBObjectStore, keyrange: IDBKeyRange | null, f: (arg0: any, arg1: any) => void | boolean | Promise<void | boolean>, direction?: 'next' | 'prev' | 'nextunique' | 'prevunique'): Promise<void>;
|
|
19
|
+
export declare function iterateKeys(store: IDBObjectStore, keyrange: IDBKeyRange | undefined, f: (arg0: any) => void | boolean | Promise<void | boolean>, direction?: 'next' | 'prev' | 'nextunique' | 'prevunique'): Promise<void>;
|
|
20
|
+
export declare function getStore(t: IDBTransaction, store: string): IDBObjectStore;
|
|
21
|
+
export declare function createIDBKeyRangeBound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange;
|
|
22
|
+
export declare function createIDBKeyRangeUpperBound(upper: any, upperOpen?: boolean): IDBKeyRange;
|
|
23
|
+
export declare function createIDBKeyRangeLowerBound(lower: any, lowerOpen?: boolean): IDBKeyRange;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { CoreObject } from 'modern-canvas';
|
|
2
|
+
import type { Document, Element } from 'modern-idoc';
|
|
3
|
+
import type { ModelEvents } from './Model';
|
|
4
|
+
import { Node } from 'modern-canvas';
|
|
5
|
+
import * as Y from 'yjs';
|
|
6
|
+
import { Model } from './Model';
|
|
7
|
+
interface AddElementOptions {
|
|
8
|
+
parentId?: string;
|
|
9
|
+
index?: number;
|
|
10
|
+
regenId?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type YElement = Y.Map<unknown> & {
|
|
13
|
+
get: ((prop: 'id') => string) & ((prop: 'name') => string) & ((prop: 'parentId') => string) & ((prop: 'style') => Y.Map<unknown>) & ((prop: 'background') => Y.Map<unknown>) & ((prop: 'shape') => Y.Map<unknown>) & ((prop: 'fill') => Y.Map<unknown>) & ((prop: 'outline') => Y.Map<unknown>) & ((prop: 'text') => Y.Map<unknown>) & ((prop: 'foreground') => Y.Map<unknown>) & ((prop: 'shadow') => Y.Map<unknown>) & ((prop: 'meta') => Y.Map<unknown>) & ((prop: 'childrenIds') => Y.Array<string>) & (<T = unknown>(prop: string) => T);
|
|
14
|
+
};
|
|
15
|
+
export interface YElementResult {
|
|
16
|
+
id: string;
|
|
17
|
+
element: YElement;
|
|
18
|
+
}
|
|
19
|
+
export declare function iElementToYElements(element: Element, parentId: string | undefined, regenId?: boolean): YElementResult[];
|
|
20
|
+
export interface DocEvents extends ModelEvents {
|
|
21
|
+
history: [arg0: Y.UndoManager];
|
|
22
|
+
}
|
|
23
|
+
export interface Doc {
|
|
24
|
+
on: <K extends keyof DocEvents & string>(event: K, listener: (...args: DocEvents[K]) => void) => this;
|
|
25
|
+
once: <K extends keyof DocEvents & string>(event: K, listener: (...args: DocEvents[K]) => void) => this;
|
|
26
|
+
off: <K extends keyof DocEvents & string>(event: K, listener: (...args: DocEvents[K]) => void) => this;
|
|
27
|
+
emit: <K extends keyof DocEvents & string>(event: K, ...args: DocEvents[K]) => this;
|
|
28
|
+
}
|
|
29
|
+
export declare class Doc extends Model {
|
|
30
|
+
_yChildren: Y.Map<YElement>;
|
|
31
|
+
_yChildrenIds: Y.Array<string>;
|
|
32
|
+
name: string;
|
|
33
|
+
readonly root: Node;
|
|
34
|
+
nodeMap: Map<string, Node>;
|
|
35
|
+
get meta(): import("modern-canvas").Meta;
|
|
36
|
+
set meta(val: import("modern-canvas").Meta);
|
|
37
|
+
constructor(id?: string);
|
|
38
|
+
setProperties(properties?: Record<string, any>): this;
|
|
39
|
+
load(initFn?: () => void | Promise<void>): Promise<this>;
|
|
40
|
+
protected _isSelfTransaction(transaction: Y.Transaction): boolean;
|
|
41
|
+
protected _onChildrenChange(event: Y.YMapEvent<Y.Map<unknown>>, transaction: Y.Transaction): void;
|
|
42
|
+
reset(): this;
|
|
43
|
+
init(): void;
|
|
44
|
+
protected _addElement(element: Element, options?: AddElementOptions): Node;
|
|
45
|
+
addElement(element: Element, options?: AddElementOptions): Node;
|
|
46
|
+
addElements(elements: Element[], options?: AddElementOptions): Node[];
|
|
47
|
+
set(source: Document): this;
|
|
48
|
+
protected _deleteElement(id: string): void;
|
|
49
|
+
deleteElement(id: string): void;
|
|
50
|
+
moveElement(id: string, toIndex: number): void;
|
|
51
|
+
protected _proxyProps(obj: CoreObject, yMap: Y.Map<any>, isMeta?: boolean): void;
|
|
52
|
+
protected _proxyChildren(node: Node, childrenIds: Y.Array<string>): void;
|
|
53
|
+
protected _proxyNode(node: Node, yEle: YElement): void;
|
|
54
|
+
protected _getOrCreateNode(yNode: YElement): Node;
|
|
55
|
+
toJSON(): Record<string, any>;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReactivableEvents } from 'modern-idoc';
|
|
2
|
+
import type { Transaction } from 'yjs';
|
|
3
|
+
import { Reactivable } from 'modern-idoc';
|
|
4
|
+
import * as Y from 'yjs';
|
|
5
|
+
import { IndexeddbProvider } from '../indexeddb';
|
|
6
|
+
export interface ModelEvents extends ReactivableEvents {
|
|
7
|
+
update: [arg0: Uint8Array, arg1: any, arg2: Y.Doc, arg3: Transaction];
|
|
8
|
+
}
|
|
9
|
+
export interface Model {
|
|
10
|
+
on: <K extends keyof ModelEvents & string>(event: K, listener: (...args: ModelEvents[K]) => void) => this;
|
|
11
|
+
once: <K extends keyof ModelEvents & string>(event: K, listener: (...args: ModelEvents[K]) => void) => this;
|
|
12
|
+
off: <K extends keyof ModelEvents & string>(event: K, listener: (...args: ModelEvents[K]) => void) => this;
|
|
13
|
+
emit: <K extends keyof ModelEvents & string>(event: K, ...args: ModelEvents[K]) => this;
|
|
14
|
+
}
|
|
15
|
+
export declare class Model extends Reactivable {
|
|
16
|
+
id: string;
|
|
17
|
+
_transacting: boolean | undefined;
|
|
18
|
+
_yDoc: Y.Doc;
|
|
19
|
+
_yProps: Y.Map<unknown>;
|
|
20
|
+
indexeddb?: IndexeddbProvider;
|
|
21
|
+
undoManager: Y.UndoManager;
|
|
22
|
+
protected _ready: boolean;
|
|
23
|
+
constructor(id?: string);
|
|
24
|
+
protected _setupUndoManager(typeScope?: any[]): void;
|
|
25
|
+
undo(): any;
|
|
26
|
+
redo(): any;
|
|
27
|
+
loadIndexeddb(): Promise<void>;
|
|
28
|
+
transact<T>(fn: () => T, should?: boolean): T;
|
|
29
|
+
load(initFn?: () => void | Promise<void>): Promise<this>;
|
|
30
|
+
reset(): this;
|
|
31
|
+
toJSON(): Record<string, any>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Doc } from './Doc';
|
|
2
|
+
import { Model } from './Model';
|
|
3
|
+
export interface WorkspaceProps {
|
|
4
|
+
name: string;
|
|
5
|
+
type: 'local' | 'cloud';
|
|
6
|
+
createdAt: number;
|
|
7
|
+
updatedAt: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class Workspace extends Model {
|
|
10
|
+
readonly docs: Map<string, Doc>;
|
|
11
|
+
name: string;
|
|
12
|
+
type: 'local' | 'cloud';
|
|
13
|
+
createdAt: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
set(source?: Partial<WorkspaceProps>): this;
|
|
16
|
+
addDoc(doc: Doc): Doc;
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace Mce {
|
|
4
|
+
interface Commands {
|
|
5
|
+
}
|
|
6
|
+
type CommandHandle = (...args: any[]) => any;
|
|
7
|
+
type CommandEvents = {
|
|
8
|
+
[K in keyof Commands as `command:${K}`]: [ReturnType<Commands[K]>];
|
|
9
|
+
};
|
|
10
|
+
interface Events extends CommandEvents {
|
|
11
|
+
}
|
|
12
|
+
interface Editor {
|
|
13
|
+
commands: Ref<Map<string, Commands[keyof Commands]>>;
|
|
14
|
+
registerCommand: {
|
|
15
|
+
<K extends keyof Commands>(key: K, command: Commands[K]): void;
|
|
16
|
+
<K extends keyof Commands>(commands: {
|
|
17
|
+
key: K;
|
|
18
|
+
handle: Commands[K];
|
|
19
|
+
}[]): void;
|
|
20
|
+
};
|
|
21
|
+
unregisterCommand: <K extends keyof Commands = keyof Commands>(key: K) => void;
|
|
22
|
+
exec: <K extends keyof Commands>(key: K, ...args: Parameters<Commands[K]>) => ReturnType<Commands[K]>;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
declare const _default: import("..").Plugin;
|
|
27
|
+
export default _default;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
namespace Mce {
|
|
3
|
+
interface Options extends Partial<Config> {
|
|
4
|
+
}
|
|
5
|
+
type Theme = 'system' | 'light' | 'dark';
|
|
6
|
+
type Language = string;
|
|
7
|
+
type ViewMode = 'frame' | 'edgeless';
|
|
8
|
+
type TypographyStrategy = 'autoHeight' | 'autoWidth' | 'fixedWidthHeight' | 'autoFontSize';
|
|
9
|
+
type HandleShape = 'rect' | 'circle';
|
|
10
|
+
interface Config {
|
|
11
|
+
theme: Theme;
|
|
12
|
+
language: Language;
|
|
13
|
+
viewMode: ViewMode;
|
|
14
|
+
checkerboard: boolean;
|
|
15
|
+
pixelGrid: boolean;
|
|
16
|
+
camera: boolean;
|
|
17
|
+
ruler: boolean;
|
|
18
|
+
scrollbar: boolean;
|
|
19
|
+
bottombar: boolean;
|
|
20
|
+
statusbar: boolean;
|
|
21
|
+
wheelZoom: boolean;
|
|
22
|
+
frameGap: number;
|
|
23
|
+
typographyStrategy: TypographyStrategy;
|
|
24
|
+
handleShape: HandleShape;
|
|
25
|
+
localDb: boolean;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
declare const _default: import("../..").Plugin;
|
|
30
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { WritableComputedRef } from 'vue';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace Mce {
|
|
4
|
+
interface Editor {
|
|
5
|
+
getConfigValue: (path: keyof Config | string, defaultValue?: any) => any;
|
|
6
|
+
setConfigValue: (path: keyof Config | string, value: any) => void;
|
|
7
|
+
getConfig: <T = any>(path: string) => WritableComputedRef<T>;
|
|
8
|
+
registerConfig: <T>(path: keyof Config | string, initValue: T) => WritableComputedRef<T>;
|
|
9
|
+
importConfig: () => Promise<void>;
|
|
10
|
+
exportConfig: () => Blob;
|
|
11
|
+
saveAsConfig: (filename?: string) => void;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
declare const _default: import("..").Plugin;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Cursor, Node, Vector2Data } from 'modern-canvas';
|
|
2
|
+
import type { ComputedRef, Ref } from 'vue';
|
|
3
|
+
import type { Doc, Workspace } from '../models';
|
|
4
|
+
import type { AxisAlignedBoundingBox } from '../types';
|
|
5
|
+
import { Camera2D, DrawboardEffect, Engine } from 'modern-canvas';
|
|
6
|
+
import { Fonts } from 'modern-font';
|
|
7
|
+
declare global {
|
|
8
|
+
namespace Mce {
|
|
9
|
+
interface Editor {
|
|
10
|
+
fonts: Fonts;
|
|
11
|
+
renderEngine: Ref<Engine>;
|
|
12
|
+
camera: Ref<Camera2D>;
|
|
13
|
+
drawboardEffect: Ref<DrawboardEffect>;
|
|
14
|
+
setCursor: (mode: Cursor | undefined) => void;
|
|
15
|
+
drawboardDom: Ref<HTMLElement | undefined>;
|
|
16
|
+
drawboardAabb: Ref<AxisAlignedBoundingBox>;
|
|
17
|
+
drawboardPointer: Ref<Vector2Data | undefined>;
|
|
18
|
+
workspace: Ref<Workspace | undefined>;
|
|
19
|
+
root: ComputedRef<Node | undefined>;
|
|
20
|
+
doc: Ref<Doc | undefined>;
|
|
21
|
+
state: Ref<State | undefined>;
|
|
22
|
+
setState: (state: State, context?: StateContext) => void;
|
|
23
|
+
stateContext: Ref<StateContext | undefined>;
|
|
24
|
+
getGlobalPointer: () => Vector2Data;
|
|
25
|
+
}
|
|
26
|
+
interface Events {
|
|
27
|
+
setState: [state: State];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
declare const _default: import("..").Plugin;
|
|
32
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import { Element2D } from 'modern-canvas';
|
|
3
|
+
declare global {
|
|
4
|
+
namespace Mce {
|
|
5
|
+
interface Editor {
|
|
6
|
+
selection: Ref<Element2D[]>;
|
|
7
|
+
textSelection: Ref<any[] | undefined>;
|
|
8
|
+
getAncestor: (element?: Element2D) => Element2D | undefined;
|
|
9
|
+
hoverElement: Ref<Element2D | undefined>;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
declare const _default: import("..").Plugin;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FontLoadedResult, FontLoadOptions, FontSource } from 'modern-font';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace Mce {
|
|
4
|
+
interface Editor {
|
|
5
|
+
loadFont: (source: FontSource, options?: FontLoadOptions) => Promise<FontLoadedResult>;
|
|
6
|
+
setDefaultFont: (source: FontSource, options?: FontLoadOptions) => Promise<void>;
|
|
7
|
+
waitUntilFontLoad: () => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
interface Options {
|
|
10
|
+
defaultFont?: FontSource;
|
|
11
|
+
}
|
|
12
|
+
interface Events {
|
|
13
|
+
loadFont: [font: FontLoadedResult];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
declare const _default: import("..").Plugin;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
namespace Mce {
|
|
3
|
+
type Translation = (key: string, fallback?: string) => string;
|
|
4
|
+
interface Editor {
|
|
5
|
+
t: Translation;
|
|
6
|
+
}
|
|
7
|
+
interface Options {
|
|
8
|
+
t?: Translation;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
declare const _default: import("..").Plugin;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Node } from 'modern-canvas';
|
|
2
|
+
import type { ComputedRef, Ref } from 'vue';
|
|
3
|
+
import type { AxisAlignedBoundingBox } from '../types';
|
|
4
|
+
import { Element2D } from 'modern-canvas';
|
|
5
|
+
declare global {
|
|
6
|
+
namespace Mce {
|
|
7
|
+
interface FrameThumb {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
url: string;
|
|
11
|
+
}
|
|
12
|
+
interface Editor {
|
|
13
|
+
frameThumbs: Ref<FrameThumb[]>;
|
|
14
|
+
frames: ComputedRef<Element2D[]>;
|
|
15
|
+
activeFrameIndex: Ref<number>;
|
|
16
|
+
activeFrame: ComputedRef<Element2D | undefined>;
|
|
17
|
+
activeFrameAabb: ComputedRef<AxisAlignedBoundingBox>;
|
|
18
|
+
isFrame: (node: Node) => node is Element2D;
|
|
19
|
+
getAncestorFrame: (element?: Element2D) => Element2D | undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
declare const _default: import("..").Plugin;
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Ref, WritableComputedRef } from 'vue';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace Mce {
|
|
4
|
+
interface Hotkeys {
|
|
5
|
+
cancel: [event: KeyboardEvent];
|
|
6
|
+
}
|
|
7
|
+
type HotkeyEvents = {
|
|
8
|
+
[K in keyof Hotkeys as `hotkey:${K}`]: Hotkeys[K];
|
|
9
|
+
};
|
|
10
|
+
interface Events extends HotkeyEvents {
|
|
11
|
+
}
|
|
12
|
+
interface Config {
|
|
13
|
+
hotkeys: HotkeyData[];
|
|
14
|
+
}
|
|
15
|
+
interface HotkeyData {
|
|
16
|
+
key: keyof Hotkeys;
|
|
17
|
+
accelerator: string | string[];
|
|
18
|
+
editable?: boolean;
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
system?: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface Hotkey extends HotkeyData {
|
|
23
|
+
condition?: (e: KeyboardEvent) => boolean;
|
|
24
|
+
handle?: (e: KeyboardEvent) => void;
|
|
25
|
+
}
|
|
26
|
+
interface Editor {
|
|
27
|
+
hotkeysData: WritableComputedRef<HotkeyData[]>;
|
|
28
|
+
hotkeys: Ref<Map<string, Hotkey>>;
|
|
29
|
+
registerHotkey: {
|
|
30
|
+
(key: string, hotkey: Hotkey): void;
|
|
31
|
+
(hotkeys: Hotkey[]): void;
|
|
32
|
+
};
|
|
33
|
+
unregisterHotkey: (key: string) => void;
|
|
34
|
+
getKbd: (key: string | keyof Hotkeys) => string;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
declare const _default: import("..").Plugin;
|
|
39
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
namespace Mce {
|
|
3
|
+
type Upload = (file: File | Blob) => Promise<string>;
|
|
4
|
+
interface Editor {
|
|
5
|
+
upload: Upload;
|
|
6
|
+
}
|
|
7
|
+
interface Options {
|
|
8
|
+
upload?: Upload;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
declare const _default: import("..").Plugin;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Node } from 'modern-canvas';
|
|
2
|
+
import type { ComputedRef } from 'vue';
|
|
3
|
+
import type { AxisAlignedBoundingBox, OrientedBoundingBox } from '../types';
|
|
4
|
+
import { Element2D } from 'modern-canvas';
|
|
5
|
+
declare global {
|
|
6
|
+
namespace Mce {
|
|
7
|
+
interface Editor {
|
|
8
|
+
obbToFit: (element: Element2D) => void;
|
|
9
|
+
getObb: (node: Node | Node[] | undefined, inTarget?: 'drawboard' | 'frame') => OrientedBoundingBox;
|
|
10
|
+
getObbInDrawboard: (node?: Node | Node[]) => OrientedBoundingBox;
|
|
11
|
+
getAabb: (node: Node | Node[] | undefined, inTarget?: 'drawboard' | 'frame') => AxisAlignedBoundingBox;
|
|
12
|
+
getAabbInDrawboard: (node?: Node | Node[]) => AxisAlignedBoundingBox;
|
|
13
|
+
aabbToDrawboardAabb: (aabb: AxisAlignedBoundingBox) => AxisAlignedBoundingBox;
|
|
14
|
+
rootAabb: ComputedRef<AxisAlignedBoundingBox>;
|
|
15
|
+
currentAabb: ComputedRef<AxisAlignedBoundingBox>;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
declare const _default: import("..").Plugin;
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Element2D } from 'modern-canvas';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
declare global {
|
|
4
|
+
namespace Mce {
|
|
5
|
+
type ExporterProgress = (current: number, total: number) => void;
|
|
6
|
+
interface ExporterOptions {
|
|
7
|
+
scale?: number;
|
|
8
|
+
selected?: boolean | Element2D[];
|
|
9
|
+
onProgress?: ExporterProgress;
|
|
10
|
+
}
|
|
11
|
+
type Exporter = (options: ExporterOptions) => any | Promise<any>;
|
|
12
|
+
interface Editor {
|
|
13
|
+
exporters: Ref<Map<string, Exporter>>;
|
|
14
|
+
registerExporter: {
|
|
15
|
+
(key: string, exporter: Exporter): void;
|
|
16
|
+
(exporters: {
|
|
17
|
+
key: string;
|
|
18
|
+
handle: Exporter;
|
|
19
|
+
}[]): void;
|
|
20
|
+
};
|
|
21
|
+
unregisterExporter: (key: keyof Exporters) => void;
|
|
22
|
+
to: <K extends keyof Exporters>(key: K, options?: ExporterOptions) => Exporters[K];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
declare const _default: import("..").Plugin;
|
|
27
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { NormalizedElement } from 'modern-idoc';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
declare global {
|
|
4
|
+
namespace Mce {
|
|
5
|
+
interface Loader {
|
|
6
|
+
name: string;
|
|
7
|
+
accept?: string;
|
|
8
|
+
test: (source: any) => boolean | Promise<boolean>;
|
|
9
|
+
load: (source: any) => Promise<NormalizedElement | undefined>;
|
|
10
|
+
}
|
|
11
|
+
interface Editor {
|
|
12
|
+
loaders: Ref<Map<string, Loader>>;
|
|
13
|
+
registerLoader: (loader: Loader | Loader[]) => void;
|
|
14
|
+
unregisterLoader: (name: string) => void;
|
|
15
|
+
load: <T = NormalizedElement>(source: any) => Promise<T>;
|
|
16
|
+
openFileDialog: (options?: {
|
|
17
|
+
multiple?: boolean;
|
|
18
|
+
}) => Promise<File[]>;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
declare const _default: import("..").Plugin;
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ComputedRef } from 'vue';
|
|
2
|
+
import type { AxisAlignedBoundingBox } from '../types';
|
|
3
|
+
declare global {
|
|
4
|
+
namespace Mce {
|
|
5
|
+
interface Editor {
|
|
6
|
+
viewAabb: ComputedRef<AxisAlignedBoundingBox>;
|
|
7
|
+
bindRenderCanvas: (canvas: HTMLCanvasElement, setEventTarget?: HTMLElement) => () => void;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
declare const _default: import("..").Plugin;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Element2D } from 'modern-canvas';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace Mce {
|
|
4
|
+
interface Editor {
|
|
5
|
+
textFontSizeToFit: (element: Element2D) => void;
|
|
6
|
+
textToFit: (element: Element2D, typography?: Mce.TypographyStrategy) => void;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
declare const _default: import("..").Plugin;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Element2D } from 'modern-canvas';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace Mce {
|
|
4
|
+
interface Commands {
|
|
5
|
+
'lock': () => void;
|
|
6
|
+
'unlock': () => void;
|
|
7
|
+
'lock/unlock': () => void;
|
|
8
|
+
}
|
|
9
|
+
interface Hotkeys {
|
|
10
|
+
'lock/unlock': [event: KeyboardEvent];
|
|
11
|
+
}
|
|
12
|
+
interface Editor {
|
|
13
|
+
isLocked: (element: Element2D) => boolean;
|
|
14
|
+
lock: (element: Element2D) => void;
|
|
15
|
+
unlock: (element: Element2D) => void;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
declare const _default: import("..").Plugin;
|
|
20
|
+
export default _default;
|