@baohu/canvas-editor-vue2 0.0.0-stage → 1.0.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 ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TaroXin
4
+ Portions (icons, dialog) adapted from canvas-editor, Copyright (c) 2021-present, hufe
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,79 @@
1
- # Temporary Holding Version
1
+ # @baohu/canvas-editor-vue2
2
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.
3
+ [`@baohu/canvas-editor`](https://www.npmjs.com/package/@baohu/canvas-editor) 的 Vue 2 组件,带工具栏和状态栏。兼容 Vue 2.6 / 2.7。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm i @baohu/canvas-editor @baohu/canvas-editor-vue2
9
+ ```
10
+
11
+ ## 使用
12
+
13
+ ```js
14
+ import Vue from 'vue'
15
+ import CanvasEditorVue2 from '@baohu/canvas-editor-vue2'
16
+
17
+ Vue.use(CanvasEditorVue2) // 注册 <canvas-editor>
18
+ ```
19
+
20
+ ```vue
21
+ <template>
22
+ <div style="height: 600px">
23
+ <canvas-editor ref="editor" :data="doc" @ready="onReady" @change="onChange" />
24
+ </div>
25
+ </template>
26
+
27
+ <script>
28
+ export default {
29
+ data: () => ({ doc: { main: [{ value: 'Hello' }] } }),
30
+ methods: {
31
+ onReady(editor) {},
32
+ onChange() {
33
+ const { data } = this.$refs.editor.getValue()
34
+ }
35
+ }
36
+ }
37
+ </script>
38
+ ```
39
+
40
+ 也可以只在单个组件里注册:`import { CanvasEditor } from '@baohu/canvas-editor-vue2'`。
41
+
42
+ ### script 直接引入
43
+
44
+ 页面已有全局 `Vue` 时,引入后会自动注册 `<canvas-editor>`:
45
+
46
+ ```html
47
+ <script src="https://unpkg.com/vue@2.7.16/dist/vue.min.js"></script>
48
+ <script src="https://unpkg.com/@baohu/canvas-editor/dist/canvas-editor.umd.cjs"></script>
49
+ <script src="https://unpkg.com/@baohu/canvas-editor-ui"></script>
50
+ <script src="https://unpkg.com/@baohu/canvas-editor-vue2"></script>
51
+ ```
52
+
53
+ ## Props
54
+
55
+ | 名称 | 类型 | 说明 |
56
+ |---|---|---|
57
+ | `data` | `IEditorData \| IElement[]` | 初始文档数据,只在创建时读取;之后用 `setValue` 修改 |
58
+ | `options` | `IEditorOption` | canvas-editor 配置 |
59
+ | `toolbar` | `IToolbarItem[] \| false` | 工具栏按钮,见 `@baohu/canvas-editor-ui` |
60
+ | `statusbar` | `IStatusbarItem[] \| false` | 状态栏项目 |
61
+ | `locale` | `Partial<ILocale>` | 覆盖界面文案 |
62
+ | `height` | `string \| number` | 组件高度,默认 `100%` |
63
+
64
+ ## 事件
65
+
66
+ | 名称 | 参数 | 说明 |
67
+ |---|---|---|
68
+ | `ready` | `(editor, ui)` | 编辑器创建完成 |
69
+ | `change` | — | 文档内容变化 |
70
+ | `range-style-change` | `(style)` | 光标处样式变化 |
71
+
72
+ ## 方法(通过 ref 调用)
73
+
74
+ | 方法 | 说明 |
75
+ |---|---|
76
+ | `getEditor()` | canvas-editor 实例 |
77
+ | `getUI()` | `EditorUI` 实例 |
78
+ | `getValue()` | 等同 `editor.command.getValue()` |
79
+ | `setValue(data)` | 替换文档内容 |
@@ -0,0 +1,68 @@
1
+ import { EditorUI as n } from "@baohu/canvas-editor-ui";
2
+ const o = {
3
+ name: "CanvasEditor",
4
+ props: {
5
+ // 初始文档数据(只在创建时读取,之后请通过 setValue 修改)
6
+ data: { type: [Object, Array], default: void 0 },
7
+ // canvas-editor 配置
8
+ options: { type: Object, default: void 0 },
9
+ // 工具栏按钮,false 隐藏
10
+ toolbar: { type: [Array, Boolean], default: void 0 },
11
+ // 状态栏项目,false 隐藏
12
+ statusbar: { type: [Array, Boolean], default: void 0 },
13
+ // 界面文案
14
+ locale: { type: Object, default: void 0 },
15
+ height: { type: [String, Number], default: "100%" }
16
+ },
17
+ mounted() {
18
+ const t = new n(this.$el, {
19
+ data: this.data,
20
+ options: this.options,
21
+ toolbar: this.toolbar,
22
+ statusbar: this.statusbar,
23
+ locale: this.locale
24
+ });
25
+ this.ui = t;
26
+ const { eventBus: e } = t.editor;
27
+ e.on("contentChange", () => this.$emit("change")), e.on("rangeStyleChange", (a) => {
28
+ this.$emit("range-style-change", a);
29
+ }), this.$emit("ready", t.editor, t);
30
+ },
31
+ beforeDestroy() {
32
+ var t;
33
+ (t = this.ui) == null || t.destroy(), this.ui = null;
34
+ },
35
+ methods: {
36
+ getEditor() {
37
+ return this.ui ? this.ui.editor : null;
38
+ },
39
+ getUI() {
40
+ return this.ui;
41
+ },
42
+ getValue() {
43
+ return this.ui ? this.ui.editor.command.getValue() : null;
44
+ },
45
+ setValue(t) {
46
+ var e;
47
+ (e = this.ui) == null || e.editor.command.executeSetValue(t);
48
+ }
49
+ },
50
+ render(t) {
51
+ const { height: e } = this;
52
+ return t("div", {
53
+ class: "ceu-vue2",
54
+ style: { height: typeof e == "number" ? `${e}px` : e }
55
+ });
56
+ }
57
+ };
58
+ function s(t) {
59
+ t.component("CanvasEditor", o);
60
+ }
61
+ const u = { install: s, CanvasEditor: o }, i = typeof window != "undefined" ? window.Vue : void 0;
62
+ i && typeof i.use == "function" && i.use(u);
63
+ export {
64
+ o as CanvasEditor,
65
+ u as default,
66
+ s as install
67
+ };
68
+ //# sourceMappingURL=canvas-editor-vue2.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas-editor-vue2.esm.js","sources":["../src/index.ts"],"sourcesContent":["import type Editor from '@baohu/canvas-editor'\nimport type { IEditorData } from '@baohu/canvas-editor'\nimport { EditorUI } from '@baohu/canvas-editor-ui'\nimport type { IEditorUIOptions } from '@baohu/canvas-editor-ui'\n\n// 不依赖 vue 运行时(不使用 defineComponent),兼容 Vue 2.6 / 2.7\ninterface IComponentInstance {\n $el: HTMLElement\n $emit: (event: string, ...args: unknown[]) => void\n $props: Record<string, unknown>\n ui: EditorUI | null\n data: IEditorUIOptions['data']\n options: IEditorUIOptions['options']\n toolbar: IEditorUIOptions['toolbar']\n statusbar: IEditorUIOptions['statusbar']\n locale: IEditorUIOptions['locale']\n height: string | number\n}\n\ntype CreateElement = (\n tag: string,\n data?: Record<string, unknown>\n) => unknown\n\nexport const CanvasEditor = {\n name: 'CanvasEditor',\n props: {\n // 初始文档数据(只在创建时读取,之后请通过 setValue 修改)\n data: { type: [Object, Array], default: undefined },\n // canvas-editor 配置\n options: { type: Object, default: undefined },\n // 工具栏按钮,false 隐藏\n toolbar: { type: [Array, Boolean], default: undefined },\n // 状态栏项目,false 隐藏\n statusbar: { type: [Array, Boolean], default: undefined },\n // 界面文案\n locale: { type: Object, default: undefined },\n height: { type: [String, Number], default: '100%' }\n },\n mounted(this: IComponentInstance) {\n // ui 不放在 data 中,避免被 Vue 转为响应式\n const ui = new EditorUI(this.$el, {\n data: this.data,\n options: this.options,\n toolbar: this.toolbar,\n statusbar: this.statusbar,\n locale: this.locale\n })\n this.ui = ui\n const { eventBus } = ui.editor\n eventBus.on('contentChange', () => this.$emit('change'))\n eventBus.on('rangeStyleChange', style => {\n this.$emit('range-style-change', style)\n })\n this.$emit('ready', ui.editor, ui)\n },\n beforeDestroy(this: IComponentInstance) {\n this.ui?.destroy()\n this.ui = null\n },\n methods: {\n getEditor(this: IComponentInstance): Editor | null {\n return this.ui ? this.ui.editor : null\n },\n getUI(this: IComponentInstance): EditorUI | null {\n return this.ui\n },\n getValue(this: IComponentInstance) {\n return this.ui ? this.ui.editor.command.getValue() : null\n },\n setValue(this: IComponentInstance, data: Partial<IEditorData>) {\n this.ui?.editor.command.executeSetValue(data)\n }\n },\n render(this: IComponentInstance, h: CreateElement) {\n const { height } = this\n return h('div', {\n class: 'ceu-vue2',\n style: { height: typeof height === 'number' ? `${height}px` : height }\n })\n }\n}\n\ninterface IVueConstructor {\n component: (name: string, component: unknown) => void\n}\n\nexport function install(Vue: IVueConstructor) {\n Vue.component('CanvasEditor', CanvasEditor)\n}\n\nconst plugin = { install, CanvasEditor }\n\n// <script> 引入时自动注册到全局 Vue\nconst globalVue = typeof window !== 'undefined' ? (window as unknown as { Vue?: IVueConstructor & { use: (plugin: unknown) => void } }).Vue : undefined\nif (globalVue && typeof globalVue.use === 'function') {\n globalVue.use(plugin)\n}\n\nexport default plugin\n"],"names":["CanvasEditor","ui","EditorUI","eventBus","style","_a","data","h","height","install","Vue","plugin","globalVue"],"mappings":";AAwBO,MAAMA,IAAe;AAAA,EAC1B,MAAM;AAAA,EACN,OAAO;AAAA;AAAA,IAEL,MAAM,EAAE,MAAM,CAAC,QAAQ,KAAK,GAAG,SAAS,OAAA;AAAA;AAAA,IAExC,SAAS,EAAE,MAAM,QAAQ,SAAS,OAAA;AAAA;AAAA,IAElC,SAAS,EAAE,MAAM,CAAC,OAAO,OAAO,GAAG,SAAS,OAAA;AAAA;AAAA,IAE5C,WAAW,EAAE,MAAM,CAAC,OAAO,OAAO,GAAG,SAAS,OAAA;AAAA;AAAA,IAE9C,QAAQ,EAAE,MAAM,QAAQ,SAAS,OAAA;AAAA,IACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ,MAAM,GAAG,SAAS,OAAA;AAAA,EAAO;AAAA,EAEpD,UAAkC;AAEhC,UAAMC,IAAK,IAAIC,EAAS,KAAK,KAAK;AAAA,MAChC,MAAM,KAAK;AAAA,MACX,SAAS,KAAK;AAAA,MACd,SAAS,KAAK;AAAA,MACd,WAAW,KAAK;AAAA,MAChB,QAAQ,KAAK;AAAA,IAAA,CACd;AACD,SAAK,KAAKD;AACV,UAAM,EAAE,UAAAE,MAAaF,EAAG;AACxB,IAAAE,EAAS,GAAG,iBAAiB,MAAM,KAAK,MAAM,QAAQ,CAAC,GACvDA,EAAS,GAAG,oBAAoB,CAAAC,MAAS;AACvC,WAAK,MAAM,sBAAsBA,CAAK;AAAA,IACxC,CAAC,GACD,KAAK,MAAM,SAASH,EAAG,QAAQA,CAAE;AAAA,EACnC;AAAA,EACA,gBAAwC;;AACtC,KAAAI,IAAA,KAAK,OAAL,QAAAA,EAAS,WACT,KAAK,KAAK;AAAA,EACZ;AAAA,EACA,SAAS;AAAA,IACP,YAAmD;AACjD,aAAO,KAAK,KAAK,KAAK,GAAG,SAAS;AAAA,IACpC;AAAA,IACA,QAAiD;AAC/C,aAAO,KAAK;AAAA,IACd;AAAA,IACA,WAAmC;AACjC,aAAO,KAAK,KAAK,KAAK,GAAG,OAAO,QAAQ,aAAa;AAAA,IACvD;AAAA,IACA,SAAmCC,GAA4B;;AAC7D,OAAAD,IAAA,KAAK,OAAL,QAAAA,EAAS,OAAO,QAAQ,gBAAgBC;AAAA,IAC1C;AAAA,EAAA;AAAA,EAEF,OAAiCC,GAAkB;AACjD,UAAM,EAAE,QAAAC,MAAW;AACnB,WAAOD,EAAE,OAAO;AAAA,MACd,OAAO;AAAA,MACP,OAAO,EAAE,QAAQ,OAAOC,KAAW,WAAW,GAAGA,CAAM,OAAOA,EAAA;AAAA,IAAO,CACtE;AAAA,EACH;AACF;AAMO,SAASC,EAAQC,GAAsB;AAC5C,EAAAA,EAAI,UAAU,gBAAgBV,CAAY;AAC5C;AAEA,MAAMW,IAAS,EAAE,SAAAF,GAAS,cAAAT,EAAA,GAGpBY,IAAY,OAAO,UAAW,cAAe,OAAqF,MAAM;AAC1IA,KAAa,OAAOA,EAAU,OAAQ,cACxCA,EAAU,IAAID,CAAM;"}
@@ -0,0 +1,2 @@
1
+ (function(t,o){typeof exports=="object"&&typeof module!="undefined"?o(exports,require("@baohu/canvas-editor-ui")):typeof define=="function"&&define.amd?define(["exports","@baohu/canvas-editor-ui"],o):(t=typeof globalThis!="undefined"?globalThis:t||self,o(t.CanvasEditorVue2={},t.CanvasEditorUI))})(this,function(t,o){"use strict";const n={name:"CanvasEditor",props:{data:{type:[Object,Array],default:void 0},options:{type:Object,default:void 0},toolbar:{type:[Array,Boolean],default:void 0},statusbar:{type:[Array,Boolean],default:void 0},locale:{type:Object,default:void 0},height:{type:[String,Number],default:"100%"}},mounted(){const e=new o.EditorUI(this.$el,{data:this.data,options:this.options,toolbar:this.toolbar,statusbar:this.statusbar,locale:this.locale});this.ui=e;const{eventBus:i}=e.editor;i.on("contentChange",()=>this.$emit("change")),i.on("rangeStyleChange",d=>{this.$emit("range-style-change",d)}),this.$emit("ready",e.editor,e)},beforeDestroy(){var e;(e=this.ui)==null||e.destroy(),this.ui=null},methods:{getEditor(){return this.ui?this.ui.editor:null},getUI(){return this.ui},getValue(){return this.ui?this.ui.editor.command.getValue():null},setValue(e){var i;(i=this.ui)==null||i.editor.command.executeSetValue(e)}},render(e){const{height:i}=this;return e("div",{class:"ceu-vue2",style:{height:typeof i=="number"?`${i}px`:i}})}};function s(e){e.component("CanvasEditor",n)}const u={install:s,CanvasEditor:n},a=typeof window!="undefined"?window.Vue:void 0;a&&typeof a.use=="function"&&a.use(u),t.CanvasEditor=n,t.default=u,t.install=s,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
2
+ //# sourceMappingURL=canvas-editor-vue2.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas-editor-vue2.umd.js","sources":["../src/index.ts"],"sourcesContent":["import type Editor from '@baohu/canvas-editor'\nimport type { IEditorData } from '@baohu/canvas-editor'\nimport { EditorUI } from '@baohu/canvas-editor-ui'\nimport type { IEditorUIOptions } from '@baohu/canvas-editor-ui'\n\n// 不依赖 vue 运行时(不使用 defineComponent),兼容 Vue 2.6 / 2.7\ninterface IComponentInstance {\n $el: HTMLElement\n $emit: (event: string, ...args: unknown[]) => void\n $props: Record<string, unknown>\n ui: EditorUI | null\n data: IEditorUIOptions['data']\n options: IEditorUIOptions['options']\n toolbar: IEditorUIOptions['toolbar']\n statusbar: IEditorUIOptions['statusbar']\n locale: IEditorUIOptions['locale']\n height: string | number\n}\n\ntype CreateElement = (\n tag: string,\n data?: Record<string, unknown>\n) => unknown\n\nexport const CanvasEditor = {\n name: 'CanvasEditor',\n props: {\n // 初始文档数据(只在创建时读取,之后请通过 setValue 修改)\n data: { type: [Object, Array], default: undefined },\n // canvas-editor 配置\n options: { type: Object, default: undefined },\n // 工具栏按钮,false 隐藏\n toolbar: { type: [Array, Boolean], default: undefined },\n // 状态栏项目,false 隐藏\n statusbar: { type: [Array, Boolean], default: undefined },\n // 界面文案\n locale: { type: Object, default: undefined },\n height: { type: [String, Number], default: '100%' }\n },\n mounted(this: IComponentInstance) {\n // ui 不放在 data 中,避免被 Vue 转为响应式\n const ui = new EditorUI(this.$el, {\n data: this.data,\n options: this.options,\n toolbar: this.toolbar,\n statusbar: this.statusbar,\n locale: this.locale\n })\n this.ui = ui\n const { eventBus } = ui.editor\n eventBus.on('contentChange', () => this.$emit('change'))\n eventBus.on('rangeStyleChange', style => {\n this.$emit('range-style-change', style)\n })\n this.$emit('ready', ui.editor, ui)\n },\n beforeDestroy(this: IComponentInstance) {\n this.ui?.destroy()\n this.ui = null\n },\n methods: {\n getEditor(this: IComponentInstance): Editor | null {\n return this.ui ? this.ui.editor : null\n },\n getUI(this: IComponentInstance): EditorUI | null {\n return this.ui\n },\n getValue(this: IComponentInstance) {\n return this.ui ? this.ui.editor.command.getValue() : null\n },\n setValue(this: IComponentInstance, data: Partial<IEditorData>) {\n this.ui?.editor.command.executeSetValue(data)\n }\n },\n render(this: IComponentInstance, h: CreateElement) {\n const { height } = this\n return h('div', {\n class: 'ceu-vue2',\n style: { height: typeof height === 'number' ? `${height}px` : height }\n })\n }\n}\n\ninterface IVueConstructor {\n component: (name: string, component: unknown) => void\n}\n\nexport function install(Vue: IVueConstructor) {\n Vue.component('CanvasEditor', CanvasEditor)\n}\n\nconst plugin = { install, CanvasEditor }\n\n// <script> 引入时自动注册到全局 Vue\nconst globalVue = typeof window !== 'undefined' ? (window as unknown as { Vue?: IVueConstructor & { use: (plugin: unknown) => void } }).Vue : undefined\nif (globalVue && typeof globalVue.use === 'function') {\n globalVue.use(plugin)\n}\n\nexport default plugin\n"],"names":["CanvasEditor","ui","EditorUI","eventBus","style","_a","data","h","height","install","Vue","plugin","globalVue"],"mappings":"0UAwBO,MAAMA,EAAe,CAC1B,KAAM,eACN,MAAO,CAEL,KAAM,CAAE,KAAM,CAAC,OAAQ,KAAK,EAAG,QAAS,MAAA,EAExC,QAAS,CAAE,KAAM,OAAQ,QAAS,MAAA,EAElC,QAAS,CAAE,KAAM,CAAC,MAAO,OAAO,EAAG,QAAS,MAAA,EAE5C,UAAW,CAAE,KAAM,CAAC,MAAO,OAAO,EAAG,QAAS,MAAA,EAE9C,OAAQ,CAAE,KAAM,OAAQ,QAAS,MAAA,EACjC,OAAQ,CAAE,KAAM,CAAC,OAAQ,MAAM,EAAG,QAAS,MAAA,CAAO,EAEpD,SAAkC,CAEhC,MAAMC,EAAK,IAAIC,WAAS,KAAK,IAAK,CAChC,KAAM,KAAK,KACX,QAAS,KAAK,QACd,QAAS,KAAK,QACd,UAAW,KAAK,UAChB,OAAQ,KAAK,MAAA,CACd,EACD,KAAK,GAAKD,EACV,KAAM,CAAE,SAAAE,GAAaF,EAAG,OACxBE,EAAS,GAAG,gBAAiB,IAAM,KAAK,MAAM,QAAQ,CAAC,EACvDA,EAAS,GAAG,mBAAoBC,GAAS,CACvC,KAAK,MAAM,qBAAsBA,CAAK,CACxC,CAAC,EACD,KAAK,MAAM,QAASH,EAAG,OAAQA,CAAE,CACnC,EACA,eAAwC,QACtCI,EAAA,KAAK,KAAL,MAAAA,EAAS,UACT,KAAK,GAAK,IACZ,EACA,QAAS,CACP,WAAmD,CACjD,OAAO,KAAK,GAAK,KAAK,GAAG,OAAS,IACpC,EACA,OAAiD,CAC/C,OAAO,KAAK,EACd,EACA,UAAmC,CACjC,OAAO,KAAK,GAAK,KAAK,GAAG,OAAO,QAAQ,WAAa,IACvD,EACA,SAAmCC,EAA4B,QAC7DD,EAAA,KAAK,KAAL,MAAAA,EAAS,OAAO,QAAQ,gBAAgBC,EAC1C,CAAA,EAEF,OAAiCC,EAAkB,CACjD,KAAM,CAAE,OAAAC,GAAW,KACnB,OAAOD,EAAE,MAAO,CACd,MAAO,WACP,MAAO,CAAE,OAAQ,OAAOC,GAAW,SAAW,GAAGA,CAAM,KAAOA,CAAA,CAAO,CACtE,CACH,CACF,EAMO,SAASC,EAAQC,EAAsB,CAC5CA,EAAI,UAAU,eAAgBV,CAAY,CAC5C,CAEA,MAAMW,EAAS,CAAE,QAAAF,EAAS,aAAAT,CAAA,EAGpBY,EAAY,OAAO,QAAW,YAAe,OAAqF,IAAM,OAC1IA,GAAa,OAAOA,EAAU,KAAQ,YACxCA,EAAU,IAAID,CAAM"}
@@ -0,0 +1,101 @@
1
+ import type Editor from '@baohu/canvas-editor';
2
+ import type { IEditorData } from '@baohu/canvas-editor';
3
+ import { EditorUI } from '@baohu/canvas-editor-ui';
4
+ import type { IEditorUIOptions } from '@baohu/canvas-editor-ui';
5
+ interface IComponentInstance {
6
+ $el: HTMLElement;
7
+ $emit: (event: string, ...args: unknown[]) => void;
8
+ $props: Record<string, unknown>;
9
+ ui: EditorUI | null;
10
+ data: IEditorUIOptions['data'];
11
+ options: IEditorUIOptions['options'];
12
+ toolbar: IEditorUIOptions['toolbar'];
13
+ statusbar: IEditorUIOptions['statusbar'];
14
+ locale: IEditorUIOptions['locale'];
15
+ height: string | number;
16
+ }
17
+ type CreateElement = (tag: string, data?: Record<string, unknown>) => unknown;
18
+ export declare const CanvasEditor: {
19
+ name: string;
20
+ props: {
21
+ data: {
22
+ type: (ObjectConstructor | ArrayConstructor)[];
23
+ default: undefined;
24
+ };
25
+ options: {
26
+ type: ObjectConstructor;
27
+ default: undefined;
28
+ };
29
+ toolbar: {
30
+ type: (ArrayConstructor | BooleanConstructor)[];
31
+ default: undefined;
32
+ };
33
+ statusbar: {
34
+ type: (ArrayConstructor | BooleanConstructor)[];
35
+ default: undefined;
36
+ };
37
+ locale: {
38
+ type: ObjectConstructor;
39
+ default: undefined;
40
+ };
41
+ height: {
42
+ type: (StringConstructor | NumberConstructor)[];
43
+ default: string;
44
+ };
45
+ };
46
+ mounted(this: IComponentInstance): void;
47
+ beforeDestroy(this: IComponentInstance): void;
48
+ methods: {
49
+ getEditor(this: IComponentInstance): Editor | null;
50
+ getUI(this: IComponentInstance): EditorUI | null;
51
+ getValue(this: IComponentInstance): import("@baohu/canvas-editor").IEditorResult | null;
52
+ setValue(this: IComponentInstance, data: Partial<IEditorData>): void;
53
+ };
54
+ render(this: IComponentInstance, h: CreateElement): unknown;
55
+ };
56
+ interface IVueConstructor {
57
+ component: (name: string, component: unknown) => void;
58
+ }
59
+ export declare function install(Vue: IVueConstructor): void;
60
+ declare const plugin: {
61
+ install: typeof install;
62
+ CanvasEditor: {
63
+ name: string;
64
+ props: {
65
+ data: {
66
+ type: (ObjectConstructor | ArrayConstructor)[];
67
+ default: undefined;
68
+ };
69
+ options: {
70
+ type: ObjectConstructor;
71
+ default: undefined;
72
+ };
73
+ toolbar: {
74
+ type: (ArrayConstructor | BooleanConstructor)[];
75
+ default: undefined;
76
+ };
77
+ statusbar: {
78
+ type: (ArrayConstructor | BooleanConstructor)[];
79
+ default: undefined;
80
+ };
81
+ locale: {
82
+ type: ObjectConstructor;
83
+ default: undefined;
84
+ };
85
+ height: {
86
+ type: (StringConstructor | NumberConstructor)[];
87
+ default: string;
88
+ };
89
+ };
90
+ mounted(this: IComponentInstance): void;
91
+ beforeDestroy(this: IComponentInstance): void;
92
+ methods: {
93
+ getEditor(this: IComponentInstance): Editor | null;
94
+ getUI(this: IComponentInstance): EditorUI | null;
95
+ getValue(this: IComponentInstance): import("@baohu/canvas-editor").IEditorResult | null;
96
+ setValue(this: IComponentInstance, data: Partial<IEditorData>): void;
97
+ };
98
+ render(this: IComponentInstance, h: CreateElement): unknown;
99
+ };
100
+ };
101
+ export default plugin;
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@baohu/canvas-editor-vue2",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "Vue 2 component for @baohu/canvas-editor with toolbar and statusbar",
5
+ "license": "MIT",
6
+ "main": "./dist/canvas-editor-vue2.umd.js",
7
+ "module": "./dist/canvas-editor-vue2.esm.js",
8
+ "unpkg": "./dist/canvas-editor-vue2.umd.js",
9
+ "jsdelivr": "./dist/canvas-editor-vue2.umd.js",
10
+ "types": "./dist/types/index.d.ts",
11
+ "files": [
12
+ "dist",
13
+ "README.md"
14
+ ],
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/TaroXin/canvas-editor-ui.git",
21
+ "directory": "packages/vue2"
22
+ },
23
+ "keywords": [
24
+ "canvas-editor",
25
+ "vue2",
26
+ "editor"
27
+ ],
28
+ "dependencies": {
29
+ "@baohu/canvas-editor-ui": "^1.0.0"
30
+ },
31
+ "peerDependencies": {
32
+ "@baohu/canvas-editor": ">=1.0.5-baohu.3",
33
+ "vue": "^2.6.0"
34
+ },
35
+ "devDependencies": {
36
+ "@baohu/canvas-editor": "1.0.5-baohu.3",
37
+ "vue": "2.7.16"
38
+ },
39
+ "scripts": {
40
+ "build": "vite build && tsc -p tsconfig.build.json",
41
+ "type:check": "tsc --noEmit"
42
+ }
6
43
  }