modern-canvas 0.9.1 → 0.9.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/dist/index.cjs CHANGED
@@ -876,6 +876,9 @@ class Input extends modernIdoc.Observable {
876
876
  let IID = 0;
877
877
  class CoreObject extends modernIdoc.Reactivable {
878
878
  instanceId = ++IID;
879
+ get json() {
880
+ return this.toJSON();
881
+ }
879
882
  _nextTick() {
880
883
  return nextTick();
881
884
  }
@@ -9701,17 +9704,7 @@ class BaseElement2DText extends CoreObject {
9701
9704
  constructor(parent) {
9702
9705
  super();
9703
9706
  this.parent = parent;
9704
- this.base.on("updateProperty", (...args) => {
9705
- switch (args[0]) {
9706
- case "content":
9707
- case "effects":
9708
- case "fill":
9709
- case "outline":
9710
- this.setProperty(args[0], args[1]);
9711
- break;
9712
- }
9713
- this._updateProperty(...args);
9714
- });
9707
+ this.base.setPropertyAccessor(this);
9715
9708
  }
9716
9709
  base = new modernText.Text();
9717
9710
  measureResult;
@@ -9737,17 +9730,8 @@ class BaseElement2DText extends CoreObject {
9737
9730
  break;
9738
9731
  }
9739
9732
  }
9740
- _update() {
9741
- this.base.style = {
9742
- justifyContent: "center",
9743
- alignItems: "center",
9744
- textAlign: "center",
9745
- ...this.parent.style.toJSON()
9746
- };
9747
- this.base.update();
9748
- }
9749
9733
  _updateTextureMap() {
9750
- this._update();
9734
+ this.base.update();
9751
9735
  this._textureMap.clear();
9752
9736
  const pGlyphBoxs = [];
9753
9737
  this.base.paragraphs.forEach((p, pIndex) => {
@@ -9803,12 +9787,6 @@ class BaseElement2DText extends CoreObject {
9803
9787
  this.content = modernIdoc.normalizeTextContent(content);
9804
9788
  }
9805
9789
  measure() {
9806
- this.base.style = {
9807
- justifyContent: "center",
9808
- alignItems: "center",
9809
- textAlign: "center",
9810
- ...this.parent.style.toJSON()
9811
- };
9812
9790
  return this.base.measure();
9813
9791
  }
9814
9792
  updateMeasure() {
@@ -9831,7 +9809,7 @@ class BaseElement2DText extends CoreObject {
9831
9809
  }
9832
9810
  draw() {
9833
9811
  const ctx = this.parent.context;
9834
- this._update();
9812
+ this.base.update();
9835
9813
  this.base.pathSets.forEach((pathSet) => {
9836
9814
  pathSet.paths.forEach((path) => {
9837
9815
  const meta = path.getMeta();
@@ -9902,22 +9880,25 @@ __decorateClass$m([
9902
9880
  modernIdoc.property({ fallback: true })
9903
9881
  ], BaseElement2DText.prototype, "enabled");
9904
9882
  __decorateClass$m([
9905
- modernIdoc.property({ alias: "base.content", fallback: () => [] })
9883
+ modernIdoc.property({ fallback: () => [] })
9906
9884
  ], BaseElement2DText.prototype, "content");
9907
9885
  __decorateClass$m([
9908
- modernIdoc.property({ alias: "base.effects" })
9886
+ modernIdoc.property({ alias: "parent.style.json" })
9887
+ ], BaseElement2DText.prototype, "style");
9888
+ __decorateClass$m([
9889
+ modernIdoc.property()
9909
9890
  ], BaseElement2DText.prototype, "effects");
9910
9891
  __decorateClass$m([
9911
- modernIdoc.property({ alias: "base.fill" })
9892
+ modernIdoc.property()
9912
9893
  ], BaseElement2DText.prototype, "fill");
9913
9894
  __decorateClass$m([
9914
- modernIdoc.property({ alias: "base.outline" })
9895
+ modernIdoc.property()
9915
9896
  ], BaseElement2DText.prototype, "outline");
9916
9897
  __decorateClass$m([
9917
- modernIdoc.property({ internal: true, alias: "base.measureDom" })
9898
+ modernIdoc.property({ alias: "base.measureDom" })
9918
9899
  ], BaseElement2DText.prototype, "measureDom");
9919
9900
  __decorateClass$m([
9920
- modernIdoc.property({ internal: true, alias: "base.fonts" })
9901
+ modernIdoc.property({ alias: "base.fonts" })
9921
9902
  ], BaseElement2DText.prototype, "fonts");
9922
9903
 
9923
9904
  var __getOwnPropDesc$k = Object.getOwnPropertyDescriptor;
package/dist/index.d.cts CHANGED
@@ -255,6 +255,7 @@ interface CoreObject {
255
255
  }
256
256
  declare class CoreObject extends Reactivable {
257
257
  readonly instanceId: number;
258
+ get json(): Record<string, any>;
258
259
  protected _nextTick(): Promise<void>;
259
260
  equal(target: CoreObject | undefined | null): boolean;
260
261
  }
@@ -2063,6 +2064,7 @@ declare class BaseElement2DText extends CoreObject {
2063
2064
  parent: BaseElement2D;
2064
2065
  enabled: boolean;
2065
2066
  content: Text['content'];
2067
+ style: Text['style'];
2066
2068
  effects: Text['effects'];
2067
2069
  fill: Text['fill'];
2068
2070
  outline: Text['outline'];
@@ -2077,7 +2079,6 @@ declare class BaseElement2DText extends CoreObject {
2077
2079
  constructor(parent: BaseElement2D);
2078
2080
  setProperties(properties?: Text$1): this;
2079
2081
  protected _updateProperty(key: string, value: any, oldValue: any): void;
2080
- protected _update(): void;
2081
2082
  protected _updateTextureMap(): void;
2082
2083
  protected _updateTexture(key: string, fill: NormalizedFill | undefined, box: any): Promise<void>;
2083
2084
  protected _loadTexture(fill: NormalizedFill, box: any): Promise<Texture2D | undefined>;
package/dist/index.d.mts CHANGED
@@ -255,6 +255,7 @@ interface CoreObject {
255
255
  }
256
256
  declare class CoreObject extends Reactivable {
257
257
  readonly instanceId: number;
258
+ get json(): Record<string, any>;
258
259
  protected _nextTick(): Promise<void>;
259
260
  equal(target: CoreObject | undefined | null): boolean;
260
261
  }
@@ -2063,6 +2064,7 @@ declare class BaseElement2DText extends CoreObject {
2063
2064
  parent: BaseElement2D;
2064
2065
  enabled: boolean;
2065
2066
  content: Text['content'];
2067
+ style: Text['style'];
2066
2068
  effects: Text['effects'];
2067
2069
  fill: Text['fill'];
2068
2070
  outline: Text['outline'];
@@ -2077,7 +2079,6 @@ declare class BaseElement2DText extends CoreObject {
2077
2079
  constructor(parent: BaseElement2D);
2078
2080
  setProperties(properties?: Text$1): this;
2079
2081
  protected _updateProperty(key: string, value: any, oldValue: any): void;
2080
- protected _update(): void;
2081
2082
  protected _updateTextureMap(): void;
2082
2083
  protected _updateTexture(key: string, fill: NormalizedFill | undefined, box: any): Promise<void>;
2083
2084
  protected _loadTexture(fill: NormalizedFill, box: any): Promise<Texture2D | undefined>;
package/dist/index.d.ts CHANGED
@@ -255,6 +255,7 @@ interface CoreObject {
255
255
  }
256
256
  declare class CoreObject extends Reactivable {
257
257
  readonly instanceId: number;
258
+ get json(): Record<string, any>;
258
259
  protected _nextTick(): Promise<void>;
259
260
  equal(target: CoreObject | undefined | null): boolean;
260
261
  }
@@ -2063,6 +2064,7 @@ declare class BaseElement2DText extends CoreObject {
2063
2064
  parent: BaseElement2D;
2064
2065
  enabled: boolean;
2065
2066
  content: Text['content'];
2067
+ style: Text['style'];
2066
2068
  effects: Text['effects'];
2067
2069
  fill: Text['fill'];
2068
2070
  outline: Text['outline'];
@@ -2077,7 +2079,6 @@ declare class BaseElement2DText extends CoreObject {
2077
2079
  constructor(parent: BaseElement2D);
2078
2080
  setProperties(properties?: Text$1): this;
2079
2081
  protected _updateProperty(key: string, value: any, oldValue: any): void;
2080
- protected _update(): void;
2081
2082
  protected _updateTextureMap(): void;
2082
2083
  protected _updateTexture(key: string, fill: NormalizedFill | undefined, box: any): Promise<void>;
2083
2084
  protected _loadTexture(fill: NormalizedFill, box: any): Promise<Texture2D | undefined>;