@po-ui/ng-code-editor 5.22.2 → 5.22.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.
Files changed (40) hide show
  1. package/README.md +20 -20
  2. package/bundles/po-ui-ng-code-editor.umd.js +929 -929
  3. package/bundles/po-ui-ng-code-editor.umd.js.map +1 -1
  4. package/esm2015/lib/components/po-code-editor/interfaces/po-code-editor-registerable-options.interface.js +2 -2
  5. package/esm2015/lib/components/po-code-editor/interfaces/po-code-editor-registerable-suggestion.interface.js +2 -2
  6. package/esm2015/lib/components/po-code-editor/interfaces/po-code-editor-registerable-tokens.interface.js +2 -2
  7. package/esm2015/lib/components/po-code-editor/interfaces/po-code-editor-registerable.interface.js +2 -2
  8. package/esm2015/lib/components/po-code-editor/po-code-editor-base.component.js +248 -248
  9. package/esm2015/lib/components/po-code-editor/po-code-editor-register.service.js +63 -63
  10. package/esm2015/lib/components/po-code-editor/po-code-editor-suggestion.service.js +28 -28
  11. package/esm2015/lib/components/po-code-editor/po-code-editor.component.js +225 -225
  12. package/esm2015/lib/components/po-code-editor/po-code-editor.module.js +31 -31
  13. package/esm2015/lib/index.js +4 -4
  14. package/esm2015/po-ui-ng-code-editor.js +6 -6
  15. package/esm2015/public-api.js +2 -2
  16. package/fesm2015/po-ui-ng-code-editor.js +574 -574
  17. package/fesm2015/po-ui-ng-code-editor.js.map +1 -1
  18. package/lib/components/po-code-editor/interfaces/po-code-editor-registerable-options.interface.d.ts +22 -22
  19. package/lib/components/po-code-editor/interfaces/po-code-editor-registerable-suggestion.interface.d.ts +37 -37
  20. package/lib/components/po-code-editor/interfaces/po-code-editor-registerable-tokens.interface.d.ts +21 -21
  21. package/lib/components/po-code-editor/interfaces/po-code-editor-registerable.interface.d.ts +17 -17
  22. package/lib/components/po-code-editor/po-code-editor-base.component.d.ts +191 -191
  23. package/lib/components/po-code-editor/po-code-editor-register.service.d.ts +67 -67
  24. package/lib/components/po-code-editor/po-code-editor-suggestion.service.d.ts +7 -7
  25. package/lib/components/po-code-editor/po-code-editor.component.d.ts +58 -58
  26. package/lib/components/po-code-editor/po-code-editor.module.d.ts +10 -10
  27. package/lib/index.d.ts +7 -7
  28. package/package.json +4 -4
  29. package/po-ui-ng-code-editor-5.22.3.tgz +0 -0
  30. package/po-ui-ng-code-editor.d.ts +6 -6
  31. package/po-ui-ng-code-editor.metadata.json +1 -1
  32. package/public-api.d.ts +1 -1
  33. package/schematics/README.md +98 -98
  34. package/schematics/collection.json +10 -10
  35. package/schematics/ng-add/index.d.ts +10 -10
  36. package/schematics/ng-add/index.js +38 -38
  37. package/schematics/ng-add/index.spec.d.ts +1 -1
  38. package/schematics/ng-add/index.spec.js +113 -113
  39. package/schematics/ng-add/schema.json +7 -7
  40. package/po-ui-ng-code-editor-5.22.2.tgz +0 -0
@@ -26,947 +26,947 @@
26
26
 
27
27
  var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
28
 
