@stratusjs/angular 0.3.9 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/angular.modules.js.map +1 -1
- package/src/app.module.js +7 -2
- package/src/app.module.js.map +1 -1
- package/src/app.module.min.js +1 -1
- package/src/app.module.ts +3 -0
- package/src/backend.service.js.map +1 -1
- package/src/base/base.component.js.map +1 -1
- package/src/confirm-dialog/confirm-dialog.component.js.map +1 -1
- package/src/editor/citation-dialog.component.html +50 -0
- package/src/editor/citation-dialog.component.js +202 -0
- package/src/editor/citation-dialog.component.js.map +1 -0
- package/src/editor/citation-dialog.component.min.html +1 -0
- package/src/editor/citation-dialog.component.min.js +1 -0
- package/src/editor/citation-dialog.component.ts +278 -0
- package/src/editor/code-view-dialog.component.js.map +1 -1
- package/src/editor/editor.component.js +52 -21
- package/src/editor/editor.component.js.map +1 -1
- package/src/editor/editor.component.min.js +1 -1
- package/src/editor/editor.component.ts +58 -19
- package/src/editor/link-dialog.component.js +8 -5
- package/src/editor/link-dialog.component.js.map +1 -1
- package/src/editor/link-dialog.component.min.js +1 -1
- package/src/editor/link-dialog.component.ts +13 -6
- package/src/editor/media-dialog.component.js.map +1 -1
- package/src/editor/quill-break-blot.plugin.js +38 -0
- package/src/editor/quill-break-blot.plugin.js.map +1 -0
- package/src/editor/quill-break-blot.plugin.min.js +1 -0
- package/src/editor/quill-html-edit.plugin.js +164 -0
- package/src/editor/quill-html-edit.plugin.js.map +1 -0
- package/src/editor/quill-html-edit.plugin.min.js +1 -0
- package/src/editor/quill-image-format.plugin.js +50 -0
- package/src/editor/quill-image-format.plugin.js.map +1 -0
- package/src/editor/quill-image-format.plugin.min.js +1 -0
- package/src/editor/quill-input-button.plugin.js +98 -0
- package/src/editor/quill-input-button.plugin.js.map +1 -0
- package/src/editor/quill-input-button.plugin.min.js +1 -0
- package/src/froala/editor/froala-editor.directive.js +328 -0
- package/src/froala/editor/froala-editor.directive.js.map +1 -0
- package/src/froala/editor/froala-editor.directive.min.js +1 -0
- package/src/froala/editor/froala-editor.module.js +37 -0
- package/src/froala/editor/froala-editor.module.js.map +1 -0
- package/src/froala/editor/froala-editor.module.min.js +1 -0
- package/src/froala/editor/index.js +22 -0
- package/src/froala/editor/index.js.map +1 -0
- package/src/froala/editor/index.min.js +1 -0
- package/src/froala/plugins/citationManager.css +23 -0
- package/src/froala/plugins/citationManager.css.map +1 -0
- package/src/froala/plugins/citationManager.js +102 -0
- package/src/froala/plugins/citationManager.js.map +1 -0
- package/src/froala/plugins/citationManager.min.css +1 -0
- package/src/froala/plugins/citationManager.min.js +1 -0
- package/src/froala/plugins/citationManager.scss +22 -0
- package/src/froala/plugins/citationManager.ts +132 -0
- package/src/froala/plugins/image_manager.js +364 -0
- package/src/froala/plugins/image_manager.js.map +1 -0
- package/src/froala/plugins/image_manager.min.js +1 -0
- package/src/froala/plugins/inputButton.js +52 -3
- package/src/froala/plugins/inputButton.js.map +1 -1
- package/src/froala/plugins/inputButton.min.js +1 -1
- package/src/froala/plugins/inputButton.ts +69 -178
- package/src/froala/plugins/linkManager.js +24 -15
- package/src/froala/plugins/linkManager.js.map +1 -1
- package/src/froala/plugins/linkManager.min.js +1 -1
- package/src/froala/plugins/linkManager.ts +37 -20
- package/src/froala/view/froala-view.directive.js +49 -0
- package/src/froala/view/froala-view.directive.js.map +1 -0
- package/src/froala/view/froala-view.directive.min.js +1 -0
- package/src/froala/view/froala-view.module.js +37 -0
- package/src/froala/view/froala-view.module.js.map +1 -0
- package/src/froala/view/froala-view.module.min.js +1 -0
- package/src/froala/view/index.js +22 -0
- package/src/froala/view/index.js.map +1 -0
- package/src/froala/view/index.min.js +1 -0
- package/src/material.js.map +1 -1
- package/src/media-selector/media-selector.component.js.map +1 -1
- package/src/root/root.component.js +43 -0
- package/src/root/root.component.js.map +1 -0
- package/src/root/root.component.min.js +1 -0
- package/src/selector/selector.component.js.map +1 -1
- package/src/test/test.directive.js.map +1 -1
- package/src/tree/tree-dialog.component.js.map +1 -1
- package/src/tree/tree-dialog.component.ts +0 -5
- package/src/tree/tree-node.component.js.map +1 -1
- package/src/tree/tree.component.js.map +1 -1
- package/src/changeset-viewer/changeset-viewer-dialog.component.js +0 -62
- package/src/changeset-viewer/changeset-viewer-dialog.component.js.map +0 -1
- package/src/changeset-viewer/changeset-viewer-dialog.component.min.js +0 -1
- package/src/changeset-viewer/changeset-viewer-dialog.css +0 -2
- package/src/changeset-viewer/changeset-viewer-dialog.css.map +0 -1
- package/src/changeset-viewer/changeset-viewer-dialog.min.css +0 -0
- package/src/changeset-viewer/changeset-viewer.component.css +0 -4
- package/src/changeset-viewer/changeset-viewer.component.css.map +0 -1
- package/src/changeset-viewer/changeset-viewer.component.js +0 -127
- package/src/changeset-viewer/changeset-viewer.component.js.map +0 -1
- package/src/changeset-viewer/changeset-viewer.component.min.css +0 -1
- package/src/changeset-viewer/changeset-viewer.component.min.js +0 -1
|
@@ -17,6 +17,10 @@ System.register(["@stratusjs/runtime/stratus", "lodash"], function (exports_1, c
|
|
|
17
17
|
this.debug = false;
|
|
18
18
|
this.name = 'inputButton';
|
|
19
19
|
this.eventName = 'input-button';
|
|
20
|
+
this.autoRestoreSelection = false;
|
|
21
|
+
this.autoSaveSelection = false;
|
|
22
|
+
this.maintainSelection = false;
|
|
23
|
+
this.maintainSnapshot = false;
|
|
20
24
|
this.uid = lodash_1.default.uniqueId(`input_button_`);
|
|
21
25
|
stratus_1.Stratus.Instances[this.uid] = this;
|
|
22
26
|
this.debug = options && options.debug;
|
|
@@ -26,6 +30,11 @@ System.register(["@stratusjs/runtime/stratus", "lodash"], function (exports_1, c
|
|
|
26
30
|
this.name = options.name || this.name;
|
|
27
31
|
this.eventName = options.eventName || this.eventName;
|
|
28
32
|
this.editor = options.editor || null;
|
|
33
|
+
this.insert = options.insert || null;
|
|
34
|
+
this.autoRestoreSelection = options.autoRestoreSelection || null;
|
|
35
|
+
this.autoSaveSelection = options.autoSaveSelection || null;
|
|
36
|
+
this.maintainSelection = options.maintainSelection || null;
|
|
37
|
+
this.maintainSnapshot = options.maintainSnapshot || null;
|
|
29
38
|
}
|
|
30
39
|
findUID(el) {
|
|
31
40
|
if ('uid' in el.dataset) {
|
|
@@ -45,6 +54,9 @@ System.register(["@stratusjs/runtime/stratus", "lodash"], function (exports_1, c
|
|
|
45
54
|
if (!instance) {
|
|
46
55
|
return;
|
|
47
56
|
}
|
|
57
|
+
if (this.autoSaveSelection) {
|
|
58
|
+
this.saveSelection();
|
|
59
|
+
}
|
|
48
60
|
this.updateSnapshot();
|
|
49
61
|
instance.trigger(this.eventName, null, this);
|
|
50
62
|
}
|
|
@@ -52,8 +64,8 @@ System.register(["@stratusjs/runtime/stratus", "lodash"], function (exports_1, c
|
|
|
52
64
|
if (this.debug) {
|
|
53
65
|
console.log(`${this.name}.trigger():`, name, data, callee);
|
|
54
66
|
}
|
|
55
|
-
if (
|
|
56
|
-
console.warn(`${this.name}.trigger():`, data, 'is not
|
|
67
|
+
if (lodash_1.default.isEmpty(data)) {
|
|
68
|
+
console.warn(`${this.name}.trigger():`, data, 'is not valid data.');
|
|
57
69
|
return;
|
|
58
70
|
}
|
|
59
71
|
if (!this.editor) {
|
|
@@ -67,10 +79,19 @@ System.register(["@stratusjs/runtime/stratus", "lodash"], function (exports_1, c
|
|
|
67
79
|
if (!this.restoreSnapshot()) {
|
|
68
80
|
return;
|
|
69
81
|
}
|
|
70
|
-
this.
|
|
82
|
+
if (this.autoRestoreSelection) {
|
|
83
|
+
this.restoreSelection();
|
|
84
|
+
}
|
|
85
|
+
this.insert ? this.insert(data) : this.editor.html.insert(data);
|
|
71
86
|
this.updateSnapshot();
|
|
87
|
+
if (this.maintainSelection) {
|
|
88
|
+
this.saveSelection();
|
|
89
|
+
}
|
|
72
90
|
}
|
|
73
91
|
restoreSnapshot() {
|
|
92
|
+
if (!this.maintainSnapshot) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
74
95
|
if (!this.snapshot) {
|
|
75
96
|
console.warn(`${this.name}.restoreSnapshot(): unable to restore editor session without a snapshot.`);
|
|
76
97
|
return false;
|
|
@@ -80,8 +101,36 @@ System.register(["@stratusjs/runtime/stratus", "lodash"], function (exports_1, c
|
|
|
80
101
|
return true;
|
|
81
102
|
}
|
|
82
103
|
updateSnapshot() {
|
|
104
|
+
if (!this.maintainSnapshot) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
83
107
|
this.snapshot = this.editor.snapshot.get();
|
|
84
108
|
}
|
|
109
|
+
restoreSelection() {
|
|
110
|
+
if (!this.editor.selection) {
|
|
111
|
+
console.warn(`${this.name}.restoreSelection(): unable to restore editor selection.`);
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
this.editor.events.focus();
|
|
115
|
+
this.editor.selection.restore();
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
saveSelection() {
|
|
119
|
+
if (!this.editor.selection) {
|
|
120
|
+
console.warn(`${this.name}.saveSelection(): unable to save editor selection.`);
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
this.editor.selection.save();
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
clearSelection() {
|
|
127
|
+
if (!this.editor.selection) {
|
|
128
|
+
console.warn(`${this.name}.clearSelection(): unable to clear editor selection.`);
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
this.editor.selection.clear();
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
85
134
|
};
|
|
86
135
|
exports_1("InputButtonPlugin", InputButtonPlugin);
|
|
87
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["inputButton.ts"],"names":[],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["inputButton.ts"],"names":[],"mappings":";;;;;;;;;;;;;;YAiBA,oBAAA,MAAa,iBAAiB;gBAiB1B,YAAY,OAAY;oBAXxB,UAAK,GAAG,KAAK,CAAA;oBACb,SAA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oBAEZ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;wBACxB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,0DAA0D,CAAC,CAAA;wBACpF,OAAO,KAAK,CAAA;qBACf;oBAED,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;oBAE1B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAA;oBAC/B,OAAO,IAAI,CAAA;gBACf,CAAC;gBAED,aAAa;oBACT,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;wBACxB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,oDAAoD,CAAC,CAAA;wBAC9E,OAAO,KAAK,CAAA;qBACf;oBACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;oBAC5B,OAAO,IAAI,CAAA;gBACf,CAAC;gBAED,cAAc;oBACV,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;wBACxB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,sDAAsD,CAAC,CAAA;wBAChF,OAAO,KAAK,CAAA;qBACf;oBACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;oBAC7B,OAAO,IAAI,CAAA;gBACf,CAAC;aACJ,CAAA;;QACD,CAAC","file":"inputButton.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
System.register(["@stratusjs/runtime/stratus","lodash"],function(t,e){"use strict";var s
|
|
1
|
+
System.register(["@stratusjs/runtime/stratus","lodash"],function(t,e){"use strict";var i,s;e&&e.id;return{setters:[function(t){i=t},function(t){s=t}],execute:function(){t("InputButtonPlugin",class{constructor(t){this.debug=!1,this.name="inputButton",this.eventName="input-button",this.autoRestoreSelection=!1,this.autoSaveSelection=!1,this.maintainSelection=!1,this.maintainSnapshot=!1,this.uid=s.default.uniqueId("input_button_"),i.Stratus.Instances[this.uid]=this,this.debug=t&&t.debug,t&&"object"==typeof t||(t={}),this.name=t.name||this.name,this.eventName=t.eventName||this.eventName,this.editor=t.editor||null,this.insert=t.insert||null,this.autoRestoreSelection=t.autoRestoreSelection||null,this.autoSaveSelection=t.autoSaveSelection||null,this.maintainSelection=t.maintainSelection||null,this.maintainSnapshot=t.maintainSnapshot||null}findUID(t){return"uid"in t.dataset?t.dataset.uid:this.findUID(t.parentElement)}getInstance(t){if(t in i.Stratus.Instances)return i.Stratus.Instances[t]}onClick(t){const e=this.findUID(t),i=this.getInstance(e);i&&(this.autoSaveSelection&&this.saveSelection(),this.updateSnapshot(),i.trigger(this.eventName,null,this))}trigger(t,e,i){this.debug&&console.log(`${this.name}.trigger():`,t,e,i),s.default.isEmpty(e)?console.warn(`${this.name}.trigger():`,e,"is not valid data."):this.editor?"insert"===t?this.restoreSnapshot()&&(this.autoRestoreSelection&&this.restoreSelection(),this.insert?this.insert(e):this.editor.html.insert(e),this.updateSnapshot(),this.maintainSelection&&this.saveSelection()):console.warn(`${this.name}.trigger():`,t,"event is not supported."):console.warn(`${this.name}.trigger(): unable to inject html without a set editor.`)}restoreSnapshot(){return!this.maintainSnapshot||(this.snapshot?(this.editor.events.focus(),this.editor.snapshot.restore(this.snapshot),!0):(console.warn(`${this.name}.restoreSnapshot(): unable to restore editor session without a snapshot.`),!1))}updateSnapshot(){if(!this.maintainSnapshot)return!0;this.snapshot=this.editor.snapshot.get()}restoreSelection(){return this.editor.selection?(this.editor.events.focus(),this.editor.selection.restore(),!0):(console.warn(`${this.name}.restoreSelection(): unable to restore editor selection.`),!1)}saveSelection(){return this.editor.selection?(this.editor.selection.save(),!0):(console.warn(`${this.name}.saveSelection(): unable to save editor selection.`),!1)}clearSelection(){return this.editor.selection?(this.editor.selection.clear(),!0):(console.warn(`${this.name}.clearSelection(): unable to clear editor selection.`),!1)}})}}});
|
|
@@ -5,13 +5,17 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
TriggerInterface
|
|
7
7
|
} from '@stratusjs/angular/core/trigger.interface'
|
|
8
|
+
import {
|
|
9
|
+
LooseFunction,
|
|
10
|
+
LooseObject
|
|
11
|
+
} from '@stratusjs/core/misc'
|
|
8
12
|
|
|
9
13
|
// External Dependencies
|
|
10
14
|
import _ from 'lodash'
|
|
11
15
|
|
|
12
16
|
// Universal Button
|
|
13
17
|
// TODO: Move this elsewhere, since it isn't specific to Froala
|
|
14
|
-
export class InputButtonPlugin implements TriggerInterface {
|
|
18
|
+
export class InputButtonPlugin<EventData = string|LooseObject> implements TriggerInterface {
|
|
15
19
|
// Local
|
|
16
20
|
uid: string
|
|
17
21
|
snapshot: any
|
|
@@ -21,6 +25,11 @@ export class InputButtonPlugin implements TriggerInterface {
|
|
|
21
25
|
name = 'inputButton'
|
|
22
26
|
eventName = 'input-button'
|
|
23
27
|
editor: any
|
|
28
|
+
insert: LooseFunction
|
|
29
|
+
autoRestoreSelection = false
|
|
30
|
+
autoSaveSelection = false
|
|
31
|
+
maintainSelection = false
|
|
32
|
+
maintainSnapshot = false
|
|
24
33
|
|
|
25
34
|
// The quill parameter should be a type of Quill, but that doesn't appear to have the container attribute
|
|
26
35
|
constructor(options: any) {
|
|
@@ -37,6 +46,11 @@ export class InputButtonPlugin implements TriggerInterface {
|
|
|
37
46
|
this.name = options.name || this.name
|
|
38
47
|
this.eventName = options.eventName || this.eventName
|
|
39
48
|
this.editor = options.editor || null
|
|
49
|
+
this.insert = options.insert || null
|
|
50
|
+
this.autoRestoreSelection = options.autoRestoreSelection || null
|
|
51
|
+
this.autoSaveSelection = options.autoSaveSelection || null
|
|
52
|
+
this.maintainSelection = options.maintainSelection || null
|
|
53
|
+
this.maintainSnapshot = options.maintainSnapshot || null
|
|
40
54
|
}
|
|
41
55
|
|
|
42
56
|
findUID(el: HTMLElement): string {
|
|
@@ -59,20 +73,23 @@ export class InputButtonPlugin implements TriggerInterface {
|
|
|
59
73
|
if (!instance) {
|
|
60
74
|
return
|
|
61
75
|
}
|
|
62
|
-
//
|
|
76
|
+
// Save selection before passing off event
|
|
77
|
+
if (this.autoSaveSelection) {
|
|
78
|
+
this.saveSelection()
|
|
79
|
+
}
|
|
63
80
|
// Get snapshot before passing off event
|
|
64
81
|
this.updateSnapshot()
|
|
65
82
|
instance.trigger(this.eventName, null, this)
|
|
66
83
|
}
|
|
67
84
|
|
|
68
|
-
trigger(name: string, data:
|
|
69
|
-
// This allows
|
|
85
|
+
trigger(name: string, data: EventData, callee: TriggerInterface) {
|
|
86
|
+
// This allows us to handle data on the return
|
|
70
87
|
if (this.debug) {
|
|
71
88
|
console.log(`${this.name}.trigger():`, name, data, callee)
|
|
72
89
|
}
|
|
73
90
|
// This checks the data and inserts it on the cursor
|
|
74
|
-
if (
|
|
75
|
-
console.warn(`${this.name}.trigger():`, data, 'is not
|
|
91
|
+
if (_.isEmpty(data)) {
|
|
92
|
+
console.warn(`${this.name}.trigger():`, data, 'is not valid data.')
|
|
76
93
|
return
|
|
77
94
|
}
|
|
78
95
|
if (!this.editor) {
|
|
@@ -83,17 +100,28 @@ export class InputButtonPlugin implements TriggerInterface {
|
|
|
83
100
|
console.warn(`${this.name}.trigger():`, name, 'event is not supported.')
|
|
84
101
|
return
|
|
85
102
|
}
|
|
86
|
-
//
|
|
103
|
+
// Handle the Froala Editor Insertion
|
|
87
104
|
if (!this.restoreSnapshot()) {
|
|
88
105
|
return
|
|
89
106
|
}
|
|
107
|
+
// Attempt to Restore Selection
|
|
108
|
+
if (this.autoRestoreSelection) {
|
|
109
|
+
this.restoreSelection()
|
|
110
|
+
}
|
|
90
111
|
// Insert our data into Froala on the caret
|
|
91
|
-
this.editor.html.insert(data)
|
|
112
|
+
this.insert ? this.insert(data): this.editor.html.insert(data)
|
|
92
113
|
// Update snapshot for next insert
|
|
93
114
|
this.updateSnapshot()
|
|
115
|
+
// Save new selection
|
|
116
|
+
if (this.maintainSelection) {
|
|
117
|
+
this.saveSelection()
|
|
118
|
+
}
|
|
94
119
|
}
|
|
95
120
|
|
|
96
121
|
restoreSnapshot(): boolean {
|
|
122
|
+
if (!this.maintainSnapshot) {
|
|
123
|
+
return true
|
|
124
|
+
}
|
|
97
125
|
if (!this.snapshot) {
|
|
98
126
|
console.warn(`${this.name}.restoreSnapshot(): unable to restore editor session without a snapshot.`)
|
|
99
127
|
return false
|
|
@@ -106,177 +134,40 @@ export class InputButtonPlugin implements TriggerInterface {
|
|
|
106
134
|
}
|
|
107
135
|
|
|
108
136
|
updateSnapshot() {
|
|
109
|
-
|
|
137
|
+
if (!this.maintainSnapshot) {
|
|
138
|
+
return true
|
|
139
|
+
}
|
|
110
140
|
this.snapshot = this.editor.snapshot.get()
|
|
111
141
|
}
|
|
112
142
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// href = this.editor.opts.linkAutoPrefix + href;
|
|
144
|
-
// }
|
|
145
|
-
// } // Sanitize the URL.
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
// href = this.editor.helpers.sanitizeURL(href); // Default attributs.
|
|
149
|
-
//
|
|
150
|
-
// if (this.editor.opts.linkAlwaysBlank) attrs.target = '_blank';
|
|
151
|
-
// if (this.editor.opts.linkAlwaysNoFollow) attrs.rel = 'nofollow';
|
|
152
|
-
//
|
|
153
|
-
// if (this.editor.helpers.isEmail(original_href)) {
|
|
154
|
-
// attrs.target = null;
|
|
155
|
-
// attrs.rel = null;
|
|
156
|
-
// } // https://github.com/froala/wysiwyg-editor/issues/1576.
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
// if (attrs.target == '_blank') {
|
|
160
|
-
// if (this.editor.opts.linkNoOpener) {
|
|
161
|
-
// if (!attrs.rel) attrs.rel = 'noopener';else attrs.rel += ' noopener';
|
|
162
|
-
// }
|
|
163
|
-
//
|
|
164
|
-
// if (this.editor.opts.linkNoReferrer) {
|
|
165
|
-
// if (!attrs.rel) attrs.rel = 'noreferrer';else attrs.rel += ' noreferrer';
|
|
166
|
-
// }
|
|
167
|
-
// } else if (attrs.target == null) {
|
|
168
|
-
// if (attrs.rel) {
|
|
169
|
-
// attrs.rel = attrs.rel.replace(/noopener/, '').replace(/noreferrer/, '');
|
|
170
|
-
// } else {
|
|
171
|
-
// attrs.rel = null;
|
|
172
|
-
// }
|
|
173
|
-
// } // Format text.
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
// text = text || '';
|
|
177
|
-
//
|
|
178
|
-
// if (href === this.editor.opts.linkAutoPrefix) {
|
|
179
|
-
// let $popup = this.editor.popups.get('link.insert');
|
|
180
|
-
// $popup.find('input[name="href"]').addClass('fr-error');
|
|
181
|
-
// this.editor.events.trigger('link.bad', [original_href]);
|
|
182
|
-
// return false;
|
|
183
|
-
// } // Check if we have selection only in one link.
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
-
// let link = get();
|
|
187
|
-
// let $link;
|
|
188
|
-
//
|
|
189
|
-
// if (link) {
|
|
190
|
-
// $link = $(link);
|
|
191
|
-
// $link.attr('href', href); // Change text if it is different.
|
|
192
|
-
//
|
|
193
|
-
// if (text.length > 0 && $link.text() != text && !$current_image) {
|
|
194
|
-
// let child = $link.get(0);
|
|
195
|
-
//
|
|
196
|
-
// while (child.childNodes.length === 1 && child.childNodes[0].nodeType == Node.ELEMENT_NODE) {
|
|
197
|
-
// child = child.childNodes[0];
|
|
198
|
-
// }
|
|
199
|
-
//
|
|
200
|
-
// $(child).text(text);
|
|
201
|
-
// }
|
|
202
|
-
//
|
|
203
|
-
// if (!$current_image) {
|
|
204
|
-
// $link.prepend(FE.START_MARKER).append(FE.END_MARKER);
|
|
205
|
-
// } // Set attributes.
|
|
206
|
-
// // https://github.com/froala-labs/froala-editor-js-2/issues/2023
|
|
207
|
-
//
|
|
208
|
-
//
|
|
209
|
-
// for (let prop in attrs) {
|
|
210
|
-
// if (!attrs[prop]) {
|
|
211
|
-
// $link.removeAttr(prop);
|
|
212
|
-
// } else {
|
|
213
|
-
// $link.attr(prop, attrs[prop]);
|
|
214
|
-
// }
|
|
215
|
-
// }
|
|
216
|
-
//
|
|
217
|
-
// if (!$current_image) {
|
|
218
|
-
// this.editor.selection.restore();
|
|
219
|
-
// }
|
|
220
|
-
// } else {
|
|
221
|
-
// // We don't have any image selected.
|
|
222
|
-
// if (!$current_image) {
|
|
223
|
-
// // Remove current links.
|
|
224
|
-
// this.editor.format.remove('a'); // Nothing is selected.
|
|
225
|
-
//
|
|
226
|
-
// if (this.editor.selection.isCollapsed()) {
|
|
227
|
-
// text = text.length === 0 ? original_href : text;
|
|
228
|
-
// this.editor.html.insert("<a href=\"".concat(href, "\">").concat(FE.START_MARKER).concat(text.replace(/&/g, '&').replace(/</, '<', '>', '>')).concat(FE.END_MARKER, "</a>"));
|
|
229
|
-
// this.editor.selection.restore();
|
|
230
|
-
// } else {
|
|
231
|
-
// if (text.length > 0 && text != this.editor.selection.text().replace(/\n/g, '')) {
|
|
232
|
-
// this.editor.selection.remove();
|
|
233
|
-
// this.editor.html.insert("<a href=\"".concat(href, "\">").concat(FE.START_MARKER).concat(text.replace(/&/g, '&')).concat(FE.END_MARKER, "</a>"));
|
|
234
|
-
// this.editor.selection.restore();
|
|
235
|
-
// } else {
|
|
236
|
-
// _split(); // Add link.
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
// this.editor.format.apply('a', {
|
|
240
|
-
// href: href
|
|
241
|
-
// });
|
|
242
|
-
// }
|
|
243
|
-
// }
|
|
244
|
-
// } else {
|
|
245
|
-
// // Just wrap current image with a link.
|
|
246
|
-
// $current_image.wrap("<a href=\"".concat(href, "\"></a>"));
|
|
247
|
-
//
|
|
248
|
-
// if (this.editor.image.hasCaption()) {
|
|
249
|
-
// $current_image.parent().append($current_image.parents('.fr-img-caption').find('.fr-inner'));
|
|
250
|
-
// }
|
|
251
|
-
// } // Set attributes.
|
|
252
|
-
//
|
|
253
|
-
//
|
|
254
|
-
// let links = allSelected();
|
|
255
|
-
//
|
|
256
|
-
// for (let i = 0; i < links.length; i++) {
|
|
257
|
-
// $link = $(links[i]);
|
|
258
|
-
// $link.attr(attrs);
|
|
259
|
-
// $link.removeAttr('_moz_dirty');
|
|
260
|
-
// } // Show link edit if only one link.
|
|
261
|
-
//
|
|
262
|
-
//
|
|
263
|
-
// if (links.length == 1 && this.editor.$wp && !$current_image) {
|
|
264
|
-
// $(links[0]).prepend(FE.START_MARKER).append(FE.END_MARKER);
|
|
265
|
-
// this.editor.selection.restore();
|
|
266
|
-
// }
|
|
267
|
-
// } // Hide popup and try to edit.
|
|
268
|
-
//
|
|
269
|
-
//
|
|
270
|
-
// if (!$current_image) {
|
|
271
|
-
// _edit();
|
|
272
|
-
// } else {
|
|
273
|
-
// let $pop = this.editor.popups.get('link.insert');
|
|
274
|
-
//
|
|
275
|
-
// if ($pop) {
|
|
276
|
-
// $pop.find('input:focus').blur();
|
|
277
|
-
// }
|
|
278
|
-
//
|
|
279
|
-
// this.editor.image.edit($current_image);
|
|
280
|
-
// }
|
|
281
|
-
// }
|
|
143
|
+
restoreSelection(): boolean {
|
|
144
|
+
// Ensure selection exists
|
|
145
|
+
if (!this.editor.selection) {
|
|
146
|
+
console.warn(`${this.name}.restoreSelection(): unable to restore editor selection.`)
|
|
147
|
+
return false
|
|
148
|
+
}
|
|
149
|
+
// Get focus back to the editor
|
|
150
|
+
this.editor.events.focus()
|
|
151
|
+
// Restore last selection
|
|
152
|
+
this.editor.selection.restore()
|
|
153
|
+
return true
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
saveSelection(): boolean {
|
|
157
|
+
if (!this.editor.selection) {
|
|
158
|
+
console.warn(`${this.name}.saveSelection(): unable to save editor selection.`)
|
|
159
|
+
return false
|
|
160
|
+
}
|
|
161
|
+
this.editor.selection.save()
|
|
162
|
+
return true
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
clearSelection(): boolean {
|
|
166
|
+
if (!this.editor.selection) {
|
|
167
|
+
console.warn(`${this.name}.clearSelection(): unable to clear editor selection.`)
|
|
168
|
+
return false
|
|
169
|
+
}
|
|
170
|
+
this.editor.selection.clear()
|
|
171
|
+
return true
|
|
172
|
+
}
|
|
282
173
|
}
|
|
@@ -23,6 +23,11 @@ System.register(["@stratusjs/angular/froala/plugins/inputButton", "froala-editor
|
|
|
23
23
|
name: 'Link Manager',
|
|
24
24
|
eventName: 'link-library',
|
|
25
25
|
editor,
|
|
26
|
+
insert: (link) => {
|
|
27
|
+
froala_editor_1.default.PLUGINS.link(editor).insert(link.url, '', { 'aria-label': link.title });
|
|
28
|
+
},
|
|
29
|
+
autoSaveSelection: true,
|
|
30
|
+
autoRestoreSelection: true,
|
|
26
31
|
debug
|
|
27
32
|
});
|
|
28
33
|
if (debug) {
|
|
@@ -44,21 +49,20 @@ System.register(["@stratusjs/angular/froala/plugins/inputButton", "froala-editor
|
|
|
44
49
|
onClick
|
|
45
50
|
};
|
|
46
51
|
};
|
|
47
|
-
froala_editor_1.default.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}),
|
|
52
|
+
froala_editor_1.default.RegisterCommand('linkManager', {
|
|
53
|
+
title: 'Insert from Link Library',
|
|
54
|
+
undo: false,
|
|
55
|
+
focus: false,
|
|
56
|
+
modal: true,
|
|
57
|
+
callback() {
|
|
58
|
+
const debug = false;
|
|
59
|
+
if (debug) {
|
|
60
|
+
console.log('clicked:', this.linkManager);
|
|
61
|
+
}
|
|
62
|
+
this.linkManager.onClick();
|
|
63
|
+
},
|
|
64
|
+
plugin: 'linkManager',
|
|
65
|
+
}),
|
|
62
66
|
froala_editor_1.default.DefineIcon('linkManager', { NAME: 'folder', SVG_KEY: 'insertLink' }),
|
|
63
67
|
froala_editor_1.default.DefineIcon('linkManagerInsert', { NAME: 'plus', SVG_KEY: 'add' }),
|
|
64
68
|
froala_editor_1.default.DefineIcon('linkManagerDelete', { NAME: 'trash', SVG_KEY: 'remove' });
|
|
@@ -71,6 +75,11 @@ System.register(["@stratusjs/angular/froala/plugins/inputButton", "froala-editor
|
|
|
71
75
|
name: 'Link Manager',
|
|
72
76
|
eventName: 'link-library',
|
|
73
77
|
editor: this,
|
|
78
|
+
insert: (link) => {
|
|
79
|
+
froala_editor_1.default.PLUGINS.link(this).insert(link.url, '', { 'aria-label': link.title });
|
|
80
|
+
},
|
|
81
|
+
autoSaveSelection: true,
|
|
82
|
+
autoRestoreSelection: true,
|
|
74
83
|
debug
|
|
75
84
|
});
|
|
76
85
|
if (!this.el) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["linkManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["linkManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;YAYA,uBAAY,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAY,CAAC,QAAQ,EAAE;gBACzD,QAAQ,EAAE,cAAc;aAC3B,CAAC,CAAA;YAKF,uBAAY,CAAC,OAAO,CAAC,WAAW,GAAG,SAAS,WAAW,CAAE,MAAW;gBAChE,IAAI,WAA8B,CAAA;gBAElC,MAAM,KAAK,GAAG,KAAK,CAAA;gBAGnB,SAAS,KAAK;oBACV,WAAW,GAAG,IAAI,+BAAiB,CAAO;wBACtC,IAAI,EAAE,cAAc;wBACpB,SAAS,EAAE,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t,i;e&&e.id;return{setters:[function(n){t=n},function(n){i=n}],execute:function(){i.default.DEFAULTS=Object.assign(i.default.DEFAULTS,{endpoint:"/Api/Content"}),i.default.PLUGINS.linkManager=function(n){let e;return{_init:function(){e=new t.InputButtonPlugin({name:"Link Manager",eventName:"link-library",editor:n,debug:false})},onClick:function(){n.el?e.onClick(n.el):console.warn("linkManager.onClick(): unable to find element")}}},i.default.
|
|
1
|
+
System.register(["@stratusjs/angular/froala/plugins/inputButton","froala-editor"],function(n,e){"use strict";var t,i;e&&e.id;return{setters:[function(n){t=n},function(n){i=n}],execute:function(){i.default.DEFAULTS=Object.assign(i.default.DEFAULTS,{endpoint:"/Api/Content"}),i.default.PLUGINS.linkManager=function(n){let e;return{_init:function(){e=new t.InputButtonPlugin({name:"Link Manager",eventName:"link-library",editor:n,insert:e=>{i.default.PLUGINS.link(n).insert(e.url,"",{"aria-label":e.title})},autoSaveSelection:!0,autoRestoreSelection:!0,debug:false})},onClick:function(){n.el?e.onClick(n.el):console.warn("linkManager.onClick(): unable to find element")}}},i.default.RegisterCommand("linkManager",{title:"Insert from Link Library",undo:!1,focus:!1,modal:!0,callback(){this.linkManager.onClick()},plugin:"linkManager"}),i.default.DefineIcon("linkManager",{NAME:"folder",SVG_KEY:"insertLink"}),i.default.DefineIcon("linkManagerInsert",{NAME:"plus",SVG_KEY:"add"}),i.default.DefineIcon("linkManagerDelete",{NAME:"trash",SVG_KEY:"remove"}),i.default.RegisterQuickInsertButton("link",{icon:"linkManager",title:"Insert from Link Library",callback:function(){const n=new t.InputButtonPlugin({name:"Link Manager",eventName:"link-library",editor:this,insert:n=>{i.default.PLUGINS.link(this).insert(n.url,"",{"aria-label":n.title})},autoSaveSelection:!0,autoRestoreSelection:!0,debug:!1});this.el?n.onClick(this.el):console.warn("linkManager.onClick(): unable to find element")},undo:!0})}}});
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
InputButtonPlugin
|
|
4
4
|
} from '@stratusjs/angular/froala/plugins/inputButton'
|
|
5
|
+
import {
|
|
6
|
+
Link
|
|
7
|
+
} from '@stratusjs/angular/editor/link-dialog.component'
|
|
5
8
|
|
|
6
9
|
// @ts-ignore
|
|
7
10
|
import FroalaEditor from 'froala-editor'
|
|
@@ -21,10 +24,15 @@ FroalaEditor.PLUGINS.linkManager = function linkManager (editor: any) {
|
|
|
21
24
|
|
|
22
25
|
// When the plugin is initialized,this will be called.
|
|
23
26
|
function _init() {
|
|
24
|
-
inputButton = new InputButtonPlugin({
|
|
27
|
+
inputButton = new InputButtonPlugin<Link>({
|
|
25
28
|
name: 'Link Manager',
|
|
26
29
|
eventName: 'link-library',
|
|
27
30
|
editor,
|
|
31
|
+
insert: (link: Link) => {
|
|
32
|
+
FroalaEditor.PLUGINS.link(editor).insert(link.url, '', {'aria-label': link.title})
|
|
33
|
+
},
|
|
34
|
+
autoSaveSelection: true,
|
|
35
|
+
autoRestoreSelection: true,
|
|
28
36
|
debug
|
|
29
37
|
})
|
|
30
38
|
|
|
@@ -61,24 +69,28 @@ FroalaEditor.PLUGINS.linkManager = function linkManager (editor: any) {
|
|
|
61
69
|
}
|
|
62
70
|
|
|
63
71
|
// Insert Plugin to Image Insert
|
|
64
|
-
FroalaEditor.DEFAULTS.imageInsertButtons.push('linkManager')
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
// FroalaEditor.DEFAULTS.imageInsertButtons.push('linkManager')
|
|
73
|
+
FroalaEditor.RegisterCommand('linkManager', {
|
|
74
|
+
title: 'Insert from Link Library',
|
|
75
|
+
undo: false,
|
|
76
|
+
focus: false,
|
|
77
|
+
modal: true,
|
|
78
|
+
callback() {
|
|
79
|
+
// debug info (move variable elsewhere)
|
|
80
|
+
const debug = false
|
|
81
|
+
if (debug) {
|
|
82
|
+
console.log('clicked:', this.linkManager)
|
|
83
|
+
}
|
|
84
|
+
// testing selection saving at earlier point to avoid loss of data
|
|
85
|
+
// this.selection.save()
|
|
86
|
+
// initiate click
|
|
87
|
+
this.linkManager.onClick()
|
|
88
|
+
},
|
|
89
|
+
plugin: 'linkManager',
|
|
90
|
+
}),
|
|
91
|
+
FroalaEditor.DefineIcon('linkManager', {NAME: 'folder', SVG_KEY: 'insertLink'}),
|
|
92
|
+
FroalaEditor.DefineIcon('linkManagerInsert', {NAME: 'plus', SVG_KEY: 'add'}),
|
|
93
|
+
FroalaEditor.DefineIcon('linkManagerDelete', {NAME: 'trash', SVG_KEY: 'remove'})
|
|
82
94
|
|
|
83
95
|
// Define a quick insert button
|
|
84
96
|
FroalaEditor.RegisterQuickInsertButton('link', {
|
|
@@ -91,11 +103,16 @@ FroalaEditor.RegisterQuickInsertButton('link', {
|
|
|
91
103
|
// Callback for the button.
|
|
92
104
|
callback: function linkManagerCallback () {
|
|
93
105
|
const debug = false
|
|
94
|
-
const inputButton = new InputButtonPlugin({
|
|
106
|
+
const inputButton = new InputButtonPlugin<Link>({
|
|
95
107
|
name: 'Link Manager',
|
|
96
108
|
eventName: 'link-library',
|
|
97
109
|
// Contextual `this` is equivalent to the editor instance
|
|
98
110
|
editor: this,
|
|
111
|
+
insert: (link: Link) => {
|
|
112
|
+
FroalaEditor.PLUGINS.link(this).insert(link.url, '', {'aria-label': link.title})
|
|
113
|
+
},
|
|
114
|
+
autoSaveSelection: true,
|
|
115
|
+
autoRestoreSelection: true,
|
|
99
116
|
debug
|
|
100
117
|
})
|
|
101
118
|
if (!this.el) {
|