x4js 1.5.7 → 1.5.9
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/lib/cjs/textarea.js +34 -3
- package/lib/cjs/version.js +1 -1
- package/lib/esm/textarea.js +34 -3
- package/lib/esm/version.js +1 -1
- package/lib/src/textarea.ts +44 -4
- package/lib/src/version.ts +1 -1
- package/lib/types/textarea.d.ts +12 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/cjs/textarea.js
CHANGED
|
@@ -107,15 +107,46 @@ class TextArea extends component_1.Component {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
|
+
* @deprected use appendText
|
|
110
111
|
* insert text at cursor position
|
|
111
112
|
*/
|
|
112
113
|
insertText(text) {
|
|
114
|
+
this.appendText(text);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* append the text
|
|
118
|
+
*/
|
|
119
|
+
appendText(text) {
|
|
120
|
+
if (this.dom) {
|
|
121
|
+
let dom = this.dom;
|
|
122
|
+
let end = dom.selectionEnd;
|
|
123
|
+
dom.setRangeText(text, end, end, "end");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
replaceText(text) {
|
|
113
127
|
if (this.dom) {
|
|
114
128
|
let dom = this.dom;
|
|
115
|
-
let start = dom.selectionStart;
|
|
116
129
|
dom.setRangeText(text);
|
|
117
|
-
|
|
118
|
-
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
getSelection() {
|
|
133
|
+
if (this.dom) {
|
|
134
|
+
let dom = this.dom;
|
|
135
|
+
return { start: dom.selectionStart, end: dom.selectionEnd };
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
return { start: 0, end: 0 };
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
setSelection(sel) {
|
|
142
|
+
if (this.dom) {
|
|
143
|
+
let dom = this.dom;
|
|
144
|
+
if (sel.start !== undefined) {
|
|
145
|
+
dom.selectionStart = sel.start;
|
|
146
|
+
}
|
|
147
|
+
if (sel.end !== undefined) {
|
|
148
|
+
dom.selectionEnd = sel.end;
|
|
149
|
+
}
|
|
119
150
|
}
|
|
120
151
|
}
|
|
121
152
|
getStoreValue() {
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/textarea.js
CHANGED
|
@@ -103,15 +103,46 @@ export class TextArea extends Component {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
|
+
* @deprected use appendText
|
|
106
107
|
* insert text at cursor position
|
|
107
108
|
*/
|
|
108
109
|
insertText(text) {
|
|
110
|
+
this.appendText(text);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* append the text
|
|
114
|
+
*/
|
|
115
|
+
appendText(text) {
|
|
116
|
+
if (this.dom) {
|
|
117
|
+
let dom = this.dom;
|
|
118
|
+
let end = dom.selectionEnd;
|
|
119
|
+
dom.setRangeText(text, end, end, "end");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
replaceText(text) {
|
|
109
123
|
if (this.dom) {
|
|
110
124
|
let dom = this.dom;
|
|
111
|
-
let start = dom.selectionStart;
|
|
112
125
|
dom.setRangeText(text);
|
|
113
|
-
|
|
114
|
-
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
getSelection() {
|
|
129
|
+
if (this.dom) {
|
|
130
|
+
let dom = this.dom;
|
|
131
|
+
return { start: dom.selectionStart, end: dom.selectionEnd };
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
return { start: 0, end: 0 };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
setSelection(sel) {
|
|
138
|
+
if (this.dom) {
|
|
139
|
+
let dom = this.dom;
|
|
140
|
+
if (sel.start !== undefined) {
|
|
141
|
+
dom.selectionStart = sel.start;
|
|
142
|
+
}
|
|
143
|
+
if (sel.end !== undefined) {
|
|
144
|
+
dom.selectionEnd = sel.end;
|
|
145
|
+
}
|
|
115
146
|
}
|
|
116
147
|
}
|
|
117
148
|
getStoreValue() {
|
package/lib/esm/version.js
CHANGED
package/lib/src/textarea.ts
CHANGED
|
@@ -35,6 +35,11 @@ interface TextAreaEventMap extends CEventMap {
|
|
|
35
35
|
change: EvChange;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
interface Selection {
|
|
39
|
+
start: number;
|
|
40
|
+
end: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
export interface TextAreaProps extends CProps {
|
|
39
44
|
text?: string;
|
|
40
45
|
readOnly?: boolean;
|
|
@@ -149,21 +154,56 @@ export class TextArea extends Component<TextAreaProps, TextAreaEventMap> {
|
|
|
149
154
|
}
|
|
150
155
|
|
|
151
156
|
/**
|
|
157
|
+
* @deprected use appendText
|
|
152
158
|
* insert text at cursor position
|
|
153
159
|
*/
|
|
154
160
|
|
|
155
161
|
public insertText(text) {
|
|
162
|
+
this.appendText( text );
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* append the text
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
public appendText( text ) {
|
|
156
170
|
if (this.dom) {
|
|
157
171
|
let dom = (<HTMLTextAreaElement>this.dom);
|
|
172
|
+
let end = dom.selectionEnd;
|
|
173
|
+
dom.setRangeText(text,end,end,"end");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
158
176
|
|
|
159
|
-
|
|
177
|
+
public replaceText( text ) {
|
|
178
|
+
if (this.dom) {
|
|
179
|
+
let dom = (<HTMLTextAreaElement>this.dom);
|
|
160
180
|
dom.setRangeText(text);
|
|
161
|
-
dom.selectionStart = start;
|
|
162
|
-
dom.selectionEnd = start + text.length;
|
|
163
181
|
}
|
|
164
182
|
}
|
|
165
|
-
|
|
166
183
|
|
|
184
|
+
public getSelection( ) : Selection {
|
|
185
|
+
if (this.dom) {
|
|
186
|
+
let dom = (<HTMLTextAreaElement>this.dom);
|
|
187
|
+
return { start: dom.selectionStart, end: dom.selectionEnd };
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
return {start: 0, end: 0 };
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
public setSelection( sel : Selection ) {
|
|
195
|
+
if (this.dom) {
|
|
196
|
+
let dom = (<HTMLTextAreaElement>this.dom);
|
|
197
|
+
if( sel.start!==undefined ) {
|
|
198
|
+
dom.selectionStart = sel.start;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if( sel.end!==undefined ) {
|
|
202
|
+
dom.selectionEnd = sel.end;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
167
207
|
public getStoreValue( ): any {
|
|
168
208
|
return this.value;
|
|
169
209
|
}
|
package/lib/src/version.ts
CHANGED
package/lib/types/textarea.d.ts
CHANGED
|
@@ -31,6 +31,10 @@ import { EvChange, EventCallback } from './x4events';
|
|
|
31
31
|
interface TextAreaEventMap extends CEventMap {
|
|
32
32
|
change: EvChange;
|
|
33
33
|
}
|
|
34
|
+
interface Selection {
|
|
35
|
+
start: number;
|
|
36
|
+
end: number;
|
|
37
|
+
}
|
|
34
38
|
export interface TextAreaProps extends CProps {
|
|
35
39
|
text?: string;
|
|
36
40
|
readOnly?: boolean;
|
|
@@ -54,9 +58,17 @@ export declare class TextArea extends Component<TextAreaProps, TextAreaEventMap>
|
|
|
54
58
|
private _calcHeight;
|
|
55
59
|
private _updateHeight;
|
|
56
60
|
/**
|
|
61
|
+
* @deprected use appendText
|
|
57
62
|
* insert text at cursor position
|
|
58
63
|
*/
|
|
59
64
|
insertText(text: any): void;
|
|
65
|
+
/**
|
|
66
|
+
* append the text
|
|
67
|
+
*/
|
|
68
|
+
appendText(text: any): void;
|
|
69
|
+
replaceText(text: any): void;
|
|
70
|
+
getSelection(): Selection;
|
|
71
|
+
setSelection(sel: Selection): void;
|
|
60
72
|
getStoreValue(): any;
|
|
61
73
|
setStoreValue(value: any): void;
|
|
62
74
|
}
|
package/lib/types/version.d.ts
CHANGED