29
- /*! *****************************************************************************
30
- Copyright (c) Microsoft Corporation.
31
-
32
- Permission to use, copy, modify, and/or distribute this software for any
33
- purpose with or without fee is hereby granted.
34
-
35
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
36
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
37
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
38
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
39
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
40
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
41
- PERFORMANCE OF THIS SOFTWARE.
42
- ***************************************************************************** */
43
- /* global Reflect, Promise */
44
- var extendStatics = function (d, b) {
45
- extendStatics = Object.setPrototypeOf ||
46
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
47
- function (d, b) { for (var p in b)
48
- if (Object.prototype.hasOwnProperty.call(b, p))
49
- d[p] = b[p]; };
50
- return extendStatics(d, b);
51
- };
52
- function __extends(d, b) {
53
- if (typeof b !== "function" && b !== null)
54
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
55
- extendStatics(d, b);
56
- function __() { this.constructor = d; }
57
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
58
- }
59
- var __assign = function () {
60
- __assign = Object.assign || function __assign(t) {
61
- for (var s, i = 1, n = arguments.length; i < n; i++) {
62
- s = arguments[i];
63
- for (var p in s)
64
- if (Object.prototype.hasOwnProperty.call(s, p))
65
- t[p] = s[p];
66
- }
67
- return t;
68
- };
69
- return __assign.apply(this, arguments);
70
- };
71
- function __rest(s, e) {
72
- var t = {};
73
- for (var p in s)
74
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
75
- t[p] = s[p];
76
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
77
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
78
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
79
- t[p[i]] = s[p[i]];
80
- }
81
- return t;
82
- }
83
- function __decorate(decorators, target, key, desc) {
84
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
85
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
86
- r = Reflect.decorate(decorators, target, key, desc);
87
- else
88
- for (var i = decorators.length - 1; i >= 0; i--)
89
- if (d = decorators[i])
90
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
91
- return c > 3 && r && Object.defineProperty(target, key, r), r;
92
- }
93
- function __param(paramIndex, decorator) {
94
- return function (target, key) { decorator(target, key, paramIndex); };
95
- }
96
- function __metadata(metadataKey, metadataValue) {
97
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
98
- return Reflect.metadata(metadataKey, metadataValue);
99
- }
100
- function __awaiter(thisArg, _arguments, P, generator) {
101
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
102
- return new (P || (P = Promise))(function (resolve, reject) {
103
- function fulfilled(value) { try {
104
- step(generator.next(value));
105
- }
106
- catch (e) {
107
- reject(e);
108
- } }
109
- function rejected(value) { try {
110
- step(generator["throw"](value));
111
- }
112
- catch (e) {
113
- reject(e);
114
- } }
115
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
116
- step((generator = generator.apply(thisArg, _arguments || [])).next());
117
- });
118
- }
119
- function __generator(thisArg, body) {
120
- var _ = { label: 0, sent: function () { if (t[0] & 1)
121
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
122
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
123
- function verb(n) { return function (v) { return step([n, v]); }; }
124
- function step(op) {
125
- if (f)
126
- throw new TypeError("Generator is already executing.");
127
- while (_)
128
- try {
129
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
130
- return t;
131
- if (y = 0, t)
132
- op = [op[0] & 2, t.value];
133
- switch (op[0]) {
134
- case 0:
135
- case 1:
136
- t = op;
137
- break;
138
- case 4:
139
- _.label++;
140
- return { value: op[1], done: false };
141
- case 5:
142
- _.label++;
143
- y = op[1];
144
- op = [0];
145
- continue;
146
- case 7:
147
- op = _.ops.pop();
148
- _.trys.pop();
149
- continue;
150
- default:
151
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
152
- _ = 0;
153
- continue;
154
- }
155
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
156
- _.label = op[1];
157
- break;
158
- }
159
- if (op[0] === 6 && _.label < t[1]) {
160
- _.label = t[1];
161
- t = op;
162
- break;
163
- }
164
- if (t && _.label < t[2]) {
165
- _.label = t[2];
166
- _.ops.push(op);
167
- break;
168
- }
169
- if (t[2])
170
- _.ops.pop();
171
- _.trys.pop();
172
- continue;
173
- }
174
- op = body.call(thisArg, _);
175
- }
176
- catch (e) {
177
- op = [6, e];
178
- y = 0;
179
- }
180
- finally {
181
- f = t = 0;
182
- }
183
- if (op[0] & 5)
184
- throw op[1];
185
- return { value: op[0] ? op[1] : void 0, done: true };
186
- }
187
- }
188
- var __createBinding = Object.create ? (function (o, m, k, k2) {
189
- if (k2 === undefined)
190
- k2 = k;
191
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
192
- }) : (function (o, m, k, k2) {
193
- if (k2 === undefined)
194
- k2 = k;
195
- o[k2] = m[k];
196
- });
197
- function __exportStar(m, o) {
198
- for (var p in m)
199
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
200
- __createBinding(o, m, p);
201
- }
202
- function __values(o) {
203
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
204
- if (m)
205
- return m.call(o);
206
- if (o && typeof o.length === "number")
207
- return {
208
- next: function () {
209
- if (o && i >= o.length)
210
- o = void 0;
211
- return { value: o && o[i++], done: !o };
212
- }
213
- };
214
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
215
- }
216
- function __read(o, n) {
217
- var m = typeof Symbol === "function" && o[Symbol.iterator];
218
- if (!m)
219
- return o;
220
- var i = m.call(o), r, ar = [], e;
221
- try {
222
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
223
- ar.push(r.value);
224
- }
225
- catch (error) {
226
- e = { error: error };
227
- }
228
- finally {
229
- try {
230
- if (r && !r.done && (m = i["return"]))
231
- m.call(i);
232
- }
233
- finally {
234
- if (e)
235
- throw e.error;
236
- }
237
- }
238
- return ar;
239
- }
240
- /** @deprecated */
241
- function __spread() {
242
- for (var ar = [], i = 0; i < arguments.length; i++)
243
- ar = ar.concat(__read(arguments[i]));
244
- return ar;
245
- }
246
- /** @deprecated */
247
- function __spreadArrays() {
248
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
249
- s += arguments[i].length;
250
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
251
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
252
- r[k] = a[j];
253
- return r;
254
- }
255
- function __spreadArray(to, from, pack) {
256
- if (pack || arguments.length === 2)
257
- for (var i = 0, l = from.length, ar; i < l; i++) {
258
- if (ar || !(i in from)) {
259
- if (!ar)
260
- ar = Array.prototype.slice.call(from, 0, i);
261
- ar[i] = from[i];
262
- }
263
- }
264
- return to.concat(ar || Array.prototype.slice.call(from));
265
- }
266
- function __await(v) {
267
- return this instanceof __await ? (this.v = v, this) : new __await(v);
268
- }
269
- function __asyncGenerator(thisArg, _arguments, generator) {
270
- if (!Symbol.asyncIterator)
271
- throw new TypeError("Symbol.asyncIterator is not defined.");
272
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
273
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
274
- function verb(n) { if (g[n])
275
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
276
- function resume(n, v) { try {
277
- step(g[n](v));
278
- }
279
- catch (e) {
280
- settle(q[0][3], e);
281
- } }
282
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
283
- function fulfill(value) { resume("next", value); }
284
- function reject(value) { resume("throw", value); }
285
- function settle(f, v) { if (f(v), q.shift(), q.length)
286
- resume(q[0][0], q[0][1]); }
287
- }
288
- function __asyncDelegator(o) {
289
- var i, p;
290
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
291
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
292
- }
293
- function __asyncValues(o) {
294
- if (!Symbol.asyncIterator)
295
- throw new TypeError("Symbol.asyncIterator is not defined.");
296
- var m = o[Symbol.asyncIterator], i;
297
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
298
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
299
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
300
- }
301
- function __makeTemplateObject(cooked, raw) {
302
- if (Object.defineProperty) {
303
- Object.defineProperty(cooked, "raw", { value: raw });
304
- }
305
- else {
306
- cooked.raw = raw;
307
- }
308
- return cooked;
309
- }
310
- ;
311
- var __setModuleDefault = Object.create ? (function (o, v) {
312
- Object.defineProperty(o, "default", { enumerable: true, value: v });
313
- }) : function (o, v) {
314
- o["default"] = v;
315
- };
316
- function __importStar(mod) {
317
- if (mod && mod.__esModule)
318
- return mod;
319
- var result = {};
320
- if (mod != null)
321
- for (var k in mod)
322
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
323
- __createBinding(result, mod, k);
324
- __setModuleDefault(result, mod);
325
- return result;
326
- }
327
- function __importDefault(mod) {
328
- return (mod && mod.__esModule) ? mod : { default: mod };
329
- }
330
- function __classPrivateFieldGet(receiver, state, kind, f) {
331
- if (kind === "a" && !f)
332
- throw new TypeError("Private accessor was defined without a getter");
333
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
334
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
335
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
336
- }
337
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
338
- if (kind === "m")
339
- throw new TypeError("Private method is not writable");
340
- if (kind === "a" && !f)
341
- throw new TypeError("Private accessor was defined without a setter");
342
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
343
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
344
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
29
+ /*! *****************************************************************************
30
+ Copyright (c) Microsoft Corporation.
31
+
32
+ Permission to use, copy, modify, and/or distribute this software for any
33
+ purpose with or without fee is hereby granted.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
36
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
37
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
38
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
39
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
40
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
41
+ PERFORMANCE OF THIS SOFTWARE.
42
+ ***************************************************************************** */
43
+ /* global Reflect, Promise */
44
+ var extendStatics = function (d, b) {
45
+ extendStatics = Object.setPrototypeOf ||
46
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
47
+ function (d, b) { for (var p in b)
48
+ if (Object.prototype.hasOwnProperty.call(b, p))
49
+ d[p] = b[p]; };
50
+ return extendStatics(d, b);
51
+ };
52
+ function __extends(d, b) {
53
+ if (typeof b !== "function" && b !== null)
54
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
55
+ extendStatics(d, b);
56
+ function __() { this.constructor = d; }
57
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
58
+ }
59
+ var __assign = function () {
60
+ __assign = Object.assign || function __assign(t) {
61
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
62
+ s = arguments[i];
63
+ for (var p in s)
64
+ if (Object.prototype.hasOwnProperty.call(s, p))
65
+ t[p] = s[p];
66
+ }
67
+ return t;
68
+ };
69
+ return __assign.apply(this, arguments);
70
+ };
71
+ function __rest(s, e) {
72
+ var t = {};
73
+ for (var p in s)
74
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
75
+ t[p] = s[p];
76
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
77
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
78
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
79
+ t[p[i]] = s[p[i]];
80
+ }
81
+ return t;
82
+ }
83
+ function __decorate(decorators, target, key, desc) {
84
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
85
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
86
+ r = Reflect.decorate(decorators, target, key, desc);
87
+ else
88
+ for (var i = decorators.length - 1; i >= 0; i--)
89
+ if (d = decorators[i])
90
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
91
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
92
+ }
93
+ function __param(paramIndex, decorator) {
94
+ return function (target, key) { decorator(target, key, paramIndex); };
95
+ }
96
+ function __metadata(metadataKey, metadataValue) {
97
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
98
+ return Reflect.metadata(metadataKey, metadataValue);
99
+ }
100
+ function __awaiter(thisArg, _arguments, P, generator) {
101
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
102
+ return new (P || (P = Promise))(function (resolve, reject) {
103
+ function fulfilled(value) { try {
104
+ step(generator.next(value));
105
+ }
106
+ catch (e) {
107
+ reject(e);
108
+ } }
109
+ function rejected(value) { try {
110
+ step(generator["throw"](value));
111
+ }
112
+ catch (e) {
113
+ reject(e);
114
+ } }
115
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
116
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
117
+ });
118
+ }
119
+ function __generator(thisArg, body) {
120
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
121
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
122
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
123
+ function verb(n) { return function (v) { return step([n, v]); }; }
124
+ function step(op) {
125
+ if (f)
126
+ throw new TypeError("Generator is already executing.");
127
+ while (_)
128
+ try {
129
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
130
+ return t;
131
+ if (y = 0, t)
132
+ op = [op[0] & 2, t.value];
133
+ switch (op[0]) {
134
+ case 0:
135
+ case 1:
136
+ t = op;
137
+ break;
138
+ case 4:
139
+ _.label++;
140
+ return { value: op[1], done: false };
141
+ case 5:
142
+ _.label++;
143
+ y = op[1];
144
+ op = [0];
145
+ continue;
146
+ case 7:
147
+ op = _.ops.pop();
148
+ _.trys.pop();
149
+ continue;
150
+ default:
151
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
152
+ _ = 0;
153
+ continue;
154
+ }
155
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
156
+ _.label = op[1];
157
+ break;
158
+ }
159
+ if (op[0] === 6 && _.label < t[1]) {
160
+ _.label = t[1];
161
+ t = op;
162
+ break;
163
+ }
164
+ if (t && _.label < t[2]) {
165
+ _.label = t[2];
166
+ _.ops.push(op);
167
+ break;
168
+ }
169
+ if (t[2])
170
+ _.ops.pop();
171
+ _.trys.pop();
172
+ continue;
173
+ }
174
+ op = body.call(thisArg, _);
175
+ }
176
+ catch (e) {
177
+ op = [6, e];
178
+ y = 0;
179
+ }
180
+ finally {
181
+ f = t = 0;
182
+ }
183
+ if (op[0] & 5)
184
+ throw op[1];
185
+ return { value: op[0] ? op[1] : void 0, done: true };
186
+ }
187
+ }
188
+ var __createBinding = Object.create ? (function (o, m, k, k2) {
189
+ if (k2 === undefined)
190
+ k2 = k;
191
+ Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
192
+ }) : (function (o, m, k, k2) {
193
+ if (k2 === undefined)
194
+ k2 = k;
195
+ o[k2] = m[k];
196
+ });
197
+ function __exportStar(m, o) {
198
+ for (var p in m)
199
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
200
+ __createBinding(o, m, p);
201
+ }
202
+ function __values(o) {
203
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
204
+ if (m)
205
+ return m.call(o);
206
+ if (o && typeof o.length === "number")
207
+ return {
208
+ next: function () {
209
+ if (o && i >= o.length)
210
+ o = void 0;
211
+ return { value: o && o[i++], done: !o };
212
+ }
213
+ };
214
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
215
+ }
216
+ function __read(o, n) {
217
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
218
+ if (!m)
219
+ return o;
220
+ var i = m.call(o), r, ar = [], e;
221
+ try {
222
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
223
+ ar.push(r.value);
224
+ }
225
+ catch (error) {
226
+ e = { error: error };
227
+ }
228
+ finally {
229
+ try {
230
+ if (r && !r.done && (m = i["return"]))
231
+ m.call(i);
232
+ }
233
+ finally {
234
+ if (e)
235
+ throw e.error;
236
+ }
237
+ }
238
+ return ar;
239
+ }
240
+ /** @deprecated */
241
+ function __spread() {
242
+ for (var ar = [], i = 0; i < arguments.length; i++)
243
+ ar = ar.concat(__read(arguments[i]));
244
+ return ar;
245
+ }
246
+ /** @deprecated */
247
+ function __spreadArrays() {
248
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++)
249
+ s += arguments[i].length;
250
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
251
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
252
+ r[k] = a[j];
253
+ return r;
254
+ }
255
+ function __spreadArray(to, from, pack) {
256
+ if (pack || arguments.length === 2)
257
+ for (var i = 0, l = from.length, ar; i < l; i++) {
258
+ if (ar || !(i in from)) {
259
+ if (!ar)
260
+ ar = Array.prototype.slice.call(from, 0, i);
261
+ ar[i] = from[i];
262
+ }
263
+ }
264
+ return to.concat(ar || Array.prototype.slice.call(from));
265
+ }
266
+ function __await(v) {
267
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
268
+ }
269
+ function __asyncGenerator(thisArg, _arguments, generator) {
270
+ if (!Symbol.asyncIterator)
271
+ throw new TypeError("Symbol.asyncIterator is not defined.");
272
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
273
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
274
+ function verb(n) { if (g[n])
275
+ i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
276
+ function resume(n, v) { try {
277
+ step(g[n](v));
278
+ }
279
+ catch (e) {
280
+ settle(q[0][3], e);
281
+ } }
282
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
283
+ function fulfill(value) { resume("next", value); }
284
+ function reject(value) { resume("throw", value); }
285
+ function settle(f, v) { if (f(v), q.shift(), q.length)
286
+ resume(q[0][0], q[0][1]); }
287
+ }
288
+ function __asyncDelegator(o) {
289
+ var i, p;
290
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
291
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
292
+ }
293
+ function __asyncValues(o) {
294
+ if (!Symbol.asyncIterator)
295
+ throw new TypeError("Symbol.asyncIterator is not defined.");
296
+ var m = o[Symbol.asyncIterator], i;
297
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
298
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
299
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
300
+ }
301
+ function __makeTemplateObject(cooked, raw) {
302
+ if (Object.defineProperty) {
303
+ Object.defineProperty(cooked, "raw", { value: raw });
304
+ }
305
+ else {
306
+ cooked.raw = raw;
307
+ }
308
+ return cooked;
309
+ }
310
+ ;
311
+ var __setModuleDefault = Object.create ? (function (o, v) {
312
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
313
+ }) : function (o, v) {
314
+ o["default"] = v;
315
+ };
316
+ function __importStar(mod) {
317
+ if (mod && mod.__esModule)
318
+ return mod;
319
+ var result = {};
320
+ if (mod != null)
321
+ for (var k in mod)
322
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
323
+ __createBinding(result, mod, k);
324
+ __setModuleDefault(result, mod);
325
+ return result;
326
+ }
327
+ function __importDefault(mod) {
328
+ return (mod && mod.__esModule) ? mod : { default: mod };
329
+ }
330
+ function __classPrivateFieldGet(receiver, state, kind, f) {
331
+ if (kind === "a" && !f)
332
+ throw new TypeError("Private accessor was defined without a getter");
333
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
334
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
335
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
336
+ }
337
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
338
+ if (kind === "m")
339
+ throw new TypeError("Private method is not writable");
340
+ if (kind === "a" && !f)
341
+ throw new TypeError("Private accessor was defined without a setter");
342
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
343
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
344
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
345
345
  }
