@zeedhi/zd-richtext-common 1.5.1 → 3.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.
@@ -0,0 +1,91 @@
1
+ var n = Object.defineProperty;
2
+ var a = (o, i, t) => i in o ? n(o, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[i] = t;
3
+ var e = (o, i, t) => a(o, typeof i != "symbol" ? i + "" : i, t);
4
+ import { ComponentRender as s } from "@zeedhi/common";
5
+ class d extends s {
6
+ constructor(t) {
7
+ super(t);
8
+ /**
9
+ * The content output format.
10
+ */
11
+ e(this, "outputFormat", "html");
12
+ e(this, "fonts", [
13
+ { font: "Inter", title: "Inter" },
14
+ { font: "Roboto", title: "Roboto" },
15
+ { font: "serif", title: "Serif" },
16
+ { font: "monospace", title: "Monospace" }
17
+ ]);
18
+ /**
19
+ * Placeholder is displayed when there is no content in the editor.
20
+ */
21
+ e(this, "placeholder", "");
22
+ /**
23
+ * Disable the component
24
+ */
25
+ e(this, "disabled", !1);
26
+ /**
27
+ * Turn the component into a readonly
28
+ */
29
+ e(this, "readonly", !1);
30
+ /**
31
+ * Toolbar color
32
+ */
33
+ e(this, "toolbarColor");
34
+ /**
35
+ * Card color
36
+ */
37
+ e(this, "cardColor", "");
38
+ /**
39
+ * Removes elevation and adds a thin border.
40
+ */
41
+ e(this, "outlined", !1);
42
+ /**
43
+ * Component width.
44
+ */
45
+ e(this, "width", "");
46
+ /**
47
+ * Component height.
48
+ */
49
+ e(this, "height", "");
50
+ e(this, "fillHeight", !1);
51
+ e(this, "formatGetter", {});
52
+ /**
53
+ * Rich text content
54
+ */
55
+ e(this, "content", "");
56
+ this.outputFormat = this.getInitValue("outputFormat", t.outputFormat, this.outputFormat), this.placeholder = this.getInitValue("placeHolder", t.placeholder, this.placeholder), this.disabled = this.getInitValue("disabled", t.disabled, this.disabled), this.toolbarColor = this.getInitValue("toolbarColor", t.toolbarColor, this.toolbarColor), this.cardColor = this.getInitValue("cardColor", t.cardColor, this.cardColor), this.outlined = this.getInitValue("outlined", t.outlined, this.outlined), this.width = this.getInitValue("width", t.width, this.width), this.height = this.getInitValue("height", t.height, this.height), this.fillHeight = this.getInitValue("fillHeight", t.fillHeight, this.fillHeight), this.formatGetter = this.getInitValue("formatGetter", t.formatGetter, this.formatGetter), this.content = this.getInitValue("content", t.content, this.content), this.value = this.getInitValue("value", t.value, this.value), this.fonts = this.getInitValue("fonts", t.fonts, this.fonts), this.readonly = this.getInitValue("readonly", t.readonly, this.readonly), this.createAccessors();
57
+ }
58
+ get value() {
59
+ return typeof this.formatGetter[this.outputFormat] == "function" ? this.formatGetter[this.outputFormat]() : this.content;
60
+ }
61
+ set value(t) {
62
+ this.content = t;
63
+ }
64
+ keydown(t, l) {
65
+ this.callEvent("keydown", {
66
+ event: t,
67
+ component: this,
68
+ key: l,
69
+ content: this.content
70
+ });
71
+ }
72
+ input(t, l, h) {
73
+ this.callEvent("input", {
74
+ text: t,
75
+ event: l,
76
+ element: h,
77
+ component: this
78
+ });
79
+ }
80
+ change(t, l, h) {
81
+ this.callEvent("change", {
82
+ text: t,
83
+ event: l,
84
+ element: h,
85
+ component: this
86
+ });
87
+ }
88
+ }
89
+ export {
90
+ d as RichText
91
+ };
@@ -1,2 +1,2 @@
1
- export * from './rich-text';
2
- export * from './interfaces';
1
+ export * from './rich-text';
2
+ export * from './interfaces';
@@ -1,28 +1,26 @@
1
- import { IComponentEvents, IComponentRender } from '@zeedhi/common';
2
- import { IDictionary, IEvent, IEventParam } from '@zeedhi/core';
3
- export interface IRichText extends IComponentRender {
4
- outputFormat?: string;
5
- placeholder?: string;
6
- disabled?: boolean;
7
- readonly?: boolean;
8
- toolbarColor?: string;
9
- formatGetter?: IDictionary<() => any>;
10
- value?: any;
11
- cardColor?: string;
12
- outlined?: boolean;
13
- width?: number | string;
14
- height?: number | string;
15
- fillHeight?: boolean;
16
- fonts?: IFonts[];
17
- }
18
- export interface IFonts {
19
- font: string;
20
- title: string;
21
- }
22
- export interface IRickTextEvents<T = IEventParam<any>> extends IComponentEvents<T> {
23
- onKeyDown?: IEvent<T> | string;
24
- onChange?: IEvent<T> | string;
25
- onBlur?: IEvent<T> | string;
26
- onFocus?: IEvent<T> | string;
27
- input?: IEvent<T> | string;
28
- }
1
+ import { IComponentEvents, IComponentRender } from '@zeedhi/common';
2
+ import { IDictionary, IEvent, IEventParam } from '@zeedhi/core';
3
+ export interface IRichText extends IComponentRender {
4
+ outputFormat?: string;
5
+ placeholder?: string;
6
+ disabled?: boolean;
7
+ readonly?: boolean;
8
+ toolbarColor?: string;
9
+ formatGetter?: IDictionary<() => any>;
10
+ value?: any;
11
+ cardColor?: string;
12
+ outlined?: boolean;
13
+ width?: number | string;
14
+ height?: number | string;
15
+ fillHeight?: boolean;
16
+ fonts?: IFonts[];
17
+ }
18
+ export interface IFonts {
19
+ font: string;
20
+ title: string;
21
+ }
22
+ export interface IRickTextEvents<T = IEventParam<any>> extends IComponentEvents<T> {
23
+ keydown?: IEvent<T> | string;
24
+ change?: IEvent<T> | string;
25
+ input?: IEvent<T> | string;
26
+ }
@@ -1,63 +1,57 @@
1
- import { ComponentRender } from '@zeedhi/common';
2
- import { IDictionary } from '@zeedhi/core';
3
- import { IFonts, IRichText, IRickTextEvents } from './interfaces';
4
- /**
5
- * Base class for Rich Text component.
6
- */
7
- export declare class RichText extends ComponentRender implements IRichText {
8
- /**
9
- * The content output format.
10
- */
11
- outputFormat: string;
12
- fonts: IFonts[];
13
- /**
14
- * Placeholder is displayed when there is no content in the editor.
15
- */
16
- placeholder: string;
17
- /**
18
- * Disable the component
19
- */
20
- disabled: boolean;
21
- /**
22
- * Turn the component into a readonly
23
- */
24
- readonly: boolean;
25
- /**
26
- * Toolbar color
27
- */
28
- toolbarColor?: string;
29
- /**
30
- * Card color
31
- */
32
- cardColor: string;
33
- /**
34
- * Removes elevation and adds a thin border.
35
- */
36
- outlined: boolean;
37
- /**
38
- * Component width.
39
- */
40
- width: number | string;
41
- /**
42
- * Component height.
43
- */
44
- height: number | string;
45
- /**
46
- * Events registered to the Rich Text
47
- */
48
- events: IRickTextEvents;
49
- get value(): any;
50
- set value(value: any);
51
- fillHeight: boolean;
52
- formatGetter: IDictionary<() => any>;
53
- /**
54
- * Rich text content
55
- */
56
- content: string;
57
- constructor(props: IRichText);
58
- onKeyDown(element?: HTMLElement, key?: string): void;
59
- input(text: string, event?: Event, element?: HTMLElement): void;
60
- onChange(text: string, event?: Event, element?: HTMLElement): void;
61
- onBlur(event?: Event, element?: HTMLElement): void;
62
- onFocus(event?: Event, element?: HTMLElement): void;
63
- }
1
+ import { ComponentRender } from '@zeedhi/common';
2
+ import { IDictionary } from '@zeedhi/core';
3
+ import { IFonts, IRichText } from './interfaces';
4
+ /**
5
+ * Base class for Rich Text component.
6
+ */
7
+ export declare class RichText extends ComponentRender implements IRichText {
8
+ /**
9
+ * The content output format.
10
+ */
11
+ outputFormat: string;
12
+ fonts: IFonts[];
13
+ /**
14
+ * Placeholder is displayed when there is no content in the editor.
15
+ */
16
+ placeholder: string;
17
+ /**
18
+ * Disable the component
19
+ */
20
+ disabled: boolean;
21
+ /**
22
+ * Turn the component into a readonly
23
+ */
24
+ readonly: boolean;
25
+ /**
26
+ * Toolbar color
27
+ */
28
+ toolbarColor?: string;
29
+ /**
30
+ * Card color
31
+ */
32
+ cardColor: string;
33
+ /**
34
+ * Removes elevation and adds a thin border.
35
+ */
36
+ outlined: boolean;
37
+ /**
38
+ * Component width.
39
+ */
40
+ width: string;
41
+ /**
42
+ * Component height.
43
+ */
44
+ height: string;
45
+ get value(): any;
46
+ set value(value: any);
47
+ fillHeight: boolean;
48
+ formatGetter: IDictionary<() => any>;
49
+ /**
50
+ * Rich text content
51
+ */
52
+ content: string;
53
+ constructor(props: IRichText);
54
+ keydown(event?: KeyboardEvent, key?: string | HTMLElement): void;
55
+ input(text: string, event?: Event, element?: HTMLElement): void;
56
+ change(text: string, event?: Event, element?: HTMLElement): void;
57
+ }
package/package.json CHANGED
@@ -1,27 +1,41 @@
1
1
  {
2
2
  "name": "@zeedhi/zd-richtext-common",
3
- "version": "1.5.1",
4
- "description": "RichTextCommon by BVR",
5
- "main": "dist/rich-text-common.umd.js",
6
- "module": "dist/rich-text-common.esm.js",
7
- "typings": "types/index.d.ts",
3
+ "version": "3.0.0",
4
+ "type": "module",
5
+ "files": [
6
+ "dist"
7
+ ],
8
8
  "publishConfig": {
9
9
  "access": "public"
10
10
  },
11
- "scripts": {
12
- "build": "rollup -c",
13
- "lint": "eslint . --fix --ext .ts",
14
- "test": "jest",
15
- "watch": "npm run build -- -w"
11
+ "module": "./dist/richtext-common.es.js",
12
+ "types": "./dist/types/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "import": "./dist/richtext-common.es.js",
16
+ "types": "./dist/types/index.d.ts"
17
+ }
16
18
  },
17
- "devDependencies": {
18
- "@types/jest": "26.0.*",
19
- "jest": "26.6.*",
20
- "ts-jest": "26.5.*"
19
+ "scripts": {
20
+ "dev": "vite",
21
+ "build": "tsc && vite build",
22
+ "test": "vitest run --coverage",
23
+ "test:watch": "vitest"
21
24
  },
22
25
  "peerDependencies": {
23
- "@zeedhi/common": "^1.74.0",
24
- "@zeedhi/core": "^1.74.0"
26
+ "@zeedhi/common": "^3.0.0",
27
+ "@zeedhi/core": "^3.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^22.10.2",
31
+ "@vitest/coverage-v8": "^2.1.8",
32
+ "@volar/typescript": "^2.4.6",
33
+ "@zeedhi/common": "^3.0.0",
34
+ "@zeedhi/core": "^3.0.0",
35
+ "typescript": "~5.6.2",
36
+ "vite": "^5.4.0",
37
+ "vite-plugin-dts": "^4.5.0",
38
+ "vitest": "^2.1.8"
25
39
  },
26
- "gitHead": "1b3715e1a7255b053f46736ebab3b87c1ee644f5"
40
+ "gitHead": "bb3da940c3647ecd89c2d97b20a0bfef0cf74a25"
27
41
  }
@@ -1,118 +0,0 @@
1
- import { VersionService } from '@zeedhi/core';
2
- import { ComponentRender } from '@zeedhi/common';
3
-
4
- /**
5
- * Base class for Rich Text component.
6
- */
7
- class RichText extends ComponentRender {
8
- constructor(props) {
9
- super(props);
10
- /**
11
- * The content output format.
12
- */
13
- this.outputFormat = 'html';
14
- this.fonts = [
15
- { font: 'Inter', title: 'Inter' },
16
- { font: 'Roboto', title: 'Roboto' },
17
- { font: 'serif', title: 'Serif' },
18
- { font: 'monospace', title: 'Monospace' },
19
- ];
20
- /**
21
- * Placeholder is displayed when there is no content in the editor.
22
- */
23
- this.placeholder = '';
24
- /**
25
- * Disable the component
26
- */
27
- this.disabled = false;
28
- /**
29
- * Turn the component into a readonly
30
- */
31
- this.readonly = false;
32
- /**
33
- * Card color
34
- */
35
- this.cardColor = '';
36
- /**
37
- * Removes elevation and adds a thin border.
38
- */
39
- this.outlined = false;
40
- /**
41
- * Component width.
42
- */
43
- this.width = '';
44
- /**
45
- * Component height.
46
- */
47
- this.height = '';
48
- this.fillHeight = false;
49
- this.formatGetter = {};
50
- /**
51
- * Rich text content
52
- */
53
- this.content = '';
54
- this.outputFormat = this.getInitValue('outputFormat', props.outputFormat, this.outputFormat);
55
- this.placeholder = this.getInitValue('placeHolder', props.placeholder, this.placeholder);
56
- this.disabled = this.getInitValue('disabled', props.disabled, this.disabled);
57
- this.toolbarColor = this.getInitValue('toolbarColor', props.toolbarColor, this.toolbarColor);
58
- this.cardColor = this.getInitValue('cardColor', props.cardColor, this.cardColor);
59
- this.outlined = this.getInitValue('outlined', props.outlined, this.outlined);
60
- this.width = this.getInitValue('width', props.width, this.width);
61
- this.height = this.getInitValue('height', props.height, this.height);
62
- this.fillHeight = this.getInitValue('fillHeight', props.fillHeight, this.fillHeight);
63
- this.formatGetter = this.getInitValue('formatGetter', props.formatGetter, this.formatGetter);
64
- this.content = this.getInitValue('content', props.content, this.content);
65
- this.value = this.getInitValue('value', props.value, this.value);
66
- this.fonts = this.getInitValue('fonts', props.fonts, this.fonts);
67
- this.createAccessors();
68
- }
69
- get value() {
70
- if (typeof this.formatGetter[this.outputFormat] === 'function') {
71
- return this.formatGetter[this.outputFormat]();
72
- }
73
- return this.content;
74
- }
75
- set value(value) {
76
- this.content = value;
77
- }
78
- onKeyDown(element, key) {
79
- this.callEvent('onKeyDown', {
80
- element, component: this, key, content: this.content,
81
- });
82
- }
83
- input(text, event, element) {
84
- this.callEvent('input', {
85
- text,
86
- event,
87
- element,
88
- component: this,
89
- });
90
- }
91
- onChange(text, event, element) {
92
- this.callEvent('onChange', {
93
- text,
94
- event,
95
- element,
96
- component: this,
97
- });
98
- }
99
- onBlur(event, element) {
100
- this.callEvent('onBlur', {
101
- event,
102
- element,
103
- component: this,
104
- });
105
- }
106
- onFocus(event, element) {
107
- this.callEvent('onFocus', {
108
- event,
109
- element,
110
- component: this,
111
- });
112
- }
113
- }
114
-
115
- const packageContent = require('../package.json');
116
- VersionService.addPackageVersion(packageContent.name, packageContent.version);
117
-
118
- export { RichText };
@@ -1,125 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@zeedhi/core'), require('@zeedhi/common')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@zeedhi/core', '@zeedhi/common'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@zeedhi/zd-richtext-common"] = {}, global["@zeedhi/core"], global["@zeedhi/common"]));
5
- })(this, (function (exports, core, common) { 'use strict';
6
-
7
- /**
8
- * Base class for Rich Text component.
9
- */
10
- class RichText extends common.ComponentRender {
11
- constructor(props) {
12
- super(props);
13
- /**
14
- * The content output format.
15
- */
16
- this.outputFormat = 'html';
17
- this.fonts = [
18
- { font: 'Inter', title: 'Inter' },
19
- { font: 'Roboto', title: 'Roboto' },
20
- { font: 'serif', title: 'Serif' },
21
- { font: 'monospace', title: 'Monospace' },
22
- ];
23
- /**
24
- * Placeholder is displayed when there is no content in the editor.
25
- */
26
- this.placeholder = '';
27
- /**
28
- * Disable the component
29
- */
30
- this.disabled = false;
31
- /**
32
- * Turn the component into a readonly
33
- */
34
- this.readonly = false;
35
- /**
36
- * Card color
37
- */
38
- this.cardColor = '';
39
- /**
40
- * Removes elevation and adds a thin border.
41
- */
42
- this.outlined = false;
43
- /**
44
- * Component width.
45
- */
46
- this.width = '';
47
- /**
48
- * Component height.
49
- */
50
- this.height = '';
51
- this.fillHeight = false;
52
- this.formatGetter = {};
53
- /**
54
- * Rich text content
55
- */
56
- this.content = '';
57
- this.outputFormat = this.getInitValue('outputFormat', props.outputFormat, this.outputFormat);
58
- this.placeholder = this.getInitValue('placeHolder', props.placeholder, this.placeholder);
59
- this.disabled = this.getInitValue('disabled', props.disabled, this.disabled);
60
- this.toolbarColor = this.getInitValue('toolbarColor', props.toolbarColor, this.toolbarColor);
61
- this.cardColor = this.getInitValue('cardColor', props.cardColor, this.cardColor);
62
- this.outlined = this.getInitValue('outlined', props.outlined, this.outlined);
63
- this.width = this.getInitValue('width', props.width, this.width);
64
- this.height = this.getInitValue('height', props.height, this.height);
65
- this.fillHeight = this.getInitValue('fillHeight', props.fillHeight, this.fillHeight);
66
- this.formatGetter = this.getInitValue('formatGetter', props.formatGetter, this.formatGetter);
67
- this.content = this.getInitValue('content', props.content, this.content);
68
- this.value = this.getInitValue('value', props.value, this.value);
69
- this.fonts = this.getInitValue('fonts', props.fonts, this.fonts);
70
- this.createAccessors();
71
- }
72
- get value() {
73
- if (typeof this.formatGetter[this.outputFormat] === 'function') {
74
- return this.formatGetter[this.outputFormat]();
75
- }
76
- return this.content;
77
- }
78
- set value(value) {
79
- this.content = value;
80
- }
81
- onKeyDown(element, key) {
82
- this.callEvent('onKeyDown', {
83
- element, component: this, key, content: this.content,
84
- });
85
- }
86
- input(text, event, element) {
87
- this.callEvent('input', {
88
- text,
89
- event,
90
- element,
91
- component: this,
92
- });
93
- }
94
- onChange(text, event, element) {
95
- this.callEvent('onChange', {
96
- text,
97
- event,
98
- element,
99
- component: this,
100
- });
101
- }
102
- onBlur(event, element) {
103
- this.callEvent('onBlur', {
104
- event,
105
- element,
106
- component: this,
107
- });
108
- }
109
- onFocus(event, element) {
110
- this.callEvent('onFocus', {
111
- event,
112
- element,
113
- component: this,
114
- });
115
- }
116
- }
117
-
118
- const packageContent = require('../package.json');
119
- core.VersionService.addPackageVersion(packageContent.name, packageContent.version);
120
-
121
- exports.RichText = RichText;
122
-
123
- Object.defineProperty(exports, '__esModule', { value: true });
124
-
125
- }));