@zeedhi/zd-richtext-common 1.3.1 → 1.3.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.
@@ -10,7 +10,7 @@ class RichText extends ComponentRender {
10
10
  /**
11
11
  * The content output format.
12
12
  */
13
- this.outputFormat = 'json';
13
+ this.outputFormat = 'html';
14
14
  /**
15
15
  * Placeholder is displayed when there is no content in the editor.
16
16
  */
@@ -36,6 +36,7 @@ class RichText extends ComponentRender {
36
36
  */
37
37
  this.height = '';
38
38
  this.fillHeight = false;
39
+ this.formatGetter = {};
39
40
  /**
40
41
  * Rich text content
41
42
  */
@@ -49,8 +50,20 @@ class RichText extends ComponentRender {
49
50
  this.width = this.getInitValue('width', props.width, this.width);
50
51
  this.height = this.getInitValue('height', props.height, this.height);
51
52
  this.fillHeight = this.getInitValue('fillHeight', props.fillHeight, this.fillHeight);
53
+ this.formatGetter = this.getInitValue('formatGetter', props.formatGetter, this.formatGetter);
54
+ this.content = this.getInitValue('content', props.content, this.content);
55
+ this.value = this.getInitValue('value', props.value, this.value);
52
56
  this.createAccessors();
53
57
  }
58
+ get value() {
59
+ if (typeof this.formatGetter[this.outputFormat] === 'function') {
60
+ return this.formatGetter[this.outputFormat]();
61
+ }
62
+ return this.content;
63
+ }
64
+ set value(value) {
65
+ this.content = value;
66
+ }
54
67
  onKeyDown(element, key) {
55
68
  this.callEvent('onKeyDown', {
56
69
  element, component: this, key, content: this.content,
@@ -13,7 +13,7 @@
13
13
  /**
14
14
  * The content output format.
15
15
  */
16
- this.outputFormat = 'json';
16
+ this.outputFormat = 'html';
17
17
  /**
18
18
  * Placeholder is displayed when there is no content in the editor.
19
19
  */
@@ -39,6 +39,7 @@
39
39
  */
40
40
  this.height = '';
41
41
  this.fillHeight = false;
42
+ this.formatGetter = {};
42
43
  /**
43
44
  * Rich text content
44
45
  */
@@ -52,8 +53,20 @@
52
53
  this.width = this.getInitValue('width', props.width, this.width);
53
54
  this.height = this.getInitValue('height', props.height, this.height);
54
55
  this.fillHeight = this.getInitValue('fillHeight', props.fillHeight, this.fillHeight);
56
+ this.formatGetter = this.getInitValue('formatGetter', props.formatGetter, this.formatGetter);
57
+ this.content = this.getInitValue('content', props.content, this.content);
58
+ this.value = this.getInitValue('value', props.value, this.value);
55
59
  this.createAccessors();
56
60
  }
61
+ get value() {
62
+ if (typeof this.formatGetter[this.outputFormat] === 'function') {
63
+ return this.formatGetter[this.outputFormat]();
64
+ }
65
+ return this.content;
66
+ }
67
+ set value(value) {
68
+ this.content = value;
69
+ }
57
70
  onKeyDown(element, key) {
58
71
  this.callEvent('onKeyDown', {
59
72
  element, component: this, key, content: this.content,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/zd-richtext-common",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "RichTextCommon by BVR",
5
5
  "main": "dist/rich-text-common.umd.js",
6
6
  "module": "dist/rich-text-common.esm.js",
@@ -23,5 +23,5 @@
23
23
  "@zeedhi/common": "*",
24
24
  "@zeedhi/core": "*"
25
25
  },
26
- "gitHead": "7f117f141fe0b7f61cc45217c9827d791a408705"
26
+ "gitHead": "5f202495829e7a912b0492c29f743ed5cc5a0c98"
27
27
  }
@@ -1,10 +1,12 @@
1
- import { IEventParam, IEvent } from '@zeedhi/core';
1
+ import { IEventParam, IEvent, IDictionary } from '@zeedhi/core';
2
2
  import { IComponentEvents, IComponentRender } from '@zeedhi/common';
3
3
  export interface IRichText extends IComponentRender {
4
4
  outputFormat?: string;
5
5
  placeholder?: string;
6
6
  disabled?: boolean;
7
7
  toolbarColor?: string;
8
+ formatGetter?: IDictionary<() => any>;
9
+ value?: any;
8
10
  cardColor?: string;
9
11
  outlined?: boolean;
10
12
  width?: number | string;
@@ -1,4 +1,5 @@
1
1
  import { ComponentRender } from '@zeedhi/common';
2
+ import { IDictionary } from '@zeedhi/core';
2
3
  import { IRichText, IRickTextEvents } from './interfaces';
3
4
  /**
4
5
  * Base class for Rich Text component.
@@ -40,11 +41,14 @@ export declare class RichText extends ComponentRender implements IRichText {
40
41
  * Events registered to the Rich Text
41
42
  */
42
43
  events: IRickTextEvents;
44
+ get value(): any;
45
+ set value(value: any);
43
46
  fillHeight: boolean;
44
- constructor(props: IRichText);
47
+ formatGetter: IDictionary<() => any>;
45
48
  /**
46
49
  * Rich text content
47
50
  */
48
51
  content: string;
52
+ constructor(props: IRichText);
49
53
  onKeyDown(element?: HTMLElement, key?: string): void;
50
54
  }