@firestitch/html-editor 9.5.7 → 9.5.8
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/app/classes/plugin.d.ts +7 -7
- package/app/components/html-editor/html-editor.component.d.ts +54 -54
- package/app/components/html-renderer/html-renderer.component.d.ts +9 -9
- package/app/consts/paragraph-buttons.const.d.ts +1 -1
- package/app/consts/rich-buttons.const.d.ts +1 -1
- package/app/consts/text-buttons.const.d.ts +1 -1
- package/app/enums/default-plugin.enum.d.ts +14 -14
- package/app/fs-html-editor.module.d.ts +25 -25
- package/app/injects/config.inject.d.ts +3 -3
- package/app/interfaces/html-editor-config.d.ts +31 -31
- package/app/interfaces/plugin-button.d.ts +12 -12
- package/app/interfaces/plugin-config.d.ts +5 -5
- package/app/plugins/checklist.plugin.d.ts +7 -7
- package/app/plugins/code.plugin.d.ts +9 -9
- package/app/plugins/configs/mention-plugin.config.d.ts +13 -12
- package/app/plugins/configs/screen-record-plugin.config.d.ts +7 -7
- package/app/plugins/mention.plugin.d.ts +15 -12
- package/app/plugins/screen-record.plugin.d.ts +11 -11
- package/app/services/froala-loader.service.d.ts +17 -17
- package/app/utils/loader.d.ts +7 -7
- package/bundles/firestitch-html-editor.umd.js +1031 -1018
- package/bundles/firestitch-html-editor.umd.js.map +1 -1
- package/bundles/firestitch-html-editor.umd.min.js +2 -2
- package/bundles/firestitch-html-editor.umd.min.js.map +1 -1
- package/esm2015/app/classes/plugin.js +4 -4
- package/esm2015/app/components/html-editor/html-editor.component.js +444 -444
- package/esm2015/app/components/html-renderer/html-renderer.component.js +33 -33
- package/esm2015/app/consts/paragraph-buttons.const.js +8 -8
- package/esm2015/app/consts/rich-buttons.const.js +6 -6
- package/esm2015/app/consts/text-buttons.const.js +18 -18
- package/esm2015/app/fs-html-editor.module.js +56 -56
- package/esm2015/app/injects/config.inject.js +3 -3
- package/esm2015/app/plugins/checklist.plugin.js +34 -34
- package/esm2015/app/plugins/code.plugin.js +62 -62
- package/esm2015/app/plugins/configs/mention-plugin.config.js +1 -1
- package/esm2015/app/plugins/mention.plugin.js +87 -73
- package/esm2015/app/plugins/screen-record.plugin.js +91 -91
- package/esm2015/app/services/froala-loader.service.js +80 -80
- package/esm2015/app/utils/loader.js +82 -82
- package/esm2015/firestitch-html-editor.js +8 -8
- package/esm2015/public_api.js +11 -11
- package/esm5/app/classes/plugin.js +8 -8
- package/esm5/app/components/html-editor/html-editor.component.js +470 -470
- package/esm5/app/components/html-renderer/html-renderer.component.js +38 -38
- package/esm5/app/consts/paragraph-buttons.const.js +8 -8
- package/esm5/app/consts/rich-buttons.const.js +6 -6
- package/esm5/app/consts/text-buttons.const.js +18 -18
- package/esm5/app/fs-html-editor.module.js +61 -61
- package/esm5/app/injects/config.inject.js +3 -3
- package/esm5/app/plugins/checklist.plugin.js +40 -40
- package/esm5/app/plugins/code.plugin.js +69 -69
- package/esm5/app/plugins/configs/mention-plugin.config.js +1 -1
- package/esm5/app/plugins/mention.plugin.js +93 -79
- package/esm5/app/plugins/screen-record.plugin.js +105 -105
- package/esm5/app/services/froala-loader.service.js +95 -95
- package/esm5/app/utils/loader.js +82 -82
- package/esm5/firestitch-html-editor.js +8 -8
- package/esm5/public_api.js +11 -11
- package/fesm2015/firestitch-html-editor.js +950 -936
- package/fesm2015/firestitch-html-editor.js.map +1 -1
- package/fesm5/firestitch-html-editor.js +1030 -1016
- package/fesm5/firestitch-html-editor.js.map +1 -1
- package/firestitch-html-editor.d.ts +9 -9
- package/firestitch-html-editor.metadata.json +1 -1
- package/package.json +1 -1
- package/public_api.d.ts +16 -16
|
@@ -9,1051 +9,1065 @@ import { shareReplay, map, tap, concatMap, switchMap, filter, startWith, distinc
|
|
|
9
9
|
import { merge, debounce } from 'lodash-es';
|
|
10
10
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
11
11
|
import Tribute from 'tributejs';
|
|
12
|
+
import { guid } from '@firestitch/common';
|
|
12
13
|
|
|
13
|
-
var RichButtons = [
|
|
14
|
-
'insertTable',
|
|
15
|
-
'insertImage',
|
|
16
|
-
'insertLink',
|
|
17
|
-
'insertVideo',
|
|
14
|
+
var RichButtons = [
|
|
15
|
+
'insertTable',
|
|
16
|
+
'insertImage',
|
|
17
|
+
'insertLink',
|
|
18
|
+
'insertVideo',
|
|
18
19
|
];
|
|
19
20
|
|
|
20
|
-
var TextButtons = [
|
|
21
|
-
'paragraphFormat',
|
|
22
|
-
'code',
|
|
23
|
-
'bold',
|
|
24
|
-
'italic',
|
|
25
|
-
'underline',
|
|
26
|
-
'strikeThrough',
|
|
27
|
-
'subscript',
|
|
28
|
-
'superscript',
|
|
29
|
-
'fontFamily',
|
|
30
|
-
'fontSize',
|
|
31
|
-
'textColor',
|
|
32
|
-
'backgroundColor',
|
|
33
|
-
'inlineClass',
|
|
34
|
-
'inlineStyle',
|
|
35
|
-
'clearFormatting',
|
|
36
|
-
'quote',
|
|
21
|
+
var TextButtons = [
|
|
22
|
+
'paragraphFormat',
|
|
23
|
+
'code',
|
|
24
|
+
'bold',
|
|
25
|
+
'italic',
|
|
26
|
+
'underline',
|
|
27
|
+
'strikeThrough',
|
|
28
|
+
'subscript',
|
|
29
|
+
'superscript',
|
|
30
|
+
'fontFamily',
|
|
31
|
+
'fontSize',
|
|
32
|
+
'textColor',
|
|
33
|
+
'backgroundColor',
|
|
34
|
+
'inlineClass',
|
|
35
|
+
'inlineStyle',
|
|
36
|
+
'clearFormatting',
|
|
37
|
+
'quote',
|
|
37
38
|
];
|
|
38
39
|
|
|
39
|
-
var ParagraphButtons = [
|
|
40
|
-
'align',
|
|
41
|
-
'formatOL',
|
|
42
|
-
'formatUL',
|
|
43
|
-
'checklist',
|
|
44
|
-
'indent',
|
|
45
|
-
'outdent',
|
|
40
|
+
var ParagraphButtons = [
|
|
41
|
+
'align',
|
|
42
|
+
'formatOL',
|
|
43
|
+
'formatUL',
|
|
44
|
+
'checklist',
|
|
45
|
+
'indent',
|
|
46
|
+
'outdent',
|
|
46
47
|
];
|
|
47
48
|
|
|
48
|
-
var FS_HTML_EDITOR_DEFAULT_CONFIG = new InjectionToken('fs-html-editor.default-config');
|
|
49
|
+
var FS_HTML_EDITOR_DEFAULT_CONFIG = new InjectionToken('fs-html-editor.default-config');
|
|
49
50
|
var FS_HTML_EDITOR_CONFIG = new InjectionToken('fs-html-editor.config');
|
|
50
51
|
|
|
51
|
-
function resourceLoaderFactory() {
|
|
52
|
-
var resourceBase = '/assets/js/froala/';
|
|
53
|
-
var stylesBase = '/assets/css/';
|
|
54
|
-
var head = document.getElementsByTagName('head')[0];
|
|
55
|
-
var files = new Map();
|
|
56
|
-
var resourcePaths = {
|
|
57
|
-
froala: 'froala_editor.min.js',
|
|
58
|
-
align: 'plugins/align.min.js',
|
|
59
|
-
colors: 'plugins/colors.min.js',
|
|
60
|
-
image: 'plugins/image.min.js',
|
|
61
|
-
link: 'plugins/link.min.js',
|
|
62
|
-
lists: 'plugins/lists.min.js',
|
|
63
|
-
paragraph_format: 'plugins/paragraph_format.min.js',
|
|
64
|
-
table: 'plugins/table.min.js',
|
|
65
|
-
url: 'plugins/url.min.js',
|
|
66
|
-
video: 'plugins/video.min.js',
|
|
67
|
-
quote: 'plugins/quote.min.js',
|
|
68
|
-
draggable: 'plugins/draggable.min.js',
|
|
69
|
-
font_size: 'plugins/font_size.min.js',
|
|
70
|
-
};
|
|
71
|
-
var stylesPaths = {
|
|
72
|
-
froala: 'froala_editor.pkgd.min.css',
|
|
73
|
-
};
|
|
74
|
-
var loadResource = function (scriptPath) {
|
|
75
|
-
if (!files.has(scriptPath)) {
|
|
76
|
-
var obs$ = new Observable(function (obs) {
|
|
77
|
-
var script = document.createElement('script');
|
|
78
|
-
script.src = scriptPath;
|
|
79
|
-
head.appendChild(script);
|
|
80
|
-
script.onload = function () {
|
|
81
|
-
obs.next();
|
|
82
|
-
obs.complete();
|
|
83
|
-
};
|
|
84
|
-
script.onerror = function (err) {
|
|
85
|
-
obs.error(err);
|
|
86
|
-
};
|
|
87
|
-
})
|
|
88
|
-
.pipe(shareReplay(1));
|
|
89
|
-
files.set(scriptPath, obs$);
|
|
90
|
-
}
|
|
91
|
-
return files.get(scriptPath);
|
|
92
|
-
};
|
|
93
|
-
var loadStyles = function (stylePath) {
|
|
94
|
-
if (!files.has(stylePath)) {
|
|
95
|
-
var obs$ = new Observable(function (obs) {
|
|
96
|
-
var style = document.createElement('link');
|
|
97
|
-
style.id = stylePath;
|
|
98
|
-
style.rel = 'stylesheet';
|
|
99
|
-
style.href = "" + stylePath;
|
|
100
|
-
head.appendChild(style);
|
|
101
|
-
style.onload = function () {
|
|
102
|
-
obs.next();
|
|
103
|
-
obs.complete();
|
|
104
|
-
};
|
|
105
|
-
style.onerror = function (err) {
|
|
106
|
-
obs.error(err);
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
files.set(stylePath, obs$);
|
|
110
|
-
}
|
|
111
|
-
return files.get(stylePath);
|
|
112
|
-
};
|
|
113
|
-
return {
|
|
114
|
-
setResourceBase: function (path) {
|
|
115
|
-
resourceBase = path;
|
|
116
|
-
},
|
|
117
|
-
setStylesBase: function (path) {
|
|
118
|
-
stylesBase = path;
|
|
119
|
-
},
|
|
120
|
-
loadResource: function (resourceName) {
|
|
121
|
-
var path = resourcePaths[resourceName] || resourceName;
|
|
122
|
-
return loadResource(resourceBase + path);
|
|
123
|
-
},
|
|
124
|
-
loadStyles: function (resourceName) {
|
|
125
|
-
var path = stylesPaths[resourceName] || resourceName;
|
|
126
|
-
return loadStyles(stylesBase + path);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}
|
|
52
|
+
function resourceLoaderFactory() {
|
|
53
|
+
var resourceBase = '/assets/js/froala/';
|
|
54
|
+
var stylesBase = '/assets/css/';
|
|
55
|
+
var head = document.getElementsByTagName('head')[0];
|
|
56
|
+
var files = new Map();
|
|
57
|
+
var resourcePaths = {
|
|
58
|
+
froala: 'froala_editor.min.js',
|
|
59
|
+
align: 'plugins/align.min.js',
|
|
60
|
+
colors: 'plugins/colors.min.js',
|
|
61
|
+
image: 'plugins/image.min.js',
|
|
62
|
+
link: 'plugins/link.min.js',
|
|
63
|
+
lists: 'plugins/lists.min.js',
|
|
64
|
+
paragraph_format: 'plugins/paragraph_format.min.js',
|
|
65
|
+
table: 'plugins/table.min.js',
|
|
66
|
+
url: 'plugins/url.min.js',
|
|
67
|
+
video: 'plugins/video.min.js',
|
|
68
|
+
quote: 'plugins/quote.min.js',
|
|
69
|
+
draggable: 'plugins/draggable.min.js',
|
|
70
|
+
font_size: 'plugins/font_size.min.js',
|
|
71
|
+
};
|
|
72
|
+
var stylesPaths = {
|
|
73
|
+
froala: 'froala_editor.pkgd.min.css',
|
|
74
|
+
};
|
|
75
|
+
var loadResource = function (scriptPath) {
|
|
76
|
+
if (!files.has(scriptPath)) {
|
|
77
|
+
var obs$ = new Observable(function (obs) {
|
|
78
|
+
var script = document.createElement('script');
|
|
79
|
+
script.src = scriptPath;
|
|
80
|
+
head.appendChild(script);
|
|
81
|
+
script.onload = function () {
|
|
82
|
+
obs.next();
|
|
83
|
+
obs.complete();
|
|
84
|
+
};
|
|
85
|
+
script.onerror = function (err) {
|
|
86
|
+
obs.error(err);
|
|
87
|
+
};
|
|
88
|
+
})
|
|
89
|
+
.pipe(shareReplay(1));
|
|
90
|
+
files.set(scriptPath, obs$);
|
|
91
|
+
}
|
|
92
|
+
return files.get(scriptPath);
|
|
93
|
+
};
|
|
94
|
+
var loadStyles = function (stylePath) {
|
|
95
|
+
if (!files.has(stylePath)) {
|
|
96
|
+
var obs$ = new Observable(function (obs) {
|
|
97
|
+
var style = document.createElement('link');
|
|
98
|
+
style.id = stylePath;
|
|
99
|
+
style.rel = 'stylesheet';
|
|
100
|
+
style.href = "" + stylePath;
|
|
101
|
+
head.appendChild(style);
|
|
102
|
+
style.onload = function () {
|
|
103
|
+
obs.next();
|
|
104
|
+
obs.complete();
|
|
105
|
+
};
|
|
106
|
+
style.onerror = function (err) {
|
|
107
|
+
obs.error(err);
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
files.set(stylePath, obs$);
|
|
111
|
+
}
|
|
112
|
+
return files.get(stylePath);
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
setResourceBase: function (path) {
|
|
116
|
+
resourceBase = path;
|
|
117
|
+
},
|
|
118
|
+
setStylesBase: function (path) {
|
|
119
|
+
stylesBase = path;
|
|
120
|
+
},
|
|
121
|
+
loadResource: function (resourceName) {
|
|
122
|
+
var path = resourcePaths[resourceName] || resourceName;
|
|
123
|
+
return loadResource(resourceBase + path);
|
|
124
|
+
},
|
|
125
|
+
loadStyles: function (resourceName) {
|
|
126
|
+
var path = stylesPaths[resourceName] || resourceName;
|
|
127
|
+
return loadStyles(stylesBase + path);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
130
131
|
var ResourceLoader = resourceLoaderFactory();
|
|
131
132
|
|
|
132
|
-
var FsFroalaLoaderService = /** @class */ (function () {
|
|
133
|
-
function FsFroalaLoaderService(_defaultConfig) {
|
|
134
|
-
this._defaultConfig = _defaultConfig;
|
|
135
|
-
this._froalaLoaded = new BehaviorSubject(false);
|
|
136
|
-
this._defaultPluginsLoaded = new BehaviorSubject(false);
|
|
137
|
-
this._loaded$ = combineLatest([this._froalaLoaded, this._defaultPluginsLoaded])
|
|
138
|
-
.pipe(map(function (_a) {
|
|
139
|
-
var _b = __read(_a, 2), FroalaReady = _b[0], pluginsRead = _b[1];
|
|
140
|
-
return pluginsRead && FroalaReady;
|
|
141
|
-
}), shareReplay(1));
|
|
142
|
-
if (this._defaultConfig) {
|
|
143
|
-
if (this._defaultConfig.assetsJSPath) {
|
|
144
|
-
ResourceLoader.setResourceBase(this._defaultConfig.assetsJSPath);
|
|
145
|
-
}
|
|
146
|
-
if (this._defaultConfig.assetsCSSPath) {
|
|
147
|
-
ResourceLoader.setStylesBase(this._defaultConfig.assetsCSSPath);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
this._load();
|
|
151
|
-
}
|
|
152
|
-
Object.defineProperty(FsFroalaLoaderService.prototype, "loaded$", {
|
|
153
|
-
get: function () {
|
|
154
|
-
return this._loaded$;
|
|
155
|
-
},
|
|
156
|
-
enumerable: true,
|
|
157
|
-
configurable: true
|
|
158
|
-
});
|
|
159
|
-
Object.defineProperty(FsFroalaLoaderService.prototype, "ready", {
|
|
160
|
-
get: function () {
|
|
161
|
-
return this._froalaLoaded.getValue() && this._defaultPluginsLoaded.getValue();
|
|
162
|
-
},
|
|
163
|
-
enumerable: true,
|
|
164
|
-
configurable: true
|
|
165
|
-
});
|
|
166
|
-
Object.defineProperty(FsFroalaLoaderService.prototype, "FroalaEditor", {
|
|
167
|
-
get: function () {
|
|
168
|
-
return this._FroalaEditor;
|
|
169
|
-
},
|
|
170
|
-
enumerable: true,
|
|
171
|
-
configurable: true
|
|
172
|
-
});
|
|
173
|
-
FsFroalaLoaderService.prototype._load = function () {
|
|
174
|
-
var _this = this;
|
|
175
|
-
combineLatest([
|
|
176
|
-
ResourceLoader.loadResource('froala'),
|
|
177
|
-
ResourceLoader.loadStyles('froala')
|
|
178
|
-
])
|
|
179
|
-
.pipe(tap(function () {
|
|
180
|
-
_this._FroalaEditor = window.FroalaEditor;
|
|
181
|
-
_this._froalaDone();
|
|
182
|
-
}), concatMap(function () {
|
|
183
|
-
return _this._loadPlugins();
|
|
184
|
-
}), tap(function () {
|
|
185
|
-
_this._defaultPluginsDone();
|
|
186
|
-
}))
|
|
187
|
-
.subscribe();
|
|
188
|
-
};
|
|
189
|
-
FsFroalaLoaderService.prototype._loadPlugins = function () {
|
|
190
|
-
var imports = this._defaultConfig
|
|
191
|
-
.defaultPlugins
|
|
192
|
-
.reduce(function (acc, pluginName) {
|
|
193
|
-
var import$ = ResourceLoader.loadResource(pluginName);
|
|
194
|
-
acc.push(import$);
|
|
195
|
-
return acc;
|
|
196
|
-
}, []);
|
|
197
|
-
return combineLatest(imports);
|
|
198
|
-
};
|
|
199
|
-
FsFroalaLoaderService.prototype._froalaDone = function () {
|
|
200
|
-
this._froalaLoaded.next(true);
|
|
201
|
-
};
|
|
202
|
-
FsFroalaLoaderService.prototype._defaultPluginsDone = function () {
|
|
203
|
-
this._defaultPluginsLoaded.next(true);
|
|
204
|
-
};
|
|
205
|
-
FsFroalaLoaderService.ctorParameters = function () { return [
|
|
206
|
-
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [FS_HTML_EDITOR_CONFIG,] }] }
|
|
207
|
-
]; };
|
|
208
|
-
FsFroalaLoaderService.ɵprov = ɵɵdefineInjectable({ factory: function FsFroalaLoaderService_Factory() { return new FsFroalaLoaderService(ɵɵinject(FS_HTML_EDITOR_CONFIG, 8)); }, token: FsFroalaLoaderService, providedIn: "root" });
|
|
209
|
-
FsFroalaLoaderService = __decorate([
|
|
210
|
-
Injectable({
|
|
211
|
-
providedIn: 'root',
|
|
212
|
-
}),
|
|
213
|
-
__param(0, Optional()), __param(0, Inject(FS_HTML_EDITOR_CONFIG)),
|
|
214
|
-
__metadata("design:paramtypes", [Object])
|
|
215
|
-
], FsFroalaLoaderService);
|
|
216
|
-
return FsFroalaLoaderService;
|
|
133
|
+
var FsFroalaLoaderService = /** @class */ (function () {
|
|
134
|
+
function FsFroalaLoaderService(_defaultConfig) {
|
|
135
|
+
this._defaultConfig = _defaultConfig;
|
|
136
|
+
this._froalaLoaded = new BehaviorSubject(false);
|
|
137
|
+
this._defaultPluginsLoaded = new BehaviorSubject(false);
|
|
138
|
+
this._loaded$ = combineLatest([this._froalaLoaded, this._defaultPluginsLoaded])
|
|
139
|
+
.pipe(map(function (_a) {
|
|
140
|
+
var _b = __read(_a, 2), FroalaReady = _b[0], pluginsRead = _b[1];
|
|
141
|
+
return pluginsRead && FroalaReady;
|
|
142
|
+
}), shareReplay(1));
|
|
143
|
+
if (this._defaultConfig) {
|
|
144
|
+
if (this._defaultConfig.assetsJSPath) {
|
|
145
|
+
ResourceLoader.setResourceBase(this._defaultConfig.assetsJSPath);
|
|
146
|
+
}
|
|
147
|
+
if (this._defaultConfig.assetsCSSPath) {
|
|
148
|
+
ResourceLoader.setStylesBase(this._defaultConfig.assetsCSSPath);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
this._load();
|
|
152
|
+
}
|
|
153
|
+
Object.defineProperty(FsFroalaLoaderService.prototype, "loaded$", {
|
|
154
|
+
get: function () {
|
|
155
|
+
return this._loaded$;
|
|
156
|
+
},
|
|
157
|
+
enumerable: true,
|
|
158
|
+
configurable: true
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(FsFroalaLoaderService.prototype, "ready", {
|
|
161
|
+
get: function () {
|
|
162
|
+
return this._froalaLoaded.getValue() && this._defaultPluginsLoaded.getValue();
|
|
163
|
+
},
|
|
164
|
+
enumerable: true,
|
|
165
|
+
configurable: true
|
|
166
|
+
});
|
|
167
|
+
Object.defineProperty(FsFroalaLoaderService.prototype, "FroalaEditor", {
|
|
168
|
+
get: function () {
|
|
169
|
+
return this._FroalaEditor;
|
|
170
|
+
},
|
|
171
|
+
enumerable: true,
|
|
172
|
+
configurable: true
|
|
173
|
+
});
|
|
174
|
+
FsFroalaLoaderService.prototype._load = function () {
|
|
175
|
+
var _this = this;
|
|
176
|
+
combineLatest([
|
|
177
|
+
ResourceLoader.loadResource('froala'),
|
|
178
|
+
ResourceLoader.loadStyles('froala')
|
|
179
|
+
])
|
|
180
|
+
.pipe(tap(function () {
|
|
181
|
+
_this._FroalaEditor = window.FroalaEditor;
|
|
182
|
+
_this._froalaDone();
|
|
183
|
+
}), concatMap(function () {
|
|
184
|
+
return _this._loadPlugins();
|
|
185
|
+
}), tap(function () {
|
|
186
|
+
_this._defaultPluginsDone();
|
|
187
|
+
}))
|
|
188
|
+
.subscribe();
|
|
189
|
+
};
|
|
190
|
+
FsFroalaLoaderService.prototype._loadPlugins = function () {
|
|
191
|
+
var imports = this._defaultConfig
|
|
192
|
+
.defaultPlugins
|
|
193
|
+
.reduce(function (acc, pluginName) {
|
|
194
|
+
var import$ = ResourceLoader.loadResource(pluginName);
|
|
195
|
+
acc.push(import$);
|
|
196
|
+
return acc;
|
|
197
|
+
}, []);
|
|
198
|
+
return combineLatest(imports);
|
|
199
|
+
};
|
|
200
|
+
FsFroalaLoaderService.prototype._froalaDone = function () {
|
|
201
|
+
this._froalaLoaded.next(true);
|
|
202
|
+
};
|
|
203
|
+
FsFroalaLoaderService.prototype._defaultPluginsDone = function () {
|
|
204
|
+
this._defaultPluginsLoaded.next(true);
|
|
205
|
+
};
|
|
206
|
+
FsFroalaLoaderService.ctorParameters = function () { return [
|
|
207
|
+
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [FS_HTML_EDITOR_CONFIG,] }] }
|
|
208
|
+
]; };
|
|
209
|
+
FsFroalaLoaderService.ɵprov = ɵɵdefineInjectable({ factory: function FsFroalaLoaderService_Factory() { return new FsFroalaLoaderService(ɵɵinject(FS_HTML_EDITOR_CONFIG, 8)); }, token: FsFroalaLoaderService, providedIn: "root" });
|
|
210
|
+
FsFroalaLoaderService = __decorate([
|
|
211
|
+
Injectable({
|
|
212
|
+
providedIn: 'root',
|
|
213
|
+
}),
|
|
214
|
+
__param(0, Optional()), __param(0, Inject(FS_HTML_EDITOR_CONFIG)),
|
|
215
|
+
__metadata("design:paramtypes", [Object])
|
|
216
|
+
], FsFroalaLoaderService);
|
|
217
|
+
return FsFroalaLoaderService;
|
|
217
218
|
}());
|
|
218
219
|
|
|
219
|
-
var FsHtmlEditorComponent = /** @class */ (function () {
|
|
220
|
-
function FsHtmlEditorComponent(_defaultConfig, _cdRef, _fr) {
|
|
221
|
-
this._defaultConfig = _defaultConfig;
|
|
222
|
-
this._cdRef = _cdRef;
|
|
223
|
-
this._fr = _fr;
|
|
224
|
-
this.classFocused = false;
|
|
225
|
-
this.classDisabled = false;
|
|
226
|
-
this.config = {};
|
|
227
|
-
this.initialized = false;
|
|
228
|
-
this._initialize$ = new ReplaySubject();
|
|
229
|
-
this._froalaReady$ = new BehaviorSubject(null);
|
|
230
|
-
this._destroy$ = new Subject();
|
|
231
|
-
this.onChange = function (data) { };
|
|
232
|
-
this.onTouched = function () { };
|
|
233
|
-
}
|
|
234
|
-
FsHtmlEditorComponent_1 = FsHtmlEditorComponent;
|
|
235
|
-
Object.defineProperty(FsHtmlEditorComponent.prototype, "el", {
|
|
236
|
-
get: function () {
|
|
237
|
-
return this.elRef.nativeElement;
|
|
238
|
-
},
|
|
239
|
-
enumerable: true,
|
|
240
|
-
configurable: true
|
|
241
|
-
});
|
|
242
|
-
Object.defineProperty(FsHtmlEditorComponent.prototype, "html", {
|
|
243
|
-
get: function () {
|
|
244
|
-
return this._html;
|
|
245
|
-
},
|
|
246
|
-
enumerable: true,
|
|
247
|
-
configurable: true
|
|
248
|
-
});
|
|
249
|
-
Object.defineProperty(FsHtmlEditorComponent.prototype, "editor", {
|
|
250
|
-
get: function () {
|
|
251
|
-
return this._editor;
|
|
252
|
-
},
|
|
253
|
-
enumerable: true,
|
|
254
|
-
configurable: true
|
|
255
|
-
});
|
|
256
|
-
Object.defineProperty(FsHtmlEditorComponent.prototype, "froalaLoaded$", {
|
|
257
|
-
get: function () {
|
|
258
|
-
return this._fr.loaded$;
|
|
259
|
-
},
|
|
260
|
-
enumerable: true,
|
|
261
|
-
configurable: true
|
|
262
|
-
});
|
|
263
|
-
FsHtmlEditorComponent.prototype.ngOnInit = function () {
|
|
264
|
-
this.config = this.config || {};
|
|
265
|
-
this.config.autofocus = this.config.autofocus !== false && !this.config.disabled;
|
|
266
|
-
this.initialized = !this.config.initOnClick;
|
|
267
|
-
this._listenLazyInit();
|
|
268
|
-
};
|
|
269
|
-
FsHtmlEditorComponent.prototype.ngAfterViewInit = function () {
|
|
270
|
-
if (!this.config.initOnClick || !this.hasContent()) {
|
|
271
|
-
this.initialized = true;
|
|
272
|
-
this._initialize$.next();
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
FsHtmlEditorComponent.prototype.hasContent = function () {
|
|
276
|
-
var el = document.createElement('div');
|
|
277
|
-
if (el.querySelector('img')) {
|
|
278
|
-
return true;
|
|
279
|
-
}
|
|
280
|
-
el.innerHTML = this._html;
|
|
281
|
-
return !!el.innerText.length;
|
|
282
|
-
};
|
|
283
|
-
FsHtmlEditorComponent.prototype.initialize = function (options) {
|
|
284
|
-
var _this = this;
|
|
285
|
-
if (options === void 0) { options = {}; }
|
|
286
|
-
var config = this._createConfig();
|
|
287
|
-
this._initPlugins(config);
|
|
288
|
-
// this.el.innerHTML = this._html || '';
|
|
289
|
-
this._editor = new this._fr.FroalaEditor(this.el, this._createOptions(), function () {
|
|
290
|
-
_this._froalaReady$.next({ config: config, options: options });
|
|
291
|
-
});
|
|
292
|
-
};
|
|
293
|
-
FsHtmlEditorComponent.prototype._processImageUpload = function (blob) {
|
|
294
|
-
var _this = this;
|
|
295
|
-
var processor = new FileProcessor();
|
|
296
|
-
var file = new FsFile(blob);
|
|
297
|
-
return processor.process([file], this.config.image)
|
|
298
|
-
.pipe(switchMap(function (_a) {
|
|
299
|
-
var _b = __read(_a, 1), f = _b[0];
|
|
300
|
-
return _this.config.image.upload(f.file);
|
|
301
|
-
}));
|
|
302
|
-
};
|
|
303
|
-
FsHtmlEditorComponent.prototype._getTextNode = function (node) {
|
|
304
|
-
if (node) {
|
|
305
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
306
|
-
return node;
|
|
307
|
-
}
|
|
308
|
-
if (node.childNodes) {
|
|
309
|
-
return this._getTextNode(node.childNodes[0]);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
FsHtmlEditorComponent.prototype.uninitializedClick = function (event) {
|
|
314
|
-
if (!event.defaultPrevented) {
|
|
315
|
-
var target_1 = event.target;
|
|
316
|
-
if (target_1 && target_1.nodeName === 'A' && target_1.getAttribute('href')) {
|
|
317
|
-
var targetTarget_1 = target_1.getAttribute('target');
|
|
318
|
-
target_1.setAttribute('target', '_blank');
|
|
319
|
-
setTimeout(function () {
|
|
320
|
-
if (targetTarget_1) {
|
|
321
|
-
target_1.setAttribute('target', targetTarget_1);
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
target_1.removeAttribute('target');
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
if (this.config.initClick) {
|
|
330
|
-
this.config.initClick(event);
|
|
331
|
-
}
|
|
332
|
-
this._initialize$.next();
|
|
333
|
-
this.initialized = true;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
FsHtmlEditorComponent.prototype.updateSize = function () {
|
|
338
|
-
// Hack: To trigger the toolbar button size modes
|
|
339
|
-
window.dispatchEvent(new Event('resize'));
|
|
340
|
-
};
|
|
341
|
-
FsHtmlEditorComponent.prototype.validate = function (control) {
|
|
342
|
-
var err = {};
|
|
343
|
-
if (this.config.maxLength && this._html) {
|
|
344
|
-
var maxLength = this.config.maxLength;
|
|
345
|
-
var length_1 = this._html.length;
|
|
346
|
-
if (length_1 > maxLength) {
|
|
347
|
-
err.maxLengthError = "Must be " + maxLength + " characters or fewer. You entered " + length_1 + " characters.";
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
return Object.keys(err).length ? err : null;
|
|
351
|
-
};
|
|
352
|
-
FsHtmlEditorComponent.prototype.focus = function (options) {
|
|
353
|
-
options = options ? options : {};
|
|
354
|
-
if (options.cursorPosition === 'end') {
|
|
355
|
-
this.editor.selection.setAtEnd(this.editor.$el.get(0));
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
this.editor.selection.setAtStart(this.editor.$el.get(0));
|
|
359
|
-
}
|
|
360
|
-
this.editor.selection.restore();
|
|
361
|
-
var elSelection = this.editor.selection.element();
|
|
362
|
-
if (elSelection) {
|
|
363
|
-
elSelection.scrollIntoView({ block: 'center' });
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
FsHtmlEditorComponent.prototype.clear = function () {
|
|
367
|
-
this.writeValue('');
|
|
368
|
-
};
|
|
369
|
-
FsHtmlEditorComponent.prototype.disable = function () {
|
|
370
|
-
this.classDisabled = true;
|
|
371
|
-
};
|
|
372
|
-
FsHtmlEditorComponent.prototype.setHtml = function (html) {
|
|
373
|
-
this.writeValue(html);
|
|
374
|
-
};
|
|
375
|
-
FsHtmlEditorComponent.prototype.writeValue = function (html) {
|
|
376
|
-
this._html = html || '';
|
|
377
|
-
if (this.editor && this.editor.html) {
|
|
378
|
-
try {
|
|
379
|
-
this.editor.html.set(this._html);
|
|
380
|
-
}
|
|
381
|
-
catch (e) {
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
this._cdRef.markForCheck();
|
|
385
|
-
};
|
|
386
|
-
FsHtmlEditorComponent.prototype.registerOnChange = function (fn) {
|
|
387
|
-
this.onChange = fn;
|
|
388
|
-
};
|
|
389
|
-
FsHtmlEditorComponent.prototype.registerOnTouched = function (fn) {
|
|
390
|
-
this.onTouched = fn;
|
|
391
|
-
};
|
|
392
|
-
FsHtmlEditorComponent.prototype.ngOnDestroy = function () {
|
|
393
|
-
this._initialize$.complete();
|
|
394
|
-
this._destroy$.next();
|
|
395
|
-
this._destroy$.complete();
|
|
396
|
-
this.destroy();
|
|
397
|
-
};
|
|
398
|
-
FsHtmlEditorComponent.prototype.destroy = function () {
|
|
399
|
-
if (this.editor) {
|
|
400
|
-
this.editor.destroy();
|
|
401
|
-
}
|
|
402
|
-
this.initialized = false;
|
|
403
|
-
this._cdRef.markForCheck();
|
|
404
|
-
this.el.innerHTML = '';
|
|
405
|
-
};
|
|
406
|
-
FsHtmlEditorComponent.prototype._createConfig = function () {
|
|
407
|
-
return merge({ froalaConfig: {} }, this._defaultConfig, this.config);
|
|
408
|
-
};
|
|
409
|
-
FsHtmlEditorComponent.prototype._change = function (html) {
|
|
410
|
-
// this._html = html;
|
|
411
|
-
this.onChange(html);
|
|
412
|
-
};
|
|
413
|
-
FsHtmlEditorComponent.prototype._initPlugins = function (config) {
|
|
414
|
-
var _this = this;
|
|
415
|
-
(config.plugins || []).forEach(function (plugin) {
|
|
416
|
-
_this._fr.FroalaEditor.PLUGINS[plugin.config.name] = function (editor) {
|
|
417
|
-
plugin.editor = editor;
|
|
418
|
-
plugin.initialize();
|
|
419
|
-
return plugin;
|
|
420
|
-
};
|
|
421
|
-
(plugin.config.buttons || []).forEach(function (button) {
|
|
422
|
-
_this._fr.FroalaEditor.DefineIcon(button.name, {
|
|
423
|
-
NAME: button.name,
|
|
424
|
-
PATH: button.svgPath,
|
|
425
|
-
});
|
|
426
|
-
_this._fr.FroalaEditor.RegisterCommand(button.name, {
|
|
427
|
-
icon: button.name,
|
|
428
|
-
title: button.tooltip,
|
|
429
|
-
undo: button.undo,
|
|
430
|
-
focus: button.focus,
|
|
431
|
-
showOnMobile: button.showOnMobile,
|
|
432
|
-
refreshAfterCallback: button.refreshAfterCallback,
|
|
433
|
-
callback: function () {
|
|
434
|
-
if (button.click) {
|
|
435
|
-
button.click(this);
|
|
436
|
-
}
|
|
437
|
-
},
|
|
438
|
-
refresh: function (button) {
|
|
439
|
-
if (button.refresh) {
|
|
440
|
-
button.refresh(this, button);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
});
|
|
445
|
-
});
|
|
446
|
-
};
|
|
447
|
-
FsHtmlEditorComponent.prototype._createOptions = function () {
|
|
448
|
-
var config = this._createConfig();
|
|
449
|
-
return merge(
|
|
450
|
-
// For some reason editor store somewhere pointer on default config object and dublicate options each time on init
|
|
451
|
-
// Extra merge level fixed this problem and allow to init config properly without legacy data
|
|
452
|
-
{}, {
|
|
453
|
-
key: config.activationKey,
|
|
454
|
-
placeholderText: config.placeholder,
|
|
455
|
-
linkAlwaysBlank: true,
|
|
456
|
-
tabSpaces: 2,
|
|
457
|
-
typingTimer: 250,
|
|
458
|
-
tooltips: false,
|
|
459
|
-
wordPasteModal: false,
|
|
460
|
-
imageDefaultWidth: 0,
|
|
461
|
-
imageDefaultAlign: 'left',
|
|
462
|
-
quickInsertEnabled: false,
|
|
463
|
-
paragraphDefaultSelection: 'Format',
|
|
464
|
-
videoUpload: false,
|
|
465
|
-
paragraphFormat: {
|
|
466
|
-
N: 'Normal',
|
|
467
|
-
H1: 'Heading 1',
|
|
468
|
-
H2: 'Heading 2',
|
|
469
|
-
H3: 'Heading 3',
|
|
470
|
-
H4: 'Heading 4',
|
|
471
|
-
BLOCKQUOTE: 'Quote',
|
|
472
|
-
},
|
|
473
|
-
paragraphFormatSelection: true,
|
|
474
|
-
toolbarButtonsXS: {
|
|
475
|
-
moreText: {
|
|
476
|
-
buttons: TextButtons,
|
|
477
|
-
buttonsVisible: 1,
|
|
478
|
-
},
|
|
479
|
-
moreParagraph: {
|
|
480
|
-
buttons: ParagraphButtons,
|
|
481
|
-
buttonsVisible: 2,
|
|
482
|
-
},
|
|
483
|
-
moreRich: {
|
|
484
|
-
buttons: RichButtons,
|
|
485
|
-
buttonsVisible: 0,
|
|
486
|
-
},
|
|
487
|
-
},
|
|
488
|
-
toolbarButtons: {
|
|
489
|
-
moreText: {
|
|
490
|
-
buttons: TextButtons,
|
|
491
|
-
buttonsVisible: 3,
|
|
492
|
-
},
|
|
493
|
-
moreParagraph: {
|
|
494
|
-
buttons: ParagraphButtons,
|
|
495
|
-
buttonsVisible: 5,
|
|
496
|
-
},
|
|
497
|
-
moreRich: {
|
|
498
|
-
buttons: RichButtons,
|
|
499
|
-
buttonsVisible: 3,
|
|
500
|
-
},
|
|
501
|
-
},
|
|
502
|
-
}, config.froalaConfig);
|
|
503
|
-
};
|
|
504
|
-
FsHtmlEditorComponent.prototype._listenLazyInit = function () {
|
|
505
|
-
var _this = this;
|
|
506
|
-
this.froalaLoaded$
|
|
507
|
-
.pipe(filter(function (ready) { return ready; }), switchMap(function () { return _this._initialize$; }), tap(function () {
|
|
508
|
-
var selection = window.getSelection();
|
|
509
|
-
var options = {};
|
|
510
|
-
if (selection.baseNode) {
|
|
511
|
-
options.selection = {
|
|
512
|
-
node: selection.baseNode.nodeValue,
|
|
513
|
-
offset: selection.baseOffset,
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
_this.initialize(options);
|
|
517
|
-
}), switchMap(function () { return _this._froalaReady$; }), filter(function (data) { return !!data; }), tap(function (_a) {
|
|
518
|
-
var config = _a.config, options = _a.options;
|
|
519
|
-
_this._setupFroala(config, options);
|
|
520
|
-
}))
|
|
521
|
-
.subscribe();
|
|
522
|
-
};
|
|
523
|
-
FsHtmlEditorComponent.prototype._contentChanged = function () {
|
|
524
|
-
var editorHTML = this._editor.html.get();
|
|
525
|
-
if (this.html !== editorHTML) {
|
|
526
|
-
this._change(editorHTML);
|
|
527
|
-
}
|
|
528
|
-
};
|
|
529
|
-
FsHtmlEditorComponent.prototype._setupFroala = function (config, options) {
|
|
530
|
-
var _this = this;
|
|
531
|
-
this._cdRef.markForCheck();
|
|
532
|
-
this.setHtml(this._html);
|
|
533
|
-
if (config.disabled) {
|
|
534
|
-
this.disable();
|
|
535
|
-
}
|
|
536
|
-
if (config.froalaConfig.events) {
|
|
537
|
-
if (config.froalaConfig.events.initialized) {
|
|
538
|
-
config.froalaConfig.events.initialized();
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
this._editor.events.on('focus', function () {
|
|
542
|
-
_this.classFocused = true;
|
|
543
|
-
_this._cdRef.markForCheck();
|
|
544
|
-
});
|
|
545
|
-
this._editor.events.on('blur', function () {
|
|
546
|
-
_this.classFocused = false;
|
|
547
|
-
_this._cdRef.markForCheck();
|
|
548
|
-
});
|
|
549
|
-
fromEventPattern(function (handler) {
|
|
550
|
-
_this._editor.events.on('contentChanged', handler);
|
|
551
|
-
}, function () { })
|
|
552
|
-
.pipe(startWith(this._html), map(function () { return _this.editor.html.get(); }), distinctUntilChanged(), skip(1))
|
|
553
|
-
.subscribe(function () {
|
|
554
|
-
_this._contentChanged();
|
|
555
|
-
});
|
|
556
|
-
// this._editor.events.on('contentChanged', () => {
|
|
557
|
-
// console.log('test');
|
|
558
|
-
// if (!this._firstChange) {
|
|
559
|
-
// this._contentChanged();
|
|
560
|
-
// }
|
|
561
|
-
// });
|
|
562
|
-
this._editor.events.on('paste.afterCleanup', function (html) {
|
|
563
|
-
var div = document.createElement('div');
|
|
564
|
-
div.innerHTML = html;
|
|
565
|
-
div.querySelectorAll('*')
|
|
566
|
-
.forEach(function (el) {
|
|
567
|
-
for (var i = 0; i < el.attributes.length; i++) {
|
|
568
|
-
var name_1 = el.attributes[0].name;
|
|
569
|
-
if (name_1 !== 'href') {
|
|
570
|
-
el.removeAttribute(name_1);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
return div.innerHTML;
|
|
575
|
-
});
|
|
576
|
-
this._editor.events.on('keydown', function () {
|
|
577
|
-
_this.onTouched();
|
|
578
|
-
});
|
|
579
|
-
if (this.config.image && this.config.image.upload) {
|
|
580
|
-
this._editor.events.on('image.beforePasteUpload', function (image) {
|
|
581
|
-
fetch(image.getAttribute('src'))
|
|
582
|
-
.then(function (res) {
|
|
583
|
-
res.blob()
|
|
584
|
-
.then(function (blob) {
|
|
585
|
-
_this._processImageUpload(blob)
|
|
586
|
-
.pipe(takeUntil(_this._destroy$))
|
|
587
|
-
.subscribe(function (url) {
|
|
588
|
-
image.setAttribute('src', url);
|
|
589
|
-
image.removeAttribute('data-fr-image-pasted');
|
|
590
|
-
_this._contentChanged();
|
|
591
|
-
});
|
|
592
|
-
});
|
|
593
|
-
});
|
|
594
|
-
return false;
|
|
595
|
-
});
|
|
596
|
-
this._editor.events.on('image.beforeUpload', function (blobs) {
|
|
597
|
-
_this._processImageUpload(blobs[0])
|
|
598
|
-
.pipe(takeUntil(_this._destroy$))
|
|
599
|
-
.subscribe(function (url) {
|
|
600
|
-
_this.editor.image.insert(url, null, null, _this.editor.image.get());
|
|
601
|
-
});
|
|
602
|
-
return false;
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
if (this.el.querySelector('.fr-second-toolbar')) {
|
|
606
|
-
this.el.querySelector('.fr-second-toolbar').remove();
|
|
607
|
-
}
|
|
608
|
-
var selection = options.selection;
|
|
609
|
-
if (selection) {
|
|
610
|
-
var node = Array.from(this.el.querySelectorAll('.fr-element *')).find(function (node) {
|
|
611
|
-
return selection.node === node.textContent;
|
|
612
|
-
});
|
|
613
|
-
if (node) {
|
|
614
|
-
var range = document.createRange();
|
|
615
|
-
var sel = window.getSelection();
|
|
616
|
-
range.setStart(this._getTextNode(node), selection.offset);
|
|
617
|
-
range.collapse(true);
|
|
618
|
-
sel.removeAllRanges();
|
|
619
|
-
sel.addRange(range);
|
|
620
|
-
}
|
|
621
|
-
else if (this.config.autofocus) {
|
|
622
|
-
this.focus();
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
else if (this.config.autofocus) {
|
|
626
|
-
this.focus();
|
|
627
|
-
}
|
|
628
|
-
};
|
|
629
|
-
var FsHtmlEditorComponent_1;
|
|
630
|
-
FsHtmlEditorComponent.ctorParameters = function () { return [
|
|
631
|
-
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [FS_HTML_EDITOR_CONFIG,] }] },
|
|
632
|
-
{ type: ChangeDetectorRef },
|
|
633
|
-
{ type: FsFroalaLoaderService }
|
|
634
|
-
]; };
|
|
635
|
-
__decorate([
|
|
636
|
-
HostBinding('class.focused'),
|
|
637
|
-
__metadata("design:type", Object)
|
|
638
|
-
], FsHtmlEditorComponent.prototype, "classFocused", void 0);
|
|
639
|
-
__decorate([
|
|
640
|
-
HostBinding('class.disabled'),
|
|
641
|
-
__metadata("design:type", Object)
|
|
642
|
-
], FsHtmlEditorComponent.prototype, "classDisabled", void 0);
|
|
643
|
-
__decorate([
|
|
644
|
-
ViewChild('elRef'),
|
|
645
|
-
__metadata("design:type", ElementRef)
|
|
646
|
-
], FsHtmlEditorComponent.prototype, "elRef", void 0);
|
|
647
|
-
__decorate([
|
|
648
|
-
Input(),
|
|
649
|
-
__metadata("design:type", Object)
|
|
650
|
-
], FsHtmlEditorComponent.prototype, "config", void 0);
|
|
651
|
-
FsHtmlEditorComponent = FsHtmlEditorComponent_1 = __decorate([
|
|
652
|
-
Component({
|
|
653
|
-
selector: 'fs-html-editor',
|
|
654
|
-
template: "<div class=\"fs-html-editor-default\">\n <ng-container *ngIf=\"initialized\">\n <ng-container *fsSkeleton=\"(froalaLoaded$ | async) !== false\">\n </ng-container>\n </ng-container>\n\n <div #elRef></div>\n\n <div class=\"bottom-line\"></div>\n <div class=\"disabled-line\"></div>\n <fs-html-renderer\n *ngIf=\"!initialized\"\n [html]=\"html\"\n (click)=\"uninitializedClick($event)\">\n </fs-html-renderer>\n</div>\n",
|
|
655
|
-
providers: [
|
|
656
|
-
{
|
|
657
|
-
provide: NG_VALUE_ACCESSOR,
|
|
658
|
-
useExisting: forwardRef(function () { return FsHtmlEditorComponent_1; }),
|
|
659
|
-
multi: true
|
|
660
|
-
},
|
|
661
|
-
{
|
|
662
|
-
provide: NG_VALIDATORS,
|
|
663
|
-
useExisting: forwardRef(function () { return FsHtmlEditorComponent_1; }),
|
|
664
|
-
multi: true
|
|
665
|
-
},
|
|
666
|
-
],
|
|
667
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
668
|
-
styles: [":host ::ng-deep .fr-box.fr-basic .fr-wrapper{border:0;border-bottom:1px solid #949494;margin-bottom:1px;background-color:transparent}:host ::ng-deep .fr-box.fr-basic .fr-element{padding:0;font-family:inherit;color:inherit;font-size:inherit;line-height:inherit;min-height:auto}:host ::ng-deep .fr-dropdown-menu .fr-dropdown-wrapper,:host ::ng-deep .fr-dropdown:after,:host ::ng-deep .fr-more-toolbar,:host ::ng-deep .fr-toolbar{transition:none!important}:host ::ng-deep .fr-toolbar{position:-webkit-sticky;position:sticky;z-index:2;border-radius:0;background-color:#fff}:host ::ng-deep .fr-toolbar .fr-btn-grp{margin:0 20px 0 0}:host ::ng-deep .fr-toolbar .fr-btn-grp:nth-child(1):after,:host ::ng-deep .fr-toolbar .fr-btn-grp:nth-child(2):after{content:\"\";position:absolute;top:9px;height:30px;border-left:1px solid #e5e5e5;margin-left:10px}:host ::ng-deep .fr-toolbar div:first-of-type:before{border:none}:host ::ng-deep .fr-toolbar.fr-toolbar-open .fr-newline{height:auto}:host ::ng-deep .fr-toolbar .fr-btn-grp:first-child{margin-left:0}:host ::ng-deep .fr-toolbar.fr-top{border:0}:host ::ng-deep .fr-toolbar .fr-newline{margin:0}:host ::ng-deep .fr-toolbar .fr-more-toolbar{z-index:auto}:host ::ng-deep .fr-toolbar .fr-command.fr-btn{z-index:auto}:host ::ng-deep .fr-toolbar .fr-command.fr-btn.fr-dropdown:after{right:3px}:host ::ng-deep .fr-toolbar .fr-command.fr-btn.fr-dropdown.fr-selection span{margin-right:24px}:host ::ng-deep .fr-toolbar .fr-command.fr-btn.fr-open{border-radius:4px;margin:4px 2px}:host ::ng-deep .fr-view ol,:host ::ng-deep .fr-view ul{list-style-position:unset}:host.disabled ::ng-deep .fr-box.fr-basic{opacity:.5;pointer-events:none}:host.disabled ::ng-deep .fr-box.fr-basic .fr-wrapper{border:none}:host.disabled ::ng-deep .disabled-line{display:block}::ng-deep .fr-popup{z-index:1001!important}::ng-deep .fr-video-by-url-layer .fr-checkbox-line{display:none}.disabled-line{display:none;position:absolute;bottom:-1px;z-index:1;background-image:linear-gradient(90deg,rgba(0,0,0,.42) 0,rgba(0,0,0,.42) 33%,transparent 0);background-size:4px 100%;background-repeat:repeat-x;height:1px;width:100%}.bottom-line{opacity:0;transform-origin:50%;transform:scaleX(.5);transition:background-color .3s cubic-bezier(.55,0,.55,.2);width:100%;border-bottom:2px solid #949494;position:absolute;bottom:-1px;z-index:1}:host{position:relative;display:block}:host.focused .bottom-line{opacity:1;display:block;transform:scaleX(1);transition:transform .3s cubic-bezier(.25,.8,.25,1),opacity .1s cubic-bezier(.25,.8,.25,1),background-color .3s cubic-bezier(.25,.8,.25,1)}::ng-deep .fs-html-editor-mention-container{position:absolute;top:0;left:0;height:auto;max-height:300px;max-width:500px;overflow:auto;display:block;z-index:999999;box-shadow:0 2px 4px -1px rgba(0,0,0,.2),0 4px 5px 0 rgba(0,0,0,.14),0 1px 10px 0 rgba(0,0,0,.12);border-bottom-left-radius:4px;border-bottom-right-radius:4px;background:#fff}::ng-deep .fs-html-editor-mention-container ul{margin:0;padding:0;list-style:none}::ng-deep .fs-html-editor-mention-container li{padding:0 16px;cursor:pointer;line-height:48px}::ng-deep .fs-html-editor-mention-container li.highlight,::ng-deep .fs-html-editor-mention-container li:hover{background:#f5f5f5}::ng-deep .fs-html-editor-mention-container li.no-match{cursor:default}"]
|
|
669
|
-
}),
|
|
670
|
-
__param(0, Optional()), __param(0, Inject(FS_HTML_EDITOR_CONFIG)),
|
|
671
|
-
__metadata("design:paramtypes", [Object, ChangeDetectorRef,
|
|
672
|
-
FsFroalaLoaderService])
|
|
673
|
-
], FsHtmlEditorComponent);
|
|
674
|
-
return FsHtmlEditorComponent;
|
|
220
|
+
var FsHtmlEditorComponent = /** @class */ (function () {
|
|
221
|
+
function FsHtmlEditorComponent(_defaultConfig, _cdRef, _fr) {
|
|
222
|
+
this._defaultConfig = _defaultConfig;
|
|
223
|
+
this._cdRef = _cdRef;
|
|
224
|
+
this._fr = _fr;
|
|
225
|
+
this.classFocused = false;
|
|
226
|
+
this.classDisabled = false;
|
|
227
|
+
this.config = {};
|
|
228
|
+
this.initialized = false;
|
|
229
|
+
this._initialize$ = new ReplaySubject();
|
|
230
|
+
this._froalaReady$ = new BehaviorSubject(null);
|
|
231
|
+
this._destroy$ = new Subject();
|
|
232
|
+
this.onChange = function (data) { };
|
|
233
|
+
this.onTouched = function () { };
|
|
234
|
+
}
|
|
235
|
+
FsHtmlEditorComponent_1 = FsHtmlEditorComponent;
|
|
236
|
+
Object.defineProperty(FsHtmlEditorComponent.prototype, "el", {
|
|
237
|
+
get: function () {
|
|
238
|
+
return this.elRef.nativeElement;
|
|
239
|
+
},
|
|
240
|
+
enumerable: true,
|
|
241
|
+
configurable: true
|
|
242
|
+
});
|
|
243
|
+
Object.defineProperty(FsHtmlEditorComponent.prototype, "html", {
|
|
244
|
+
get: function () {
|
|
245
|
+
return this._html;
|
|
246
|
+
},
|
|
247
|
+
enumerable: true,
|
|
248
|
+
configurable: true
|
|
249
|
+
});
|
|
250
|
+
Object.defineProperty(FsHtmlEditorComponent.prototype, "editor", {
|
|
251
|
+
get: function () {
|
|
252
|
+
return this._editor;
|
|
253
|
+
},
|
|
254
|
+
enumerable: true,
|
|
255
|
+
configurable: true
|
|
256
|
+
});
|
|
257
|
+
Object.defineProperty(FsHtmlEditorComponent.prototype, "froalaLoaded$", {
|
|
258
|
+
get: function () {
|
|
259
|
+
return this._fr.loaded$;
|
|
260
|
+
},
|
|
261
|
+
enumerable: true,
|
|
262
|
+
configurable: true
|
|
263
|
+
});
|
|
264
|
+
FsHtmlEditorComponent.prototype.ngOnInit = function () {
|
|
265
|
+
this.config = this.config || {};
|
|
266
|
+
this.config.autofocus = this.config.autofocus !== false && !this.config.disabled;
|
|
267
|
+
this.initialized = !this.config.initOnClick;
|
|
268
|
+
this._listenLazyInit();
|
|
269
|
+
};
|
|
270
|
+
FsHtmlEditorComponent.prototype.ngAfterViewInit = function () {
|
|
271
|
+
if (!this.config.initOnClick || !this.hasContent()) {
|
|
272
|
+
this.initialized = true;
|
|
273
|
+
this._initialize$.next();
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
FsHtmlEditorComponent.prototype.hasContent = function () {
|
|
277
|
+
var el = document.createElement('div');
|
|
278
|
+
if (el.querySelector('img')) {
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
el.innerHTML = this._html;
|
|
282
|
+
return !!el.innerText.length;
|
|
283
|
+
};
|
|
284
|
+
FsHtmlEditorComponent.prototype.initialize = function (options) {
|
|
285
|
+
var _this = this;
|
|
286
|
+
if (options === void 0) { options = {}; }
|
|
287
|
+
var config = this._createConfig();
|
|
288
|
+
this._initPlugins(config);
|
|
289
|
+
// this.el.innerHTML = this._html || '';
|
|
290
|
+
this._editor = new this._fr.FroalaEditor(this.el, this._createOptions(), function () {
|
|
291
|
+
_this._froalaReady$.next({ config: config, options: options });
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
FsHtmlEditorComponent.prototype._processImageUpload = function (blob) {
|
|
295
|
+
var _this = this;
|
|
296
|
+
var processor = new FileProcessor();
|
|
297
|
+
var file = new FsFile(blob);
|
|
298
|
+
return processor.process([file], this.config.image)
|
|
299
|
+
.pipe(switchMap(function (_a) {
|
|
300
|
+
var _b = __read(_a, 1), f = _b[0];
|
|
301
|
+
return _this.config.image.upload(f.file);
|
|
302
|
+
}));
|
|
303
|
+
};
|
|
304
|
+
FsHtmlEditorComponent.prototype._getTextNode = function (node) {
|
|
305
|
+
if (node) {
|
|
306
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
307
|
+
return node;
|
|
308
|
+
}
|
|
309
|
+
if (node.childNodes) {
|
|
310
|
+
return this._getTextNode(node.childNodes[0]);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
FsHtmlEditorComponent.prototype.uninitializedClick = function (event) {
|
|
315
|
+
if (!event.defaultPrevented) {
|
|
316
|
+
var target_1 = event.target;
|
|
317
|
+
if (target_1 && target_1.nodeName === 'A' && target_1.getAttribute('href')) {
|
|
318
|
+
var targetTarget_1 = target_1.getAttribute('target');
|
|
319
|
+
target_1.setAttribute('target', '_blank');
|
|
320
|
+
setTimeout(function () {
|
|
321
|
+
if (targetTarget_1) {
|
|
322
|
+
target_1.setAttribute('target', targetTarget_1);
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
target_1.removeAttribute('target');
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
if (this.config.initClick) {
|
|
331
|
+
this.config.initClick(event);
|
|
332
|
+
}
|
|
333
|
+
this._initialize$.next();
|
|
334
|
+
this.initialized = true;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
FsHtmlEditorComponent.prototype.updateSize = function () {
|
|
339
|
+
// Hack: To trigger the toolbar button size modes
|
|
340
|
+
window.dispatchEvent(new Event('resize'));
|
|
341
|
+
};
|
|
342
|
+
FsHtmlEditorComponent.prototype.validate = function (control) {
|
|
343
|
+
var err = {};
|
|
344
|
+
if (this.config.maxLength && this._html) {
|
|
345
|
+
var maxLength = this.config.maxLength;
|
|
346
|
+
var length_1 = this._html.length;
|
|
347
|
+
if (length_1 > maxLength) {
|
|
348
|
+
err.maxLengthError = "Must be " + maxLength + " characters or fewer. You entered " + length_1 + " characters.";
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return Object.keys(err).length ? err : null;
|
|
352
|
+
};
|
|
353
|
+
FsHtmlEditorComponent.prototype.focus = function (options) {
|
|
354
|
+
options = options ? options : {};
|
|
355
|
+
if (options.cursorPosition === 'end') {
|
|
356
|
+
this.editor.selection.setAtEnd(this.editor.$el.get(0));
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
this.editor.selection.setAtStart(this.editor.$el.get(0));
|
|
360
|
+
}
|
|
361
|
+
this.editor.selection.restore();
|
|
362
|
+
var elSelection = this.editor.selection.element();
|
|
363
|
+
if (elSelection) {
|
|
364
|
+
elSelection.scrollIntoView({ block: 'center' });
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
FsHtmlEditorComponent.prototype.clear = function () {
|
|
368
|
+
this.writeValue('');
|
|
369
|
+
};
|
|
370
|
+
FsHtmlEditorComponent.prototype.disable = function () {
|
|
371
|
+
this.classDisabled = true;
|
|
372
|
+
};
|
|
373
|
+
FsHtmlEditorComponent.prototype.setHtml = function (html) {
|
|
374
|
+
this.writeValue(html);
|
|
375
|
+
};
|
|
376
|
+
FsHtmlEditorComponent.prototype.writeValue = function (html) {
|
|
377
|
+
this._html = html || '';
|
|
378
|
+
if (this.editor && this.editor.html) {
|
|
379
|
+
try {
|
|
380
|
+
this.editor.html.set(this._html);
|
|
381
|
+
}
|
|
382
|
+
catch (e) {
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
this._cdRef.markForCheck();
|
|
386
|
+
};
|
|
387
|
+
FsHtmlEditorComponent.prototype.registerOnChange = function (fn) {
|
|
388
|
+
this.onChange = fn;
|
|
389
|
+
};
|
|
390
|
+
FsHtmlEditorComponent.prototype.registerOnTouched = function (fn) {
|
|
391
|
+
this.onTouched = fn;
|
|
392
|
+
};
|
|
393
|
+
FsHtmlEditorComponent.prototype.ngOnDestroy = function () {
|
|
394
|
+
this._initialize$.complete();
|
|
395
|
+
this._destroy$.next();
|
|
396
|
+
this._destroy$.complete();
|
|
397
|
+
this.destroy();
|
|
398
|
+
};
|
|
399
|
+
FsHtmlEditorComponent.prototype.destroy = function () {
|
|
400
|
+
if (this.editor) {
|
|
401
|
+
this.editor.destroy();
|
|
402
|
+
}
|
|
403
|
+
this.initialized = false;
|
|
404
|
+
this._cdRef.markForCheck();
|
|
405
|
+
this.el.innerHTML = '';
|
|
406
|
+
};
|
|
407
|
+
FsHtmlEditorComponent.prototype._createConfig = function () {
|
|
408
|
+
return merge({ froalaConfig: {} }, this._defaultConfig, this.config);
|
|
409
|
+
};
|
|
410
|
+
FsHtmlEditorComponent.prototype._change = function (html) {
|
|
411
|
+
// this._html = html;
|
|
412
|
+
this.onChange(html);
|
|
413
|
+
};
|
|
414
|
+
FsHtmlEditorComponent.prototype._initPlugins = function (config) {
|
|
415
|
+
var _this = this;
|
|
416
|
+
(config.plugins || []).forEach(function (plugin) {
|
|
417
|
+
_this._fr.FroalaEditor.PLUGINS[plugin.config.name] = function (editor) {
|
|
418
|
+
plugin.editor = editor;
|
|
419
|
+
plugin.initialize();
|
|
420
|
+
return plugin;
|
|
421
|
+
};
|
|
422
|
+
(plugin.config.buttons || []).forEach(function (button) {
|
|
423
|
+
_this._fr.FroalaEditor.DefineIcon(button.name, {
|
|
424
|
+
NAME: button.name,
|
|
425
|
+
PATH: button.svgPath,
|
|
426
|
+
});
|
|
427
|
+
_this._fr.FroalaEditor.RegisterCommand(button.name, {
|
|
428
|
+
icon: button.name,
|
|
429
|
+
title: button.tooltip,
|
|
430
|
+
undo: button.undo,
|
|
431
|
+
focus: button.focus,
|
|
432
|
+
showOnMobile: button.showOnMobile,
|
|
433
|
+
refreshAfterCallback: button.refreshAfterCallback,
|
|
434
|
+
callback: function () {
|
|
435
|
+
if (button.click) {
|
|
436
|
+
button.click(this);
|
|
437
|
+
}
|
|
438
|
+
},
|
|
439
|
+
refresh: function (button) {
|
|
440
|
+
if (button.refresh) {
|
|
441
|
+
button.refresh(this, button);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
FsHtmlEditorComponent.prototype._createOptions = function () {
|
|
449
|
+
var config = this._createConfig();
|
|
450
|
+
return merge(
|
|
451
|
+
// For some reason editor store somewhere pointer on default config object and dublicate options each time on init
|
|
452
|
+
// Extra merge level fixed this problem and allow to init config properly without legacy data
|
|
453
|
+
{}, {
|
|
454
|
+
key: config.activationKey,
|
|
455
|
+
placeholderText: config.placeholder,
|
|
456
|
+
linkAlwaysBlank: true,
|
|
457
|
+
tabSpaces: 2,
|
|
458
|
+
typingTimer: 250,
|
|
459
|
+
tooltips: false,
|
|
460
|
+
wordPasteModal: false,
|
|
461
|
+
imageDefaultWidth: 0,
|
|
462
|
+
imageDefaultAlign: 'left',
|
|
463
|
+
quickInsertEnabled: false,
|
|
464
|
+
paragraphDefaultSelection: 'Format',
|
|
465
|
+
videoUpload: false,
|
|
466
|
+
paragraphFormat: {
|
|
467
|
+
N: 'Normal',
|
|
468
|
+
H1: 'Heading 1',
|
|
469
|
+
H2: 'Heading 2',
|
|
470
|
+
H3: 'Heading 3',
|
|
471
|
+
H4: 'Heading 4',
|
|
472
|
+
BLOCKQUOTE: 'Quote',
|
|
473
|
+
},
|
|
474
|
+
paragraphFormatSelection: true,
|
|
475
|
+
toolbarButtonsXS: {
|
|
476
|
+
moreText: {
|
|
477
|
+
buttons: TextButtons,
|
|
478
|
+
buttonsVisible: 1,
|
|
479
|
+
},
|
|
480
|
+
moreParagraph: {
|
|
481
|
+
buttons: ParagraphButtons,
|
|
482
|
+
buttonsVisible: 2,
|
|
483
|
+
},
|
|
484
|
+
moreRich: {
|
|
485
|
+
buttons: RichButtons,
|
|
486
|
+
buttonsVisible: 0,
|
|
487
|
+
},
|
|
488
|
+
},
|
|
489
|
+
toolbarButtons: {
|
|
490
|
+
moreText: {
|
|
491
|
+
buttons: TextButtons,
|
|
492
|
+
buttonsVisible: 3,
|
|
493
|
+
},
|
|
494
|
+
moreParagraph: {
|
|
495
|
+
buttons: ParagraphButtons,
|
|
496
|
+
buttonsVisible: 5,
|
|
497
|
+
},
|
|
498
|
+
moreRich: {
|
|
499
|
+
buttons: RichButtons,
|
|
500
|
+
buttonsVisible: 3,
|
|
501
|
+
},
|
|
502
|
+
},
|
|
503
|
+
}, config.froalaConfig);
|
|
504
|
+
};
|
|
505
|
+
FsHtmlEditorComponent.prototype._listenLazyInit = function () {
|
|
506
|
+
var _this = this;
|
|
507
|
+
this.froalaLoaded$
|
|
508
|
+
.pipe(filter(function (ready) { return ready; }), switchMap(function () { return _this._initialize$; }), tap(function () {
|
|
509
|
+
var selection = window.getSelection();
|
|
510
|
+
var options = {};
|
|
511
|
+
if (selection.baseNode) {
|
|
512
|
+
options.selection = {
|
|
513
|
+
node: selection.baseNode.nodeValue,
|
|
514
|
+
offset: selection.baseOffset,
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
_this.initialize(options);
|
|
518
|
+
}), switchMap(function () { return _this._froalaReady$; }), filter(function (data) { return !!data; }), tap(function (_a) {
|
|
519
|
+
var config = _a.config, options = _a.options;
|
|
520
|
+
_this._setupFroala(config, options);
|
|
521
|
+
}))
|
|
522
|
+
.subscribe();
|
|
523
|
+
};
|
|
524
|
+
FsHtmlEditorComponent.prototype._contentChanged = function () {
|
|
525
|
+
var editorHTML = this._editor.html.get();
|
|
526
|
+
if (this.html !== editorHTML) {
|
|
527
|
+
this._change(editorHTML);
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
FsHtmlEditorComponent.prototype._setupFroala = function (config, options) {
|
|
531
|
+
var _this = this;
|
|
532
|
+
this._cdRef.markForCheck();
|
|
533
|
+
this.setHtml(this._html);
|
|
534
|
+
if (config.disabled) {
|
|
535
|
+
this.disable();
|
|
536
|
+
}
|
|
537
|
+
if (config.froalaConfig.events) {
|
|
538
|
+
if (config.froalaConfig.events.initialized) {
|
|
539
|
+
config.froalaConfig.events.initialized();
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
this._editor.events.on('focus', function () {
|
|
543
|
+
_this.classFocused = true;
|
|
544
|
+
_this._cdRef.markForCheck();
|
|
545
|
+
});
|
|
546
|
+
this._editor.events.on('blur', function () {
|
|
547
|
+
_this.classFocused = false;
|
|
548
|
+
_this._cdRef.markForCheck();
|
|
549
|
+
});
|
|
550
|
+
fromEventPattern(function (handler) {
|
|
551
|
+
_this._editor.events.on('contentChanged', handler);
|
|
552
|
+
}, function () { })
|
|
553
|
+
.pipe(startWith(this._html), map(function () { return _this.editor.html.get(); }), distinctUntilChanged(), skip(1))
|
|
554
|
+
.subscribe(function () {
|
|
555
|
+
_this._contentChanged();
|
|
556
|
+
});
|
|
557
|
+
// this._editor.events.on('contentChanged', () => {
|
|
558
|
+
// console.log('test');
|
|
559
|
+
// if (!this._firstChange) {
|
|
560
|
+
// this._contentChanged();
|
|
561
|
+
// }
|
|
562
|
+
// });
|
|
563
|
+
this._editor.events.on('paste.afterCleanup', function (html) {
|
|
564
|
+
var div = document.createElement('div');
|
|
565
|
+
div.innerHTML = html;
|
|
566
|
+
div.querySelectorAll('*')
|
|
567
|
+
.forEach(function (el) {
|
|
568
|
+
for (var i = 0; i < el.attributes.length; i++) {
|
|
569
|
+
var name_1 = el.attributes[0].name;
|
|
570
|
+
if (name_1 !== 'href') {
|
|
571
|
+
el.removeAttribute(name_1);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
return div.innerHTML;
|
|
576
|
+
});
|
|
577
|
+
this._editor.events.on('keydown', function () {
|
|
578
|
+
_this.onTouched();
|
|
579
|
+
});
|
|
580
|
+
if (this.config.image && this.config.image.upload) {
|
|
581
|
+
this._editor.events.on('image.beforePasteUpload', function (image) {
|
|
582
|
+
fetch(image.getAttribute('src'))
|
|
583
|
+
.then(function (res) {
|
|
584
|
+
res.blob()
|
|
585
|
+
.then(function (blob) {
|
|
586
|
+
_this._processImageUpload(blob)
|
|
587
|
+
.pipe(takeUntil(_this._destroy$))
|
|
588
|
+
.subscribe(function (url) {
|
|
589
|
+
image.setAttribute('src', url);
|
|
590
|
+
image.removeAttribute('data-fr-image-pasted');
|
|
591
|
+
_this._contentChanged();
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
});
|
|
595
|
+
return false;
|
|
596
|
+
});
|
|
597
|
+
this._editor.events.on('image.beforeUpload', function (blobs) {
|
|
598
|
+
_this._processImageUpload(blobs[0])
|
|
599
|
+
.pipe(takeUntil(_this._destroy$))
|
|
600
|
+
.subscribe(function (url) {
|
|
601
|
+
_this.editor.image.insert(url, null, null, _this.editor.image.get());
|
|
602
|
+
});
|
|
603
|
+
return false;
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
if (this.el.querySelector('.fr-second-toolbar')) {
|
|
607
|
+
this.el.querySelector('.fr-second-toolbar').remove();
|
|
608
|
+
}
|
|
609
|
+
var selection = options.selection;
|
|
610
|
+
if (selection) {
|
|
611
|
+
var node = Array.from(this.el.querySelectorAll('.fr-element *')).find(function (node) {
|
|
612
|
+
return selection.node === node.textContent;
|
|
613
|
+
});
|
|
614
|
+
if (node) {
|
|
615
|
+
var range = document.createRange();
|
|
616
|
+
var sel = window.getSelection();
|
|
617
|
+
range.setStart(this._getTextNode(node), selection.offset);
|
|
618
|
+
range.collapse(true);
|
|
619
|
+
sel.removeAllRanges();
|
|
620
|
+
sel.addRange(range);
|
|
621
|
+
}
|
|
622
|
+
else if (this.config.autofocus) {
|
|
623
|
+
this.focus();
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
else if (this.config.autofocus) {
|
|
627
|
+
this.focus();
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
var FsHtmlEditorComponent_1;
|
|
631
|
+
FsHtmlEditorComponent.ctorParameters = function () { return [
|
|
632
|
+
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [FS_HTML_EDITOR_CONFIG,] }] },
|
|
633
|
+
{ type: ChangeDetectorRef },
|
|
634
|
+
{ type: FsFroalaLoaderService }
|
|
635
|
+
]; };
|
|
636
|
+
__decorate([
|
|
637
|
+
HostBinding('class.focused'),
|
|
638
|
+
__metadata("design:type", Object)
|
|
639
|
+
], FsHtmlEditorComponent.prototype, "classFocused", void 0);
|
|
640
|
+
__decorate([
|
|
641
|
+
HostBinding('class.disabled'),
|
|
642
|
+
__metadata("design:type", Object)
|
|
643
|
+
], FsHtmlEditorComponent.prototype, "classDisabled", void 0);
|
|
644
|
+
__decorate([
|
|
645
|
+
ViewChild('elRef'),
|
|
646
|
+
__metadata("design:type", ElementRef)
|
|
647
|
+
], FsHtmlEditorComponent.prototype, "elRef", void 0);
|
|
648
|
+
__decorate([
|
|
649
|
+
Input(),
|
|
650
|
+
__metadata("design:type", Object)
|
|
651
|
+
], FsHtmlEditorComponent.prototype, "config", void 0);
|
|
652
|
+
FsHtmlEditorComponent = FsHtmlEditorComponent_1 = __decorate([
|
|
653
|
+
Component({
|
|
654
|
+
selector: 'fs-html-editor',
|
|
655
|
+
template: "<div class=\"fs-html-editor-default\">\n <ng-container *ngIf=\"initialized\">\n <ng-container *fsSkeleton=\"(froalaLoaded$ | async) !== false\">\n </ng-container>\n </ng-container>\n\n <div #elRef></div>\n\n <div class=\"bottom-line\"></div>\n <div class=\"disabled-line\"></div>\n <fs-html-renderer\n *ngIf=\"!initialized\"\n [html]=\"html\"\n (click)=\"uninitializedClick($event)\">\n </fs-html-renderer>\n</div>\n",
|
|
656
|
+
providers: [
|
|
657
|
+
{
|
|
658
|
+
provide: NG_VALUE_ACCESSOR,
|
|
659
|
+
useExisting: forwardRef(function () { return FsHtmlEditorComponent_1; }),
|
|
660
|
+
multi: true
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
provide: NG_VALIDATORS,
|
|
664
|
+
useExisting: forwardRef(function () { return FsHtmlEditorComponent_1; }),
|
|
665
|
+
multi: true
|
|
666
|
+
},
|
|
667
|
+
],
|
|
668
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
669
|
+
styles: [":host ::ng-deep .fr-box.fr-basic .fr-wrapper{border:0;border-bottom:1px solid #949494;margin-bottom:1px;background-color:transparent}:host ::ng-deep .fr-box.fr-basic .fr-element{padding:0;font-family:inherit;color:inherit;font-size:inherit;line-height:inherit;min-height:auto}:host ::ng-deep .fr-dropdown-menu .fr-dropdown-wrapper,:host ::ng-deep .fr-dropdown:after,:host ::ng-deep .fr-more-toolbar,:host ::ng-deep .fr-toolbar{transition:none!important}:host ::ng-deep .fr-toolbar.fr-top{position:-webkit-sticky;position:sticky;z-index:2;border-radius:0;background-color:#fff}:host ::ng-deep .fr-toolbar.fr-top .fr-btn-grp{margin:0 20px 0 0}:host ::ng-deep .fr-toolbar.fr-top .fr-btn-grp:nth-child(1):after,:host ::ng-deep .fr-toolbar.fr-top .fr-btn-grp:nth-child(2):after{content:\"\";position:absolute;top:9px;height:30px;border-left:1px solid #e5e5e5;margin-left:10px}:host ::ng-deep .fr-toolbar.fr-top div:first-of-type:before{border:none}:host ::ng-deep .fr-toolbar.fr-top.fr-toolbar-open .fr-newline{height:auto}:host ::ng-deep .fr-toolbar.fr-top .fr-btn-grp:first-child{margin-left:0}:host ::ng-deep .fr-toolbar.fr-top.fr-top{border:0}:host ::ng-deep .fr-toolbar.fr-top .fr-newline{margin:0}:host ::ng-deep .fr-toolbar.fr-top .fr-more-toolbar{z-index:auto}:host ::ng-deep .fr-toolbar.fr-top .fr-command.fr-btn{z-index:auto}:host ::ng-deep .fr-toolbar.fr-top .fr-command.fr-btn.fr-dropdown:after{right:3px}:host ::ng-deep .fr-toolbar.fr-top .fr-command.fr-btn.fr-dropdown.fr-selection span{margin-right:24px}:host ::ng-deep .fr-toolbar.fr-top .fr-command.fr-btn.fr-open{border-radius:4px;margin:4px 2px}:host ::ng-deep .fr-view ol,:host ::ng-deep .fr-view ul{list-style-position:unset}:host.disabled ::ng-deep .fr-box.fr-basic{opacity:.5;pointer-events:none}:host.disabled ::ng-deep .fr-box.fr-basic .fr-wrapper{border:none}:host.disabled ::ng-deep .disabled-line{display:block}::ng-deep .fr-popup{z-index:1001!important}::ng-deep .fr-video-by-url-layer .fr-checkbox-line{display:none}.disabled-line{display:none;position:absolute;bottom:-1px;z-index:1;background-image:linear-gradient(90deg,rgba(0,0,0,.42) 0,rgba(0,0,0,.42) 33%,transparent 0);background-size:4px 100%;background-repeat:repeat-x;height:1px;width:100%}.bottom-line{opacity:0;transform-origin:50%;transform:scaleX(.5);transition:background-color .3s cubic-bezier(.55,0,.55,.2);width:100%;border-bottom:2px solid #949494;position:absolute;bottom:-1px;z-index:1}:host{position:relative;display:block}:host.focused .bottom-line{opacity:1;display:block;transform:scaleX(1);transition:transform .3s cubic-bezier(.25,.8,.25,1),opacity .1s cubic-bezier(.25,.8,.25,1),background-color .3s cubic-bezier(.25,.8,.25,1)}::ng-deep .fs-html-editor-mention-container{position:absolute;top:0;left:0;height:auto;max-height:300px;max-width:500px;overflow:auto;display:block;z-index:999999;box-shadow:0 2px 4px -1px rgba(0,0,0,.2),0 4px 5px 0 rgba(0,0,0,.14),0 1px 10px 0 rgba(0,0,0,.12);border-bottom-left-radius:4px;border-bottom-right-radius:4px;background:#fff}::ng-deep .fs-html-editor-mention-container ul{margin:0;padding:0;list-style:none}::ng-deep .fs-html-editor-mention-container li{padding:0 16px;cursor:pointer;line-height:48px}::ng-deep .fs-html-editor-mention-container li.highlight,::ng-deep .fs-html-editor-mention-container li:hover{background:#f5f5f5}::ng-deep .fs-html-editor-mention-container li.no-match{cursor:default}"]
|
|
670
|
+
}),
|
|
671
|
+
__param(0, Optional()), __param(0, Inject(FS_HTML_EDITOR_CONFIG)),
|
|
672
|
+
__metadata("design:paramtypes", [Object, ChangeDetectorRef,
|
|
673
|
+
FsFroalaLoaderService])
|
|
674
|
+
], FsHtmlEditorComponent);
|
|
675
|
+
return FsHtmlEditorComponent;
|
|
675
676
|
}());
|
|
676
677
|
|
|
677
|
-
var FsHtmlRendererComponent = /** @class */ (function () {
|
|
678
|
-
function FsHtmlRendererComponent(sanitized, _cdRef) {
|
|
679
|
-
this.sanitized = sanitized;
|
|
680
|
-
this._cdRef = _cdRef;
|
|
681
|
-
}
|
|
682
|
-
Object.defineProperty(FsHtmlRendererComponent.prototype, "setHtml", {
|
|
683
|
-
set: function (html) {
|
|
684
|
-
this.trustedHtml = this.sanitized.bypassSecurityTrustHtml(html);
|
|
685
|
-
this._cdRef.markForCheck();
|
|
686
|
-
},
|
|
687
|
-
enumerable: true,
|
|
688
|
-
configurable: true
|
|
689
|
-
});
|
|
690
|
-
FsHtmlRendererComponent.ctorParameters = function () { return [
|
|
691
|
-
{ type: DomSanitizer },
|
|
692
|
-
{ type: ChangeDetectorRef }
|
|
693
|
-
]; };
|
|
694
|
-
__decorate([
|
|
695
|
-
Input('html'),
|
|
696
|
-
__metadata("design:type", Object),
|
|
697
|
-
__metadata("design:paramtypes", [Object])
|
|
698
|
-
], FsHtmlRendererComponent.prototype, "setHtml", null);
|
|
699
|
-
FsHtmlRendererComponent = __decorate([
|
|
700
|
-
Component({
|
|
701
|
-
selector: 'fs-html-renderer',
|
|
702
|
-
template: "<div class=\"fr-view fs-html-editor-default\" [innerHtml]=\"trustedHtml\"></div>\n",
|
|
703
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
704
|
-
styles: [""]
|
|
705
|
-
}),
|
|
706
|
-
__metadata("design:paramtypes", [DomSanitizer,
|
|
707
|
-
ChangeDetectorRef])
|
|
708
|
-
], FsHtmlRendererComponent);
|
|
709
|
-
return FsHtmlRendererComponent;
|
|
678
|
+
var FsHtmlRendererComponent = /** @class */ (function () {
|
|
679
|
+
function FsHtmlRendererComponent(sanitized, _cdRef) {
|
|
680
|
+
this.sanitized = sanitized;
|
|
681
|
+
this._cdRef = _cdRef;
|
|
682
|
+
}
|
|
683
|
+
Object.defineProperty(FsHtmlRendererComponent.prototype, "setHtml", {
|
|
684
|
+
set: function (html) {
|
|
685
|
+
this.trustedHtml = this.sanitized.bypassSecurityTrustHtml(html);
|
|
686
|
+
this._cdRef.markForCheck();
|
|
687
|
+
},
|
|
688
|
+
enumerable: true,
|
|
689
|
+
configurable: true
|
|
690
|
+
});
|
|
691
|
+
FsHtmlRendererComponent.ctorParameters = function () { return [
|
|
692
|
+
{ type: DomSanitizer },
|
|
693
|
+
{ type: ChangeDetectorRef }
|
|
694
|
+
]; };
|
|
695
|
+
__decorate([
|
|
696
|
+
Input('html'),
|
|
697
|
+
__metadata("design:type", Object),
|
|
698
|
+
__metadata("design:paramtypes", [Object])
|
|
699
|
+
], FsHtmlRendererComponent.prototype, "setHtml", null);
|
|
700
|
+
FsHtmlRendererComponent = __decorate([
|
|
701
|
+
Component({
|
|
702
|
+
selector: 'fs-html-renderer',
|
|
703
|
+
template: "<div class=\"fr-view fs-html-editor-default\" [innerHtml]=\"trustedHtml\"></div>\n",
|
|
704
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
705
|
+
styles: [""]
|
|
706
|
+
}),
|
|
707
|
+
__metadata("design:paramtypes", [DomSanitizer,
|
|
708
|
+
ChangeDetectorRef])
|
|
709
|
+
], FsHtmlRendererComponent);
|
|
710
|
+
return FsHtmlRendererComponent;
|
|
710
711
|
}());
|
|
711
712
|
|
|
712
|
-
var FsHtmlEditorModule = /** @class */ (function () {
|
|
713
|
-
function FsHtmlEditorModule() {
|
|
714
|
-
}
|
|
715
|
-
FsHtmlEditorModule_1 = FsHtmlEditorModule;
|
|
716
|
-
FsHtmlEditorModule.forRoot = function (config) {
|
|
717
|
-
if (config === void 0) { config = {}; }
|
|
718
|
-
return {
|
|
719
|
-
ngModule: FsHtmlEditorModule_1,
|
|
720
|
-
providers: [
|
|
721
|
-
{ provide: FS_HTML_EDITOR_DEFAULT_CONFIG, useValue: config },
|
|
722
|
-
{
|
|
723
|
-
provide: FS_HTML_EDITOR_CONFIG,
|
|
724
|
-
useFactory: FsHtmlEditorConfigFactory,
|
|
725
|
-
deps: [FS_HTML_EDITOR_DEFAULT_CONFIG]
|
|
726
|
-
}
|
|
727
|
-
]
|
|
728
|
-
};
|
|
729
|
-
};
|
|
730
|
-
var FsHtmlEditorModule_1;
|
|
731
|
-
FsHtmlEditorModule = FsHtmlEditorModule_1 = __decorate([
|
|
732
|
-
NgModule({
|
|
733
|
-
imports: [
|
|
734
|
-
CommonModule,
|
|
735
|
-
FsSkeletonModule,
|
|
736
|
-
],
|
|
737
|
-
exports: [
|
|
738
|
-
FsHtmlEditorComponent,
|
|
739
|
-
FsHtmlRendererComponent,
|
|
740
|
-
],
|
|
741
|
-
declarations: [
|
|
742
|
-
FsHtmlEditorComponent,
|
|
743
|
-
FsHtmlRendererComponent,
|
|
744
|
-
],
|
|
745
|
-
})
|
|
746
|
-
], FsHtmlEditorModule);
|
|
747
|
-
return FsHtmlEditorModule;
|
|
748
|
-
}());
|
|
749
|
-
function FsHtmlEditorConfigFactory(config) {
|
|
750
|
-
return __assign({ defaultPlugins: [
|
|
751
|
-
"align" /* Align */,
|
|
752
|
-
"colors" /* Colors */,
|
|
753
|
-
"image" /* Image */,
|
|
754
|
-
"link" /* Link */,
|
|
755
|
-
"lists" /* Lists */,
|
|
756
|
-
"paragraph_format" /* ParagraphFormat */,
|
|
757
|
-
"quote" /* Quote */,
|
|
758
|
-
"table" /* Table */,
|
|
759
|
-
"url" /* Url */,
|
|
760
|
-
"video" /* Video */,
|
|
761
|
-
"draggable" /* Draggable */,
|
|
762
|
-
"font_size" /* FontSize */,
|
|
763
|
-
] }, config);
|
|
713
|
+
var FsHtmlEditorModule = /** @class */ (function () {
|
|
714
|
+
function FsHtmlEditorModule() {
|
|
715
|
+
}
|
|
716
|
+
FsHtmlEditorModule_1 = FsHtmlEditorModule;
|
|
717
|
+
FsHtmlEditorModule.forRoot = function (config) {
|
|
718
|
+
if (config === void 0) { config = {}; }
|
|
719
|
+
return {
|
|
720
|
+
ngModule: FsHtmlEditorModule_1,
|
|
721
|
+
providers: [
|
|
722
|
+
{ provide: FS_HTML_EDITOR_DEFAULT_CONFIG, useValue: config },
|
|
723
|
+
{
|
|
724
|
+
provide: FS_HTML_EDITOR_CONFIG,
|
|
725
|
+
useFactory: FsHtmlEditorConfigFactory,
|
|
726
|
+
deps: [FS_HTML_EDITOR_DEFAULT_CONFIG]
|
|
727
|
+
}
|
|
728
|
+
]
|
|
729
|
+
};
|
|
730
|
+
};
|
|
731
|
+
var FsHtmlEditorModule_1;
|
|
732
|
+
FsHtmlEditorModule = FsHtmlEditorModule_1 = __decorate([
|
|
733
|
+
NgModule({
|
|
734
|
+
imports: [
|
|
735
|
+
CommonModule,
|
|
736
|
+
FsSkeletonModule,
|
|
737
|
+
],
|
|
738
|
+
exports: [
|
|
739
|
+
FsHtmlEditorComponent,
|
|
740
|
+
FsHtmlRendererComponent,
|
|
741
|
+
],
|
|
742
|
+
declarations: [
|
|
743
|
+
FsHtmlEditorComponent,
|
|
744
|
+
FsHtmlRendererComponent,
|
|
745
|
+
],
|
|
746
|
+
})
|
|
747
|
+
], FsHtmlEditorModule);
|
|
748
|
+
return FsHtmlEditorModule;
|
|
749
|
+
}());
|
|
750
|
+
function FsHtmlEditorConfigFactory(config) {
|
|
751
|
+
return __assign({ defaultPlugins: [
|
|
752
|
+
"align" /* Align */,
|
|
753
|
+
"colors" /* Colors */,
|
|
754
|
+
"image" /* Image */,
|
|
755
|
+
"link" /* Link */,
|
|
756
|
+
"lists" /* Lists */,
|
|
757
|
+
"paragraph_format" /* ParagraphFormat */,
|
|
758
|
+
"quote" /* Quote */,
|
|
759
|
+
"table" /* Table */,
|
|
760
|
+
"url" /* Url */,
|
|
761
|
+
"video" /* Video */,
|
|
762
|
+
"draggable" /* Draggable */,
|
|
763
|
+
"font_size" /* FontSize */,
|
|
764
|
+
] }, config);
|
|
764
765
|
}
|
|
765
766
|
|
|
766
|
-
var Plugin = /** @class */ (function () {
|
|
767
|
-
function Plugin() {
|
|
768
|
-
}
|
|
769
|
-
Plugin.prototype.initialize = function () { };
|
|
770
|
-
Plugin.prototype.destroy = function () { };
|
|
771
|
-
return Plugin;
|
|
767
|
+
var Plugin = /** @class */ (function () {
|
|
768
|
+
function Plugin() {
|
|
769
|
+
}
|
|
770
|
+
Plugin.prototype.initialize = function () { };
|
|
771
|
+
Plugin.prototype.destroy = function () { };
|
|
772
|
+
return Plugin;
|
|
772
773
|
}());
|
|
773
774
|
|
|
774
|
-
var MentionPlugin = /** @class */ (function (_super) {
|
|
775
|
-
__extends(MentionPlugin, _super);
|
|
776
|
-
function MentionPlugin(config) {
|
|
777
|
-
var _this = _super.call(this) || this;
|
|
778
|
-
_this.config = config;
|
|
779
|
-
_this.
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
if (
|
|
834
|
-
|
|
835
|
-
}
|
|
836
|
-
});
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
775
|
+
var MentionPlugin = /** @class */ (function (_super) {
|
|
776
|
+
__extends(MentionPlugin, _super);
|
|
777
|
+
function MentionPlugin(config) {
|
|
778
|
+
var _this = _super.call(this) || this;
|
|
779
|
+
_this.config = config;
|
|
780
|
+
_this._guid = guid();
|
|
781
|
+
_this.selected = function (event) {
|
|
782
|
+
if (_this.config.selected) {
|
|
783
|
+
if (MentionPlugin._currentGuid === _this._guid) {
|
|
784
|
+
_this.config.selected(event.detail.item.original);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
_this.config = __assign(__assign({}, config), { buttons: [
|
|
789
|
+
{
|
|
790
|
+
name: config.name,
|
|
791
|
+
tooltip: config.tooltip,
|
|
792
|
+
svgPath: config.iconPath,
|
|
793
|
+
click: function (editor) {
|
|
794
|
+
_this._closeAll();
|
|
795
|
+
_this._tribute.showMenuForCollection(editor.el);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
] });
|
|
799
|
+
_this._tribute = new Tribute({
|
|
800
|
+
values: debounce(_this._loadValues.bind(_this), 200),
|
|
801
|
+
searchOpts: {
|
|
802
|
+
pre: '',
|
|
803
|
+
post: '',
|
|
804
|
+
skip: true
|
|
805
|
+
},
|
|
806
|
+
containerClass: "fs-html-editor-mention-container " + (_this.config.containerClass || ''),
|
|
807
|
+
itemClass: "fs-html-editor-mention-menu-item " + (_this.config.menuItemClass || ''),
|
|
808
|
+
trigger: _this.config.trigger,
|
|
809
|
+
allowSpaces: true,
|
|
810
|
+
menuItemTemplate: function (item) {
|
|
811
|
+
return _this.config.menuItemTemplate(item.original);
|
|
812
|
+
},
|
|
813
|
+
selectTemplate: function (item) {
|
|
814
|
+
var template = _this.config.selectedTemplate(item.original);
|
|
815
|
+
var p = document.createElement('p');
|
|
816
|
+
p.innerHTML = template;
|
|
817
|
+
var node = p.firstElementChild;
|
|
818
|
+
if (!node) {
|
|
819
|
+
node = document.createElement('span');
|
|
820
|
+
node.innerHTML = template;
|
|
821
|
+
}
|
|
822
|
+
node.setAttribute('contenteditable', 'false');
|
|
823
|
+
node.classList.add('fr-deletable');
|
|
824
|
+
return node.outerHTML;
|
|
825
|
+
},
|
|
826
|
+
});
|
|
827
|
+
MentionPlugin._tributes.push(_this._tribute);
|
|
828
|
+
return _this;
|
|
829
|
+
}
|
|
830
|
+
MentionPlugin.prototype.initialize = function () {
|
|
831
|
+
var _this = this;
|
|
832
|
+
this._tribute.attach(this.editor.el);
|
|
833
|
+
this.editor.events.on('keydown', function (e) {
|
|
834
|
+
if (e.key === 'Enter' && _this._tribute.isActive) {
|
|
835
|
+
return false;
|
|
836
|
+
}
|
|
837
|
+
}, true);
|
|
838
|
+
this.editor.el.addEventListener("tribute-replaced", this.selected);
|
|
839
|
+
};
|
|
840
|
+
MentionPlugin.prototype.destroy = function () {
|
|
841
|
+
this.editor.el.removeEventListener("tribute-replaced", this.selected);
|
|
842
|
+
};
|
|
843
|
+
MentionPlugin.prototype._closeAll = function () {
|
|
844
|
+
MentionPlugin._tributes.forEach(function (tribute) {
|
|
845
|
+
if (tribute.menu) {
|
|
846
|
+
tribute.hideMenu();
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
};
|
|
850
|
+
MentionPlugin.prototype._loadValues = function (keyword, cb) {
|
|
851
|
+
MentionPlugin._currentGuid = this._guid;
|
|
852
|
+
return this.config.fetch(keyword)
|
|
853
|
+
.subscribe(function (data) {
|
|
854
|
+
cb(data);
|
|
855
|
+
});
|
|
856
|
+
};
|
|
857
|
+
MentionPlugin._currentGuid = null;
|
|
858
|
+
MentionPlugin._tributes = [];
|
|
859
|
+
return MentionPlugin;
|
|
846
860
|
}(Plugin));
|
|
847
861
|
|
|
848
|
-
var ChecklistPlugin = /** @class */ (function (_super) {
|
|
849
|
-
__extends(ChecklistPlugin, _super);
|
|
850
|
-
function ChecklistPlugin(config) {
|
|
851
|
-
if (config === void 0) { config = { name: 'checklist' }; }
|
|
852
|
-
var _this = _super.call(this) || this;
|
|
853
|
-
_this.config = config;
|
|
854
|
-
_this.config = __assign(__assign({}, config), { name: 'checklist', buttons: [
|
|
855
|
-
{
|
|
856
|
-
name: 'checklist',
|
|
857
|
-
svgPath: 'M8.4,10.3l-1.2,1.2l4,4L20,6.7l-1.2-1.2l-7.6,7.6L8.4,10.3z M18.2,18.2H5.8V5.8h8.9V4H5.8C4.8,4,4,4.8,4,5.8v12.4c0,1,0.8,1.8,1.8,1.8h12.4c1,0,1.8-0.8,1.8-1.8v-7.1h-1.8V18.2z',
|
|
858
|
-
click: function (editor) {
|
|
859
|
-
editor.html.insert('<ul class="checklist"><li></li></ul>');
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
] });
|
|
863
|
-
return _this;
|
|
864
|
-
}
|
|
865
|
-
ChecklistPlugin.prototype.initialize = function () {
|
|
866
|
-
this.editor.events.on('click', function (e) {
|
|
867
|
-
var li = e.target;
|
|
868
|
-
if (li.nodeName === 'LI' && e.offsetX < 0) {
|
|
869
|
-
var items = __spread([li], li.querySelectorAll('li'));
|
|
870
|
-
if (li.classList.contains('checked')) {
|
|
871
|
-
items.forEach(function (item) {
|
|
872
|
-
item.classList.remove('checked');
|
|
873
|
-
});
|
|
874
|
-
}
|
|
875
|
-
else {
|
|
876
|
-
items.forEach(function (item) {
|
|
877
|
-
item.classList.add('checked');
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
}, false);
|
|
882
|
-
};
|
|
883
|
-
return ChecklistPlugin;
|
|
862
|
+
var ChecklistPlugin = /** @class */ (function (_super) {
|
|
863
|
+
__extends(ChecklistPlugin, _super);
|
|
864
|
+
function ChecklistPlugin(config) {
|
|
865
|
+
if (config === void 0) { config = { name: 'checklist' }; }
|
|
866
|
+
var _this = _super.call(this) || this;
|
|
867
|
+
_this.config = config;
|
|
868
|
+
_this.config = __assign(__assign({}, config), { name: 'checklist', buttons: [
|
|
869
|
+
{
|
|
870
|
+
name: 'checklist',
|
|
871
|
+
svgPath: 'M8.4,10.3l-1.2,1.2l4,4L20,6.7l-1.2-1.2l-7.6,7.6L8.4,10.3z M18.2,18.2H5.8V5.8h8.9V4H5.8C4.8,4,4,4.8,4,5.8v12.4c0,1,0.8,1.8,1.8,1.8h12.4c1,0,1.8-0.8,1.8-1.8v-7.1h-1.8V18.2z',
|
|
872
|
+
click: function (editor) {
|
|
873
|
+
editor.html.insert('<ul class="checklist"><li></li></ul>');
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
] });
|
|
877
|
+
return _this;
|
|
878
|
+
}
|
|
879
|
+
ChecklistPlugin.prototype.initialize = function () {
|
|
880
|
+
this.editor.events.on('click', function (e) {
|
|
881
|
+
var li = e.target;
|
|
882
|
+
if (li.nodeName === 'LI' && e.offsetX < 0) {
|
|
883
|
+
var items = __spread([li], li.querySelectorAll('li'));
|
|
884
|
+
if (li.classList.contains('checked')) {
|
|
885
|
+
items.forEach(function (item) {
|
|
886
|
+
item.classList.remove('checked');
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
else {
|
|
890
|
+
items.forEach(function (item) {
|
|
891
|
+
item.classList.add('checked');
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
}, false);
|
|
896
|
+
};
|
|
897
|
+
return ChecklistPlugin;
|
|
884
898
|
}(Plugin));
|
|
885
899
|
|
|
886
|
-
var CodePlugin = /** @class */ (function (_super) {
|
|
887
|
-
__extends(CodePlugin, _super);
|
|
888
|
-
function CodePlugin(config) {
|
|
889
|
-
if (config === void 0) { config = { name: 'code' }; }
|
|
890
|
-
var _this = _super.call(this) || this;
|
|
891
|
-
_this.config = config;
|
|
892
|
-
_this.config = __assign(__assign({}, config), { name: 'code', buttons: [
|
|
893
|
-
{
|
|
894
|
-
name: 'code',
|
|
895
|
-
svgPath: 'M8.9,7.3L4.2,12l4.7,4.7l1.1-1.1L6.4,12L10,8.4L8.9,7.3z M15.1,7.3L14,8.4l3.6,3.6L14,15.6l1.1,1.1l4.7-4.7L15.1,7.3z',
|
|
896
|
-
click: function (editor) {
|
|
897
|
-
var node = editor.selection.get();
|
|
898
|
-
var codeEl = _this._getCodeEl(node.baseNode);
|
|
899
|
-
if (codeEl) {
|
|
900
|
-
codeEl.classList.remove('code');
|
|
901
|
-
}
|
|
902
|
-
else {
|
|
903
|
-
editor.html.insert('<p class="code">' + editor.selection.get().toString().replace(/\n{1,}/g, '<br>') + '</p>');
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
] });
|
|
908
|
-
return _this;
|
|
909
|
-
}
|
|
910
|
-
CodePlugin.prototype.initialize = function () {
|
|
911
|
-
var _this = this;
|
|
912
|
-
this.editor.events.on('keydown', function (e) {
|
|
913
|
-
if (e.keyCode === 13) {
|
|
914
|
-
var selection = _this.editor.selection.get();
|
|
915
|
-
if (selection && _this._getCodeEl(selection.baseNode)) {
|
|
916
|
-
e.preventDefault();
|
|
917
|
-
e.stopPropagation();
|
|
918
|
-
e.stopImmediatePropagation();
|
|
919
|
-
var br = '<br>';
|
|
920
|
-
var base = selection.baseNode;
|
|
921
|
-
if (base.nodeName === '#text' && selection.baseOffset === base.length) {
|
|
922
|
-
if (!(base.nextSibling && base.nextSibling.nodeName === 'BR')) {
|
|
923
|
-
br += '<br>';
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
else {
|
|
927
|
-
var el = Array.from(base.childNodes).splice(selection.baseOffset - 1, 1).pop();
|
|
928
|
-
if (el && el.nodeName !== 'BR') {
|
|
929
|
-
br += '<br>';
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
_this.editor.html.insert(br);
|
|
933
|
-
return false;
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
}, true);
|
|
937
|
-
};
|
|
938
|
-
CodePlugin.prototype.destroy = function () { };
|
|
939
|
-
CodePlugin.prototype._getCodeEl = function (el) {
|
|
940
|
-
if (el) {
|
|
941
|
-
if (el.classList && el.classList.contains('code')) {
|
|
942
|
-
return el;
|
|
943
|
-
}
|
|
944
|
-
if (el.parentElement) {
|
|
945
|
-
return this._getCodeEl(el.parentElement);
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
return null;
|
|
949
|
-
};
|
|
950
|
-
return CodePlugin;
|
|
900
|
+
var CodePlugin = /** @class */ (function (_super) {
|
|
901
|
+
__extends(CodePlugin, _super);
|
|
902
|
+
function CodePlugin(config) {
|
|
903
|
+
if (config === void 0) { config = { name: 'code' }; }
|
|
904
|
+
var _this = _super.call(this) || this;
|
|
905
|
+
_this.config = config;
|
|
906
|
+
_this.config = __assign(__assign({}, config), { name: 'code', buttons: [
|
|
907
|
+
{
|
|
908
|
+
name: 'code',
|
|
909
|
+
svgPath: 'M8.9,7.3L4.2,12l4.7,4.7l1.1-1.1L6.4,12L10,8.4L8.9,7.3z M15.1,7.3L14,8.4l3.6,3.6L14,15.6l1.1,1.1l4.7-4.7L15.1,7.3z',
|
|
910
|
+
click: function (editor) {
|
|
911
|
+
var node = editor.selection.get();
|
|
912
|
+
var codeEl = _this._getCodeEl(node.baseNode);
|
|
913
|
+
if (codeEl) {
|
|
914
|
+
codeEl.classList.remove('code');
|
|
915
|
+
}
|
|
916
|
+
else {
|
|
917
|
+
editor.html.insert('<p class="code">' + editor.selection.get().toString().replace(/\n{1,}/g, '<br>') + '</p>');
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
] });
|
|
922
|
+
return _this;
|
|
923
|
+
}
|
|
924
|
+
CodePlugin.prototype.initialize = function () {
|
|
925
|
+
var _this = this;
|
|
926
|
+
this.editor.events.on('keydown', function (e) {
|
|
927
|
+
if (e.keyCode === 13) {
|
|
928
|
+
var selection = _this.editor.selection.get();
|
|
929
|
+
if (selection && _this._getCodeEl(selection.baseNode)) {
|
|
930
|
+
e.preventDefault();
|
|
931
|
+
e.stopPropagation();
|
|
932
|
+
e.stopImmediatePropagation();
|
|
933
|
+
var br = '<br>';
|
|
934
|
+
var base = selection.baseNode;
|
|
935
|
+
if (base.nodeName === '#text' && selection.baseOffset === base.length) {
|
|
936
|
+
if (!(base.nextSibling && base.nextSibling.nodeName === 'BR')) {
|
|
937
|
+
br += '<br>';
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
else {
|
|
941
|
+
var el = Array.from(base.childNodes).splice(selection.baseOffset - 1, 1).pop();
|
|
942
|
+
if (el && el.nodeName !== 'BR') {
|
|
943
|
+
br += '<br>';
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
_this.editor.html.insert(br);
|
|
947
|
+
return false;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}, true);
|
|
951
|
+
};
|
|
952
|
+
CodePlugin.prototype.destroy = function () { };
|
|
953
|
+
CodePlugin.prototype._getCodeEl = function (el) {
|
|
954
|
+
if (el) {
|
|
955
|
+
if (el.classList && el.classList.contains('code')) {
|
|
956
|
+
return el;
|
|
957
|
+
}
|
|
958
|
+
if (el.parentElement) {
|
|
959
|
+
return this._getCodeEl(el.parentElement);
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
return null;
|
|
963
|
+
};
|
|
964
|
+
return CodePlugin;
|
|
951
965
|
}(Plugin));
|
|
952
966
|
|
|
953
|
-
var ScreenRecordPlugin = /** @class */ (function (_super) {
|
|
954
|
-
__extends(ScreenRecordPlugin, _super);
|
|
955
|
-
function ScreenRecordPlugin(config) {
|
|
956
|
-
if (config === void 0) { config = {}; }
|
|
957
|
-
var _this = _super.call(this) || this;
|
|
958
|
-
_this.config = config;
|
|
959
|
-
_this.config = __assign(__assign({}, config), { name: config.name || 'screenRecord', buttons: [
|
|
960
|
-
{
|
|
961
|
-
name: 'screenRecord',
|
|
962
|
-
svgPath: "M14.7,7.7v6.1H7.1V7.7H14.7 M16.3,9.6V6.9c0-0.4-0.3-0.8-0.8-0.8H6.4c-0.4,0-0.8,0.3-0.8,0.8v7.6c0,0.4,0.3,0.8,0.8,0.8h9.1c0.4,0,0.8-0.3,0.8-0.8v-2.7l1.7,1.7c0.3,0.3,0.8,0.3,1.1,0c0.1-0.1,0.2-0.3,0.2-0.5V8.4c0-0.4-0.3-0.8-0.8-0.8\n\tc-0.2,0-0.4,0.1-0.5,0.2L16.3,9.6z M21.5,1.6H2.9c-0.7,0-1.3,0.7-1.3,1.6v14.6c0,0.9,0.6,1.6,1.3,1.6h7.6v1.1l-5,1c-0.2,0-0.4,0.3-0.4,0.6c0,0.3,0.2,0.4,0.4,0.4c0,0,0,0,0.1,0l5.3-1h2.6l5.3,1c0,0,0,0,0.1,0c0.2,0,0.4-0.2,0.4-0.4\n c0-0.3-0.1-0.6-0.4-0.6l-5-1v-1.1h7.6c0.7,0,1.3-0.7,1.3-1.6V3.2C22.9,2.3,22.3,1.6,21.5,1.6z M21.1,17.3H3.3V3.7h17.8L21.1,17.3L21.1,17.3z",
|
|
963
|
-
tooltip: 'Screen Record',
|
|
964
|
-
click: function (editor) {
|
|
965
|
-
navigator.mediaDevices.getDisplayMedia({ video: true })
|
|
966
|
-
.then(function (stream) {
|
|
967
|
-
var chunks = [];
|
|
968
|
-
var options = { mimeType: 'video/webm; codecs=vp9' };
|
|
969
|
-
var mediaRecorder = new MediaRecorder(stream, options);
|
|
970
|
-
stream.addEventListener('inactive', function (e) {
|
|
971
|
-
mediaRecorder.stop();
|
|
972
|
-
mediaRecorder = null;
|
|
973
|
-
stream.getTracks().forEach(function (track) { return track.stop(); });
|
|
974
|
-
stream = null;
|
|
975
|
-
var blob = new Blob(chunks, { type: 'video/webm' });
|
|
976
|
-
config.upload(blob)
|
|
977
|
-
.subscribe(function (url) {
|
|
978
|
-
editor.html.insert("<span class=\"fr-screen-record fr-deletable fr-draggable\"><video controls style=\"max-width:" + config.maxWidth + "\"><source src=\"" + url + "\" type=\"video/webm\"></video></span>");
|
|
979
|
-
});
|
|
980
|
-
});
|
|
981
|
-
mediaRecorder.addEventListener('dataavailable', function (event) {
|
|
982
|
-
if (event.data && event.data.size > 0) {
|
|
983
|
-
chunks.push(event.data);
|
|
984
|
-
}
|
|
985
|
-
});
|
|
986
|
-
mediaRecorder.start(10);
|
|
987
|
-
})
|
|
988
|
-
.catch(function (e) { });
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
] });
|
|
992
|
-
return _this;
|
|
993
|
-
}
|
|
994
|
-
ScreenRecordPlugin.prototype.initialize = function () {
|
|
995
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
996
|
-
var FroalaEditor;
|
|
997
|
-
var _this = this;
|
|
998
|
-
return __generator(this, function (_a) {
|
|
999
|
-
switch (_a.label) {
|
|
1000
|
-
case 0: return [4 /*yield*/, ResourceLoader.loadStyles('froala')
|
|
1001
|
-
.toPromise()];
|
|
1002
|
-
case 1:
|
|
1003
|
-
_a.sent();
|
|
1004
|
-
FroalaEditor = window.FroalaEditor;
|
|
1005
|
-
this.editor.events.on('mouseup', function (e) {
|
|
1006
|
-
var el = _this._getEl(e.target);
|
|
1007
|
-
if (el) {
|
|
1008
|
-
_this.editor.popups.hideAll();
|
|
1009
|
-
_this._activeEl = el;
|
|
1010
|
-
_this._showPopup(el);
|
|
1011
|
-
}
|
|
1012
|
-
});
|
|
1013
|
-
FroalaEditor.POPUP_TEMPLATES["screenRecordPlugin.popup"] = '[_BUTTONS_]';
|
|
1014
|
-
FroalaEditor.DefineIcon('popupClose', { NAME: 'trash', SVG_KEY: 'remove' });
|
|
1015
|
-
FroalaEditor.RegisterCommand('popupClose', {
|
|
1016
|
-
title: 'Remove',
|
|
1017
|
-
undo: false,
|
|
1018
|
-
focus: false,
|
|
1019
|
-
callback: function () {
|
|
1020
|
-
if (_this._activeEl) {
|
|
1021
|
-
_this._activeEl.remove();
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
});
|
|
1025
|
-
return [2 /*return*/];
|
|
1026
|
-
}
|
|
1027
|
-
});
|
|
1028
|
-
});
|
|
1029
|
-
};
|
|
1030
|
-
ScreenRecordPlugin.prototype._createPopup = function () {
|
|
1031
|
-
var template = {
|
|
1032
|
-
buttons: "<div class=\"fr-buttons\">" + this.editor.button.buildList(['popupClose']) + "</div>",
|
|
1033
|
-
};
|
|
1034
|
-
return this.editor.popups.create('screenRecordPlugin.popup', template);
|
|
1035
|
-
};
|
|
1036
|
-
ScreenRecordPlugin.prototype._showPopup = function (el) {
|
|
1037
|
-
var $popup = this.editor.popups.get('screenRecordPlugin.popup');
|
|
1038
|
-
if (!$popup) {
|
|
1039
|
-
$popup = this._createPopup();
|
|
1040
|
-
}
|
|
1041
|
-
this.editor.popups.setContainer('screenRecordPlugin.popup', this.editor.$(el));
|
|
1042
|
-
var left = el.offsetLeft + el.offsetWidth / 2;
|
|
1043
|
-
this.editor.popups.show('screenRecordPlugin.popup', left, null);
|
|
1044
|
-
};
|
|
1045
|
-
ScreenRecordPlugin.prototype._getEl = function (el) {
|
|
1046
|
-
if (el && el.classList) {
|
|
1047
|
-
if (el.classList.contains('fr-screen-record'))
|
|
1048
|
-
return el;
|
|
1049
|
-
return this._getEl(el.parentNode);
|
|
1050
|
-
}
|
|
1051
|
-
};
|
|
1052
|
-
return ScreenRecordPlugin;
|
|
967
|
+
var ScreenRecordPlugin = /** @class */ (function (_super) {
|
|
968
|
+
__extends(ScreenRecordPlugin, _super);
|
|
969
|
+
function ScreenRecordPlugin(config) {
|
|
970
|
+
if (config === void 0) { config = {}; }
|
|
971
|
+
var _this = _super.call(this) || this;
|
|
972
|
+
_this.config = config;
|
|
973
|
+
_this.config = __assign(__assign({}, config), { name: config.name || 'screenRecord', buttons: [
|
|
974
|
+
{
|
|
975
|
+
name: 'screenRecord',
|
|
976
|
+
svgPath: "M14.7,7.7v6.1H7.1V7.7H14.7 M16.3,9.6V6.9c0-0.4-0.3-0.8-0.8-0.8H6.4c-0.4,0-0.8,0.3-0.8,0.8v7.6c0,0.4,0.3,0.8,0.8,0.8h9.1c0.4,0,0.8-0.3,0.8-0.8v-2.7l1.7,1.7c0.3,0.3,0.8,0.3,1.1,0c0.1-0.1,0.2-0.3,0.2-0.5V8.4c0-0.4-0.3-0.8-0.8-0.8\n\tc-0.2,0-0.4,0.1-0.5,0.2L16.3,9.6z M21.5,1.6H2.9c-0.7,0-1.3,0.7-1.3,1.6v14.6c0,0.9,0.6,1.6,1.3,1.6h7.6v1.1l-5,1c-0.2,0-0.4,0.3-0.4,0.6c0,0.3,0.2,0.4,0.4,0.4c0,0,0,0,0.1,0l5.3-1h2.6l5.3,1c0,0,0,0,0.1,0c0.2,0,0.4-0.2,0.4-0.4\n c0-0.3-0.1-0.6-0.4-0.6l-5-1v-1.1h7.6c0.7,0,1.3-0.7,1.3-1.6V3.2C22.9,2.3,22.3,1.6,21.5,1.6z M21.1,17.3H3.3V3.7h17.8L21.1,17.3L21.1,17.3z",
|
|
977
|
+
tooltip: 'Screen Record',
|
|
978
|
+
click: function (editor) {
|
|
979
|
+
navigator.mediaDevices.getDisplayMedia({ video: true })
|
|
980
|
+
.then(function (stream) {
|
|
981
|
+
var chunks = [];
|
|
982
|
+
var options = { mimeType: 'video/webm; codecs=vp9' };
|
|
983
|
+
var mediaRecorder = new MediaRecorder(stream, options);
|
|
984
|
+
stream.addEventListener('inactive', function (e) {
|
|
985
|
+
mediaRecorder.stop();
|
|
986
|
+
mediaRecorder = null;
|
|
987
|
+
stream.getTracks().forEach(function (track) { return track.stop(); });
|
|
988
|
+
stream = null;
|
|
989
|
+
var blob = new Blob(chunks, { type: 'video/webm' });
|
|
990
|
+
config.upload(blob)
|
|
991
|
+
.subscribe(function (url) {
|
|
992
|
+
editor.html.insert("<span class=\"fr-screen-record fr-deletable fr-draggable\"><video controls style=\"max-width:" + config.maxWidth + "\"><source src=\"" + url + "\" type=\"video/webm\"></video></span>");
|
|
993
|
+
});
|
|
994
|
+
});
|
|
995
|
+
mediaRecorder.addEventListener('dataavailable', function (event) {
|
|
996
|
+
if (event.data && event.data.size > 0) {
|
|
997
|
+
chunks.push(event.data);
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
mediaRecorder.start(10);
|
|
1001
|
+
})
|
|
1002
|
+
.catch(function (e) { });
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
] });
|
|
1006
|
+
return _this;
|
|
1007
|
+
}
|
|
1008
|
+
ScreenRecordPlugin.prototype.initialize = function () {
|
|
1009
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1010
|
+
var FroalaEditor;
|
|
1011
|
+
var _this = this;
|
|
1012
|
+
return __generator(this, function (_a) {
|
|
1013
|
+
switch (_a.label) {
|
|
1014
|
+
case 0: return [4 /*yield*/, ResourceLoader.loadStyles('froala')
|
|
1015
|
+
.toPromise()];
|
|
1016
|
+
case 1:
|
|
1017
|
+
_a.sent();
|
|
1018
|
+
FroalaEditor = window.FroalaEditor;
|
|
1019
|
+
this.editor.events.on('mouseup', function (e) {
|
|
1020
|
+
var el = _this._getEl(e.target);
|
|
1021
|
+
if (el) {
|
|
1022
|
+
_this.editor.popups.hideAll();
|
|
1023
|
+
_this._activeEl = el;
|
|
1024
|
+
_this._showPopup(el);
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
FroalaEditor.POPUP_TEMPLATES["screenRecordPlugin.popup"] = '[_BUTTONS_]';
|
|
1028
|
+
FroalaEditor.DefineIcon('popupClose', { NAME: 'trash', SVG_KEY: 'remove' });
|
|
1029
|
+
FroalaEditor.RegisterCommand('popupClose', {
|
|
1030
|
+
title: 'Remove',
|
|
1031
|
+
undo: false,
|
|
1032
|
+
focus: false,
|
|
1033
|
+
callback: function () {
|
|
1034
|
+
if (_this._activeEl) {
|
|
1035
|
+
_this._activeEl.remove();
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
});
|
|
1039
|
+
return [2 /*return*/];
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
});
|
|
1043
|
+
};
|
|
1044
|
+
ScreenRecordPlugin.prototype._createPopup = function () {
|
|
1045
|
+
var template = {
|
|
1046
|
+
buttons: "<div class=\"fr-buttons\">" + this.editor.button.buildList(['popupClose']) + "</div>",
|
|
1047
|
+
};
|
|
1048
|
+
return this.editor.popups.create('screenRecordPlugin.popup', template);
|
|
1049
|
+
};
|
|
1050
|
+
ScreenRecordPlugin.prototype._showPopup = function (el) {
|
|
1051
|
+
var $popup = this.editor.popups.get('screenRecordPlugin.popup');
|
|
1052
|
+
if (!$popup) {
|
|
1053
|
+
$popup = this._createPopup();
|
|
1054
|
+
}
|
|
1055
|
+
this.editor.popups.setContainer('screenRecordPlugin.popup', this.editor.$(el));
|
|
1056
|
+
var left = el.offsetLeft + el.offsetWidth / 2;
|
|
1057
|
+
this.editor.popups.show('screenRecordPlugin.popup', left, null);
|
|
1058
|
+
};
|
|
1059
|
+
ScreenRecordPlugin.prototype._getEl = function (el) {
|
|
1060
|
+
if (el && el.classList) {
|
|
1061
|
+
if (el.classList.contains('fr-screen-record'))
|
|
1062
|
+
return el;
|
|
1063
|
+
return this._getEl(el.parentNode);
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
return ScreenRecordPlugin;
|
|
1053
1067
|
}(Plugin));
|
|
1054
1068
|
|
|
1055
|
-
/**
|
|
1056
|
-
* Generated bundle index. Do not edit.
|
|
1069
|
+
/**
|
|
1070
|
+
* Generated bundle index. Do not edit.
|
|
1057
1071
|
*/
|
|
1058
1072
|
|
|
1059
1073
|
export { ChecklistPlugin, CodePlugin, FS_HTML_EDITOR_CONFIG, FsHtmlEditorComponent, FsHtmlEditorModule, FsHtmlRendererComponent, MentionPlugin, ParagraphButtons, RichButtons, ScreenRecordPlugin, TextButtons, FsHtmlEditorConfigFactory as ɵa, FS_HTML_EDITOR_DEFAULT_CONFIG as ɵb, FsFroalaLoaderService as ɵc, Plugin as ɵe };
|