kritzel-vue 0.3.14 → 0.3.15
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/dist/composables.d.ts +28 -0
- package/dist/composables.js +41 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves the native Kritzel editor element from a specific Vue template ref.
|
|
3
|
+
*
|
|
4
|
+
* Because `<KritzelEditor>` 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 { KritzelEditor, getEditorRef } from 'kritzel-vue'
|
|
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
|
+
* <KritzelEditor ref="editorComponent" @isReady="onReady" />
|
|
25
|
+
* </template>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function getEditorRef(componentRef: string): import("vue").ComputedRef<HTMLKritzelEditorElement | null>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { computed, useTemplateRef, } from "vue";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the native Kritzel editor element from a specific Vue template ref.
|
|
4
|
+
*
|
|
5
|
+
* Because `<KritzelEditor>` 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 { KritzelEditor, getEditorRef } from 'kritzel-vue'
|
|
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
|
+
* <KritzelEditor ref="editorComponent" @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
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './components';
|
|
2
|
+
export * from './composables';
|
|
2
3
|
export * from './plugin';
|
|
3
4
|
export { KritzelBaseObject, KritzelText, KritzelPath, KritzelImage, KritzelLine, KritzelShape, KritzelGroup, KritzelBrushTool, KritzelTextTool, KritzelLineTool, KritzelShapeTool, KritzelEraserTool, KritzelSelectionTool, KritzelImageTool, KritzelWorkspace, InMemorySyncProvider, IndexedDBSyncProvider, BroadcastSyncProvider, WebSocketSyncProvider, HocuspocusSyncProvider, KritzelThemeManager, ShapeType, KritzelAlignment, lightTheme, darkTheme, DEFAULT_BRUSH_CONFIG, DEFAULT_TEXT_CONFIG, } from 'kritzel-stencil';
|
|
4
5
|
export type { KritzelToolbarControl, KritzelBrushToolConfig, KritzelLineToolConfig, KritzelShapeToolConfig, KritzelTextToolConfig, KritzelSyncConfig, KritzelTheme, KritzelViewportState, ContextMenuItem, ThemeAwareColor, ThemeName, LoginEvent, EditorIsReadyEvent, ActiveWorkspaceChangeEvent, ObjectsAddedEvent, ObjectsRemovedEvent, ObjectsUpdatedEvent, } from 'kritzel-stencil';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './components';
|
|
2
|
+
export * from './composables';
|
|
2
3
|
export * from './plugin';
|
|
3
4
|
export { KritzelBaseObject, KritzelText, KritzelPath, KritzelImage, KritzelLine, KritzelShape, KritzelGroup, KritzelBrushTool, KritzelTextTool, KritzelLineTool, KritzelShapeTool, KritzelEraserTool, KritzelSelectionTool, KritzelImageTool, KritzelWorkspace, InMemorySyncProvider, IndexedDBSyncProvider, BroadcastSyncProvider, WebSocketSyncProvider, HocuspocusSyncProvider, KritzelThemeManager, ShapeType, KritzelAlignment, lightTheme, darkTheme, DEFAULT_BRUSH_CONFIG, DEFAULT_TEXT_CONFIG, } from 'kritzel-stencil';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kritzel-vue",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15",
|
|
4
4
|
"homepage": "https://github.com/kasual1/kritzel#readme",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
"@stencil/vue-output-target": "0.11.8"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"kritzel-stencil": "^0.3.
|
|
37
|
+
"kritzel-stencil": "^0.3.15"
|
|
38
38
|
}
|
|
39
39
|
}
|