346
346
 
347
- var PO_CODE_EDITOR_THEMES = ['vs-dark', 'vs', 'hc-black'];
348
- var PO_CODE_EDITOR_THEME_DEFAULT = 'vs';
349
- /**
350
- * @description
351
- *
352
- * O `po-code-editor` é um componente para edição de código fonte baseado no Monaco Editor da Microsoft.
353
- *
354
- * Sendo assim, algumas configurações presentes no Monaco podem ser utilizadas aqui, como a escolha da linguagem
355
- * (utilizando o highlight syntax específico), escolha do tema e opção de diff, além de ser muito similar ao Visual
356
- * Studio Code, com autocomplete e fechamento automático de brackets.
357
- *
358
- * Este componente pode ser usado em qualquer situação que necessite de adição de códigos, como por exemplo, criar
359
- * receitas utilizando Terraform para gerenciar topologias.
360
- * É importante ressaltar que este não é um componente para edição de textos comuns.
361
- *
362
- * O [(ngModel)] deve ser usado para manipular o conteúdo do po-code-editor, ou seja, tanto para incluir um conteúdo quanto
363
- * para recuperar o conteúdo do po-code-editor, utiliza-se uma variável passada por [(ngModel)].
364
- *
365
- * #### Adicionando o pacote @po-ui/ng-code-editor
366
- *
367
- * Para instalar o pacote `po-code-editor` em sua aplicação execute:
368
- *
369
- * ```shell
370
- * ng add @po-ui/ng-code-editor
371
- * ```
372
- *
373
- * O comando `ng add` do `Angular CLI`:
374
- * - inclui o `po-code-editor` no seu projeto;
375
- * - adiciona o módulo `PoCodeEditorModule`:;
376
- *
377
- * ```
378
- * // app.module.ts
379
- * ...
380
- * import { PoModule } from '@po-ui/ng-components';
381
- * import { PoCodeEditorModule } from '@po-ui/ng-code-editor';
382
- * ...
383
- * @NgModule({
384
- * imports: [
385
- * ...
386
- * PoModule,
387
- * PoCodeEditorModule
388
- * ],
389
- * ...
390
- * })
391
- * export class AppModule { }
392
- * ```
393
- *
394
- * - adiciona o tema PO UI e também o *asset* do Monaco no arquivo `angular.json`, conforme abaixo:
395
- *
396
- * <pre ngNonBindable>
397
- * ...
398
- * "assets": [
399
- * { "glob": "&#42;&#42;/&#42;", "input": "node_modules/monaco-editor/min", "output": "/assets/monaco/" }
400
- * ],
401
- * "styles": [
402
- * "./node_modules/@po-ui/style/css/po-theme-default.min.css"
403
- * ]
404
- * ...
405
- * </pre>
406
- */
407
- var PoCodeEditorBaseComponent = /** @class */ (function () {
408
- function PoCodeEditorBaseComponent() {
409
- this.modifiedValue = '';
410
- this.value = '';
411
- this._height = 150;
412
- this._language = 'plainText';
413
- this._readonly = false;
414
- this._showDiff = false;
415
- this._theme = PO_CODE_EDITOR_THEME_DEFAULT;
416
- /* istanbul ignore next */
417
- this.onTouched = function (value) { };
418
- /* istanbul ignore next */
419
- this.onChangePropagate = function (value) { };
420
- }
421
- Object.defineProperty(PoCodeEditorBaseComponent.prototype, "language", {
422
- get: function () {
423
- return this._language;
424
- },
425
- /**
426
- * @optional
427
- *
428
- * @description
429
- *
430
- * Linguagem na qual será apresentado o código fonte.
431
- * Para saber quais são as linguagens compatíveis, consulte a documentação oficial do
432
- * [**Monaco Editor**](https://microsoft.github.io/monaco-editor/).
433
- *
434
- * Também é possível adicionar uma nova linguagem personalizada utilizando o serviço:
435
- * [**po-code-editor-register**](https://po-ui.io/documentation/po-code-editor-register?view=doc).
436
- *
437
- * @default `plainText`
438
- */
439
- set: function (language) {
440
- this._language = language && language.length ? language.trim() : 'plainText';
441
- if (this.editor && this._language) {
442
- this.setLanguage(this._language);
443
- }
444
- },
445
- enumerable: false,
446
- configurable: true
447
- });
448
- Object.defineProperty(PoCodeEditorBaseComponent.prototype, "readonly", {
449
- get: function () {
450
- return this._readonly;
451
- },
452
- /**
453
- * @optional
454
- *
455
- * @description
456
- *
457
- * Indica se o editor será aberto em modo de leitura.
458
- *
459
- * Neste caso, não é possível editar o código inserido.
460
- *
461
- * Obs: Esta propriedade não refletirá efeito se alterada após o carregamento do componente.
462
- *
463
- * @default `false`
464
- */
465
- set: function (readonly) {
466
- this._readonly = readonly === '' ? true : this.convertToBoolean(readonly);
467
- if (this.editor) {
468
- this.setReadOnly(readonly);
469
- }
470
- },
471
- enumerable: false,
472
- configurable: true
473
- });
474
- Object.defineProperty(PoCodeEditorBaseComponent.prototype, "showDiff", {
475
- get: function () {
476
- return this._showDiff;
477
- },
478
- /**
479
- * @optional
480
- *
481
- * @description
482
- *
483
- * Indica se o editor será aberto em modo de comparação.
484
- *
485
- * Caso esteja habilitada esta opção, então o [(ngModel)] deverá ser passado como um array, cuja primeira opção deve
486
- * conter uma string com o código original e na segunda posição uma string código modificado para efeito de
487
- * comparação. Neste caso, o usuário conseguirá editar apenas o código modificado e isso refletirá na segunda posição
488
- * do array consequentemente.
489
- *
490
- * Obs: Esta propriedade não refletirá efeito se alterada após o carregamento do componente.
491
- *
492
- * @default `false`
493
- */
494
- set: function (showDiff) {
495
- this._showDiff = showDiff === '' ? true : this.convertToBoolean(showDiff);
496
- },
497
- enumerable: false,
498
- configurable: true
499
- });
500
- Object.defineProperty(PoCodeEditorBaseComponent.prototype, "suggestions", {
501
- get: function () {
502
- return this._suggestions;
503
- },
504
- /**
505
- * @optional
506
- *
507
- * @description
508
- *
509
- * Lista de sugestões usadas pelo autocomplete dentro do editor.
510
- *
511
- * Para visualizar a lista de sugestões use o comando `CTRL + SPACE`.
512
- *
513
- * Caso o editor esteja usando uma linguagem que já tenha uma lista de sugestões predefinida, o valor passado será adicionado
514
- * a lista preexistente, aumentando as opções para o usuário.
515
- *
516
- * Caso tenha mais de um editor da mesma linguagem na aplicação, as sugestões serão adicionadas para que todos os editores da mesma linguagem
517
- * tenham as mesmas sugestões.
518
- *
519
- * ```
520
- * <po-code-editor
521
- * [p-suggestions]="[{ label: 'po', insertText: 'Portinari UI' }, { label: 'ng', insertText: 'Angular' }]">
522
- * </po-code-editor>
523
- * ```
524
- *
525
- * Ao fornecer uma lista de sugestões é possível acelerar a escrita de scripts pelos usuários.
526
- */
527
- set: function (values) {
528
- this._suggestions = values;
529
- if (this.editor && this._suggestions) {
530
- this.setSuggestions(this._suggestions);
531
- }
532
- },
533
- enumerable: false,
534
- configurable: true
535
- });
536
- Object.defineProperty(PoCodeEditorBaseComponent.prototype, "theme", {
537
- get: function () {
538
- return this._theme;
539
- },
540
- /**
541
- * @optional
542
- *
543
- * @description
544
- *
545
- * Define um tema para o editor.
546
- *
547
- * Temas válidos:
548
- * - `vs-dark`
549
- * - `vs`
550
- * - `hc-black`
551
- *
552
- * É importante salientar que o tema será aplicados a todos os componentes po-code-editor existentes na tela,
553
- * ou seja, todas as instâncias do componente receberão o último tema atribuído ou o tema da última instância
554
- * criada.
555
- *
556
- * @default `vs`
557
- */
558
- set: function (theme) {
559
- this._theme = PO_CODE_EDITOR_THEMES.includes(theme) ? theme : PO_CODE_EDITOR_THEME_DEFAULT;
560
- if (this.editor) {
561
- this.setTheme(theme);
562
- }
563
- },
564
- enumerable: false,
565
- configurable: true
566
- });
567
- Object.defineProperty(PoCodeEditorBaseComponent.prototype, "height", {
568
- get: function () {
569
- return this._height + "px";
570
- },
571
- /**
572
- * @optional
573
- *
574
- * @description
575
- *
576
- * Define a altura do componente em pixels do po-code-editor.
577
- * Esta propriedade não poderá ser alterada após o componente ter sido iniciado.
578
- * A altura mínima é 150 pixels.
579
- */
580
- set: function (height) {
581
- this._height = parseFloat(height) >= 150 ? parseFloat(height) : 150;
582
- },
583
- enumerable: false,
584
- configurable: true
585
- });
586
- PoCodeEditorBaseComponent.prototype.getOptions = function () {
587
- return { language: this.language, theme: this.theme, readOnly: this.readonly };
588
- };
589
- PoCodeEditorBaseComponent.prototype.registerOnChange = function (fn) {
590
- this.onChangePropagate = fn;
591
- };
592
- PoCodeEditorBaseComponent.prototype.registerOnTouched = function (fn) {
593
- this.onTouched = fn;
594
- };
595
- PoCodeEditorBaseComponent.prototype.convertToBoolean = function (val) {
596
- if (typeof val === 'string') {
597
- val = val.toLowerCase().trim();
598
- return val === 'true' || val === 'on' || val === '';
599
- }
600
- if (typeof val === 'number') {
601
- return val === 1;
602
- }
603
- return !!val;
604
- };
605
- return PoCodeEditorBaseComponent;
606
- }());
607
- PoCodeEditorBaseComponent.decorators = [
608
- { type: i0.Directive }
609
- ];
610
- PoCodeEditorBaseComponent.propDecorators = {
611
- language: [{ type: i0.Input, args: ['p-language',] }],
612
- readonly: [{ type: i0.Input, args: ['p-readonly',] }],
613
- showDiff: [{ type: i0.Input, args: ['p-show-diff',] }],
614
- suggestions: [{ type: i0.Input, args: ['p-suggestions',] }],
615
- theme: [{ type: i0.Input, args: ['p-theme',] }],
616
- height: [{ type: i0.Input, args: ['p-height',] }]
347
+ var PO_CODE_EDITOR_THEMES = ['vs-dark', 'vs', 'hc-black'];
348
+ var PO_CODE_EDITOR_THEME_DEFAULT = 'vs';
349
+ /**
350
+ * @description
351
+ *
352
+ * O `po-code-editor` é um componente para edição de código fonte baseado no Monaco Editor da Microsoft.
353
+ *
354
+ * Sendo assim, algumas configurações presentes no Monaco podem ser utilizadas aqui, como a escolha da linguagem
355
+ * (utilizando o highlight syntax específico), escolha do tema e opção de diff, além de ser muito similar ao Visual
356
+ * Studio Code, com autocomplete e fechamento automático de brackets.
357
+ *
358
+ * Este componente pode ser usado em qualquer situação que necessite de adição de códigos, como por exemplo, criar
359
+ * receitas utilizando Terraform para gerenciar topologias.
360
+ * É importante ressaltar que este não é um componente para edição de textos comuns.
361
+ *
362
+ * O [(ngModel)] deve ser usado para manipular o conteúdo do po-code-editor, ou seja, tanto para incluir um conteúdo quanto
363
+ * para recuperar o conteúdo do po-code-editor, utiliza-se uma variável passada por [(ngModel)].
364
+ *
365
+ * #### Adicionando o pacote @po-ui/ng-code-editor
366
+ *
367
+ * Para instalar o pacote `po-code-editor` em sua aplicação execute:
368
+ *
369
+ * ```shell
370
+ * ng add @po-ui/ng-code-editor
371
+ * ```
372
+ *
373
+ * O comando `ng add` do `Angular CLI`:
374
+ * - inclui o `po-code-editor` no seu projeto;
375
+ * - adiciona o módulo `PoCodeEditorModule`:;
376
+ *
377
+ * ```
378
+ * // app.module.ts
379
+ * ...
380
+ * import { PoModule } from '@po-ui/ng-components';
381
+ * import { PoCodeEditorModule } from '@po-ui/ng-code-editor';
382
+ * ...
383
+ * @NgModule({
384
+ * imports: [
385
+ * ...
386
+ * PoModule,
387
+ * PoCodeEditorModule
388
+ * ],
389
+ * ...
390
+ * })
391
+ * export class AppModule { }
392
+ * ```
393
+ *
394
+ * - adiciona o tema PO UI e também o *asset* do Monaco no arquivo `angular.json`, conforme abaixo:
395
+ *
396
+ * <pre ngNonBindable>
397
+ * ...
398
+ * "assets": [
399
+ * { "glob": "&#42;&#42;/&#42;", "input": "node_modules/monaco-editor/min", "output": "/assets/monaco/" }
400
+ * ],
401
+ * "styles": [
402
+ * "./node_modules/@po-ui/style/css/po-theme-default.min.css"
403
+ * ]
404
+ * ...
405
+ * </pre>
406
+ */
407
+ var PoCodeEditorBaseComponent = /** @class */ (function () {
408
+ function PoCodeEditorBaseComponent() {
409
+ this.modifiedValue = '';
410
+ this.value = '';
411
+ this._height = 150;
412
+ this._language = 'plainText';
413
+ this._readonly = false;
414
+ this._showDiff = false;
415
+ this._theme = PO_CODE_EDITOR_THEME_DEFAULT;
416
+ /* istanbul ignore next */
417
+ this.onTouched = function (value) { };
418
+ /* istanbul ignore next */
419
+ this.onChangePropagate = function (value) { };
420
+ }
421
+ Object.defineProperty(PoCodeEditorBaseComponent.prototype, "language", {
422
+ get: function () {
423
+ return this._language;
424
+ },
425
+ /**
426
+ * @optional
427
+ *
428
+ * @description
429
+ *
430
+ * Linguagem na qual será apresentado o código fonte.
431
+ * Para saber quais são as linguagens compatíveis, consulte a documentação oficial do
432
+ * [**Monaco Editor**](https://microsoft.github.io/monaco-editor/).
433
+ *
434
+ * Também é possível adicionar uma nova linguagem personalizada utilizando o serviço:
435
+ * [**po-code-editor-register**](https://po-ui.io/documentation/po-code-editor-register?view=doc).
436
+ *
437
+ * @default `plainText`
438
+ */
439
+ set: function (language) {
440
+ this._language = language && language.length ? language.trim() : 'plainText';
441
+ if (this.editor && this._language) {
442
+ this.setLanguage(this._language);
443
+ }
444
+ },
445
+ enumerable: false,
446
+ configurable: true
447
+ });
448
+ Object.defineProperty(PoCodeEditorBaseComponent.prototype, "readonly", {
449
+ get: function () {
450
+ return this._readonly;
451
+ },
452
+ /**
453
+ * @optional
454
+ *
455
+ * @description
456
+ *
457
+ * Indica se o editor será aberto em modo de leitura.
458
+ *
459
+ * Neste caso, não é possível editar o código inserido.
460
+ *
461
+ * Obs: Esta propriedade não refletirá efeito se alterada após o carregamento do componente.
462
+ *
463
+ * @default `false`
464
+ */
465
+ set: function (readonly) {
466
+ this._readonly = readonly === '' ? true : this.convertToBoolean(readonly);
467
+ if (this.editor) {
468
+ this.setReadOnly(readonly);
469
+ }
470
+ },
471
+ enumerable: false,
472
+ configurable: true
473
+ });
474
+ Object.defineProperty(PoCodeEditorBaseComponent.prototype, "showDiff", {
475
+ get: function () {
476
+ return this._showDiff;
477
+ },
478
+ /**
479
+ * @optional
480
+ *
481
+ * @description
482
+ *
483
+ * Indica se o editor será aberto em modo de comparação.
484
+ *
485
+ * Caso esteja habilitada esta opção, então o [(ngModel)] deverá ser passado como um array, cuja primeira opção deve
486
+ * conter uma string com o código original e na segunda posição uma string código modificado para efeito de
487
+ * comparação. Neste caso, o usuário conseguirá editar apenas o código modificado e isso refletirá na segunda posição
488
+ * do array consequentemente.
489
+ *
490
+ * Obs: Esta propriedade não refletirá efeito se alterada após o carregamento do componente.
491
+ *
492
+ * @default `false`
493
+ */
494
+ set: function (showDiff) {
495
+ this._showDiff = showDiff === '' ? true : this.convertToBoolean(showDiff);
496
+ },
497
+ enumerable: false,
498
+ configurable: true
499
+ });
500
+ Object.defineProperty(PoCodeEditorBaseComponent.prototype, "suggestions", {
501
+ get: function () {
502
+ return this._suggestions;
503
+ },
504
+ /**
505
+ * @optional
506
+ *
507
+ * @description
508
+ *
509
+ * Lista de sugestões usadas pelo autocomplete dentro do editor.
510
+ *
511
+ * Para visualizar a lista de sugestões use o comando `CTRL + SPACE`.
512
+ *
513
+ * Caso o editor esteja usando uma linguagem que já tenha uma lista de sugestões predefinida, o valor passado será adicionado
514
+ * a lista preexistente, aumentando as opções para o usuário.
515
+ *
516
+ * Caso tenha mais de um editor da mesma linguagem na aplicação, as sugestões serão adicionadas para que todos os editores da mesma linguagem
517
+ * tenham as mesmas sugestões.
518
+ *
519
+ * ```
520
+ * <po-code-editor
521
+ * [p-suggestions]="[{ label: 'po', insertText: 'Portinari UI' }, { label: 'ng', insertText: 'Angular' }]">
522
+ * </po-code-editor>
523
+ * ```
524
+ *
525
+ * Ao fornecer uma lista de sugestões é possível acelerar a escrita de scripts pelos usuários.
526
+ */
527
+ set: function (values) {
528
+ this._suggestions = values;
529
+ if (this.editor && this._suggestions) {
530
+ this.setSuggestions(this._suggestions);
531
+ }
532
+ },
533
+ enumerable: false,
534
+ configurable: true
535
+ });
536
+ Object.defineProperty(PoCodeEditorBaseComponent.prototype, "theme", {
537
+ get: function () {
538
+ return this._theme;
539
+ },
540
+ /**
541
+ * @optional
542
+ *
543
+ * @description
544
+ *
545
+ * Define um tema para o editor.
546
+ *
547
+ * Temas válidos:
548
+ * - `vs-dark`
549
+ * - `vs`
550
+ * - `hc-black`
551
+ *
552
+ * É importante salientar que o tema será aplicados a todos os componentes po-code-editor existentes na tela,
553
+ * ou seja, todas as instâncias do componente receberão o último tema atribuído ou o tema da última instância
554
+ * criada.
555
+ *
556
+ * @default `vs`
557
+ */
558
+ set: function (theme) {
559
+ this._theme = PO_CODE_EDITOR_THEMES.includes(theme) ? theme : PO_CODE_EDITOR_THEME_DEFAULT;
560
+ if (this.editor) {
561
+ this.setTheme(theme);
562
+ }
563
+ },
564
+ enumerable: false,
565
+ configurable: true
566
+ });
567
+ Object.defineProperty(PoCodeEditorBaseComponent.prototype, "height", {
568
+ get: function () {
569
+ return this._height + "px";
570
+ },
571
+ /**
572
+ * @optional
573
+ *
574
+ * @description
575
+ *
576
+ * Define a altura do componente em pixels do po-code-editor.
577
+ * Esta propriedade não poderá ser alterada após o componente ter sido iniciado.
578
+ * A altura mínima é 150 pixels.
579
+ */
580
+ set: function (height) {
581
+ this._height = parseFloat(height) >= 150 ? parseFloat(height) : 150;
582
+ },
583
+ enumerable: false,
584
+ configurable: true
585
+ });
586
+ PoCodeEditorBaseComponent.prototype.getOptions = function () {
587
+ return { language: this.language, theme: this.theme, readOnly: this.readonly };
588
+ };
589
+ PoCodeEditorBaseComponent.prototype.registerOnChange = function (fn) {
590
+ this.onChangePropagate = fn;
591
+ };
592
+ PoCodeEditorBaseComponent.prototype.registerOnTouched = function (fn) {
593
+ this.onTouched = fn;
594
+ };
595
+ PoCodeEditorBaseComponent.prototype.convertToBoolean = function (val) {
596
+ if (typeof val === 'string') {
597
+ val = val.toLowerCase().trim();
598
+ return val === 'true' || val === 'on' || val === '';
599
+ }
600
+ if (typeof val === 'number') {
601
+ return val === 1;
602
+ }
603
+ return !!val;
604
+ };
605
+ return PoCodeEditorBaseComponent;
606
+ }());
607
+ PoCodeEditorBaseComponent.decorators = [
608
+ { type: i0.Directive }
609
+ ];
610
+ PoCodeEditorBaseComponent.propDecorators = {
611
+ language: [{ type: i0.Input, args: ['p-language',] }],
612
+ readonly: [{ type: i0.Input, args: ['p-readonly',] }],
613
+ showDiff: [{ type: i0.Input, args: ['p-show-diff',] }],
614
+ suggestions: [{ type: i0.Input, args: ['p-suggestions',] }],
615
+ theme: [{ type: i0.Input, args: ['p-theme',] }],
616
+ height: [{ type: i0.Input, args: ['p-height',] }]
617
617
  };
618
618
 
619
- /**
620
- * @description
621
- *
622
- * Wrapper para registro de sintaxes customizadas para o po-code-editor.
623
- *
624
- * Para utilização do serviço de idiomas **PoCodeEditorRegister**,
625
- * deve-se importar o módulo PoCodeEditorModule mesmo já tendo importado
626
- * o módulo PoModule.
627
- * Na importação opcionalmente pode ser invocado o método **forRegister** informando um objeto para configuração.
628
- *
629
- * Exemplo de configuração:
630
- * ```
631
- * import { PoCodeEditorModule, PoCodeEditorRegisterable } from '@po-ui/ng-code-editor';
632
- *
633
- * declare const monaco: any; // Importante para usar configurações com tipos definidos pelo Monaco
634
- *
635
- * // A função `provideCompletionItems` precisa ser exportada para ser compatível com AOT.
636
- * export function provideCompletionItems() {
637
- * const suggestions = [{
638
- * label: 'terraform',
639
- * insertText: '#terraform language'
640
- * }, {
641
- * label: 'server',
642
- * insertText: 'server ${1:ip}'
643
- * }];
644
- *
645
- * return { suggestions: suggestions };
646
- * }
647
- *
648
- * const customEditor: PoCodeEditorRegisterable = {
649
- * language: 'terraform',
650
- * options: {
651
- * keywords: ['resource', 'provider', 'variable', 'output', 'module', 'true', 'false'],
652
- * operators: ['{', '}', '(', ')', '[', ']', '?', ':'],
653
- * symbols: /[=><!~?:&|+\-*\/\^%]+/,
654
- * escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
655
- * tokenizer: {
656
- * ...
657
- * }
658
- * },
659
- * suggestions: { provideCompletionItems: provideCompletionItems }
660
- * };
661
- *
662
- * @NgModule({
663
- * declarations: [],
664
- * imports: [
665
- * PoModule,
666
- * PoCodeEditorModule.forRegister(customEditor)
667
- * ],
668
- * bootstrap: [AppComponent]
669
- * })
670
- * ```
671
- *
672
- * > As configurações para o registro de uma nova sintaxe no Monaco code editor podem ser encontradas em
673
- * > [**Monaco Editor**](https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-custom-languages).
674
- */
675
- var PoCodeEditorRegister = /** @class */ (function () {
676
- function PoCodeEditorRegister() {
677
- }
678
- return PoCodeEditorRegister;
679
- }());
680
- PoCodeEditorRegister.decorators = [
681
- { type: i0.Injectable }
619
+ /**
620
+ * @description
621
+ *
622
+ * Wrapper para registro de sintaxes customizadas para o po-code-editor.
623
+ *
624
+ * Para utilização do serviço de idiomas **PoCodeEditorRegister**,
625
+ * deve-se importar o módulo PoCodeEditorModule mesmo já tendo importado
626
+ * o módulo PoModule.
627
+ * Na importação opcionalmente pode ser invocado o método **forRegister** informando um objeto para configuração.
628
+ *
629
+ * Exemplo de configuração:
630
+ * ```
631
+ * import { PoCodeEditorModule, PoCodeEditorRegisterable } from '@po-ui/ng-code-editor';
632
+ *
633
+ * declare const monaco: any; // Importante para usar configurações com tipos definidos pelo Monaco
634
+ *
635
+ * // A função `provideCompletionItems` precisa ser exportada para ser compatível com AOT.
636
+ * export function provideCompletionItems() {
637
+ * const suggestions = [{
638
+ * label: 'terraform',
639
+ * insertText: '#terraform language'
640
+ * }, {
641
+ * label: 'server',
642
+ * insertText: 'server ${1:ip}'
643
+ * }];
644
+ *
645
+ * return { suggestions: suggestions };
646
+ * }
647
+ *
648
+ * const customEditor: PoCodeEditorRegisterable = {
649
+ * language: 'terraform',
650
+ * options: {
651
+ * keywords: ['resource', 'provider', 'variable', 'output', 'module', 'true', 'false'],
652
+ * operators: ['{', '}', '(', ')', '[', ']', '?', ':'],
653
+ * symbols: /[=><!~?:&|+\-*\/\^%]+/,
654
+ * escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
655
+ * tokenizer: {
656
+ * ...
657
+ * }
658
+ * },
659
+ * suggestions: { provideCompletionItems: provideCompletionItems }
660
+ * };
661
+ *
662
+ * @NgModule({
663
+ * declarations: [],
664
+ * imports: [
665
+ * PoModule,
666
+ * PoCodeEditorModule.forRegister(customEditor)
667
+ * ],
668
+ * bootstrap: [AppComponent]
669
+ * })
670
+ * ```
671
+ *
672
+ * > As configurações para o registro de uma nova sintaxe no Monaco code editor podem ser encontradas em
673
+ * > [**Monaco Editor**](https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-custom-languages).
674
+ */
675
+ var PoCodeEditorRegister = /** @class */ (function () {
676
+ function PoCodeEditorRegister() {
677
+ }
678
+ return PoCodeEditorRegister;
679
+ }());
680
+ PoCodeEditorRegister.decorators = [
681
+ { type: i0.Injectable }
682
682
  ];
683
683
 
684
- var PoCodeEditorSuggestionService = /** @class */ (function () {
685
- function PoCodeEditorSuggestionService() {
686
- this.suggestions = {};
687
- }
688
- PoCodeEditorSuggestionService.prototype.getSuggestion = function (language, newSuggestion) {
689
- if (this.suggestions[language]) {
690
- var deduplicateSuggestions = this.deduplicateSuggestions(this.suggestions[language], newSuggestion);
691
- this.suggestions[language] = __spreadArray(__spreadArray([], __read(this.suggestions[language])), __read(deduplicateSuggestions));
692
- return deduplicateSuggestions;
693
- }
694
- else {
695
- return (this.suggestions[language] = __spreadArray([], __read(newSuggestion)));
696
- }
697
- };
698
- PoCodeEditorSuggestionService.prototype.deduplicateSuggestions = function (originalSuggestions, newSuggestions) {
699
- return newSuggestions.filter(function (newItem) { return !originalSuggestions.find(function (originalItem) { return originalItem['label'] === newItem['label']; }); });
700
- };
701
- return PoCodeEditorSuggestionService;
702
- }());
703
- PoCodeEditorSuggestionService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PoCodeEditorSuggestionService_Factory() { return new PoCodeEditorSuggestionService(); }, token: PoCodeEditorSuggestionService, providedIn: "root" });
704
- PoCodeEditorSuggestionService.decorators = [
705
- { type: i0.Injectable, args: [{
706
- providedIn: 'root'
707
- },] }
708
- ];
684
+ var PoCodeEditorSuggestionService = /** @class */ (function () {
685
+ function PoCodeEditorSuggestionService() {
686
+ this.suggestions = {};
687
+ }
688
+ PoCodeEditorSuggestionService.prototype.getSuggestion = function (language, newSuggestion) {
689
+ if (this.suggestions[language]) {
690
+ var deduplicateSuggestions = this.deduplicateSuggestions(this.suggestions[language], newSuggestion);
691
+ this.suggestions[language] = __spreadArray(__spreadArray([], __read(this.suggestions[language])), __read(deduplicateSuggestions));
692
+ return deduplicateSuggestions;
693
+ }
694
+ else {
695
+ return (this.suggestions[language] = __spreadArray([], __read(newSuggestion)));
696
+ }
697
+ };
698
+ PoCodeEditorSuggestionService.prototype.deduplicateSuggestions = function (originalSuggestions, newSuggestions) {
699
+ return newSuggestions.filter(function (newItem) { return !originalSuggestions.find(function (originalItem) { return originalItem['label'] === newItem['label']; }); });
700
+ };
701
+ return PoCodeEditorSuggestionService;
702
+ }());
703
+ PoCodeEditorSuggestionService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PoCodeEditorSuggestionService_Factory() { return new PoCodeEditorSuggestionService(); }, token: PoCodeEditorSuggestionService, providedIn: "root" });
704
+ PoCodeEditorSuggestionService.decorators = [
705
+ { type: i0.Injectable, args: [{
706
+ providedIn: 'root'
707
+ },] }
708
+ ];
709
709
  PoCodeEditorSuggestionService.ctorParameters = function () { return []; };
