@upmade/vue-editor 0.0.0-stage → 0.6.2

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.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Lukas Mühlenbeck
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,95 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # Upmade Editor for Vue
2
+
3
+ Build infinite canvas and collaborative whiteboard experiences in Vue with Upmade's native wrapper and TypeScript-first API.
4
+
5
+ Upmade is a framework-agnostic infinite canvas and collaborative whiteboard engine. It provides web components that work natively in any framework, with a first-class Vue wrapper for idiomatic template integration.
6
+
7
+ Upmade handles the hard parts of canvas-based applications — infinite pan and zoom, hit-testing, CRDT-based collaboration, undo and redo, and cross-browser rendering — so you can focus on your product's domain logic.
8
+
9
+ **Full documentation:** [upmade.io/docs/vue/getting-started/quick-start](https://upmade.io/docs/vue/getting-started/quick-start)
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install @upmade/vue-editor
15
+ ```
16
+
17
+ ## Setup
18
+
19
+ Render Upmade in your component:
20
+
21
+ ```html
22
+ <script setup lang="ts">
23
+ import { UpmadeEditor } from '@upmade/vue-editor'
24
+ </script>
25
+
26
+ <template>
27
+ <UpmadeEditor style="display: block; width: 100%; height: 100vh" />
28
+ </template>
29
+ ```
30
+
31
+ This renders the editor with the **full default toolbar**: selection, brush, eraser, line, shape, text, and image tools.
32
+
33
+ ## Optional Enhancements
34
+
35
+ ### Persist Canvas State
36
+
37
+ By default, the editor uses an empty sync provider list, so canvas state is reset on reload. To persist objects locally across page reloads, configure `syncConfig` explicitly with `IndexedDBSyncProvider`.
38
+
39
+ ```html
40
+ <script setup lang="ts">
41
+ import { UpmadeEditor, IndexedDBSyncProvider } from '@upmade/vue-editor'
42
+
43
+ const syncConfig = {
44
+ providers: [IndexedDBSyncProvider],
45
+ }
46
+ </script>
47
+
48
+ <template>
49
+ <UpmadeEditor :syncConfig="syncConfig" style="display: block; width: 100%; height: 100vh" />
50
+ </template>
51
+ ```
52
+
53
+ ### Apply Full Viewport Styling
54
+
55
+ To ensure the Upmade editor occupies the entire viewport and prevents unwanted scrolling, add the following CSS to your global stylesheet (e.g. `styles.css`):
56
+
57
+ ```css
58
+ html,
59
+ body,
60
+ #app {
61
+ width: 100dvw;
62
+ height: 100dvh;
63
+ margin: 0;
64
+ padding: 0;
65
+ overflow: hidden;
66
+ }
67
+ ```
68
+
69
+ ### Include Mobile Viewport Meta Tag
70
+
71
+ For optimal rendering and responsiveness on mobile devices, add this meta tag within the `<head>` section of your `index.html`:
72
+
73
+ ```html
74
+ <meta
75
+ name="viewport"
76
+ content="viewport-fit=cover, width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0, interactive-widget=resizes-content"
77
+ />
78
+ ```
79
+
80
+ ## Fundamentals
81
+
82
+ Upmade is composed of a small set of core concepts that work together to power your canvas experience:
83
+
84
+ - **[Components](https://upmade.io/docs/vue/getting-started/basic-usage)** — Two entry points, a batteries-included editor and a headless engine, to match any integration style.
85
+ - **[Tools](https://upmade.io/docs/vue/fundamentals/tools)** — State-machine interaction handlers that define how users draw, select, and manipulate the canvas.
86
+ - **[Objects](https://upmade.io/docs/vue/fundamentals/objects)** — The visual building blocks on the canvas, such as paths, shapes, text, and images with shared spatial properties.
87
+ - **[Workspaces](https://upmade.io/docs/vue/fundamentals/workspaces)** — Containers that manage an entire canvas collection, view state, and editor configuration.
88
+ - **[Theming](https://upmade.io/docs/vue/customization/themes)** — Built-in light and dark themes with full CSS variable customization to match your brand.
89
+ - **[Collaboration](https://upmade.io/docs/vue/advanced/collaboration)** — Real-time multi-user sync powered by Yjs CRDTs with pluggable transport providers.
90
+
91
+ Learn more in the [full documentation](https://upmade.io/docs/vue/getting-started/basic-usage).
92
+
93
+ ## License
94
+
95
+ Upmade is released under the [MIT License](./LICENSE.md).
@@ -0,0 +1,9 @@
1
+ import { type StencilVueComponent } from '@stencil/vue-output-target/runtime';
2
+ import type { JSX } from '@upmade/editor/dist/components';
3
+ export declare const UpmadeChatBox: StencilVueComponent<JSX.UpmadeChatBox>;
4
+ export declare const UpmadeEditor: StencilVueComponent<JSX.UpmadeEditor>;
5
+ export declare const UpmadeSettings: StencilVueComponent<JSX.UpmadeSettings>;
6
+ export declare const UpmadeShapeFill: StencilVueComponent<JSX.UpmadeShapeFill>;
7
+ export declare const UpmadeShareDialog: StencilVueComponent<JSX.UpmadeShareDialog>;
8
+ export declare const UpmadeSplitButton: StencilVueComponent<JSX.UpmadeSplitButton>;
9
+ export declare const UpmadeStrokeSize: StencilVueComponent<JSX.UpmadeStrokeSize>;
@@ -0,0 +1,179 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ /* auto-generated vue proxies */
4
+ import { defineContainer } from '@stencil/vue-output-target/runtime';
5
+ import { defineCustomElement as defineUpmadeChatBox } from '@upmade/editor/dist/components/upmade-chat-box.js';
6
+ import { defineCustomElement as defineUpmadeEditor } from '@upmade/editor/dist/components/upmade-editor.js';
7
+ import { defineCustomElement as defineUpmadeSettings } from '@upmade/editor/dist/components/upmade-settings.js';
8
+ import { defineCustomElement as defineUpmadeShapeFill } from '@upmade/editor/dist/components/upmade-shape-fill.js';
9
+ import { defineCustomElement as defineUpmadeShareDialog } from '@upmade/editor/dist/components/upmade-share-dialog.js';
10
+ import { defineCustomElement as defineUpmadeSplitButton } from '@upmade/editor/dist/components/upmade-split-button.js';
11
+ import { defineCustomElement as defineUpmadeStrokeSize } from '@upmade/editor/dist/components/upmade-stroke-size.js';
12
+ export const UpmadeChatBox = /*@__PURE__*/ defineContainer('upmade-chat-box', defineUpmadeChatBox, [
13
+ 'value',
14
+ 'mode',
15
+ 'placeholder',
16
+ 'disabled',
17
+ 'loading',
18
+ 'terms',
19
+ 'chips',
20
+ 'chatSubmit',
21
+ 'chatStop',
22
+ 'modeChange',
23
+ 'chatChipRemove'
24
+ ], [
25
+ 'chatSubmit',
26
+ 'chatStop',
27
+ 'modeChange',
28
+ 'chatChipRemove'
29
+ ]);
30
+ export const UpmadeEditor = /*@__PURE__*/ defineContainer('upmade-editor', defineUpmadeEditor, [
31
+ 'scaleMax',
32
+ 'scaleMin',
33
+ 'lockDrawingScale',
34
+ 'viewportBoundaryLeft',
35
+ 'viewportBoundaryRight',
36
+ 'viewportBoundaryTop',
37
+ 'viewportBoundaryBottom',
38
+ 'debugInfo',
39
+ 'user',
40
+ 'activeUsers',
41
+ 'isAgentAvatarsVisible',
42
+ 'toolbarItems',
43
+ 'globalContextMenuItems',
44
+ 'objectContextMenuItems',
45
+ 'objectConfig',
46
+ 'objectTitlebar',
47
+ 'moreMenuItems',
48
+ 'themes',
49
+ 'theme',
50
+ 'locale',
51
+ 'locales',
52
+ 'fallbackLocale',
53
+ 'customSvgIcons',
54
+ 'customFonts',
55
+ 'isPanningEnabled',
56
+ 'isZoomingEnabled',
57
+ 'isToolbarVisible',
58
+ 'isChatBoxVisible',
59
+ 'chatBoxMode',
60
+ 'isChatBoxLoading',
61
+ 'chatBoxChips',
62
+ 'chatSession',
63
+ 'isUtilityPanelVisible',
64
+ 'isWorkspaceManagerVisible',
65
+ 'isMoreMenuVisible',
66
+ 'isZoomPanelVisible',
67
+ 'isWatermarkVisible',
68
+ 'syncConfig',
69
+ 'assetStorageConfig',
70
+ 'cursorTarget',
71
+ 'loginConfig',
72
+ 'editorId',
73
+ 'activeWorkspaceId',
74
+ 'workspaces',
75
+ 'isReady',
76
+ 'activeWorkspaceChange',
77
+ 'objectsChange',
78
+ 'objectsAdded',
79
+ 'objectsRemoved',
80
+ 'objectsUpdated',
81
+ 'objectsSelectionChange',
82
+ 'undoStateChange',
83
+ 'themeChange',
84
+ 'localeChange',
85
+ 'viewportChange',
86
+ 'logout',
87
+ 'login',
88
+ 'isPublicChange',
89
+ 'awarenessChange',
90
+ 'chatSubmit',
91
+ 'chatStop',
92
+ 'chatChipRemove',
93
+ 'agentsChange',
94
+ 'objectTitlebarAction',
95
+ 'objectElementHover',
96
+ 'objectElementClick',
97
+ 'objectElementPick'
98
+ ], [
99
+ 'isReady',
100
+ 'activeWorkspaceChange',
101
+ 'objectsChange',
102
+ 'objectsAdded',
103
+ 'objectsRemoved',
104
+ 'objectsUpdated',
105
+ 'objectsSelectionChange',
106
+ 'undoStateChange',
107
+ 'themeChange',
108
+ 'localeChange',
109
+ 'viewportChange',
110
+ 'logout',
111
+ 'login',
112
+ 'isPublicChange',
113
+ 'awarenessChange',
114
+ 'chatSubmit',
115
+ 'chatStop',
116
+ 'chatChipRemove',
117
+ 'agentsChange',
118
+ 'objectTitlebarAction',
119
+ 'objectElementHover',
120
+ 'objectElementClick',
121
+ 'objectElementPick'
122
+ ]);
123
+ export const UpmadeSettings = /*@__PURE__*/ defineContainer('upmade-settings', defineUpmadeSettings, [
124
+ 'availableThemes',
125
+ 'availableLocales',
126
+ 'shortcuts',
127
+ 'terms',
128
+ 'settings',
129
+ 'settingsChange'
130
+ ], [
131
+ 'settingsChange'
132
+ ]);
133
+ export const UpmadeShapeFill = /*@__PURE__*/ defineContainer('upmade-shape-fill', defineUpmadeShapeFill, [
134
+ 'value',
135
+ 'valueChange'
136
+ ], [
137
+ 'valueChange'
138
+ ]);
139
+ export const UpmadeShareDialog = /*@__PURE__*/ defineContainer('upmade-share-dialog', defineUpmadeShareDialog, [
140
+ 'isPublic',
141
+ 'workspaceId',
142
+ 'terms',
143
+ 'toggleIsPublic',
144
+ 'dialogClosed'
145
+ ], [
146
+ 'toggleIsPublic',
147
+ 'dialogClosed'
148
+ ]);
149
+ export const UpmadeSplitButton = /*@__PURE__*/ defineContainer('upmade-split-button', defineUpmadeSplitButton, [
150
+ 'buttonIcon',
151
+ 'dropdownIcon',
152
+ 'items',
153
+ 'mainButtonDisabled',
154
+ 'menuButtonDisabled',
155
+ 'mainButtonClick',
156
+ 'itemSelect',
157
+ 'itemSave',
158
+ 'itemCancel',
159
+ 'itemToggleChildMenu',
160
+ 'itemCloseChildMenu',
161
+ 'menuOpen',
162
+ 'menuClose'
163
+ ], [
164
+ 'mainButtonClick',
165
+ 'itemSelect',
166
+ 'itemSave',
167
+ 'itemCancel',
168
+ 'itemToggleChildMenu',
169
+ 'itemCloseChildMenu',
170
+ 'menuOpen',
171
+ 'menuClose'
172
+ ]);
173
+ export const UpmadeStrokeSize = /*@__PURE__*/ defineContainer('upmade-stroke-size', defineUpmadeStrokeSize, [
174
+ 'sizes',
175
+ 'selectedSize',
176
+ 'sizeChange'
177
+ ], [
178
+ 'sizeChange'
179
+ ]);
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Resolves the native Upmade editor element from a specific Vue template ref.
3
+ *
4
+ * Because `<UpmadeEditor>` is a Vue component (not a raw custom element),
5
+ * a template ref points to the component instance rather than the DOM element.
6
+ * Pass the same ref that is bound in your template to make sure the resolved
7
+ * editor always belongs to that exact component instance.
8
+ *
9
+ * @example
10
+ * ```vue
11
+ * <script setup lang="ts">
12
+ * import { UpmadeEditor, getEditorRef } from '@upmade/vue-editor'
13
+ * import { ref, type ComponentPublicInstance } from 'vue'
14
+ *
15
+ * const editorComponent = ref<ComponentPublicInstance | null>(null)
16
+ * const editor = getEditorRef(editorComponent)
17
+ *
18
+ * async function onReady() {
19
+ * await editor.value?.addObject(...)
20
+ * }
21
+ * </script>
22
+ *
23
+ * <template>
24
+ * <UpmadeEditor ref="editor" @isReady="onReady" />
25
+ * </template>
26
+ * ```
27
+ */
28
+ export declare function getEditorRef(componentRef: string): import("vue").ComputedRef<HTMLUpmadeEditorElement>;
29
+ /**
30
+ * Resolves the native Upmade engine element from a specific Vue template ref.
31
+ *
32
+ * Because `<UpmadeEngine>` is a Vue component (not a raw custom element),
33
+ * a template ref points to the component instance rather than the DOM element.
34
+ * Pass the same ref that is bound in your template to make sure the resolved
35
+ * engine always belongs to that exact component instance.
36
+ */
37
+ export declare function getEngineRef(componentRef: string): import("vue").ComputedRef<HTMLUpmadeEngineElement>;
@@ -0,0 +1,62 @@
1
+ import { computed, useTemplateRef, } from "vue";
2
+ /**
3
+ * Resolves the native Upmade editor element from a specific Vue template ref.
4
+ *
5
+ * Because `<UpmadeEditor>` is a Vue component (not a raw custom element),
6
+ * a template ref points to the component instance rather than the DOM element.
7
+ * Pass the same ref that is bound in your template to make sure the resolved
8
+ * editor always belongs to that exact component instance.
9
+ *
10
+ * @example
11
+ * ```vue
12
+ * <script setup lang="ts">
13
+ * import { UpmadeEditor, getEditorRef } from '@upmade/vue-editor'
14
+ * import { ref, type ComponentPublicInstance } from 'vue'
15
+ *
16
+ * const editorComponent = ref<ComponentPublicInstance | null>(null)
17
+ * const editor = getEditorRef(editorComponent)
18
+ *
19
+ * async function onReady() {
20
+ * await editor.value?.addObject(...)
21
+ * }
22
+ * </script>
23
+ *
24
+ * <template>
25
+ * <UpmadeEditor ref="editor" @isReady="onReady" />
26
+ * </template>
27
+ * ```
28
+ */
29
+ export function getEditorRef(componentRef) {
30
+ const editorComponent = useTemplateRef(componentRef);
31
+ return computed(() => {
32
+ var _a;
33
+ const value = editorComponent.value;
34
+ if (!value) {
35
+ return null;
36
+ }
37
+ return "$el" in value
38
+ ? ((_a = value.$el) !== null && _a !== void 0 ? _a : null)
39
+ : value;
40
+ });
41
+ }
42
+ /**
43
+ * Resolves the native Upmade engine element from a specific Vue template ref.
44
+ *
45
+ * Because `<UpmadeEngine>` is a Vue component (not a raw custom element),
46
+ * a template ref points to the component instance rather than the DOM element.
47
+ * Pass the same ref that is bound in your template to make sure the resolved
48
+ * engine always belongs to that exact component instance.
49
+ */
50
+ export function getEngineRef(componentRef) {
51
+ const engineComponent = useTemplateRef(componentRef);
52
+ return computed(() => {
53
+ var _a;
54
+ const value = engineComponent.value;
55
+ if (!value) {
56
+ return null;
57
+ }
58
+ return "$el" in value
59
+ ? ((_a = value.$el) !== null && _a !== void 0 ? _a : null)
60
+ : value;
61
+ });
62
+ }
@@ -0,0 +1,7 @@
1
+ export * from './components';
2
+ export * from './composables';
3
+ export * from './plugin';
4
+ export * from './vue-dynamic-object-renderer';
5
+ export { UpmadeBaseObject, UpmadeText, UpmadePath, UpmadeImage, UpmadeLine, UpmadeShape, UpmadeGroup, UpmadeDynamicObject, UpmadeIframeObject, UpmadeDynamicObjectRendererRegistry, UpmadeFontRegistry, UpmadeBaseTool, UpmadeBrushTool, UpmadeTextTool, UpmadeLineTool, UpmadeShapeTool, UpmadeEraserTool, UpmadeSelectionTool, UpmadeImageTool, UpmadeWorkspace, InMemorySyncProvider, IndexedDBSyncProvider, BroadcastSyncProvider, WebSocketSyncProvider, HocuspocusSyncProvider, IndexedDBAssetProvider, HttpAssetProvider, PresignedAssetProvider, AssetNotFoundError, DEFAULT_ASSET_STORAGE_CONFIG, UpmadeThemeManager, UpmadeLocalizationManager, ShapeType, UpmadeAlignment, lightTheme, darkTheme, UPMADE_DEFAULT_OBJECT_TITLEBAR, EN_LOCALE, DE_LOCALE, FR_LOCALE, DEFAULT_BRUSH_CONFIG, DEFAULT_TEXT_CONFIG, DEFAULT_SHAPE_CONFIG, hasRemoteSyncProvider, UpmadeAgent, UpmadeAgentActionError, isUpmadeAgent, formatAgentToolResult, parsePartialJson, AGENT_TOOL_REASON_HINTS, MODEL_IFRAME_CONTENT_SECURITY_POLICY, UpmadeChatSession, isUpmadeChatSession, createScriptedTransport, createHttpTransport, UpmadeChatHttpError, UPMADE_CHAT_PROTOCOL_VERSION, } from '@upmade/engine';
6
+ export type { HTMLUpmadeEditorElement } from '@upmade/editor';
7
+ export type { HTMLUpmadeEngineElement, UpmadeToolDefinition, UpmadeToolbarItem, UpmadeBrushToolConfig, UpmadeLineToolConfig, UpmadeShapeToolConfig, UpmadeTextToolConfig, UpmadeTextConfig, UpmadeShapeConfig, UpmadeLineConfig, UpmadePathConfig, UpmadeImageConfig, UpmadeGroupConfig, UpmadeDynamicObjectConfig, UpmadeIframeContent, UpmadeIframeObjectConfig, UpmadeIframeObjectLifecycleContext, UpmadeEmbeddedObject, UpmadeWorkspaceConfig, UpmadeFontDefinition, UpmadeFontRegistration, UpmadeRegisteredFont, UpmadeFontMap, UpmadeSyncConfig, UpmadeAssetStorageConfig, UpmadeAsset, UpmadeAssetKind, UpmadeAssetLoadState, UpmadeAssetPutMetadata, IAssetStorageProvider, AssetProviderType, AssetProviderFactory, AssetProviderConfig, IndexedDBAssetProviderOptions, HttpAssetProviderOptions, HttpAssetUploadResponse, PresignedAssetProviderOptions, UpmadePresignedUpload, UpmadeTheme, UpmadeViewportState, UpmadeAgentTool, UpmadeAgentToolSchema, UpmadeAgentToolContext, UpmadeAgentToolCall, UpmadeAgentToolsOptions, UpmadeChatSessionOptions, UpmadeChatActor, UpmadeChatTool, UpmadeChatToolContext, UpmadeChatSessionEventMap, UpmadeChatInput, UpmadeChatSendResult, UpmadeChatMessage, UpmadeChatPart, UpmadeChatTextPart, UpmadeChatImagePart, UpmadeChatToolCallPart, UpmadeChatToolResultPart, UpmadeChatProviderData, UpmadeChatToolDefinition, UpmadeChatRequest, UpmadeChatResponse, UpmadeChatStopReason, UpmadeChatStreamEvent, UpmadeChatToolCallUpdate, UpmadeChatToolCallState, UpmadeChatTransport, UpmadeChatTransportOptions, UpmadeScriptedStep, UpmadeScriptedAnswer, UpmadeScriptedToolCall, UpmadeScriptedTransportOptions, UpmadeHttpTransportOptions, UpmadeAgentToolResult, UpmadeCanvasObject, UpmadeCanvasElement, UpmadeCanvasSnapshot, UpmadeObserveOptions, UpmadeRemoteAgentPresence, BroadcastSyncOptions, UpmadeAgentOptions, UpmadeAgentState, UpmadeAgentDetachedEvent, UpmadeAgentInterruptedEvent, UpmadeAgentEventMap, UpmadeAgentPresence, UpmadeAgentsChangeEvent, UpmadeAgenticObjectStyle, UpmadeAgenticSetStyleAction, UpmadeAgenticAddObjectAction, UpmadeAgenticFill, UpmadeAgenticAnchor, UpmadeAgenticAttachment, UpmadeAgenticMoveOptions, UpmadeAgenticMoveResult, UpmadeAgenticObjectTarget, UpmadeAgenticElementTarget, UpmadeAgenticPointTarget, UpmadeAgenticTarget, UpmadeAgenticAction, UpmadeAgenticActionFailureReason, UpmadeAgenticActionOptions, UpmadeAgenticActionResult, UpmadeAgenticActionType, UpmadeAgentChangeSource, UpmadeAgenticClearSelectionAction, UpmadeAgenticClickAction, UpmadeAgenticInteractWithElementAction, UpmadeAgenticColor, UpmadeAgenticConnectAction, UpmadeAgenticLineEnd, UpmadeAgenticDrawLineAction, UpmadeAgenticEditLineAction, UpmadeAgenticCreateShapeAction, UpmadeAgenticCreateTextAction, UpmadeAgenticDrawPathAction, UpmadeAgenticLineStyle, UpmadeAgenticResizeHandle, UpmadeAgenticResizeObjectAction, UpmadeAgenticRotateObjectAction, UpmadeAgenticCopyObjectsAction, UpmadeAgenticGroupObjectsAction, UpmadeAgenticUngroupObjectsAction, UpmadeAgenticOrderObjectsAction, UpmadeAgenticOrder, UpmadeAgenticShapeStyle, UpmadeAgenticStrokeStyle, UpmadeAgenticTextStyle, UpmadeAgenticTypeTextAction, UpmadeAgenticDeleteObjectsAction, UpmadeAgenticMoveObjectAction, UpmadeAgenticRedoAction, UpmadeAgenticSelectAction, UpmadeAgenticUndoAction, UpmadeEasing, UpmadeObjectChangeSource, LineArrowConfig, ArrowHeadConfig, ArrowHeadStyle, UpmadePoint, ContextMenuItem, UpmadeObjectConfig, UpmadeObjectTitlebarConfig, UpmadeObjectTitlebarContext, UpmadeObjectTitlebarActionEvent, UpmadeObjectTitlebarMenuState, UpmadeElementAwareObject, UpmadeObjectElementRect, UpmadeObjectElementInfo, UpmadeObjectElementState, UpmadeObjectElementQueryOptions, UpmadeObjectElementInteraction, UpmadeObjectElementInteractionType, UpmadeObjectElementInteractionOptions, UpmadeObjectElementInteractionFailureReason, UpmadeObjectElementInteractionResult, UpmadeObjectElementHighlight, UpmadeObjectElementPickingOptions, UpmadeObjectElementModifiers, UpmadeObjectElementHoverEvent, UpmadeObjectElementClickEvent, UpmadeObjectElementPickEvent, UpmadeChatBoxChip, UpmadeTitlebarElement, UpmadeTitlebarTitle, UpmadeTitlebarText, UpmadeTitlebarIcon, UpmadeTitlebarButton, UpmadeTitlebarMenu, UpmadeTitlebarMenuItem, UpmadeTitlebarSpacer, UpmadeTitlebarValue, UpmadeTitlebarSection, UpmadeObjectExportFormat, UpmadeObjectExportContext, UpmadeExportable, ThemeAwareColor, ThemeName, UpmadeLocale, LocaleCode, UpmadeTerms, UpmadeTermKey, UpmadeTermVars, UpmadeLoginConfig, UpmadeLoginProvider, LoginEvent, EditorIsReadyEvent, ActiveWorkspaceChangeEvent, ObjectsAddedEvent, ObjectsRemovedEvent, ObjectsUpdatedEvent, ObjectsInViewportChangeEvent, UpmadeUndoState, IUpmadeIsPublicChangeEvent, UpmadeEngineState, UpmadeDebugInfo, IUpmadeUser, } from '@upmade/engine';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './components';
2
+ export * from './composables';
3
+ export * from './plugin';
4
+ export * from './vue-dynamic-object-renderer';
5
+ export { UpmadeBaseObject, UpmadeText, UpmadePath, UpmadeImage, UpmadeLine, UpmadeShape, UpmadeGroup, UpmadeDynamicObject, UpmadeIframeObject, UpmadeDynamicObjectRendererRegistry, UpmadeFontRegistry, UpmadeBaseTool, UpmadeBrushTool, UpmadeTextTool, UpmadeLineTool, UpmadeShapeTool, UpmadeEraserTool, UpmadeSelectionTool, UpmadeImageTool, UpmadeWorkspace, InMemorySyncProvider, IndexedDBSyncProvider, BroadcastSyncProvider, WebSocketSyncProvider, HocuspocusSyncProvider, IndexedDBAssetProvider, HttpAssetProvider, PresignedAssetProvider, AssetNotFoundError, DEFAULT_ASSET_STORAGE_CONFIG, UpmadeThemeManager, UpmadeLocalizationManager, ShapeType, UpmadeAlignment, lightTheme, darkTheme, UPMADE_DEFAULT_OBJECT_TITLEBAR, EN_LOCALE, DE_LOCALE, FR_LOCALE, DEFAULT_BRUSH_CONFIG, DEFAULT_TEXT_CONFIG, DEFAULT_SHAPE_CONFIG, hasRemoteSyncProvider, UpmadeAgent, UpmadeAgentActionError, isUpmadeAgent, formatAgentToolResult, parsePartialJson, AGENT_TOOL_REASON_HINTS, MODEL_IFRAME_CONTENT_SECURITY_POLICY, UpmadeChatSession, isUpmadeChatSession, createScriptedTransport, createHttpTransport, UpmadeChatHttpError, UPMADE_CHAT_PROTOCOL_VERSION, } from '@upmade/engine';
@@ -0,0 +1 @@
1
+ export declare const ComponentLibrary: any;
package/dist/plugin.js ADDED
@@ -0,0 +1,6 @@
1
+ // Components are registered on demand by the generated proxies (dist-custom-elements build).
2
+ // Calling the lazy loader from '@upmade/engine/loader' here would register a second,
3
+ // lazy-loaded `upmade-engine` that wins the race against the editor's bundled one.
4
+ export const ComponentLibrary = {
5
+ install() { },
6
+ };
@@ -0,0 +1,16 @@
1
+ export interface InputProps<T> {
2
+ modelValue?: T;
3
+ }
4
+ /**
5
+ * Create a callback to define a Vue component wrapper around a Web Component.
6
+ *
7
+ * @prop name - The component tag name (i.e. `ion-button`)
8
+ * @prop componentProps - An array of properties on the
9
+ * component. These usually match up with the @Prop definitions
10
+ * in each component's TSX file.
11
+ * @prop customElement - An option custom element instance to pass
12
+ * to customElements.define. Only set if `includeImportCustomElements: true` in your config.
13
+ * @prop modelProp - The prop that v-model binds to (i.e. value)
14
+ * @prop modelUpdateEvent - The event that is fired from your Web Component when the value changes (i.e. ionChange)
15
+ */
16
+ export declare const defineContainer: <Props, VModelType = string | number | boolean>(name: string, defineCustomElement: any, componentProps?: string[], modelProp?: string, modelUpdateEvent?: string) => import("vue").DefineSetupFnComponent<Props & InputProps<VModelType>, {}, {}, Props & InputProps<VModelType> & {}, import("vue").PublicProps>;
@@ -0,0 +1,188 @@
1
+ // @ts-nocheck
2
+ // It's easier and safer for Volar to disable typechecking and let the return type inference do its job.
3
+ import { defineComponent, getCurrentInstance, h, inject, ref, withDirectives } from 'vue';
4
+ const UPDATE_VALUE_EVENT = 'update:modelValue';
5
+ const MODEL_VALUE = 'modelValue';
6
+ const ROUTER_LINK_VALUE = 'routerLink';
7
+ const NAV_MANAGER = 'navManager';
8
+ const ROUTER_PROP_PREFIX = 'router';
9
+ const ARIA_PROP_PREFIX = 'aria';
10
+ /**
11
+ * Starting in Vue 3.1.0, all properties are
12
+ * added as keys to the props object, even if
13
+ * they are not being used. In order to correctly
14
+ * account for both value props and v-model props,
15
+ * we need to check if the key exists for Vue <3.1.0
16
+ * and then check if it is not undefined for Vue >= 3.1.0.
17
+ * See https://github.com/vuejs/vue-next/issues/3889
18
+ */
19
+ const EMPTY_PROP = Symbol();
20
+ const DEFAULT_EMPTY_PROP = { default: EMPTY_PROP };
21
+ const getComponentClasses = (classes) => {
22
+ return (classes === null || classes === void 0 ? void 0 : classes.split(' ')) || [];
23
+ };
24
+ const getElementClasses = (ref, componentClasses, defaultClasses = []) => {
25
+ var _a;
26
+ return [...Array.from(((_a = ref.value) === null || _a === void 0 ? void 0 : _a.classList) || []), ...defaultClasses].filter((c, i, self) => !componentClasses.has(c) && self.indexOf(c) === i);
27
+ };
28
+ /**
29
+ * Create a callback to define a Vue component wrapper around a Web Component.
30
+ *
31
+ * @prop name - The component tag name (i.e. `ion-button`)
32
+ * @prop componentProps - An array of properties on the
33
+ * component. These usually match up with the @Prop definitions
34
+ * in each component's TSX file.
35
+ * @prop customElement - An option custom element instance to pass
36
+ * to customElements.define. Only set if `includeImportCustomElements: true` in your config.
37
+ * @prop modelProp - The prop that v-model binds to (i.e. value)
38
+ * @prop modelUpdateEvent - The event that is fired from your Web Component when the value changes (i.e. ionChange)
39
+ */
40
+ export const defineContainer = (name, defineCustomElement, componentProps = [], modelProp, modelUpdateEvent) => {
41
+ /**
42
+ * Create a Vue component wrapper around a Web Component.
43
+ * Note: The `props` here are not all properties on a component.
44
+ * They refer to whatever properties are set on an instance of a component.
45
+ */
46
+ if (defineCustomElement !== undefined) {
47
+ defineCustomElement();
48
+ }
49
+ const Container = defineComponent((props, { attrs, slots, emit }) => {
50
+ var _a;
51
+ let modelPropValue = props[modelProp];
52
+ const containerRef = ref();
53
+ const classes = new Set(getComponentClasses(attrs.class));
54
+ /**
55
+ * This directive is responsible for updating any reactive
56
+ * reference associated with v-model on the component.
57
+ * This code must be run inside of the "created" callback.
58
+ * Since the following listener callbacks as well as any potential
59
+ * event callback defined in the developer's app are set on
60
+ * the same element, we need to make sure the following callbacks
61
+ * are set first so they fire first. If the developer's callback fires first
62
+ * then the reactive reference will not have been updated yet.
63
+ */
64
+ const vModelDirective = {
65
+ created: (el) => {
66
+ const eventsNames = Array.isArray(modelUpdateEvent) ? modelUpdateEvent : [modelUpdateEvent];
67
+ eventsNames.forEach((eventName) => {
68
+ el.addEventListener(eventName.toLowerCase(), (e) => {
69
+ /**
70
+ * Only update the v-model binding if the event's target is the element we are
71
+ * listening on. For example, Component A could emit ionChange, but it could also
72
+ * have a descendant Component B that also emits ionChange. We only want to update
73
+ * the v-model for Component A when ionChange originates from that element and not
74
+ * when ionChange bubbles up from Component B.
75
+ */
76
+ if (e.target.tagName === el.tagName) {
77
+ modelPropValue = (e === null || e === void 0 ? void 0 : e.target)[modelProp];
78
+ emit(UPDATE_VALUE_EVENT, modelPropValue);
79
+ }
80
+ });
81
+ });
82
+ },
83
+ };
84
+ const currentInstance = getCurrentInstance();
85
+ const hasRouter = (_a = currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.appContext) === null || _a === void 0 ? void 0 : _a.provides[NAV_MANAGER];
86
+ const navManager = hasRouter ? inject(NAV_MANAGER) : undefined;
87
+ const handleRouterLink = (ev) => {
88
+ const { routerLink } = props;
89
+ if (routerLink === EMPTY_PROP)
90
+ return;
91
+ if (navManager !== undefined) {
92
+ /**
93
+ * This prevents the browser from
94
+ * performing a page reload when pressing
95
+ * an Ionic component with routerLink.
96
+ * The page reload interferes with routing
97
+ * and causes ion-back-button to disappear
98
+ * since the local history is wiped on reload.
99
+ */
100
+ ev.preventDefault();
101
+ let navigationPayload = { event: ev };
102
+ for (const key in props) {
103
+ const value = props[key];
104
+ if (props.hasOwnProperty(key) && key.startsWith(ROUTER_PROP_PREFIX) && value !== EMPTY_PROP) {
105
+ navigationPayload[key] = value;
106
+ }
107
+ }
108
+ navManager.navigate(navigationPayload);
109
+ }
110
+ else {
111
+ console.warn('Tried to navigate, but no router was found. Make sure you have mounted Vue Router.');
112
+ }
113
+ };
114
+ return () => {
115
+ modelPropValue = props[modelProp];
116
+ getComponentClasses(attrs.class).forEach((value) => {
117
+ classes.add(value);
118
+ });
119
+ const oldClick = props.onClick;
120
+ const handleClick = (ev) => {
121
+ if (oldClick !== undefined) {
122
+ oldClick(ev);
123
+ }
124
+ if (!ev.defaultPrevented) {
125
+ handleRouterLink(ev);
126
+ }
127
+ };
128
+ let propsToAdd = {
129
+ ref: containerRef,
130
+ class: getElementClasses(containerRef, classes),
131
+ onClick: handleClick,
132
+ };
133
+ /**
134
+ * We can use Object.entries here
135
+ * to avoid the hasOwnProperty check,
136
+ * but that would require 2 iterations
137
+ * where as this only requires 1.
138
+ */
139
+ for (const key in props) {
140
+ const value = props[key];
141
+ if ((props.hasOwnProperty(key) && value !== EMPTY_PROP) || key.startsWith(ARIA_PROP_PREFIX)) {
142
+ propsToAdd[key] = value;
143
+ }
144
+ }
145
+ if (modelProp) {
146
+ /**
147
+ * If form value property was set using v-model
148
+ * then we should use that value.
149
+ * Otherwise, check to see if form value property
150
+ * was set as a static value (i.e. no v-model).
151
+ */
152
+ if (props[MODEL_VALUE] !== EMPTY_PROP) {
153
+ propsToAdd = Object.assign(Object.assign({}, propsToAdd), { [modelProp]: props[MODEL_VALUE] });
154
+ }
155
+ else if (modelPropValue !== EMPTY_PROP) {
156
+ propsToAdd = Object.assign(Object.assign({}, propsToAdd), { [modelProp]: modelPropValue });
157
+ }
158
+ }
159
+ // If router link is defined, add href to props
160
+ // in order to properly render an anchor tag inside
161
+ // of components that should become activatable and
162
+ // focusable with router link.
163
+ if (props[ROUTER_LINK_VALUE] !== EMPTY_PROP) {
164
+ propsToAdd = Object.assign(Object.assign({}, propsToAdd), { href: props[ROUTER_LINK_VALUE] });
165
+ }
166
+ /**
167
+ * vModelDirective is only needed on components that support v-model.
168
+ * As a result, we conditionally call withDirectives with v-model components.
169
+ */
170
+ const node = h(name, propsToAdd, slots.default && slots.default());
171
+ return modelProp === undefined ? node : withDirectives(node, [[vModelDirective]]);
172
+ };
173
+ });
174
+ if (typeof Container !== 'function') {
175
+ Container.name = name;
176
+ Container.props = {
177
+ [ROUTER_LINK_VALUE]: DEFAULT_EMPTY_PROP,
178
+ };
179
+ componentProps.forEach((componentProp) => {
180
+ Container.props[componentProp] = DEFAULT_EMPTY_PROP;
181
+ });
182
+ if (modelProp) {
183
+ Container.props[MODEL_VALUE] = DEFAULT_EMPTY_PROP;
184
+ Container.emits = [UPDATE_VALUE_EVENT];
185
+ }
186
+ }
187
+ return Container;
188
+ };
@@ -0,0 +1,14 @@
1
+ import { type DefineComponent } from 'vue';
2
+ import { type UpmadeDynamicObjectRenderContext, type UpmadeDynamicObjectRenderer } from '@upmade/engine';
3
+ export interface VueDynamicObjectRendererOptions<TState = unknown> {
4
+ tagName: string;
5
+ component: DefineComponent<any, any, any, any, any, any, any, any>;
6
+ createInitialState?: () => TState;
7
+ getInitialState?: (data: unknown, context: UpmadeDynamicObjectRenderContext) => TState;
8
+ mapProps?: (state: TState | undefined, context: UpmadeDynamicObjectRenderContext) => Record<string, unknown>;
9
+ normalizeState?: (state: unknown, context: UpmadeDynamicObjectRenderContext) => TState;
10
+ onStateChangeProp?: string | null;
11
+ styles?: string;
12
+ }
13
+ export declare function createVueDynamicObjectRenderer<TState = unknown>(options: VueDynamicObjectRendererOptions<TState>): UpmadeDynamicObjectRenderer;
14
+ export declare function registerVueDynamicObjectRenderer<TState = unknown>(rendererKey: string, options: VueDynamicObjectRendererOptions<TState>): () => void;
@@ -0,0 +1,75 @@
1
+ import { defineCustomElement } from 'vue';
2
+ import { UpmadeDynamicObjectRendererRegistry, } from '@upmade/engine';
3
+ function setHostProps(host, props) {
4
+ Object.entries(props).forEach(([key, value]) => {
5
+ host[key] = value;
6
+ });
7
+ }
8
+ export function createVueDynamicObjectRenderer(options) {
9
+ const mountedElements = new Map();
10
+ const ensureCustomElementDefined = () => {
11
+ if (!customElements.get(options.tagName)) {
12
+ customElements.define(options.tagName, defineCustomElement(options.component));
13
+ }
14
+ };
15
+ return {
16
+ onMount: (context) => {
17
+ var _a, _b;
18
+ if (!context.container) {
19
+ return;
20
+ }
21
+ ensureCustomElementDefined();
22
+ const initialState = options.getInitialState
23
+ ? options.getInitialState(context.data, context)
24
+ : (_a = context.data) !== null && _a !== void 0 ? _a : (_b = options.createInitialState) === null || _b === void 0 ? void 0 : _b.call(options);
25
+ const host = document.createElement(options.tagName);
26
+ const mounted = {
27
+ host,
28
+ latestState: initialState,
29
+ };
30
+ const baseProps = options.mapProps
31
+ ? options.mapProps(initialState, context)
32
+ : (initialState !== undefined ? { initialState } : {});
33
+ const onStateChangeProp = options.onStateChangeProp === undefined ? 'onStateChange' : options.onStateChangeProp;
34
+ if (onStateChangeProp !== null) {
35
+ const existing = baseProps[onStateChangeProp];
36
+ baseProps[onStateChangeProp] = (nextState) => {
37
+ mounted.latestState = options.normalizeState
38
+ ? options.normalizeState(nextState, context)
39
+ : nextState;
40
+ if (typeof existing === 'function') {
41
+ existing(nextState);
42
+ }
43
+ };
44
+ }
45
+ context.container.innerHTML = '';
46
+ if (options.styles) {
47
+ const styleElement = document.createElement('style');
48
+ styleElement.textContent = options.styles;
49
+ context.container.appendChild(styleElement);
50
+ }
51
+ setHostProps(host, baseProps);
52
+ context.container.appendChild(host);
53
+ mountedElements.set(context.object.id, mounted);
54
+ },
55
+ onUnmount: (context) => {
56
+ const mounted = mountedElements.get(context.object.id);
57
+ if (!mounted) {
58
+ return undefined;
59
+ }
60
+ mounted.host.remove();
61
+ mountedElements.delete(context.object.id);
62
+ if (context.container) {
63
+ context.container.innerHTML = '';
64
+ }
65
+ return mounted.latestState;
66
+ },
67
+ };
68
+ }
69
+ export function registerVueDynamicObjectRenderer(rendererKey, options) {
70
+ const renderer = createVueDynamicObjectRenderer(options);
71
+ UpmadeDynamicObjectRendererRegistry.register(rendererKey, renderer);
72
+ return () => {
73
+ UpmadeDynamicObjectRendererRegistry.unregister(rendererKey);
74
+ };
75
+ }
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
- {
2
- "name": "@upmade/vue-editor",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "@upmade/vue-editor",
3
+ "version": "0.6.2",
4
+ "homepage": "https://upmade.io/",
5
+ "description": "Upmade helps you build infinite canvas experiences with Vue.",
6
+ "keywords": [
7
+ "infinite canvas",
8
+ "collaboration",
9
+ "whiteboard",
10
+ "drawing",
11
+ "vue"
12
+ ],
13
+ "license": "MIT",
14
+ "main": "dist/index.js",
15
+ "types": "dist/index.d.ts",
16
+ "directories": {
17
+ "lib": "lib",
18
+ "test": "__tests__"
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "test": "echo \"Error: run tests from root\" && exit 1",
25
+ "build": "npm run tsc",
26
+ "tsc": "tsc -p . --outDir ./dist",
27
+ "clean": "rimraf dist node_modules",
28
+ "bump": "npm version patch",
29
+ "release": "npm publish"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/kasual1/kritzel/issues"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "dependencies": {
38
+ "@upmade/editor": "^0.6.2",
39
+ "@upmade/engine": "^0.6.2",
40
+ "@stencil/vue-output-target": "0.11.8"
41
+ }
42
+ }