@stratusjs/angular 0.4.5 → 0.4.7
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/package.json +1 -1
- package/src/data/convoy.interface.ts +1 -1
- package/src/editor/citation-dialog.component.css +7 -0
- package/src/editor/citation-dialog.component.css.map +1 -0
- package/src/editor/citation-dialog.component.html +12 -14
- package/src/editor/citation-dialog.component.js +27 -12
- package/src/editor/citation-dialog.component.js.map +1 -1
- package/src/editor/citation-dialog.component.min.css +1 -0
- package/src/editor/citation-dialog.component.min.html +1 -1
- package/src/editor/citation-dialog.component.min.js +1 -1
- package/src/editor/citation-dialog.component.scss +10 -0
- package/src/editor/citation-dialog.component.ts +35 -17
- package/src/editor/editor.component.css +5 -0
- package/src/editor/editor.component.css.map +1 -1
- package/src/editor/editor.component.js +2 -5
- package/src/editor/editor.component.js.map +1 -1
- package/src/editor/editor.component.min.css +1 -1
- package/src/editor/editor.component.min.js +1 -1
- package/src/editor/editor.component.scss +6 -0
- package/src/editor/editor.component.ts +8 -6
- package/src/editor/link-dialog.component.css +3 -0
- package/src/editor/link-dialog.component.css.map +1 -1
- package/src/editor/link-dialog.component.html +5 -2
- package/src/editor/link-dialog.component.js +38 -6
- package/src/editor/link-dialog.component.js.map +1 -1
- package/src/editor/link-dialog.component.min.css +1 -1
- package/src/editor/link-dialog.component.min.html +1 -1
- package/src/editor/link-dialog.component.min.js +1 -1
- package/src/editor/link-dialog.component.scss +3 -0
- package/src/editor/link-dialog.component.ts +54 -11
- package/src/froala/plugins/citationManager.css +18 -7
- package/src/froala/plugins/citationManager.css.map +1 -1
- package/src/froala/plugins/citationManager.js +106 -9
- package/src/froala/plugins/citationManager.js.map +1 -1
- package/src/froala/plugins/citationManager.min.css +1 -1
- package/src/froala/plugins/citationManager.min.js +1 -1
- package/src/froala/plugins/citationManager.scss +18 -7
- package/src/froala/plugins/citationManager.ts +166 -13
- package/src/tree/tree-dialog.component.html +1 -1
- package/src/tree/tree-dialog.component.min.html +1 -1
|
@@ -93,9 +93,11 @@ export class LinkDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
93
93
|
// TODO: Move this to its own AutoComplete Component
|
|
94
94
|
// AutoComplete Data
|
|
95
95
|
apiBase = '/Api/Content'
|
|
96
|
-
contentEntities:
|
|
96
|
+
contentEntities: ContentEntity[] = []
|
|
97
|
+
contentEntity: ContentEntity
|
|
97
98
|
dialogContentForm: FormGroup
|
|
98
99
|
isContentLoading = true
|
|
100
|
+
isSingleContentLoading = false
|
|
99
101
|
lastContentQuery: string
|
|
100
102
|
|
|
101
103
|
// Pagination Data
|
|
@@ -119,10 +121,10 @@ export class LinkDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
119
121
|
|
|
120
122
|
// User Input
|
|
121
123
|
content: ContentEntity
|
|
122
|
-
linkType
|
|
123
|
-
linkText
|
|
124
|
-
linkURL
|
|
125
|
-
linkTarget
|
|
124
|
+
linkType = ''
|
|
125
|
+
linkText = ''
|
|
126
|
+
linkURL = ''
|
|
127
|
+
linkTarget = false
|
|
126
128
|
|
|
127
129
|
// Icon Localization
|
|
128
130
|
svgIcons: {
|
|
@@ -234,7 +236,9 @@ export class LinkDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
234
236
|
|
|
235
237
|
// Populate Data from Froala Element
|
|
236
238
|
this.linkType = this.element && this.element.hasAttribute('data-content-id') ? 'content' : 'url'
|
|
237
|
-
this.dialogContentForm
|
|
239
|
+
this.dialogContentForm
|
|
240
|
+
.get('linkTypeRadio')
|
|
241
|
+
.patchValue(this.linkType)
|
|
238
242
|
|
|
239
243
|
// Subscribe to Link Text Input Field
|
|
240
244
|
this.dialogContentForm
|
|
@@ -247,7 +251,9 @@ export class LinkDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
247
251
|
|
|
248
252
|
// Populate Data from Froala Element
|
|
249
253
|
this.linkText = this.element ? this.element.textContent : ''
|
|
250
|
-
this.dialogContentForm
|
|
254
|
+
this.dialogContentForm
|
|
255
|
+
.get('linkTextInput')
|
|
256
|
+
.patchValue(this.linkText)
|
|
251
257
|
|
|
252
258
|
// Subscribe to Link Text Input Field
|
|
253
259
|
this.dialogContentForm
|
|
@@ -260,7 +266,9 @@ export class LinkDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
260
266
|
|
|
261
267
|
// Populate Data from Froala Element
|
|
262
268
|
this.linkURL = this.element && this.element.hasAttribute('href') ? this.element.getAttribute('href') : ''
|
|
263
|
-
this.dialogContentForm
|
|
269
|
+
this.dialogContentForm
|
|
270
|
+
.get('linkURLInput')
|
|
271
|
+
.patchValue(this.linkURL)
|
|
264
272
|
|
|
265
273
|
// Subscribe to Link Target Checkbox Field
|
|
266
274
|
this.dialogContentForm
|
|
@@ -273,7 +281,41 @@ export class LinkDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
273
281
|
|
|
274
282
|
// Populate Data from Froala Element
|
|
275
283
|
this.linkTarget = this.element ? this.element.hasAttribute('target') : false
|
|
276
|
-
this.dialogContentForm
|
|
284
|
+
this.dialogContentForm
|
|
285
|
+
.get('linkTargetCheckbox')
|
|
286
|
+
.patchValue(this.linkTarget)
|
|
287
|
+
|
|
288
|
+
// Hydrate Selected Content
|
|
289
|
+
if (this.element && this.element.hasAttribute('data-content-id')) {
|
|
290
|
+
this.isSingleContentLoading = true
|
|
291
|
+
this.backend
|
|
292
|
+
.get(
|
|
293
|
+
this.getQueryUrl(
|
|
294
|
+
null,
|
|
295
|
+
this.element.getAttribute('data-content-id')
|
|
296
|
+
)
|
|
297
|
+
)
|
|
298
|
+
.pipe(
|
|
299
|
+
finalize(() => this.isSingleContentLoading = false),
|
|
300
|
+
)
|
|
301
|
+
.subscribe((response: HttpResponse<Convoy<ContentEntity>>) => {
|
|
302
|
+
if (!response.ok || response.status !== 200 || _.isEmpty(response.body)) {
|
|
303
|
+
return null
|
|
304
|
+
}
|
|
305
|
+
const payload = _.get(response.body, 'payload') || response.body
|
|
306
|
+
if (_.isEmpty(payload) || Array.isArray(payload) || !_.isObject(payload)) {
|
|
307
|
+
return null
|
|
308
|
+
}
|
|
309
|
+
// @ts-ignore
|
|
310
|
+
this.contentEntity = payload
|
|
311
|
+
this.isSingleContentLoading = false
|
|
312
|
+
this.dialogContentForm
|
|
313
|
+
.get('contentSelectorInput')
|
|
314
|
+
.patchValue(this.contentEntity)
|
|
315
|
+
this.refresh()
|
|
316
|
+
return this.contentEntity
|
|
317
|
+
})
|
|
318
|
+
}
|
|
277
319
|
|
|
278
320
|
// Mark as complete
|
|
279
321
|
this.isInitialized = true
|
|
@@ -306,9 +348,10 @@ export class LinkDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
306
348
|
)
|
|
307
349
|
}
|
|
308
350
|
|
|
309
|
-
getQueryUrl(query?: string): string {
|
|
351
|
+
getQueryUrl(query?: string, id?: string|number): string {
|
|
310
352
|
query = (!_.isString(query) || _.isEmpty(query)) ? '' : `"${query}"`
|
|
311
|
-
|
|
353
|
+
id = _.isEmpty(id) ? '' : `/${id}`
|
|
354
|
+
return `${this.apiBase}${id}?limit=${this.limit}&options[isContent]=null&options[isCollection]=null&options[showRoutable]=true&options[showRouting]=true&q=${query}`
|
|
312
355
|
}
|
|
313
356
|
|
|
314
357
|
getQuery(query?: string): Observable<HttpResponse<any>> {
|
|
@@ -4,20 +4,31 @@
|
|
|
4
4
|
.editor-component stratus-citation {
|
|
5
5
|
position: relative;
|
|
6
6
|
display: inline-block;
|
|
7
|
-
counter-increment: stratus-citation-counter;
|
|
8
|
-
color: transparent;
|
|
9
7
|
border-style: dotted;
|
|
10
8
|
border-color: cornflowerblue;
|
|
9
|
+
border-width: 2px;
|
|
10
|
+
color: #f85b3b; /* handle generic color better */
|
|
11
11
|
cursor: pointer;
|
|
12
|
-
height:
|
|
13
|
-
width: 20px;
|
|
14
|
-
|
|
12
|
+
min-height: 17px;
|
|
13
|
+
min-width: 20px;
|
|
14
|
+
}
|
|
15
|
+
.editor-component stratus-citation stratus-citation-content {
|
|
16
|
+
display: none;
|
|
17
|
+
}
|
|
18
|
+
.editor-component stratus-citation stratus-citation-title {
|
|
19
|
+
display: block;
|
|
20
|
+
position: relative;
|
|
21
|
+
top: -4px;
|
|
22
|
+
margin-bottom: -6px;
|
|
23
|
+
padding-top: 4px;
|
|
24
|
+
padding-right: 1px;
|
|
25
|
+
font-size: 0.75em;
|
|
15
26
|
}
|
|
16
|
-
.editor-component stratus-citation::before {
|
|
27
|
+
.editor-component stratus-citation stratus-citation-notitle::before {
|
|
28
|
+
counter-increment: stratus-citation-counter;
|
|
17
29
|
content: counter(stratus-citation-counter);
|
|
18
30
|
position: absolute;
|
|
19
31
|
left: 2px;
|
|
20
32
|
font-size: 0.75em;
|
|
21
|
-
color: #f85b3b; /* handle generic color better */
|
|
22
33
|
}
|
|
23
34
|
/*# sourceMappingURL=citationManager.css.map */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/angular/src/froala/plugins/citationManager.scss"],"names":[],"mappings":"AAAA;EACE;;AACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;
|
|
1
|
+
{"version":3,"sources":["packages/angular/src/froala/plugins/citationManager.scss"],"names":[],"mappings":"AAAA;EACE;;AACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACE;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;AAEF;EACE;EACA;EACA;EACA;EACA","file":"citationManager.css","sourcesContent":[".editor-component {\n counter-reset: stratus-citation-counter;\n stratus-citation {\n position: relative;\n display: inline-block;\n border-style: dotted;\n border-color: cornflowerblue;\n border-width: 2px;\n color: #f85b3b; /* handle generic color better */\n cursor: pointer;\n min-height: 17px;\n min-width: 20px;\n stratus-citation-content {\n display: none;\n }\n stratus-citation-title {\n display: block;\n position: relative;\n top: -4px;\n margin-bottom: -6px;\n padding-top: 4px;\n padding-right: 1px;\n font-size: 0.75em;\n }\n stratus-citation-notitle::before {\n counter-increment: stratus-citation-counter;\n content: counter(stratus-citation-counter);\n position: absolute;\n left: 2px;\n font-size: 0.75em;\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
System.register(["@stratusjs/core/environment", "@stratusjs/runtime/stratus", "@stratusjs/angular/froala/plugins/inputButton", "froala-editor"], function (exports_1, context_1) {
|
|
1
|
+
System.register(["@stratusjs/core/environment", "@stratusjs/runtime/stratus", "lodash", "@stratusjs/angular/froala/plugins/inputButton", "froala-editor"], function (exports_1, context_1) {
|
|
2
2
|
"use strict";
|
|
3
|
-
var environment_1, stratus_1, inputButton_1, froala_editor_1, systemDir, moduleName, parentModuleName, min, localDir;
|
|
3
|
+
var environment_1, stratus_1, lodash_1, inputButton_1, froala_editor_1, systemDir, moduleName, parentModuleName, min, localDir;
|
|
4
4
|
var __moduleName = context_1 && context_1.id;
|
|
5
5
|
return {
|
|
6
6
|
setters: [
|
|
@@ -10,6 +10,9 @@ System.register(["@stratusjs/core/environment", "@stratusjs/runtime/stratus", "@
|
|
|
10
10
|
function (stratus_1_1) {
|
|
11
11
|
stratus_1 = stratus_1_1;
|
|
12
12
|
},
|
|
13
|
+
function (lodash_1_1) {
|
|
14
|
+
lodash_1 = lodash_1_1;
|
|
15
|
+
},
|
|
13
16
|
function (inputButton_1_1) {
|
|
14
17
|
inputButton_1 = inputButton_1_1;
|
|
15
18
|
},
|
|
@@ -23,12 +26,15 @@ System.register(["@stratusjs/core/environment", "@stratusjs/runtime/stratus", "@
|
|
|
23
26
|
parentModuleName = 'froala/plugins';
|
|
24
27
|
min = !environment_1.cookie('env') ? '.min' : '';
|
|
25
28
|
localDir = `${stratus_1.Stratus.BaseUrl}${boot.configuration.paths[`${systemDir}/*`].replace(/[^/]*$/, '')}`;
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
lodash_1.extend(froala_editor_1.default.POPUP_TEMPLATES, {
|
|
30
|
+
'citationManager.toolbar': '[_BUTTONS_]'
|
|
31
|
+
});
|
|
32
|
+
lodash_1.extend(froala_editor_1.default.DEFAULTS, {
|
|
33
|
+
citationToolbarButtons: ['citationEdit', 'citationDelete']
|
|
28
34
|
});
|
|
29
35
|
froala_editor_1.default.PLUGINS.citationManager = function citationManager(editor) {
|
|
30
36
|
let inputButton;
|
|
31
|
-
const debug =
|
|
37
|
+
const debug = false;
|
|
32
38
|
function _init() {
|
|
33
39
|
stratus_1.Stratus.Internals.CssLoader(`${localDir}${parentModuleName}/${moduleName}${min}.css`);
|
|
34
40
|
inputButton = new inputButton_1.InputButtonPlugin({
|
|
@@ -41,10 +47,19 @@ System.register(["@stratusjs/core/environment", "@stratusjs/runtime/stratus", "@
|
|
|
41
47
|
});
|
|
42
48
|
if (debug) {
|
|
43
49
|
console.log('initialized:', {
|
|
44
|
-
options: editor.opts.endpoint,
|
|
45
50
|
instance: this
|
|
46
51
|
});
|
|
47
52
|
}
|
|
53
|
+
editor.events.on('click', (clickEvent) => {
|
|
54
|
+
if (clickEvent.hasOwnProperty('target') &&
|
|
55
|
+
(clickEvent.target.nodeName === 'STRATUS-CITATION' ||
|
|
56
|
+
clickEvent.target.nodeName === 'STRATUS-CITATION-TITLE')) {
|
|
57
|
+
const citation = getSelectedCitation();
|
|
58
|
+
if (citation) {
|
|
59
|
+
editor.citationManager.showToolbar(clickEvent, citation);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
48
63
|
}
|
|
49
64
|
function onClick() {
|
|
50
65
|
if (!editor.el) {
|
|
@@ -53,12 +68,80 @@ System.register(["@stratusjs/core/environment", "@stratusjs/runtime/stratus", "@
|
|
|
53
68
|
}
|
|
54
69
|
inputButton.onClick(editor.el);
|
|
55
70
|
}
|
|
71
|
+
function getSelectedCitation() {
|
|
72
|
+
let containedElement = editor.selection.endElement();
|
|
73
|
+
if (containedElement.tagName === 'STRATUS-CITATION') {
|
|
74
|
+
return containedElement;
|
|
75
|
+
}
|
|
76
|
+
containedElement = editor.selection.element();
|
|
77
|
+
if (containedElement.tagName === 'STRATUS-CITATION') {
|
|
78
|
+
return containedElement;
|
|
79
|
+
}
|
|
80
|
+
containedElement = containedElement.parentElement;
|
|
81
|
+
if (containedElement.tagName === 'STRATUS-CITATION') {
|
|
82
|
+
return containedElement;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
function getLastKnownCitation() {
|
|
87
|
+
return editor.citationManager.lastCitation || null;
|
|
88
|
+
}
|
|
89
|
+
function setLastKnownCitation(el) {
|
|
90
|
+
editor.citationManager.lastCitation = el;
|
|
91
|
+
}
|
|
92
|
+
function initToolbar() {
|
|
93
|
+
let citationToolbarButtons = '';
|
|
94
|
+
if (editor.opts.citationToolbarButtons.length > 1) {
|
|
95
|
+
citationToolbarButtons += '<div class="fr-buttons">';
|
|
96
|
+
citationToolbarButtons += editor.button.buildList(editor.opts.citationToolbarButtons);
|
|
97
|
+
citationToolbarButtons += '</div>';
|
|
98
|
+
}
|
|
99
|
+
const template = {
|
|
100
|
+
buttons: citationToolbarButtons
|
|
101
|
+
};
|
|
102
|
+
return editor.popups.create('citationManager.toolbar', template);
|
|
103
|
+
}
|
|
104
|
+
function showToolbar(clickEvent, citation) {
|
|
105
|
+
const popup = editor.popups.get('citationManager.toolbar');
|
|
106
|
+
if (!popup)
|
|
107
|
+
initToolbar();
|
|
108
|
+
editor.popups.setContainer('citationManager.toolbar', editor.$tb);
|
|
109
|
+
const btn = editor.$tb.find('.fr-command[data-cmd="myButton"]');
|
|
110
|
+
const left = clickEvent.pageX;
|
|
111
|
+
const top = clickEvent.pageY;
|
|
112
|
+
editor.popups.show('citationManager.toolbar', left, top, btn.outerHeight());
|
|
113
|
+
editor.citationManager.setLastKnownCitation(citation);
|
|
114
|
+
}
|
|
115
|
+
function hideToolbar() {
|
|
116
|
+
editor.citationManager.setLastKnownCitation(null);
|
|
117
|
+
editor.popups.hide('citationManager.toolbar');
|
|
118
|
+
}
|
|
56
119
|
return {
|
|
57
120
|
_init,
|
|
58
|
-
onClick
|
|
121
|
+
onClick,
|
|
122
|
+
showToolbar,
|
|
123
|
+
hideToolbar,
|
|
124
|
+
getSelectedCitation,
|
|
125
|
+
getLastKnownCitation,
|
|
126
|
+
setLastKnownCitation
|
|
59
127
|
};
|
|
60
128
|
};
|
|
61
|
-
froala_editor_1.default.
|
|
129
|
+
froala_editor_1.default.DefineIcon('citationDelete', { NAME: 'citationDelete', SVG_KEY: 'remove' });
|
|
130
|
+
froala_editor_1.default.RegisterCommand('citationDelete', {
|
|
131
|
+
title: 'Delete Citation',
|
|
132
|
+
undo: false,
|
|
133
|
+
focus: false,
|
|
134
|
+
callback() {
|
|
135
|
+
const containedElement = this.citationManager.getSelectedCitation();
|
|
136
|
+
if (containedElement) {
|
|
137
|
+
containedElement.remove();
|
|
138
|
+
}
|
|
139
|
+
this.citationManager.hideToolbar();
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
froala_editor_1.default.DefineIcon('citationManager', { NAME: 'citationManager', SVG_KEY: 'imageCaption' });
|
|
143
|
+
froala_editor_1.default.RegisterCommand('citationInsert', {
|
|
144
|
+
icon: 'citationManager',
|
|
62
145
|
title: 'Insert Citation',
|
|
63
146
|
undo: false,
|
|
64
147
|
focus: false,
|
|
@@ -72,7 +155,21 @@ System.register(["@stratusjs/core/environment", "@stratusjs/runtime/stratus", "@
|
|
|
72
155
|
},
|
|
73
156
|
plugin: 'citationManager',
|
|
74
157
|
});
|
|
75
|
-
froala_editor_1.default.
|
|
158
|
+
froala_editor_1.default.RegisterCommand('citationEdit', {
|
|
159
|
+
icon: 'citationManager',
|
|
160
|
+
title: 'Edit Citation',
|
|
161
|
+
undo: false,
|
|
162
|
+
focus: false,
|
|
163
|
+
modal: true,
|
|
164
|
+
callback(cmd, _val, _params) {
|
|
165
|
+
const debug = false;
|
|
166
|
+
if (debug) {
|
|
167
|
+
console.log('clicked:', this.citationManager);
|
|
168
|
+
}
|
|
169
|
+
this.citationManager.onClick();
|
|
170
|
+
},
|
|
171
|
+
plugin: 'citationManager',
|
|
172
|
+
});
|
|
76
173
|
froala_editor_1.default.RegisterQuickInsertButton('citation', {
|
|
77
174
|
icon: 'citationManager',
|
|
78
175
|
title: 'Insert Citation',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["citationManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["citationManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;YAaM,SAAS,GAAG,oBAAoB,CAAA;YAChC,UAAU,GAAG,iBAAiB,CAAA;YAC9B,gBAAgB,GAAG,gBAAgB,CAAA;YAGnC,GAAG,GAAG,CAAC,oBAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;YAClC,QAAQ,GAAG,GAAG,iBAAO,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAA;YAGxG,eAAM,CAAC,uBAAY,CAAC,eAAe,EAAC;gBAChC,yBAAyB,EAAE,aAAa;aAC3C,CAAC,CAAA;YAGF,eAAM,CAAC,uBAAY,CAAC,QAAQ,EAAC;gBACzB,sBAAsB,EAAE,CAAC,cAAc,EAAE,gBAAgB,CAAC;aAC7D,CAAC,CAAA;YAKF,uBAAY,CAAC,OAAO,CAAC,eAAe,GAAG,SAAS,eAAe,CAAC,MAAW;gBACvE,IAAI,WAA8B,CAAA;gBAElC,MAAM,KAAK,GAAG,KAAK,CAAA;gBAGnB,SAAS,KAAK;oBACV,iBAAO,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,QAAQ,GAAG,gBAAgB,IAAI,UAAU,GAAG,GAAG,MAAM,CAAC,CAAA;oBACrF,WAAW,GAAG,IAAI,+BAAiB,CAAC;wBAChC,IAAI,EAAE,kBAAkB;wBACxB,SAAS,EAAE,gBAAgB;wBAC3B,MAAM;wBACN,iBAAiB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AAA;oBACF,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE;wBACV,OAAO,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAA;wBACjE,OAAM;qBACT;oBACD,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAChC,CAAC;gBAGD,IAAI,EAAE,IAAI;aACb,CAAC,CAAA;QACF,CAAC","file":"citationManager.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.editor-component{counter-reset:stratus-citation-counter}.editor-component stratus-citation{position:relative;display:inline-block;
|
|
1
|
+
.editor-component{counter-reset:stratus-citation-counter}.editor-component stratus-citation{position:relative;display:inline-block;border-style:dotted;border-color:#6495ed;border-width:2px;color:#f85b3b;cursor:pointer;min-height:17px;min-width:20px}.editor-component stratus-citation stratus-citation-content{display:none}.editor-component stratus-citation stratus-citation-title{display:block;position:relative;top:-4px;margin-bottom:-6px;padding-top:4px;padding-right:1px;font-size:.75em}.editor-component stratus-citation stratus-citation-notitle::before{counter-increment:stratus-citation-counter;content:counter(stratus-citation-counter);position:absolute;left:2px;font-size:.75em}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
System.register(["@stratusjs/core/environment","@stratusjs/runtime/stratus","@stratusjs/angular/froala/plugins/inputButton","froala-editor"],function(t,n){"use strict";var e,i,
|
|
1
|
+
System.register(["@stratusjs/core/environment","@stratusjs/runtime/stratus","lodash","@stratusjs/angular/froala/plugins/inputButton","froala-editor"],function(t,n){"use strict";var a,e,i,o,c,r,l;n&&n.id;return{setters:[function(t){a=t},function(t){e=t},function(t){i=t},function(t){o=t},function(t){c=t}],execute:function(){"@stratusjs/angular","citationManager","froala/plugins",r=a.cookie("env")?"":".min",l=`${e.Stratus.BaseUrl}${boot.configuration.paths["@stratusjs/angular/*"].replace(/[^/]*$/,"")}`,i.extend(c.default.POPUP_TEMPLATES,{"citationManager.toolbar":"[_BUTTONS_]"}),i.extend(c.default.DEFAULTS,{citationToolbarButtons:["citationEdit","citationDelete"]}),c.default.PLUGINS.citationManager=function(t){let n;function a(){let n=t.selection.endElement();return"STRATUS-CITATION"===n.tagName?n:(n=t.selection.element(),"STRATUS-CITATION"===n.tagName?n:(n=n.parentElement,"STRATUS-CITATION"===n.tagName?n:null))}return{_init:function(){e.Stratus.Internals.CssLoader(`${l}froala/plugins/citationManager${r}.css`),n=new o.InputButtonPlugin({name:"Citation Manager",eventName:"citation-input",editor:t,autoSaveSelection:!0,autoRestoreSelection:!0,debug:false}),t.events.on("click",n=>{if(n.hasOwnProperty("target")&&("STRATUS-CITATION"===n.target.nodeName||"STRATUS-CITATION-TITLE"===n.target.nodeName)){const e=a();e&&t.citationManager.showToolbar(n,e)}})},onClick:function(){t.el?n.onClick(t.el):console.warn("citationManager.onClick(): unable to find element")},showToolbar:function(n,a){t.popups.get("citationManager.toolbar")||function(){let n="";t.opts.citationToolbarButtons.length>1&&(n+='<div class="fr-buttons">',n+=t.button.buildList(t.opts.citationToolbarButtons),n+="</div>");const a={buttons:n};t.popups.create("citationManager.toolbar",a)}(),t.popups.setContainer("citationManager.toolbar",t.$tb);const e=t.$tb.find('.fr-command[data-cmd="myButton"]'),i=n.pageX,o=n.pageY;t.popups.show("citationManager.toolbar",i,o,e.outerHeight()),t.citationManager.setLastKnownCitation(a)},hideToolbar:function(){t.citationManager.setLastKnownCitation(null),t.popups.hide("citationManager.toolbar")},getSelectedCitation:a,getLastKnownCitation:function(){return t.citationManager.lastCitation||null},setLastKnownCitation:function(n){t.citationManager.lastCitation=n}}},c.default.DefineIcon("citationDelete",{NAME:"citationDelete",SVG_KEY:"remove"}),c.default.RegisterCommand("citationDelete",{title:"Delete Citation",undo:!1,focus:!1,callback(){const t=this.citationManager.getSelectedCitation();t&&t.remove(),this.citationManager.hideToolbar()}}),c.default.DefineIcon("citationManager",{NAME:"citationManager",SVG_KEY:"imageCaption"}),c.default.RegisterCommand("citationInsert",{icon:"citationManager",title:"Insert Citation",undo:!1,focus:!1,modal:!0,callback(t,n,a){this.citationManager.onClick()},plugin:"citationManager"}),c.default.RegisterCommand("citationEdit",{icon:"citationManager",title:"Edit Citation",undo:!1,focus:!1,modal:!0,callback(t,n,a){this.citationManager.onClick()},plugin:"citationManager"}),c.default.RegisterQuickInsertButton("citation",{icon:"citationManager",title:"Insert Citation",callback:function(){const t=new o.InputButtonPlugin({name:"Citation Manager",eventName:"citation-input",editor:this,autoSaveSelection:!0,autoRestoreSelection:!0,debug:!1});this.el?t.onClick(this.el):console.warn("citationManager.onClick(): unable to find element")},undo:!0})}}});
|
|
@@ -3,20 +3,31 @@
|
|
|
3
3
|
stratus-citation {
|
|
4
4
|
position: relative;
|
|
5
5
|
display: inline-block;
|
|
6
|
-
counter-increment: stratus-citation-counter;
|
|
7
|
-
color: transparent;
|
|
8
6
|
border-style: dotted;
|
|
9
7
|
border-color: cornflowerblue;
|
|
8
|
+
border-width: 2px;
|
|
9
|
+
color: #f85b3b; /* handle generic color better */
|
|
10
10
|
cursor: pointer;
|
|
11
|
-
height:
|
|
12
|
-
width: 20px;
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
min-height: 17px;
|
|
12
|
+
min-width: 20px;
|
|
13
|
+
stratus-citation-content {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
16
|
+
stratus-citation-title {
|
|
17
|
+
display: block;
|
|
18
|
+
position: relative;
|
|
19
|
+
top: -4px;
|
|
20
|
+
margin-bottom: -6px;
|
|
21
|
+
padding-top: 4px;
|
|
22
|
+
padding-right: 1px;
|
|
23
|
+
font-size: 0.75em;
|
|
24
|
+
}
|
|
25
|
+
stratus-citation-notitle::before {
|
|
26
|
+
counter-increment: stratus-citation-counter;
|
|
15
27
|
content: counter(stratus-citation-counter);
|
|
16
28
|
position: absolute;
|
|
17
29
|
left: 2px;
|
|
18
30
|
font-size: 0.75em;
|
|
19
|
-
color: #f85b3b; /* handle generic color better */
|
|
20
31
|
}
|
|
21
32
|
}
|
|
22
33
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {cookie} from '@stratusjs/core/environment'
|
|
2
2
|
import {Stratus} from '@stratusjs/runtime/stratus'
|
|
3
|
+
import {extend} from 'lodash'
|
|
3
4
|
// Universal Button
|
|
4
5
|
import {
|
|
5
6
|
InputButtonPlugin
|
|
@@ -18,18 +19,23 @@ const parentModuleName = 'froala/plugins'
|
|
|
18
19
|
const min = !cookie('env') ? '.min' : ''
|
|
19
20
|
const localDir = `${Stratus.BaseUrl}${boot.configuration.paths[`${systemDir}/*`].replace(/[^/]*$/, '')}`
|
|
20
21
|
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
// Define toolbar template.
|
|
23
|
+
extend(FroalaEditor.POPUP_TEMPLATES,{
|
|
24
|
+
'citationManager.toolbar': '[_BUTTONS_]'
|
|
24
25
|
})
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
// Define toolbar buttons.
|
|
28
|
+
extend(FroalaEditor.DEFAULTS,{
|
|
29
|
+
citationToolbarButtons: ['citationEdit', 'citationDelete']
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
/*
|
|
27
33
|
* @param editor The Froala instance
|
|
28
34
|
*/
|
|
29
|
-
FroalaEditor.PLUGINS.citationManager = function citationManager
|
|
35
|
+
FroalaEditor.PLUGINS.citationManager = function citationManager(editor: any) {
|
|
30
36
|
let inputButton: InputButtonPlugin
|
|
31
37
|
|
|
32
|
-
const debug =
|
|
38
|
+
const debug = false
|
|
33
39
|
|
|
34
40
|
// When the plugin is initialized,this will be called.
|
|
35
41
|
function _init() {
|
|
@@ -45,7 +51,6 @@ FroalaEditor.PLUGINS.citationManager = function citationManager (editor: any) {
|
|
|
45
51
|
|
|
46
52
|
if (debug) {
|
|
47
53
|
console.log('initialized:', {
|
|
48
|
-
options: editor.opts.endpoint,
|
|
49
54
|
instance: this
|
|
50
55
|
})
|
|
51
56
|
}
|
|
@@ -54,7 +59,21 @@ FroalaEditor.PLUGINS.citationManager = function citationManager (editor: any) {
|
|
|
54
59
|
// editor.methodName(params);
|
|
55
60
|
|
|
56
61
|
// Event listeners
|
|
57
|
-
|
|
62
|
+
editor.events.on('click', (clickEvent: MouseEvent) => {
|
|
63
|
+
if (
|
|
64
|
+
clickEvent.hasOwnProperty('target') &&
|
|
65
|
+
// clickEvent.target.hasOwnProperty('nodeName') &&
|
|
66
|
+
(
|
|
67
|
+
(clickEvent.target as Element).nodeName === 'STRATUS-CITATION' ||
|
|
68
|
+
(clickEvent.target as Element).nodeName === 'STRATUS-CITATION-TITLE'
|
|
69
|
+
)
|
|
70
|
+
) {
|
|
71
|
+
const citation = getSelectedCitation() // If citation isn't fully grabbed, will not attempt
|
|
72
|
+
if (citation) {
|
|
73
|
+
editor.citationManager.showToolbar(clickEvent, citation)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
})
|
|
58
77
|
}
|
|
59
78
|
|
|
60
79
|
function onClick() {
|
|
@@ -65,17 +84,136 @@ FroalaEditor.PLUGINS.citationManager = function citationManager (editor: any) {
|
|
|
65
84
|
inputButton.onClick(editor.el)
|
|
66
85
|
}
|
|
67
86
|
|
|
87
|
+
function getSelectedCitation(): Element | null {
|
|
88
|
+
let containedElement = editor.selection.endElement()
|
|
89
|
+
if (containedElement.tagName === 'STRATUS-CITATION') {
|
|
90
|
+
// console.log('returning endElement', containedElement.tagName)
|
|
91
|
+
return containedElement
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// console.log('endElement was a ', containedElement.tagName, containedElement)
|
|
95
|
+
containedElement = editor.selection.element()
|
|
96
|
+
if (containedElement.tagName === 'STRATUS-CITATION') {
|
|
97
|
+
// console.log('returning element', containedElement.tagName)
|
|
98
|
+
return containedElement
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// console.log('element was a ', containedElement.tagName, containedElement)
|
|
102
|
+
// Check the parent just to be sure
|
|
103
|
+
containedElement = containedElement.parentElement
|
|
104
|
+
if (containedElement.tagName === 'STRATUS-CITATION') {
|
|
105
|
+
// console.log('returning parent element', containedElement.tagName)
|
|
106
|
+
return containedElement
|
|
107
|
+
}
|
|
108
|
+
// console.log('parent element was a ', containedElement.tagName, containedElement, 'returning nothing')
|
|
109
|
+
|
|
110
|
+
return null
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function getLastKnownCitation() {
|
|
114
|
+
// console.log('returning last citation', editor.citationManager.lastCitation)
|
|
115
|
+
return editor.citationManager.lastCitation || null
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function setLastKnownCitation(el: Element | null) {
|
|
119
|
+
// console.log('setting last citation to', el)
|
|
120
|
+
editor.citationManager.lastCitation = el
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Create custom inline toolbar.
|
|
124
|
+
function initToolbar() {
|
|
125
|
+
// Toolbar buttons.
|
|
126
|
+
let citationToolbarButtons = ''
|
|
127
|
+
// Create the list of buttons.
|
|
128
|
+
if (editor.opts.citationToolbarButtons.length > 1) {
|
|
129
|
+
citationToolbarButtons += '<div class="fr-buttons">'
|
|
130
|
+
citationToolbarButtons += editor.button.buildList(editor.opts.citationToolbarButtons)
|
|
131
|
+
citationToolbarButtons += '</div>'
|
|
132
|
+
}
|
|
133
|
+
// Load popup template.
|
|
134
|
+
const template = {
|
|
135
|
+
buttons: citationToolbarButtons
|
|
136
|
+
}
|
|
137
|
+
// Create popup.
|
|
138
|
+
return editor.popups.create('citationManager.toolbar', template)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Show the toolbar
|
|
142
|
+
function showToolbar(clickEvent: MouseEvent, citation: Element) {
|
|
143
|
+
// Get the popup object defined above.
|
|
144
|
+
const popup = editor.popups.get('citationManager.toolbar')
|
|
145
|
+
// If popup doesn't exist then create it.
|
|
146
|
+
// To improve performance it is best to create the popup when it is first needed
|
|
147
|
+
// and not when the editor is initialized.
|
|
148
|
+
if (!popup) initToolbar()
|
|
149
|
+
|
|
150
|
+
// Set the editor toolbar as the popup's container.
|
|
151
|
+
editor.popups.setContainer('citationManager.toolbar', editor.$tb)
|
|
152
|
+
// This will trigger the refresh event assigned to the popup.
|
|
153
|
+
// editor.popups.refresh('citationManager.toolbar');
|
|
154
|
+
// This custom popup is opened by pressing a button from the editor's toolbar.
|
|
155
|
+
// Get the button's object in order to place the popup relative to it.
|
|
156
|
+
const btn = editor.$tb.find('.fr-command[data-cmd="myButton"]')
|
|
157
|
+
// Set the popup's position.
|
|
158
|
+
const left = clickEvent.pageX
|
|
159
|
+
const top = clickEvent.pageY
|
|
160
|
+
// Show the custom toolbar.
|
|
161
|
+
// The button's outerHeight is required in case the popup needs to be displayed above it.
|
|
162
|
+
editor.popups.show('citationManager.toolbar', left, top, btn.outerHeight())
|
|
163
|
+
// Hold onto this lastKnown for the dialog to use -this- element
|
|
164
|
+
editor.citationManager.setLastKnownCitation(citation)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Hide the custom popup.
|
|
168
|
+
function hideToolbar() {
|
|
169
|
+
editor.citationManager.setLastKnownCitation(null)
|
|
170
|
+
editor.popups.hide('citationManager.toolbar')
|
|
171
|
+
}
|
|
172
|
+
|
|
68
173
|
// Expose public methods.
|
|
69
174
|
// Public methods can be accessed through the editor API:
|
|
70
175
|
// editor.myPlugin.publicMethod();
|
|
71
176
|
return {
|
|
72
177
|
// If _init is not public then the plugin won't be initialized.
|
|
73
178
|
_init,
|
|
74
|
-
onClick
|
|
179
|
+
onClick,
|
|
180
|
+
showToolbar,
|
|
181
|
+
hideToolbar,
|
|
182
|
+
getSelectedCitation,
|
|
183
|
+
getLastKnownCitation,
|
|
184
|
+
setLastKnownCitation
|
|
75
185
|
}
|
|
76
186
|
}
|
|
187
|
+
export type CitationManager = {
|
|
188
|
+
hideToolbar(): void
|
|
189
|
+
showToolbar(): void
|
|
190
|
+
getSelectedCitation(): Element | null
|
|
191
|
+
getLastKnownCitation(): Element | null
|
|
192
|
+
setLastKnownCitation(el: Element | null): void
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
FroalaEditor.DefineIcon('citationDelete',{NAME: 'citationDelete', SVG_KEY: 'remove'})
|
|
196
|
+
FroalaEditor.RegisterCommand('citationDelete', {
|
|
197
|
+
title: 'Delete Citation',
|
|
198
|
+
undo: false,
|
|
199
|
+
focus: false,
|
|
200
|
+
callback() {
|
|
201
|
+
/// only grab the selectedCitation
|
|
202
|
+
const containedElement = this.citationManager.getSelectedCitation()
|
|
203
|
+
if (containedElement) {
|
|
204
|
+
(containedElement as Element).remove()
|
|
205
|
+
}
|
|
206
|
+
this.citationManager.hideToolbar()
|
|
207
|
+
}
|
|
208
|
+
})
|
|
77
209
|
|
|
78
|
-
|
|
210
|
+
// Define button icons
|
|
211
|
+
FroalaEditor.DefineIcon('citationManager', {NAME: 'citationManager', SVG_KEY: 'imageCaption'})
|
|
212
|
+
// See https://froala.com/wysiwyg-editor/docs/concepts/custom/icon/ for making new icons
|
|
213
|
+
|
|
214
|
+
// Define a insert button
|
|
215
|
+
FroalaEditor.RegisterCommand('citationInsert', {
|
|
216
|
+
icon: 'citationManager',
|
|
79
217
|
title: 'Insert Citation',
|
|
80
218
|
undo: false,
|
|
81
219
|
focus: false,
|
|
@@ -93,9 +231,24 @@ FroalaEditor.RegisterCommand('citationManager', {
|
|
|
93
231
|
plugin: 'citationManager',
|
|
94
232
|
})
|
|
95
233
|
|
|
96
|
-
// Define button
|
|
97
|
-
FroalaEditor.
|
|
98
|
-
|
|
234
|
+
// Define a edit button
|
|
235
|
+
FroalaEditor.RegisterCommand('citationEdit', {
|
|
236
|
+
icon: 'citationManager',
|
|
237
|
+
title: 'Edit Citation',
|
|
238
|
+
undo: false,
|
|
239
|
+
focus: false,
|
|
240
|
+
modal: true,
|
|
241
|
+
callback(cmd: unknown, _val: unknown, _params: unknown) {
|
|
242
|
+
const debug = false
|
|
243
|
+
if (debug) {
|
|
244
|
+
console.log('clicked:', this.citationManager)
|
|
245
|
+
}
|
|
246
|
+
this.citationManager.onClick()
|
|
247
|
+
},
|
|
248
|
+
plugin: 'citationManager',
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
|
|
99
252
|
|
|
100
253
|
// Define a quick insert button
|
|
101
254
|
FroalaEditor.RegisterQuickInsertButton('citation', {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
#auto="matAutocomplete"
|
|
57
57
|
[displayWith]="displayContentText">
|
|
58
58
|
<mat-option *ngIf="isContentLoading" class="is-loading">
|
|
59
|
-
<mat-
|
|
59
|
+
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
|
|
60
60
|
</mat-option>
|
|
61
61
|
<ng-container *ngIf="!isContentLoading">
|
|
62
62
|
<!-- TODO: Modify to filteredContentModels|async which should improve responsiveness -->
|