710
710
 
711
- // variáveis relacionadas ao Monaco
712
- var loadedMonaco = false;
713
- var loadPromise;
714
- /* istanbul ignore next */
715
- var providers = [
716
- {
717
- provide: forms.NG_VALUE_ACCESSOR,
718
- // eslint-disable-next-line
719
- useExisting: i0.forwardRef(function () { return PoCodeEditorComponent; }),
720
- multi: true
721
- }
722
- ];
723
- /**
724
- * @docsExtends PoCodeEditorBaseComponent
725
- *
726
- * @example
727
- *
728
- * <example name="po-code-editor-basic" title="PO Code Editor Basic">
729
- * <file name="sample-po-code-editor-basic/sample-po-code-editor-basic.component.html"> </file>
730
- * <file name="sample-po-code-editor-basic/sample-po-code-editor-basic.component.ts"> </file>
731
- * </example>
732
- *
733
- * <example name="po-code-editor-labs" title="PO Code Editor Labs">
734
- * <file name="sample-po-code-editor-labs/sample-po-code-editor-labs.component.html"> </file>
735
- * <file name="sample-po-code-editor-labs/sample-po-code-editor-labs.component.ts"> </file>
736
- * </example>
737
- *
738
- * <example name="po-code-editor-diff" title="PO Code Editor - Diff">
739
- * <file name="sample-po-code-editor-diff/sample-po-code-editor-diff.component.html"> </file>
740
- * <file name="sample-po-code-editor-diff/sample-po-code-editor-diff.component.ts"> </file>
741
- * </example>
742
- *
743
- * <example name="po-code-editor-terraform" title="PO Code Editor - Terraform">
744
- * <file name="sample-po-code-editor-terraform/sample-po-code-editor-terraform.component.html"> </file>
745
- * <file name="sample-po-code-editor-terraform/sample-po-code-editor-terraform.component.ts"> </file>
746
- * <file name="sample-po-code-editor-terraform/sample-po-code-editor-terraform.constant.ts"> </file>
747
- * <file name="sample-po-code-editor-terraform/sample-po-code-editor-terraform.module.ts"> </file>
748
- * </example>
749
- *
750
- * <example name="po-code-editor-suggestion" title="PO Code Editor Suggestion">
751
- * <file name="sample-po-code-editor-suggestion/sample-po-code-editor-suggestion.component.html"> </file>
752
- * <file name="sample-po-code-editor-suggestion/sample-po-code-editor-suggestion.component.ts"> </file>
753
- * </example>
754
- */
755
- var PoCodeEditorComponent = /** @class */ (function (_super) {
756
- __extends(PoCodeEditorComponent, _super);
757
- function PoCodeEditorComponent(zone, el, poCodeEditorSuggestionService, codeEditorRegister) {
758
- var _this = _super.call(this) || this;
759
- _this.zone = zone;
760
- _this.el = el;
761
- _this.poCodeEditorSuggestionService = poCodeEditorSuggestionService;
762
- _this.codeEditorRegister = codeEditorRegister;
763
- _this.canLoad = false;
764
- return _this;
765
- }
766
- /* istanbul ignore next */
767
- PoCodeEditorComponent.prototype.ngAfterViewInit = function () {
768
- var _this = this;
769
- if (loadedMonaco) {
770
- /* istanbul ignore next */
771
- loadPromise.then(function () {
772
- setTimeout(function () {
773
- if (_this.el.nativeElement.offsetWidth) {
774
- _this.registerCustomLanguage();
775
- _this.initMonaco(_this.getOptions());
776
- }
777
- else {
778
- _this.canLoad = true;
779
- }
780
- });
781
- });
782
- }
783
- else {
784
- loadedMonaco = true;
785
- loadPromise = new Promise(function (resolve) {
786
- /* istanbul ignore next */
787
- var onGotAmdLoader = function () {
788
- window.require.config({ paths: { 'vs': './assets/monaco/vs' } });
789
- window.require(['vs/editor/editor.main'], function () {
790
- setTimeout(function () {
791
- if (_this.el.nativeElement.offsetWidth) {
792
- _this.registerCustomLanguage();
793
- _this.initMonaco(_this.getOptions());
794
- }
795
- else {
796
- _this.canLoad = true;
797
- }
798
- resolve();
799
- });
800
- });
801
- };
802
- if (!window.require) {
803
- var loaderScript = document.createElement('script');
804
- loaderScript.type = 'text/javascript';
805
- loaderScript.src = './assets/monaco/vs/loader.js';
806
- loaderScript.addEventListener('load', onGotAmdLoader);
807
- document.body.appendChild(loaderScript);
808
- }
809
- });
810
- }
811
- };
812
- PoCodeEditorComponent.prototype.ngDoCheck = function () {
813
- if (this.canLoad && this.el.nativeElement.offsetWidth) {
814
- this.registerCustomLanguage();
815
- this.initMonaco(this.getOptions());
816
- this.canLoad = false;
817
- }
818
- };
819
- /* istanbul ignore next */
820
- PoCodeEditorComponent.prototype.monacoCreateModel = function (value) {
821
- return monaco.editor.createModel(value);
822
- };
823
- PoCodeEditorComponent.prototype.setValueInEditor = function () {
824
- var _this = this;
825
- if (this.showDiff) {
826
- setTimeout(function () {
827
- if (_this.editor) {
828
- _this.editor.setModel({
829
- original: _this.monacoCreateModel(_this.value),
830
- modified: _this.monacoCreateModel(_this.modifiedValue)
831
- });
832
- }
833
- });
834
- }
835
- else {
836
- setTimeout(function () {
837
- if (_this.editor) {
838
- _this.editor.setValue(_this.value);
839
- }
840
- });
841
- }
842
- };
843
- PoCodeEditorComponent.prototype.setLanguage = function (language) {
844
- if (this.showDiff) {
845
- this.setMonacoLanguage(this.editor.getModel().original, language);
846
- this.setMonacoLanguage(this.editor.getModel().modified, language);
847
- }
848
- else {
849
- this.setMonacoLanguage(this.editor.getModel(), language);
850
- }
851
- };
852
- /* istanbul ignore next */
853
- PoCodeEditorComponent.prototype.setTheme = function (theme) {
854
- monaco.editor.setTheme(theme);
855
- };
856
- PoCodeEditorComponent.prototype.setReadOnly = function (readOnly) {
857
- this.editor.updateOptions({ readOnly: readOnly });
858
- };
859
- /* istanbul ignore next */
860
- PoCodeEditorComponent.prototype.setSuggestions = function (newSuggestions, language) {
861
- if (language === void 0) { language = this.language; }
862
- if (!newSuggestions) {
863
- return;
864
- }
865
- var suggestions = this.poCodeEditorSuggestionService.getSuggestion(language, newSuggestions);
866
- monaco.languages.registerCompletionItemProvider(language, {
867
- provideCompletionItems: function () { return ({ suggestions: suggestions }); }
868
- });
869
- };
870
- PoCodeEditorComponent.prototype.writeValue = function (value) {
871
- this.value = value && value instanceof Array ? value[0] : value;
872
- this.modifiedValue = value && value instanceof Array && value.length > 0 ? value[1] : '';
873
- this.setValueInEditor();
874
- };
875
- /* istanbul ignore next */
876
- PoCodeEditorComponent.prototype.initMonaco = function (options) {
877
- var _this = this;
878
- if (this.showDiff) {
879
- this.editor = monaco.editor.createDiffEditor(this.editorContainer.nativeElement, options);
880
- this.editor.setModel({
881
- original: monaco.editor.createModel(this.value),
882
- modified: monaco.editor.createModel(this.modifiedValue)
883
- });
884
- this.editor.onDidUpdateDiff(function (e) {
885
- var original = _this.editor.getModel().original.getValue();
886
- var modified = _this.editor.getModel().modified.getValue();
887
- _this.onChangePropagate([original, modified]);
888
- });
889
- }
890
- else {
891
- this.editor = monaco.editor.create(this.editorContainer.nativeElement, options);
892
- this.editor.setValue(this.value);
893
- this.editor.onDidChangeModelContent(function (e) {
894
- var value = _this.editor.getValue();
895
- _this.onChangePropagate(value);
896
- _this.zone.run(function () { return (_this.value = value); });
897
- });
898
- }
899
- setTimeout(function () {
900
- _this.setLanguage(_this.language);
901
- _this.setSuggestions(_this.suggestions);
902
- }, 500);
903
- };
904
- /* istanbul ignore next */
905
- PoCodeEditorComponent.prototype.setMonacoLanguage = function (model, language) {
906
- monaco.editor.setModelLanguage(model, language);
907
- };
908
- PoCodeEditorComponent.prototype.registerCustomLanguage = function () {
909
- if (this.codeEditorRegister.language) {
910
- monaco.languages.register({ id: this.codeEditorRegister.language });
911
- if (this.codeEditorRegister.options) {
912
- monaco.languages.setMonarchTokensProvider(this.codeEditorRegister.language, this.codeEditorRegister.options);
913
- }
914
- if (this.codeEditorRegister.suggestions) {
915
- this.setSuggestions(this.codeEditorRegister.suggestions.provideCompletionItems().suggestions, this.codeEditorRegister.language);
916
- }
917
- }
918
- };
919
- return PoCodeEditorComponent;
920
- }(PoCodeEditorBaseComponent));
921
- PoCodeEditorComponent.decorators = [
922
- { type: i0.Component, args: [{
923
- selector: 'po-code-editor',
924
- template: "<div #editorContainer [style.height]=\"height\"></div>\n",
925
- providers: providers
926
- },] }
927
- ];
928
- PoCodeEditorComponent.ctorParameters = function () { return [
929
- { type: i0.NgZone },
930
- { type: i0.ElementRef },
931
- { type: PoCodeEditorSuggestionService },
932
- { type: PoCodeEditorRegister }
933
- ]; };
934
- PoCodeEditorComponent.propDecorators = {
935
- editorContainer: [{ type: i0.ViewChild, args: ['editorContainer', { static: true },] }]
711
+ // variáveis relacionadas ao Monaco
712
+ var loadedMonaco = false;
713
+ var loadPromise;
714
+ /* istanbul ignore next */
715
+ var providers = [
716
+ {
717
+ provide: forms.NG_VALUE_ACCESSOR,
718
+ // eslint-disable-next-line
719
+ useExisting: i0.forwardRef(function () { return PoCodeEditorComponent; }),
720
+ multi: true
721
+ }
722
+ ];
723
+ /**
724
+ * @docsExtends PoCodeEditorBaseComponent
725
+ *
726
+ * @example
727
+ *
728
+ * <example name="po-code-editor-basic" title="PO Code Editor Basic">
729
+ * <file name="sample-po-code-editor-basic/sample-po-code-editor-basic.component.html"> </file>
730
+ * <file name="sample-po-code-editor-basic/sample-po-code-editor-basic.component.ts"> </file>
731
+ * </example>
732
+ *
733
+ * <example name="po-code-editor-labs" title="PO Code Editor Labs">
734
+ * <file name="sample-po-code-editor-labs/sample-po-code-editor-labs.component.html"> </file>
735
+ * <file name="sample-po-code-editor-labs/sample-po-code-editor-labs.component.ts"> </file>
736
+ * </example>
737
+ *
738
+ * <example name="po-code-editor-diff" title="PO Code Editor - Diff">
739
+ * <file name="sample-po-code-editor-diff/sample-po-code-editor-diff.component.html"> </file>
740
+ * <file name="sample-po-code-editor-diff/sample-po-code-editor-diff.component.ts"> </file>
741
+ * </example>
742
+ *
743
+ * <example name="po-code-editor-terraform" title="PO Code Editor - Terraform">
744
+ * <file name="sample-po-code-editor-terraform/sample-po-code-editor-terraform.component.html"> </file>
745
+ * <file name="sample-po-code-editor-terraform/sample-po-code-editor-terraform.component.ts"> </file>
746
+ * <file name="sample-po-code-editor-terraform/sample-po-code-editor-terraform.constant.ts"> </file>
747
+ * <file name="sample-po-code-editor-terraform/sample-po-code-editor-terraform.module.ts"> </file>
748
+ * </example>
749
+ *
750
+ * <example name="po-code-editor-suggestion" title="PO Code Editor Suggestion">
751
+ * <file name="sample-po-code-editor-suggestion/sample-po-code-editor-suggestion.component.html"> </file>
752
+ * <file name="sample-po-code-editor-suggestion/sample-po-code-editor-suggestion.component.ts"> </file>
753
+ * </example>
754
+ */
755
+ var PoCodeEditorComponent = /** @class */ (function (_super) {
756
+ __extends(PoCodeEditorComponent, _super);
757
+ function PoCodeEditorComponent(zone, el, poCodeEditorSuggestionService, codeEditorRegister) {
758
+ var _this = _super.call(this) || this;
759
+ _this.zone = zone;
760
+ _this.el = el;
761
+ _this.poCodeEditorSuggestionService = poCodeEditorSuggestionService;
762
+ _this.codeEditorRegister = codeEditorRegister;
763
+ _this.canLoad = false;
764
+ return _this;
765
+ }
766
+ /* istanbul ignore next */
767
+ PoCodeEditorComponent.prototype.ngAfterViewInit = function () {
768
+ var _this = this;
769
+ if (loadedMonaco) {
770
+ /* istanbul ignore next */
771
+ loadPromise.then(function () {
772
+ setTimeout(function () {
773
+ if (_this.el.nativeElement.offsetWidth) {
774
+ _this.registerCustomLanguage();
775
+ _this.initMonaco(_this.getOptions());
776
+ }
777
+ else {
778
+ _this.canLoad = true;
779
+ }
780
+ });
781
+ });
782
+ }
783
+ else {
784
+ loadedMonaco = true;
785
+ loadPromise = new Promise(function (resolve) {
786
+ /* istanbul ignore next */
787
+ var onGotAmdLoader = function () {
788
+ window.require.config({ paths: { 'vs': './assets/monaco/vs' } });
789
+ window.require(['vs/editor/editor.main'], function () {
790
+ setTimeout(function () {
791
+ if (_this.el.nativeElement.offsetWidth) {
792
+ _this.registerCustomLanguage();
793
+ _this.initMonaco(_this.getOptions());
794
+ }
795
+ else {
796
+ _this.canLoad = true;
797
+ }
798
+ resolve();
799
+ });
800
+ });
801
+ };
802
+ if (!window.require) {
803
+ var loaderScript = document.createElement('script');
804
+ loaderScript.type = 'text/javascript';
805
+ loaderScript.src = './assets/monaco/vs/loader.js';
806
+ loaderScript.addEventListener('load', onGotAmdLoader);
807
+ document.body.appendChild(loaderScript);
808
+ }
809
+ });
810
+ }
811
+ };
812
+ PoCodeEditorComponent.prototype.ngDoCheck = function () {
813
+ if (this.canLoad && this.el.nativeElement.offsetWidth) {
814
+ this.registerCustomLanguage();
815
+ this.initMonaco(this.getOptions());
816
+ this.canLoad = false;
817
+ }
818
+ };
819
+ /* istanbul ignore next */
820
+ PoCodeEditorComponent.prototype.monacoCreateModel = function (value) {
821
+ return monaco.editor.createModel(value);
822
+ };
823
+ PoCodeEditorComponent.prototype.setValueInEditor = function () {
824
+ var _this = this;
825
+ if (this.showDiff) {
826
+ setTimeout(function () {
827
+ if (_this.editor) {
828
+ _this.editor.setModel({
829
+ original: _this.monacoCreateModel(_this.value),
830
+ modified: _this.monacoCreateModel(_this.modifiedValue)
831
+ });
832
+ }
833
+ });
834
+ }
835
+ else {
836
+ setTimeout(function () {
837
+ if (_this.editor) {
838
+ _this.editor.setValue(_this.value);
839
+ }
840
+ });
841
+ }
842
+ };
843
+ PoCodeEditorComponent.prototype.setLanguage = function (language) {
844
+ if (this.showDiff) {
845
+ this.setMonacoLanguage(this.editor.getModel().original, language);
846
+ this.setMonacoLanguage(this.editor.getModel().modified, language);
847
+ }
848
+ else {
849
+ this.setMonacoLanguage(this.editor.getModel(), language);
850
+ }
851
+ };
852
+ /* istanbul ignore next */
853
+ PoCodeEditorComponent.prototype.setTheme = function (theme) {
854
+ monaco.editor.setTheme(theme);
855
+ };
856
+ PoCodeEditorComponent.prototype.setReadOnly = function (readOnly) {
857
+ this.editor.updateOptions({ readOnly: readOnly });
858
+ };
859
+ /* istanbul ignore next */
860
+ PoCodeEditorComponent.prototype.setSuggestions = function (newSuggestions, language) {
861
+ if (language === void 0) { language = this.language; }
862
+ if (!newSuggestions) {
863
+ return;
864
+ }
865
+ var suggestions = this.poCodeEditorSuggestionService.getSuggestion(language, newSuggestions);
866
+ monaco.languages.registerCompletionItemProvider(language, {
867
+ provideCompletionItems: function () { return ({ suggestions: suggestions }); }
868
+ });
869
+ };
870
+ PoCodeEditorComponent.prototype.writeValue = function (value) {
871
+ this.value = value && value instanceof Array ? value[0] : value;
872
+ this.modifiedValue = value && value instanceof Array && value.length > 0 ? value[1] : '';
873
+ this.setValueInEditor();
874
+ };
875
+ /* istanbul ignore next */
876
+ PoCodeEditorComponent.prototype.initMonaco = function (options) {
877
+ var _this = this;
878
+ if (this.showDiff) {
879
+ this.editor = monaco.editor.createDiffEditor(this.editorContainer.nativeElement, options);
880
+ this.editor.setModel({
881
+ original: monaco.editor.createModel(this.value),
882
+ modified: monaco.editor.createModel(this.modifiedValue)
883
+ });
884
+ this.editor.onDidUpdateDiff(function (e) {
885
+ var original = _this.editor.getModel().original.getValue();
886
+ var modified = _this.editor.getModel().modified.getValue();
887
+ _this.onChangePropagate([original, modified]);
888
+ });
889
+ }
890
+ else {
891
+ this.editor = monaco.editor.create(this.editorContainer.nativeElement, options);
892
+ this.editor.setValue(this.value);
893
+ this.editor.onDidChangeModelContent(function (e) {
894
+ var value = _this.editor.getValue();
895
+ _this.onChangePropagate(value);
896
+ _this.zone.run(function () { return (_this.value = value); });
897
+ });
898
+ }
899
+ setTimeout(function () {
900
+ _this.setLanguage(_this.language);
901
+ _this.setSuggestions(_this.suggestions);
902
+ }, 500);
903
+ };
904
+ /* istanbul ignore next */
905
+ PoCodeEditorComponent.prototype.setMonacoLanguage = function (model, language) {
906
+ monaco.editor.setModelLanguage(model, language);
907
+ };
908
+ PoCodeEditorComponent.prototype.registerCustomLanguage = function () {
909
+ if (this.codeEditorRegister.language) {
910
+ monaco.languages.register({ id: this.codeEditorRegister.language });
911
+ if (this.codeEditorRegister.options) {
912
+ monaco.languages.setMonarchTokensProvider(this.codeEditorRegister.language, this.codeEditorRegister.options);
913
+ }
914
+ if (this.codeEditorRegister.suggestions) {
915
+ this.setSuggestions(this.codeEditorRegister.suggestions.provideCompletionItems().suggestions, this.codeEditorRegister.language);
916
+ }
917
+ }
918
+ };
919
+ return PoCodeEditorComponent;
920
+ }(PoCodeEditorBaseComponent));
921
+ PoCodeEditorComponent.decorators = [
922
+ { type: i0.Component, args: [{
923
+ selector: 'po-code-editor',
924
+ template: "<div #editorContainer [style.height]=\"height\"></div>\r\n",
925
+ providers: providers
926
+ },] }
927
+ ];
928
+ PoCodeEditorComponent.ctorParameters = function () { return [
929
+ { type: i0.NgZone },
930
+ { type: i0.ElementRef },
931
+ { type: PoCodeEditorSuggestionService },
932
+ { type: PoCodeEditorRegister }
933
+ ]; };
934
+ PoCodeEditorComponent.propDecorators = {
935
+ editorContainer: [{ type: i0.ViewChild, args: ['editorContainer', { static: true },] }]
936
936
  };
937
937
 
938
- /**
939
- * @description
940
- *
941
- * Módulo do componente po-code-editor.
942
- */
943
- var PoCodeEditorModule = /** @class */ (function () {
944
- function PoCodeEditorModule() {
945
- }
946
- PoCodeEditorModule.forRegister = function (props) {
947
- return {
948
- ngModule: PoCodeEditorModule,
949
- providers: [
950
- {
951
- provide: PoCodeEditorRegister,
952
- useValue: props
953
- }
954
- ]
955
- };
956
- };
957
- return PoCodeEditorModule;
958
- }());
959
- PoCodeEditorModule.decorators = [
960
- { type: i0.NgModule, args: [{
961
- imports: [common.CommonModule],
962
- declarations: [PoCodeEditorComponent],
963
- exports: [PoCodeEditorComponent],
964
- providers: [PoCodeEditorRegister]
965
- },] }
938
+ /**
939
+ * @description
940
+ *
941
+ * Módulo do componente po-code-editor.
942
+ */
943
+ var PoCodeEditorModule = /** @class */ (function () {
944
+ function PoCodeEditorModule() {
945
+ }
946
+ PoCodeEditorModule.forRegister = function (props) {
947
+ return {
948
+ ngModule: PoCodeEditorModule,
949
+ providers: [
950
+ {
951
+ provide: PoCodeEditorRegister,
952
+ useValue: props
953
+ }
954
+ ]
955
+ };
956
+ };
957
+ return PoCodeEditorModule;
958
+ }());
959
+ PoCodeEditorModule.decorators = [
960
+ { type: i0.NgModule, args: [{
961
+ imports: [common.CommonModule],
962
+ declarations: [PoCodeEditorComponent],
963
+ exports: [PoCodeEditorComponent],
964
+ providers: [PoCodeEditorRegister]
965
+ },] }
966
966
  ];
967
967
 
968
- /**
969
- * Generated bundle index. Do not edit.
968
+ /**
969
+ * Generated bundle index. Do not edit.
970
970
  */
971
971
 
972
972
  exports.PoCodeEditorComponent = PoCodeEditorComponent;