@wanghe1995/docx-editor-ui-lite 1.0.1 → 1.0.3

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.
@@ -0,0 +1,56 @@
1
+ var i = Object.defineProperty;
2
+ var s = (e, t, r) => t in e ? i(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var n = (e, t, r) => s(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import h from "@wanghe1995/docx-editor-core";
5
+ export * from "@wanghe1995/docx-editor-core";
6
+ const a = (e) => {
7
+ if (typeof e == "string") {
8
+ const t = document.querySelector(e);
9
+ if (!t)
10
+ throw new Error(`Mount target not found: ${e}`);
11
+ return t;
12
+ }
13
+ if (!e)
14
+ throw new Error("Mount target is required");
15
+ return e;
16
+ };
17
+ class f {
18
+ constructor(t) {
19
+ n(this, "config");
20
+ n(this, "editor", null);
21
+ n(this, "_container");
22
+ var r;
23
+ this.config = t, this._container = a(t.container), this._applyDefaultTheme(), this.editor = new h(this._container, t.data || { main: [] }, t.options || {}), this._bindListeners(), (r = t.onReady) == null || r.call(t, this.editor);
24
+ }
25
+ _applyDefaultTheme() {
26
+ const t = document.documentElement;
27
+ t.style.setProperty("--tabs-bg-color", "#2B579A"), t.style.setProperty("--tabs-text-color", "#ffffff");
28
+ }
29
+ _bindListeners() {
30
+ this.editor && (this.config.onChange && (this.editor.listener.contentChange = this.config.onChange), this.config.onPageChange && (this.editor.listener.pageSizeChange = this.config.onPageChange), this.config.onScaleChange && (this.editor.listener.pageScaleChange = this.config.onScaleChange));
31
+ }
32
+ get command() {
33
+ var t;
34
+ return (t = this.editor) == null ? void 0 : t.command;
35
+ }
36
+ get listener() {
37
+ var t;
38
+ return (t = this.editor) == null ? void 0 : t.listener;
39
+ }
40
+ get container() {
41
+ return this._container;
42
+ }
43
+ executeCommand(t, ...r) {
44
+ if (!this.editor)
45
+ return;
46
+ const o = this.editor.command[t];
47
+ if (typeof o == "function")
48
+ return o(...r);
49
+ }
50
+ destroy() {
51
+ this.editor && (this.editor.destroy(), this.editor = null);
52
+ }
53
+ }
54
+ export {
55
+ f as WordEditor
56
+ };
@@ -0,0 +1 @@
1
+ (function(t,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@wanghe1995/docx-editor-core")):typeof define=="function"&&define.amd?define(["exports","@wanghe1995/docx-editor-core"],n):(t=typeof globalThis<"u"?globalThis:t||self,n(t["docx-editor-lite"]={},t.DocxEditorCore))})(this,function(t,n){"use strict";var a=Object.defineProperty;var c=(t,n,o)=>n in t?a(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o;var s=(t,n,o)=>c(t,typeof n!="symbol"?n+"":n,o);const o=i=>{if(typeof i=="string"){const e=document.querySelector(i);if(!e)throw new Error(`Mount target not found: ${i}`);return e}if(!i)throw new Error("Mount target is required");return i};class h{constructor(e){s(this,"config");s(this,"editor",null);s(this,"_container");var r;this.config=e,this._container=o(e.container),this._applyDefaultTheme(),this.editor=new n(this._container,e.data||{main:[]},e.options||{}),this._bindListeners(),(r=e.onReady)==null||r.call(e,this.editor)}_applyDefaultTheme(){const e=document.documentElement;e.style.setProperty("--tabs-bg-color","#2B579A"),e.style.setProperty("--tabs-text-color","#ffffff")}_bindListeners(){this.editor&&(this.config.onChange&&(this.editor.listener.contentChange=this.config.onChange),this.config.onPageChange&&(this.editor.listener.pageSizeChange=this.config.onPageChange),this.config.onScaleChange&&(this.editor.listener.pageScaleChange=this.config.onScaleChange))}get command(){var e;return(e=this.editor)==null?void 0:e.command}get listener(){var e;return(e=this.editor)==null?void 0:e.listener}get container(){return this._container}executeCommand(e,...r){if(!this.editor)return;const d=this.editor.command[e];if(typeof d=="function")return d(...r)}destroy(){this.editor&&(this.editor.destroy(),this.editor=null)}}t.WordEditor=h,Object.keys(n).forEach(i=>{i!=="default"&&!Object.prototype.hasOwnProperty.call(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:()=>n[i]})}),Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,3 @@
1
+ export * from '@wanghe1995/docx-editor-core';
2
+ export { WordEditor } from '../object/WordEditor';
3
+ export type { WordEditorOptions } from '../object/WordEditor';
@@ -0,0 +1,24 @@
1
+ import DocxEditor from '@wanghe1995/docx-editor-core';
2
+ import type { IEditorData, IElement, IEditorOption } from '@wanghe1995/docx-editor-core';
3
+ export interface WordEditorOptions {
4
+ container: string | HTMLElement;
5
+ data?: IEditorData | IElement[];
6
+ options?: IEditorOption;
7
+ onReady?: (editor: DocxEditor) => void;
8
+ onChange?: () => void;
9
+ onPageChange?: (pageNo: number) => void;
10
+ onScaleChange?: (scale: number) => void;
11
+ }
12
+ export declare class WordEditor {
13
+ private config;
14
+ private editor;
15
+ private _container;
16
+ constructor(config: WordEditorOptions);
17
+ private _applyDefaultTheme;
18
+ private _bindListeners;
19
+ get command(): import("@wanghe1995/docx-editor-transform").Command | undefined;
20
+ get listener(): import("@wanghe1995/docx-editor-state").Listener | undefined;
21
+ get container(): HTMLDivElement;
22
+ executeCommand(command: string, ...args: any[]): any;
23
+ destroy(): void;
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wanghe1995/docx-editor-ui-lite",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "DocxEditor 精简版UI库(Lite)",
5
5
  "author": "wanghe",
6
6
  "license": "MIT",