@ecodev/natural-editor 1.1.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.
- package/README.md +42 -0
- package/bundles/ecodev-natural-editor.umd.js +858 -0
- package/bundles/ecodev-natural-editor.umd.js.map +1 -0
- package/ecodev-natural-editor.d.ts +5 -0
- package/esm2015/ecodev-natural-editor.js +5 -0
- package/esm2015/lib/editor.component.js +161 -0
- package/esm2015/lib/editor.module.js +72 -0
- package/esm2015/lib/link-dialog/link-dialog.component.js +43 -0
- package/esm2015/lib/menu.js +220 -0
- package/esm2015/lib/schema.js +21 -0
- package/esm2015/public-api.js +8 -0
- package/fesm2015/ecodev-natural-editor.js +508 -0
- package/fesm2015/ecodev-natural-editor.js.map +1 -0
- package/lib/editor.component.d.ts +47 -0
- package/lib/editor.module.d.ts +19 -0
- package/lib/link-dialog/link-dialog.component.d.ts +18 -0
- package/lib/menu.d.ts +39 -0
- package/lib/schema.d.ts +2 -0
- package/package.json +37 -0
- package/public-api.d.ts +3 -0
|
@@ -0,0 +1,858 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/localize/init'), require('@angular/core'), require('prosemirror-view'), require('prosemirror-state'), require('prosemirror-example-setup'), require('prosemirror-model'), require('prosemirror-schema-basic'), require('prosemirror-schema-list'), require('@angular/common'), require('prosemirror-menu'), require('prosemirror-commands'), require('@angular/material/dialog'), require('@angular/forms'), require('@angular/material/form-field'), require('@angular/material/button'), require('@angular/material/input'), require('@angular/material/toolbar'), require('@angular/material/button-toggle'), require('@angular/material/icon'), require('@angular/material/menu'), require('@angular/material/tooltip')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@ecodev/natural-editor', ['exports', '@angular/localize/init', '@angular/core', 'prosemirror-view', 'prosemirror-state', 'prosemirror-example-setup', 'prosemirror-model', 'prosemirror-schema-basic', 'prosemirror-schema-list', '@angular/common', 'prosemirror-menu', 'prosemirror-commands', '@angular/material/dialog', '@angular/forms', '@angular/material/form-field', '@angular/material/button', '@angular/material/input', '@angular/material/toolbar', '@angular/material/button-toggle', '@angular/material/icon', '@angular/material/menu', '@angular/material/tooltip'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ecodev = global.ecodev || {}, global.ecodev["natural-editor"] = {}), global.ng.localize.init, global.ng.core, global["prosemirror-view"], global["prosemirror-state"], global["prosemirror-example-setup"], global["prosemirror-model"], global["prosemirror-schema-basic"], global["prosemirror-schema-list"], global.ng.common, global["prosemirror-menu"], global["prosemirror-commands"], global.ng.material.dialog, global.ng.forms, global.ng.material.formField, global.ng.material.button, global.ng.material.input, global.ng.material.toolbar, global.ng.material.buttonToggle, global.ng.material.icon, global.ng.material.menu, global.ng.material.tooltip));
|
|
5
|
+
})(this, (function (exports, init, i0, prosemirrorView, prosemirrorState, prosemirrorExampleSetup, prosemirrorModel, prosemirrorSchemaBasic, prosemirrorSchemaList, i6, prosemirrorMenu, prosemirrorCommands, i1, i4, i2, i3, i5, i3$1, i4$1, i5$1, i7, i9) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
26
|
+
var i6__namespace = /*#__PURE__*/_interopNamespace(i6);
|
|
27
|
+
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
28
|
+
var i4__namespace = /*#__PURE__*/_interopNamespace(i4);
|
|
29
|
+
var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
|
|
30
|
+
var i3__namespace = /*#__PURE__*/_interopNamespace(i3);
|
|
31
|
+
var i5__namespace = /*#__PURE__*/_interopNamespace(i5);
|
|
32
|
+
var i3__namespace$1 = /*#__PURE__*/_interopNamespace(i3$1);
|
|
33
|
+
var i4__namespace$1 = /*#__PURE__*/_interopNamespace(i4$1);
|
|
34
|
+
var i5__namespace$1 = /*#__PURE__*/_interopNamespace(i5$1);
|
|
35
|
+
var i7__namespace = /*#__PURE__*/_interopNamespace(i7);
|
|
36
|
+
var i9__namespace = /*#__PURE__*/_interopNamespace(i9);
|
|
37
|
+
|
|
38
|
+
/*! *****************************************************************************
|
|
39
|
+
Copyright (c) Microsoft Corporation.
|
|
40
|
+
|
|
41
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
42
|
+
purpose with or without fee is hereby granted.
|
|
43
|
+
|
|
44
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
45
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
46
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
47
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
48
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
49
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
50
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
51
|
+
***************************************************************************** */
|
|
52
|
+
/* global Reflect, Promise */
|
|
53
|
+
var extendStatics = function (d, b) {
|
|
54
|
+
extendStatics = Object.setPrototypeOf ||
|
|
55
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
56
|
+
function (d, b) { for (var p in b)
|
|
57
|
+
if (Object.prototype.hasOwnProperty.call(b, p))
|
|
58
|
+
d[p] = b[p]; };
|
|
59
|
+
return extendStatics(d, b);
|
|
60
|
+
};
|
|
61
|
+
function __extends(d, b) {
|
|
62
|
+
if (typeof b !== "function" && b !== null)
|
|
63
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
64
|
+
extendStatics(d, b);
|
|
65
|
+
function __() { this.constructor = d; }
|
|
66
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
67
|
+
}
|
|
68
|
+
var __assign = function () {
|
|
69
|
+
__assign = Object.assign || function __assign(t) {
|
|
70
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
71
|
+
s = arguments[i];
|
|
72
|
+
for (var p in s)
|
|
73
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
74
|
+
t[p] = s[p];
|
|
75
|
+
}
|
|
76
|
+
return t;
|
|
77
|
+
};
|
|
78
|
+
return __assign.apply(this, arguments);
|
|
79
|
+
};
|
|
80
|
+
function __rest(s, e) {
|
|
81
|
+
var t = {};
|
|
82
|
+
for (var p in s)
|
|
83
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
84
|
+
t[p] = s[p];
|
|
85
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
86
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
87
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
88
|
+
t[p[i]] = s[p[i]];
|
|
89
|
+
}
|
|
90
|
+
return t;
|
|
91
|
+
}
|
|
92
|
+
function __decorate(decorators, target, key, desc) {
|
|
93
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
94
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
95
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
96
|
+
else
|
|
97
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
98
|
+
if (d = decorators[i])
|
|
99
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
100
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
101
|
+
}
|
|
102
|
+
function __param(paramIndex, decorator) {
|
|
103
|
+
return function (target, key) { decorator(target, key, paramIndex); };
|
|
104
|
+
}
|
|
105
|
+
function __metadata(metadataKey, metadataValue) {
|
|
106
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
107
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
108
|
+
}
|
|
109
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
110
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
111
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
112
|
+
function fulfilled(value) { try {
|
|
113
|
+
step(generator.next(value));
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
reject(e);
|
|
117
|
+
} }
|
|
118
|
+
function rejected(value) { try {
|
|
119
|
+
step(generator["throw"](value));
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
reject(e);
|
|
123
|
+
} }
|
|
124
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
125
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function __generator(thisArg, body) {
|
|
129
|
+
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
130
|
+
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
131
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
132
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
133
|
+
function step(op) {
|
|
134
|
+
if (f)
|
|
135
|
+
throw new TypeError("Generator is already executing.");
|
|
136
|
+
while (_)
|
|
137
|
+
try {
|
|
138
|
+
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)
|
|
139
|
+
return t;
|
|
140
|
+
if (y = 0, t)
|
|
141
|
+
op = [op[0] & 2, t.value];
|
|
142
|
+
switch (op[0]) {
|
|
143
|
+
case 0:
|
|
144
|
+
case 1:
|
|
145
|
+
t = op;
|
|
146
|
+
break;
|
|
147
|
+
case 4:
|
|
148
|
+
_.label++;
|
|
149
|
+
return { value: op[1], done: false };
|
|
150
|
+
case 5:
|
|
151
|
+
_.label++;
|
|
152
|
+
y = op[1];
|
|
153
|
+
op = [0];
|
|
154
|
+
continue;
|
|
155
|
+
case 7:
|
|
156
|
+
op = _.ops.pop();
|
|
157
|
+
_.trys.pop();
|
|
158
|
+
continue;
|
|
159
|
+
default:
|
|
160
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
161
|
+
_ = 0;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
165
|
+
_.label = op[1];
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
169
|
+
_.label = t[1];
|
|
170
|
+
t = op;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
if (t && _.label < t[2]) {
|
|
174
|
+
_.label = t[2];
|
|
175
|
+
_.ops.push(op);
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
if (t[2])
|
|
179
|
+
_.ops.pop();
|
|
180
|
+
_.trys.pop();
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
op = body.call(thisArg, _);
|
|
184
|
+
}
|
|
185
|
+
catch (e) {
|
|
186
|
+
op = [6, e];
|
|
187
|
+
y = 0;
|
|
188
|
+
}
|
|
189
|
+
finally {
|
|
190
|
+
f = t = 0;
|
|
191
|
+
}
|
|
192
|
+
if (op[0] & 5)
|
|
193
|
+
throw op[1];
|
|
194
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
198
|
+
if (k2 === undefined)
|
|
199
|
+
k2 = k;
|
|
200
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
|
201
|
+
}) : (function (o, m, k, k2) {
|
|
202
|
+
if (k2 === undefined)
|
|
203
|
+
k2 = k;
|
|
204
|
+
o[k2] = m[k];
|
|
205
|
+
});
|
|
206
|
+
function __exportStar(m, o) {
|
|
207
|
+
for (var p in m)
|
|
208
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
209
|
+
__createBinding(o, m, p);
|
|
210
|
+
}
|
|
211
|
+
function __values(o) {
|
|
212
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
213
|
+
if (m)
|
|
214
|
+
return m.call(o);
|
|
215
|
+
if (o && typeof o.length === "number")
|
|
216
|
+
return {
|
|
217
|
+
next: function () {
|
|
218
|
+
if (o && i >= o.length)
|
|
219
|
+
o = void 0;
|
|
220
|
+
return { value: o && o[i++], done: !o };
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
224
|
+
}
|
|
225
|
+
function __read(o, n) {
|
|
226
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
227
|
+
if (!m)
|
|
228
|
+
return o;
|
|
229
|
+
var i = m.call(o), r, ar = [], e;
|
|
230
|
+
try {
|
|
231
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
232
|
+
ar.push(r.value);
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
e = { error: error };
|
|
236
|
+
}
|
|
237
|
+
finally {
|
|
238
|
+
try {
|
|
239
|
+
if (r && !r.done && (m = i["return"]))
|
|
240
|
+
m.call(i);
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
if (e)
|
|
244
|
+
throw e.error;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return ar;
|
|
248
|
+
}
|
|
249
|
+
/** @deprecated */
|
|
250
|
+
function __spread() {
|
|
251
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
252
|
+
ar = ar.concat(__read(arguments[i]));
|
|
253
|
+
return ar;
|
|
254
|
+
}
|
|
255
|
+
/** @deprecated */
|
|
256
|
+
function __spreadArrays() {
|
|
257
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
258
|
+
s += arguments[i].length;
|
|
259
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
260
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
261
|
+
r[k] = a[j];
|
|
262
|
+
return r;
|
|
263
|
+
}
|
|
264
|
+
function __spreadArray(to, from, pack) {
|
|
265
|
+
if (pack || arguments.length === 2)
|
|
266
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
267
|
+
if (ar || !(i in from)) {
|
|
268
|
+
if (!ar)
|
|
269
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
270
|
+
ar[i] = from[i];
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
274
|
+
}
|
|
275
|
+
function __await(v) {
|
|
276
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
277
|
+
}
|
|
278
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
279
|
+
if (!Symbol.asyncIterator)
|
|
280
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
281
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
282
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
283
|
+
function verb(n) { if (g[n])
|
|
284
|
+
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
285
|
+
function resume(n, v) { try {
|
|
286
|
+
step(g[n](v));
|
|
287
|
+
}
|
|
288
|
+
catch (e) {
|
|
289
|
+
settle(q[0][3], e);
|
|
290
|
+
} }
|
|
291
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
292
|
+
function fulfill(value) { resume("next", value); }
|
|
293
|
+
function reject(value) { resume("throw", value); }
|
|
294
|
+
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
295
|
+
resume(q[0][0], q[0][1]); }
|
|
296
|
+
}
|
|
297
|
+
function __asyncDelegator(o) {
|
|
298
|
+
var i, p;
|
|
299
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
300
|
+
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; }
|
|
301
|
+
}
|
|
302
|
+
function __asyncValues(o) {
|
|
303
|
+
if (!Symbol.asyncIterator)
|
|
304
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
305
|
+
var m = o[Symbol.asyncIterator], i;
|
|
306
|
+
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);
|
|
307
|
+
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); }); }; }
|
|
308
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
309
|
+
}
|
|
310
|
+
function __makeTemplateObject(cooked, raw) {
|
|
311
|
+
if (Object.defineProperty) {
|
|
312
|
+
Object.defineProperty(cooked, "raw", { value: raw });
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
cooked.raw = raw;
|
|
316
|
+
}
|
|
317
|
+
return cooked;
|
|
318
|
+
}
|
|
319
|
+
;
|
|
320
|
+
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
321
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
322
|
+
}) : function (o, v) {
|
|
323
|
+
o["default"] = v;
|
|
324
|
+
};
|
|
325
|
+
function __importStar(mod) {
|
|
326
|
+
if (mod && mod.__esModule)
|
|
327
|
+
return mod;
|
|
328
|
+
var result = {};
|
|
329
|
+
if (mod != null)
|
|
330
|
+
for (var k in mod)
|
|
331
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
332
|
+
__createBinding(result, mod, k);
|
|
333
|
+
__setModuleDefault(result, mod);
|
|
334
|
+
return result;
|
|
335
|
+
}
|
|
336
|
+
function __importDefault(mod) {
|
|
337
|
+
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
338
|
+
}
|
|
339
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
340
|
+
if (kind === "a" && !f)
|
|
341
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
342
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
343
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
344
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
345
|
+
}
|
|
346
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
347
|
+
if (kind === "m")
|
|
348
|
+
throw new TypeError("Private method is not writable");
|
|
349
|
+
if (kind === "a" && !f)
|
|
350
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
351
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
352
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
353
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
var myNodes = {
|
|
357
|
+
heading: prosemirrorSchemaBasic.nodes.heading,
|
|
358
|
+
doc: prosemirrorSchemaBasic.nodes.doc,
|
|
359
|
+
paragraph: prosemirrorSchemaBasic.nodes.paragraph,
|
|
360
|
+
text: prosemirrorSchemaBasic.nodes.text,
|
|
361
|
+
hard_break: prosemirrorSchemaBasic.nodes.hard_break,
|
|
362
|
+
};
|
|
363
|
+
var myMarks = {
|
|
364
|
+
link: prosemirrorSchemaBasic.marks.link,
|
|
365
|
+
em: prosemirrorSchemaBasic.marks.em,
|
|
366
|
+
strong: prosemirrorSchemaBasic.marks.strong,
|
|
367
|
+
};
|
|
368
|
+
var basicSchema = new prosemirrorModel.Schema({ nodes: myNodes, marks: myMarks });
|
|
369
|
+
var schema = new prosemirrorModel.Schema({
|
|
370
|
+
nodes: prosemirrorSchemaList.addListNodes(basicSchema.spec.nodes, 'paragraph block*', 'block'),
|
|
371
|
+
marks: basicSchema.spec.marks,
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
var LinkDialogComponent = /** @class */ (function () {
|
|
375
|
+
function LinkDialogComponent(data, dialogRef) {
|
|
376
|
+
this.dialogRef = dialogRef;
|
|
377
|
+
this.hrefControl = new i4.FormControl('', i4.Validators.required);
|
|
378
|
+
this.titleControl = new i4.FormControl('');
|
|
379
|
+
this.form = new i4.FormGroup({
|
|
380
|
+
href: this.hrefControl,
|
|
381
|
+
title: this.titleControl,
|
|
382
|
+
});
|
|
383
|
+
this.form.setValue(data);
|
|
384
|
+
}
|
|
385
|
+
LinkDialogComponent.prototype.maybeConfirm = function () {
|
|
386
|
+
if (this.form.valid) {
|
|
387
|
+
this.confirm();
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
LinkDialogComponent.prototype.confirm = function () {
|
|
391
|
+
this.dialogRef.close(this.form.value);
|
|
392
|
+
};
|
|
393
|
+
return LinkDialogComponent;
|
|
394
|
+
}());
|
|
395
|
+
LinkDialogComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.9", ngImport: i0__namespace, type: LinkDialogComponent, deps: [{ token: i1.MAT_DIALOG_DATA }, { token: i1__namespace.MatDialogRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
|
|
396
|
+
LinkDialogComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.9", type: LinkDialogComponent, selector: "ng-component", ngImport: i0__namespace, template: "<h2 i18n mat-dialog-title>Ins\u00E9rer un lien</h2>\n\n<mat-dialog-content [formGroup]=\"form\">\n <mat-form-field>\n <mat-label i18n>URL</mat-label>\n <input matInput [formControl]=\"hrefControl\" (keydown.enter)=\"maybeConfirm()\" />\n <mat-error *ngIf=\"hrefControl.hasError('required')\" i18n>Ce champ est requis</mat-error>\n </mat-form-field>\n <mat-form-field>\n <mat-label i18n>Titre</mat-label>\n <input matInput [formControl]=\"titleControl\" (keydown.enter)=\"maybeConfirm()\" />\n </mat-form-field>\n</mat-dialog-content>\n\n<mat-dialog-actions>\n <button mat-button [mat-dialog-close] i18n>Annuler</button>\n <button mat-stroked-button (click)=\"maybeConfirm()\" [disabled]=\"!form.valid\"><span i18n>Valider</span></button>\n</mat-dialog-actions>\n", styles: ["mat-dialog-actions{display:flex;flex-direction:row;justify-content:flex-end}mat-dialog-content{width:70vw;max-width:60em;display:grid}\n"], components: [{ type: i2__namespace.MatFormField, selector: "mat-form-field", inputs: ["color", "floatLabel", "appearance", "hideRequiredMarker", "hintLabel"], exportAs: ["matFormField"] }, { type: i3__namespace.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i1__namespace.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i1__namespace.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i4__namespace.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i4__namespace.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i2__namespace.MatLabel, selector: "mat-label" }, { type: i5__namespace.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["id", "disabled", "required", "type", "value", "readonly", "placeholder", "errorStateMatcher", "aria-describedby"], exportAs: ["matInput"] }, { type: i4__namespace.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4__namespace.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4__namespace.FormControlDirective, selector: "[formControl]", inputs: ["disabled", "formControl", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i6__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2__namespace.MatError, selector: "mat-error", inputs: ["id"] }, { type: i1__namespace.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }, { type: i1__namespace.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["type", "mat-dialog-close", "aria-label", "matDialogClose"], exportAs: ["matDialogClose"] }] });
|
|
397
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.9", ngImport: i0__namespace, type: LinkDialogComponent, decorators: [{
|
|
398
|
+
type: i0.Component,
|
|
399
|
+
args: [{
|
|
400
|
+
templateUrl: './link-dialog.component.html',
|
|
401
|
+
styleUrls: ['./link-dialog.component.scss'],
|
|
402
|
+
}]
|
|
403
|
+
}], ctorParameters: function () {
|
|
404
|
+
return [{ type: undefined, decorators: [{
|
|
405
|
+
type: i0.Inject,
|
|
406
|
+
args: [i1.MAT_DIALOG_DATA]
|
|
407
|
+
}] }, { type: i1__namespace.MatDialogRef }];
|
|
408
|
+
} });
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* One item of the menu.
|
|
412
|
+
*
|
|
413
|
+
* This is the equivalent of `MenuItem` but without all the rendering logic since we use Angular
|
|
414
|
+
* templates for rendering. Also it caches the state of the item everytime the editor state changes,
|
|
415
|
+
* so Angular can query the state as often as needed without performance hit.
|
|
416
|
+
*/
|
|
417
|
+
var Item = /** @class */ (function () {
|
|
418
|
+
function Item(spec) {
|
|
419
|
+
this.spec = spec;
|
|
420
|
+
/**
|
|
421
|
+
* Whether the item is 'active' (for example, the item for toggling the strong mark might be active when the cursor is in strong text).
|
|
422
|
+
*/
|
|
423
|
+
this.active = false;
|
|
424
|
+
/**
|
|
425
|
+
* Button is shown but disabled, because the item cannot be (un-)applied
|
|
426
|
+
*/
|
|
427
|
+
this.disabled = false;
|
|
428
|
+
/**
|
|
429
|
+
* Whether the item is shown at the moment
|
|
430
|
+
*/
|
|
431
|
+
this.show = true;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Update the item state according to the editor state
|
|
435
|
+
*/
|
|
436
|
+
Item.prototype.update = function (view, state) {
|
|
437
|
+
if (this.spec.active) {
|
|
438
|
+
this.active = this.spec.active(state);
|
|
439
|
+
}
|
|
440
|
+
if (this.spec.enable) {
|
|
441
|
+
this.disabled = !this.spec.enable(state);
|
|
442
|
+
}
|
|
443
|
+
if (this.spec.select) {
|
|
444
|
+
this.show = this.spec.select(state);
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
return Item;
|
|
448
|
+
}());
|
|
449
|
+
/**
|
|
450
|
+
* Convert built-in `MenuItem` into our Angular specific `Item`
|
|
451
|
+
*/
|
|
452
|
+
function toItem(item) {
|
|
453
|
+
return new Item(item.spec);
|
|
454
|
+
}
|
|
455
|
+
function canInsert(state, nodeType) {
|
|
456
|
+
var $from = state.selection.$from;
|
|
457
|
+
for (var d = $from.depth; d >= 0; d--) {
|
|
458
|
+
var index = $from.index(d);
|
|
459
|
+
if ($from.node(d).canReplaceWith(index, index, nodeType)) {
|
|
460
|
+
return true;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return false;
|
|
464
|
+
}
|
|
465
|
+
// function insertImageItem(nodeType: NodeType) {
|
|
466
|
+
// return new MenuItem({
|
|
467
|
+
// enable(state): boolean {
|
|
468
|
+
// return canInsert(state, nodeType);
|
|
469
|
+
// },
|
|
470
|
+
// run(state, _, view) {
|
|
471
|
+
// let {from, to} = state.selection,
|
|
472
|
+
// attrs = null;
|
|
473
|
+
// if (state.selection instanceof NodeSelection && state.selection.node.type == nodeType) {
|
|
474
|
+
// attrs = state.selection.node.attrs;
|
|
475
|
+
// }
|
|
476
|
+
// openPrompt({
|
|
477
|
+
// title: 'Insert image',
|
|
478
|
+
// fields: {
|
|
479
|
+
// src: new TextField({label: 'Location', required: true, value: attrs && attrs.src}),
|
|
480
|
+
// title: new TextField({label: 'Title', value: attrs && attrs.title}),
|
|
481
|
+
// alt: new TextField({
|
|
482
|
+
// label: 'Description',
|
|
483
|
+
// value: attrs ? attrs.alt : state.doc.textBetween(from, to, ' '),
|
|
484
|
+
// }),
|
|
485
|
+
// },
|
|
486
|
+
// callback(attrs) {
|
|
487
|
+
// view.dispatch(view.state.tr.replaceSelectionWith(nodeType.createAndFill(attrs)));
|
|
488
|
+
// view.focus();
|
|
489
|
+
// },
|
|
490
|
+
// });
|
|
491
|
+
// },
|
|
492
|
+
// });
|
|
493
|
+
// }
|
|
494
|
+
function cmdItem(cmd, options, useEnable) {
|
|
495
|
+
if (options === void 0) { options = {}; }
|
|
496
|
+
if (useEnable === void 0) { useEnable = false; }
|
|
497
|
+
var passedOptions = Object.assign({ run: cmd }, options);
|
|
498
|
+
if ((!options.enable || useEnable) && !options.select) {
|
|
499
|
+
passedOptions[options.enable ? 'enable' : 'select'] = function (state) { return cmd(state); };
|
|
500
|
+
}
|
|
501
|
+
return new Item(passedOptions);
|
|
502
|
+
}
|
|
503
|
+
function markActive(state, type) {
|
|
504
|
+
var _a = state.selection, from = _a.from, $from = _a.$from, to = _a.to, empty = _a.empty;
|
|
505
|
+
if (empty) {
|
|
506
|
+
return !!type.isInSet(state.storedMarks || $from.marks());
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
return state.doc.rangeHasMark(from, to, type);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
function markItem(markType, options) {
|
|
513
|
+
if (options === void 0) { options = {}; }
|
|
514
|
+
var passedOptions = Object.assign({ active: function (state) {
|
|
515
|
+
return markActive(state, markType);
|
|
516
|
+
} }, options);
|
|
517
|
+
return cmdItem(prosemirrorCommands.toggleMark(markType), passedOptions, true);
|
|
518
|
+
}
|
|
519
|
+
function linkItem(markType, dialog) {
|
|
520
|
+
return new Item({
|
|
521
|
+
active: function (state) {
|
|
522
|
+
return markActive(state, markType);
|
|
523
|
+
},
|
|
524
|
+
enable: function (state) {
|
|
525
|
+
return !state.selection.empty;
|
|
526
|
+
},
|
|
527
|
+
run: function (state, dispatch, view) {
|
|
528
|
+
if (markActive(state, markType)) {
|
|
529
|
+
prosemirrorCommands.toggleMark(markType)(state, dispatch);
|
|
530
|
+
return true;
|
|
531
|
+
}
|
|
532
|
+
dialog
|
|
533
|
+
.open(LinkDialogComponent, {
|
|
534
|
+
data: {
|
|
535
|
+
href: '',
|
|
536
|
+
title: '',
|
|
537
|
+
},
|
|
538
|
+
})
|
|
539
|
+
.afterClosed()
|
|
540
|
+
.subscribe(function (result) {
|
|
541
|
+
if (result && !result.title) {
|
|
542
|
+
delete result.title;
|
|
543
|
+
}
|
|
544
|
+
prosemirrorCommands.toggleMark(markType, result)(view.state, view.dispatch);
|
|
545
|
+
view.focus();
|
|
546
|
+
});
|
|
547
|
+
},
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
function wrapListItem(nodeType) {
|
|
551
|
+
return cmdItem(prosemirrorSchemaList.wrapInList(nodeType));
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Given a schema, look for default mark and node types in it and
|
|
555
|
+
* return an object with relevant menu items relating to those marks:
|
|
556
|
+
*/
|
|
557
|
+
function buildMenuItems(schema, dialog) {
|
|
558
|
+
var r = {
|
|
559
|
+
joinUp: toItem(prosemirrorMenu.joinUpItem),
|
|
560
|
+
lift: toItem(prosemirrorMenu.liftItem),
|
|
561
|
+
selectParentNode: toItem(prosemirrorMenu.selectParentNodeItem),
|
|
562
|
+
undo: toItem(prosemirrorMenu.undoItem),
|
|
563
|
+
redo: toItem(prosemirrorMenu.redoItem),
|
|
564
|
+
};
|
|
565
|
+
var type;
|
|
566
|
+
type = schema.marks.strong;
|
|
567
|
+
if (type) {
|
|
568
|
+
r.toggleStrong = markItem(type);
|
|
569
|
+
}
|
|
570
|
+
type = schema.marks.em;
|
|
571
|
+
if (type) {
|
|
572
|
+
r.toggleEm = markItem(type);
|
|
573
|
+
}
|
|
574
|
+
type = schema.marks.code;
|
|
575
|
+
if (type) {
|
|
576
|
+
r.toggleCode = markItem(type);
|
|
577
|
+
}
|
|
578
|
+
type = schema.marks.link;
|
|
579
|
+
if (type) {
|
|
580
|
+
r.toggleLink = linkItem(type, dialog);
|
|
581
|
+
}
|
|
582
|
+
type = schema.nodes.image;
|
|
583
|
+
if (type) {
|
|
584
|
+
// r.insertImage = insertImageItem(type);
|
|
585
|
+
}
|
|
586
|
+
type = schema.nodes.bullet_list;
|
|
587
|
+
if (type) {
|
|
588
|
+
r.wrapBulletList = wrapListItem(type);
|
|
589
|
+
}
|
|
590
|
+
type = schema.nodes.ordered_list;
|
|
591
|
+
if (type) {
|
|
592
|
+
r.wrapOrderedList = wrapListItem(type);
|
|
593
|
+
}
|
|
594
|
+
type = schema.nodes.blockquote;
|
|
595
|
+
if (type) {
|
|
596
|
+
r.wrapBlockQuote = toItem(prosemirrorMenu.wrapItem(type, {}));
|
|
597
|
+
}
|
|
598
|
+
type = schema.nodes.paragraph;
|
|
599
|
+
if (type) {
|
|
600
|
+
r.makeParagraph = toItem(prosemirrorMenu.blockTypeItem(type, {}));
|
|
601
|
+
}
|
|
602
|
+
type = schema.nodes.code_block;
|
|
603
|
+
if (type) {
|
|
604
|
+
r.makeCodeBlock = toItem(prosemirrorMenu.blockTypeItem(type, {}));
|
|
605
|
+
}
|
|
606
|
+
type = schema.nodes.heading;
|
|
607
|
+
if (type) {
|
|
608
|
+
r.makeHead1 = toItem(prosemirrorMenu.blockTypeItem(type, { attrs: { level: 1 } }));
|
|
609
|
+
r.makeHead2 = toItem(prosemirrorMenu.blockTypeItem(type, { attrs: { level: 2 } }));
|
|
610
|
+
r.makeHead3 = toItem(prosemirrorMenu.blockTypeItem(type, { attrs: { level: 3 } }));
|
|
611
|
+
r.makeHead4 = toItem(prosemirrorMenu.blockTypeItem(type, { attrs: { level: 4 } }));
|
|
612
|
+
r.makeHead5 = toItem(prosemirrorMenu.blockTypeItem(type, { attrs: { level: 5 } }));
|
|
613
|
+
r.makeHead6 = toItem(prosemirrorMenu.blockTypeItem(type, { attrs: { level: 6 } }));
|
|
614
|
+
}
|
|
615
|
+
type = schema.nodes.horizontal_rule;
|
|
616
|
+
if (type) {
|
|
617
|
+
var hr_1 = type;
|
|
618
|
+
r.insertHorizontalRule = new Item({
|
|
619
|
+
enable: function (state) {
|
|
620
|
+
return canInsert(state, hr_1);
|
|
621
|
+
},
|
|
622
|
+
run: function (state, dispatch) {
|
|
623
|
+
dispatch(state.tr.replaceSelectionWith(hr_1.create()));
|
|
624
|
+
},
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
return r;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Prosemirror component
|
|
632
|
+
*
|
|
633
|
+
* Usage :
|
|
634
|
+
*
|
|
635
|
+
* ```html
|
|
636
|
+
* <natural-editor [(ngModel)]="htmlString"></natural-editor>
|
|
637
|
+
* ```
|
|
638
|
+
*/
|
|
639
|
+
// @dynamic
|
|
640
|
+
var NaturalEditorComponent = /** @class */ (function () {
|
|
641
|
+
function NaturalEditorComponent(ngControl, document, dialog) {
|
|
642
|
+
this.ngControl = ngControl;
|
|
643
|
+
this.document = document;
|
|
644
|
+
this.dialog = dialog;
|
|
645
|
+
this.view = null;
|
|
646
|
+
this.contentChange = new i0.EventEmitter();
|
|
647
|
+
/**
|
|
648
|
+
* HTML string
|
|
649
|
+
*/
|
|
650
|
+
this.content = '';
|
|
651
|
+
this.menu = null;
|
|
652
|
+
if (this.ngControl !== null) {
|
|
653
|
+
this.ngControl.valueAccessor = this;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
NaturalEditorComponent.prototype.ngOnInit = function () {
|
|
657
|
+
var _this = this;
|
|
658
|
+
this.menu = buildMenuItems(schema, this.dialog);
|
|
659
|
+
var serializer = prosemirrorModel.DOMSerializer.fromSchema(schema);
|
|
660
|
+
var state = this.createState();
|
|
661
|
+
this.view = new prosemirrorView.EditorView(this.editor.nativeElement, {
|
|
662
|
+
state: state,
|
|
663
|
+
dispatchTransaction: function (transaction) {
|
|
664
|
+
if (!_this.view) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
var newState = _this.view.state.apply(transaction);
|
|
668
|
+
_this.view.updateState(newState);
|
|
669
|
+
// Transform doc into HTML string
|
|
670
|
+
var dom = serializer.serializeFragment(_this.view.state.doc);
|
|
671
|
+
var el = _this.document.createElement('_');
|
|
672
|
+
el.appendChild(dom);
|
|
673
|
+
var newContent = el.innerHTML;
|
|
674
|
+
if (_this.content === newContent) {
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
_this.content = el.innerHTML;
|
|
678
|
+
if (_this.onChange) {
|
|
679
|
+
_this.onChange(_this.content);
|
|
680
|
+
}
|
|
681
|
+
_this.contentChange.emit(_this.content);
|
|
682
|
+
},
|
|
683
|
+
});
|
|
684
|
+
this.update();
|
|
685
|
+
};
|
|
686
|
+
NaturalEditorComponent.prototype.writeValue = function (val) {
|
|
687
|
+
if (typeof val === 'string' && val !== this.content) {
|
|
688
|
+
this.content = val;
|
|
689
|
+
}
|
|
690
|
+
if (this.view !== null) {
|
|
691
|
+
var state = this.createState();
|
|
692
|
+
this.view.updateState(state);
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
NaturalEditorComponent.prototype.createState = function () {
|
|
696
|
+
var template = this.document.createElement('_');
|
|
697
|
+
template.innerHTML = '<div>' + this.content + '</div>';
|
|
698
|
+
if (!template.firstChild) {
|
|
699
|
+
throw new Error('child of template element could not be created');
|
|
700
|
+
}
|
|
701
|
+
var parser = prosemirrorModel.DOMParser.fromSchema(schema);
|
|
702
|
+
var doc = parser.parse(template.firstChild);
|
|
703
|
+
var self = this;
|
|
704
|
+
return prosemirrorState.EditorState.create({
|
|
705
|
+
doc: doc,
|
|
706
|
+
plugins: __spreadArray(__spreadArray([], __read(prosemirrorExampleSetup.exampleSetup({ schema: schema, menuBar: false }))), [
|
|
707
|
+
new prosemirrorState.Plugin({
|
|
708
|
+
view: function () { return self; },
|
|
709
|
+
}),
|
|
710
|
+
]),
|
|
711
|
+
});
|
|
712
|
+
};
|
|
713
|
+
/**
|
|
714
|
+
* Called by Prosemirror whenever the editor state changes. So we update our menu states.
|
|
715
|
+
*/
|
|
716
|
+
NaturalEditorComponent.prototype.update = function () {
|
|
717
|
+
var e_1, _a;
|
|
718
|
+
if (!this.view || !this.menu) {
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
try {
|
|
722
|
+
for (var _b = __values(Object.values(this.menu)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
723
|
+
var item = _c.value;
|
|
724
|
+
item.update(this.view, this.view.state);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
728
|
+
finally {
|
|
729
|
+
try {
|
|
730
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
731
|
+
}
|
|
732
|
+
finally { if (e_1) throw e_1.error; }
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
NaturalEditorComponent.prototype.registerOnChange = function (fn) {
|
|
736
|
+
this.onChange = fn;
|
|
737
|
+
};
|
|
738
|
+
NaturalEditorComponent.prototype.registerOnTouched = function (fn) { };
|
|
739
|
+
NaturalEditorComponent.prototype.setDisabledState = function (isDisabled) {
|
|
740
|
+
// TODO disable editor ?
|
|
741
|
+
};
|
|
742
|
+
NaturalEditorComponent.prototype.ngOnDestroy = function () {
|
|
743
|
+
if (this.view) {
|
|
744
|
+
this.view.destroy();
|
|
745
|
+
this.view = null;
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
NaturalEditorComponent.prototype.run = function (event, key) {
|
|
749
|
+
if (!this.view || !this.menu) {
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
var item = this.menu[key];
|
|
753
|
+
if (!item || item.disabled || !item.show) {
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
item.spec.run(this.view.state, this.view.dispatch, this.view, event);
|
|
757
|
+
this.view.focus();
|
|
758
|
+
};
|
|
759
|
+
return NaturalEditorComponent;
|
|
760
|
+
}());
|
|
761
|
+
NaturalEditorComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.9", ngImport: i0__namespace, type: NaturalEditorComponent, deps: [{ token: i4__namespace.NgControl, optional: true, self: true }, { token: i6.DOCUMENT }, { token: i1__namespace.MatDialog }], target: i0__namespace.ɵɵFactoryTarget.Component });
|
|
762
|
+
NaturalEditorComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.9", type: NaturalEditorComponent, selector: "natural-editor", outputs: { contentChange: "contentChange" }, viewQueries: [{ propertyName: "editor", first: true, predicate: ["editor"], descendants: true, read: i0.ElementRef, static: true }], ngImport: i0__namespace, template: "<mat-toolbar *ngIf=\"menu\">\n <mat-button-toggle-group multiple>\n <mat-button-toggle\n *ngIf=\"menu.toggleStrong\"\n [disabled]=\"menu.toggleStrong.disabled\"\n [checked]=\"menu.toggleStrong.active\"\n (click)=\"run($event, 'toggleStrong')\"\n i18n-matTooltip\n matTooltip=\"Gras\"\n >\n <mat-icon>format_bold</mat-icon>\n </mat-button-toggle>\n\n <mat-button-toggle\n *ngIf=\"menu.toggleEm\"\n [disabled]=\"menu.toggleEm.disabled\"\n [checked]=\"menu.toggleEm.active\"\n (click)=\"run($event, 'toggleEm')\"\n i18n-matTooltip\n matTooltip=\"Italique\"\n >\n <mat-icon>format_italic</mat-icon>\n </mat-button-toggle>\n\n <mat-button-toggle\n *ngIf=\"menu.toggleCode\"\n [disabled]=\"menu.toggleCode.disabled\"\n [checked]=\"menu.toggleCode.active\"\n (click)=\"run($event, 'toggleCode')\"\n i18n-matTooltip\n matTooltip=\"Code\"\n >\n <mat-icon>code</mat-icon>\n </mat-button-toggle>\n\n <mat-button-toggle\n *ngIf=\"menu.toggleLink\"\n [disabled]=\"menu.toggleLink.disabled\"\n [checked]=\"menu.toggleLink.active\"\n (click)=\"run($event, 'toggleLink')\"\n i18n-matTooltip\n matTooltip=\"Ins\u00E9rer un lien...\"\n >\n <mat-icon>insert_link</mat-icon>\n </mat-button-toggle>\n </mat-button-toggle-group>\n\n <button mat-button [matMenuTriggerFor]=\"blockMenu\">\n <span i18n>Type</span>\n <mat-icon>arrow_drop_down</mat-icon>\n </button>\n\n <mat-menu #blockMenu=\"matMenu\">\n <button\n mat-menu-item\n *ngIf=\"menu.makeParagraph\"\n [disabled]=\"menu.makeParagraph.disabled\"\n (click)=\"run($event, 'makeParagraph')\"\n i18n\n >Paragraphe\n </button>\n <button\n mat-menu-item\n *ngIf=\"menu.makeCodeBlock\"\n [disabled]=\"menu.makeCodeBlock.disabled\"\n (click)=\"run($event, 'makeCodeBlock')\"\n i18n\n >Code\n </button>\n <button\n mat-menu-item\n *ngIf=\"menu.makeHead1\"\n [disabled]=\"menu.makeHead1.disabled\"\n (click)=\"run($event, 'makeHead1')\"\n i18n\n >Titre 1\n </button>\n <button\n mat-menu-item\n *ngIf=\"menu.makeHead2\"\n [disabled]=\"menu.makeHead2.disabled\"\n (click)=\"run($event, 'makeHead2')\"\n i18n\n >Titre 2\n </button>\n <button\n mat-menu-item\n *ngIf=\"menu.makeHead3\"\n [disabled]=\"menu.makeHead3.disabled\"\n (click)=\"run($event, 'makeHead3')\"\n i18n\n >Titre 3\n </button>\n <button\n mat-menu-item\n *ngIf=\"menu.makeHead4\"\n [disabled]=\"menu.makeHead4.disabled\"\n (click)=\"run($event, 'makeHead4')\"\n i18n\n >Titre 4\n </button>\n <button\n mat-menu-item\n *ngIf=\"menu.makeHead5\"\n [disabled]=\"menu.makeHead5.disabled\"\n (click)=\"run($event, 'makeHead5')\"\n i18n\n >Titre 5\n </button>\n <button\n mat-menu-item\n *ngIf=\"menu.makeHead6\"\n [disabled]=\"menu.makeHead6.disabled\"\n (click)=\"run($event, 'makeHead6')\"\n i18n\n >Titre 6\n </button>\n </mat-menu>\n\n <button\n mat-button\n *ngIf=\"menu.undo\"\n [disabled]=\"menu.undo.disabled\"\n (click)=\"run($event, 'undo')\"\n i18n-matTooltip\n matTooltip=\"Annuler\"\n >\n <mat-icon>undo</mat-icon>\n </button>\n\n <button\n mat-button\n *ngIf=\"menu.redo\"\n [disabled]=\"menu.redo.disabled\"\n (click)=\"run($event, 'redo')\"\n i18n-matTooltip\n matTooltip=\"Refaire\"\n >\n <mat-icon>redo</mat-icon>\n </button>\n\n <button\n mat-button\n *ngIf=\"menu.wrapBulletList && menu.wrapBulletList.show\"\n [disabled]=\"menu.wrapBulletList.disabled\"\n (click)=\"run($event, 'wrapBulletList')\"\n i18n-matTooltip\n matTooltip=\"Liste \u00E0 puce\"\n >\n <mat-icon>format_list_bulleted</mat-icon>\n </button>\n\n <button\n mat-button\n *ngIf=\"menu.wrapOrderedList && menu.wrapOrderedList.show\"\n [disabled]=\"menu.wrapOrderedList.disabled\"\n (click)=\"run($event, 'wrapOrderedList')\"\n i18n-matTooltip\n matTooltip=\"Liste \u00E0 num\u00E9ro\"\n >\n <mat-icon>format_list_numbered</mat-icon>\n </button>\n\n <button\n mat-button\n *ngIf=\"menu.wrapBlockQuote && menu.wrapBlockQuote.show\"\n [disabled]=\"menu.wrapBlockQuote.disabled\"\n (click)=\"run($event, 'wrapBlockQuote')\"\n i18n-matTooltip\n matTooltip=\"Citation\"\n >\n <mat-icon>format_quote</mat-icon>\n </button>\n\n <button\n mat-button\n *ngIf=\"menu.joinUp && menu.joinUp.show\"\n [disabled]=\"menu.joinUp.disabled\"\n (click)=\"run($event, 'joinUp')\"\n i18n-matTooltip\n matTooltip=\"Fusionner avec l'\u00E9l\u00E9ment du haut\"\n >\n <mat-icon>move_up</mat-icon>\n </button>\n\n <button\n mat-button\n *ngIf=\"menu.lift && menu.lift.show\"\n [disabled]=\"menu.lift.disabled\"\n (click)=\"run($event, 'lift')\"\n i18n-matTooltip\n matTooltip=\"D\u00E9sindenter\"\n >\n <mat-icon>format_indent_decrease</mat-icon>\n </button>\n\n <button\n mat-button\n *ngIf=\"menu.selectParentNode && menu.selectParentNode.show\"\n [disabled]=\"menu.selectParentNode.disabled\"\n (click)=\"run($event, 'selectParentNode')\"\n i18n-matTooltip\n matTooltip=\"S\u00E9lectionner l'\u00E9l\u00E9ment parent\"\n >\n <mat-icon>select_all</mat-icon>\n </button>\n</mat-toolbar>\n<div #editor></div>\n", styles: ["::ng-deep .ProseMirror{position:relative;background:rgba(0,0,0,.1)}::ng-deep .ProseMirror{word-wrap:break-word;white-space:pre-wrap;-webkit-font-variant-ligatures:none;font-feature-settings:none;font-variant-ligatures:none}::ng-deep .ProseMirror pre{white-space:pre-wrap}::ng-deep .ProseMirror li{position:relative}::ng-deep .ProseMirror-hideselection *::selection{background:transparent}::ng-deep .ProseMirror-hideselection *::-moz-selection{background:transparent}::ng-deep .ProseMirror-hideselection{caret-color:transparent}::ng-deep .ProseMirror-selectednode{outline:2px solid #8cf}::ng-deep li.ProseMirror-selectednode{outline:none}::ng-deep li.ProseMirror-selectednode:after{content:\"\";position:absolute;left:-32px;right:-2px;top:-2px;bottom:-2px;border:2px solid #8cf;pointer-events:none}::ng-deep .ProseMirror-gapcursor{display:none;pointer-events:none;position:absolute}::ng-deep .ProseMirror-gapcursor:after{content:\"\";display:block;position:absolute;top:-2px;width:20px;border-top:1px solid black;animation:ProseMirror-cursor-blink 1.1s steps(2,start) infinite}@keyframes ProseMirror-cursor-blink{to{visibility:hidden}}::ng-deep .ProseMirror-focused .ProseMirror-gapcursor{display:block}::ng-deep .ProseMirror-example-setup-style hr{padding:2px 10px;border:none;margin:1em 0}::ng-deep .ProseMirror-example-setup-style hr:after{content:\"\";display:block;height:1px;background-color:silver;line-height:2px}::ng-deep .ProseMirror ul,::ng-deep .ProseMirror ol{padding-left:30px}::ng-deep .ProseMirror blockquote{padding-left:1em;border-left:3px solid #eee;margin-left:0;margin-right:0}::ng-deep .ProseMirror-example-setup-style img{cursor:default}::ng-deep #editor,::ng-deep .editor{background:white;color:#000;background-clip:padding-box;border-radius:4px;border:2px solid rgba(0,0,0,.2);padding:5px 0;margin-bottom:23px}::ng-deep .ProseMirror p:first-child,::ng-deep .ProseMirror h1:first-child,::ng-deep .ProseMirror h2:first-child,::ng-deep .ProseMirror h3:first-child,::ng-deep .ProseMirror h4:first-child,::ng-deep .ProseMirror h5:first-child,::ng-deep .ProseMirror h6:first-child{margin-top:10px}::ng-deep .ProseMirror{padding:4px 8px 4px 14px;line-height:1.2;outline:none}::ng-deep .ProseMirror p{margin-bottom:1em}\n"], components: [{ type: i3__namespace$1.MatToolbar, selector: "mat-toolbar", inputs: ["color"], exportAs: ["matToolbar"] }, { type: i4__namespace$1.MatButtonToggle, selector: "mat-button-toggle", inputs: ["disableRipple", "aria-labelledby", "tabIndex", "appearance", "checked", "disabled", "id", "name", "aria-label", "value"], outputs: ["change"], exportAs: ["matButtonToggle"] }, { type: i5__namespace$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i3__namespace.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i7__namespace.MatMenu, selector: "mat-menu", exportAs: ["matMenu"] }, { type: i7__namespace.MatMenuItem, selector: "[mat-menu-item]", inputs: ["disabled", "disableRipple", "role"], exportAs: ["matMenuItem"] }], directives: [{ type: i6__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4__namespace$1.MatButtonToggleGroup, selector: "mat-button-toggle-group", inputs: ["appearance", "name", "vertical", "value", "multiple", "disabled"], outputs: ["valueChange", "change"], exportAs: ["matButtonToggleGroup"] }, { type: i9__namespace.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { type: i7__namespace.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", exportAs: ["matMenuTrigger"] }] });
|
|
763
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.9", ngImport: i0__namespace, type: NaturalEditorComponent, decorators: [{
|
|
764
|
+
type: i0.Component,
|
|
765
|
+
args: [{
|
|
766
|
+
selector: 'natural-editor',
|
|
767
|
+
templateUrl: './editor.component.html',
|
|
768
|
+
styleUrls: ['./editor.component.scss'],
|
|
769
|
+
}]
|
|
770
|
+
}], ctorParameters: function () {
|
|
771
|
+
return [{ type: i4__namespace.NgControl, decorators: [{
|
|
772
|
+
type: i0.Optional
|
|
773
|
+
}, {
|
|
774
|
+
type: i0.Self
|
|
775
|
+
}] }, { type: Document, decorators: [{
|
|
776
|
+
type: i0.Inject,
|
|
777
|
+
args: [i6.DOCUMENT]
|
|
778
|
+
}] }, { type: i1__namespace.MatDialog }];
|
|
779
|
+
}, propDecorators: { editor: [{
|
|
780
|
+
type: i0.ViewChild,
|
|
781
|
+
args: ['editor', { read: i0.ElementRef, static: true }]
|
|
782
|
+
}], contentChange: [{
|
|
783
|
+
type: i0.Output
|
|
784
|
+
}] } });
|
|
785
|
+
|
|
786
|
+
var imports = [
|
|
787
|
+
i6.CommonModule,
|
|
788
|
+
i3.MatButtonModule,
|
|
789
|
+
i4$1.MatButtonToggleModule,
|
|
790
|
+
i1.MatDialogModule,
|
|
791
|
+
i2.MatFormFieldModule,
|
|
792
|
+
i5$1.MatIconModule,
|
|
793
|
+
i5.MatInputModule,
|
|
794
|
+
i7.MatMenuModule,
|
|
795
|
+
i3$1.MatToolbarModule,
|
|
796
|
+
i9.MatTooltipModule,
|
|
797
|
+
i4.ReactiveFormsModule,
|
|
798
|
+
];
|
|
799
|
+
var NaturalEditorModule = /** @class */ (function () {
|
|
800
|
+
function NaturalEditorModule() {
|
|
801
|
+
}
|
|
802
|
+
return NaturalEditorModule;
|
|
803
|
+
}());
|
|
804
|
+
NaturalEditorModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.9", ngImport: i0__namespace, type: NaturalEditorModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
805
|
+
NaturalEditorModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.9", ngImport: i0__namespace, type: NaturalEditorModule, declarations: [NaturalEditorComponent, LinkDialogComponent], imports: [i6.CommonModule,
|
|
806
|
+
i3.MatButtonModule,
|
|
807
|
+
i4$1.MatButtonToggleModule,
|
|
808
|
+
i1.MatDialogModule,
|
|
809
|
+
i2.MatFormFieldModule,
|
|
810
|
+
i5$1.MatIconModule,
|
|
811
|
+
i5.MatInputModule,
|
|
812
|
+
i7.MatMenuModule,
|
|
813
|
+
i3$1.MatToolbarModule,
|
|
814
|
+
i9.MatTooltipModule,
|
|
815
|
+
i4.ReactiveFormsModule], exports: [i6.CommonModule,
|
|
816
|
+
i3.MatButtonModule,
|
|
817
|
+
i4$1.MatButtonToggleModule,
|
|
818
|
+
i1.MatDialogModule,
|
|
819
|
+
i2.MatFormFieldModule,
|
|
820
|
+
i5$1.MatIconModule,
|
|
821
|
+
i5.MatInputModule,
|
|
822
|
+
i7.MatMenuModule,
|
|
823
|
+
i3$1.MatToolbarModule,
|
|
824
|
+
i9.MatTooltipModule,
|
|
825
|
+
i4.ReactiveFormsModule, NaturalEditorComponent] });
|
|
826
|
+
NaturalEditorModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.9", ngImport: i0__namespace, type: NaturalEditorModule, imports: [__spreadArray([], __read(imports)), i6.CommonModule,
|
|
827
|
+
i3.MatButtonModule,
|
|
828
|
+
i4$1.MatButtonToggleModule,
|
|
829
|
+
i1.MatDialogModule,
|
|
830
|
+
i2.MatFormFieldModule,
|
|
831
|
+
i5$1.MatIconModule,
|
|
832
|
+
i5.MatInputModule,
|
|
833
|
+
i7.MatMenuModule,
|
|
834
|
+
i3$1.MatToolbarModule,
|
|
835
|
+
i9.MatTooltipModule,
|
|
836
|
+
i4.ReactiveFormsModule] });
|
|
837
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.9", ngImport: i0__namespace, type: NaturalEditorModule, decorators: [{
|
|
838
|
+
type: i0.NgModule,
|
|
839
|
+
args: [{
|
|
840
|
+
declarations: [NaturalEditorComponent, LinkDialogComponent],
|
|
841
|
+
imports: __spreadArray([], __read(imports)),
|
|
842
|
+
exports: __spreadArray(__spreadArray([], __read(imports)), [NaturalEditorComponent]),
|
|
843
|
+
}]
|
|
844
|
+
}] });
|
|
845
|
+
|
|
846
|
+
// Load `$localize` onto the global scope - to be able to use that function to translate strings in components/services.
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Generated bundle index. Do not edit.
|
|
850
|
+
*/
|
|
851
|
+
|
|
852
|
+
exports.NaturalEditorComponent = NaturalEditorComponent;
|
|
853
|
+
exports.NaturalEditorModule = NaturalEditorModule;
|
|
854
|
+
|
|
855
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
856
|
+
|
|
857
|
+
}));
|
|
858
|
+
//# sourceMappingURL=ecodev-natural-editor.umd.js.map
|