@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.
Files changed (97) hide show
  1. package/package.json +4 -4
  2. package/src/angular.modules.js.map +1 -1
  3. package/src/app.module.js +7 -2
  4. package/src/app.module.js.map +1 -1
  5. package/src/app.module.min.js +1 -1
  6. package/src/app.module.ts +3 -0
  7. package/src/backend.service.js.map +1 -1
  8. package/src/base/base.component.js.map +1 -1
  9. package/src/confirm-dialog/confirm-dialog.component.js.map +1 -1
  10. package/src/editor/citation-dialog.component.html +50 -0
  11. package/src/editor/citation-dialog.component.js +202 -0
  12. package/src/editor/citation-dialog.component.js.map +1 -0
  13. package/src/editor/citation-dialog.component.min.html +1 -0
  14. package/src/editor/citation-dialog.component.min.js +1 -0
  15. package/src/editor/citation-dialog.component.ts +278 -0
  16. package/src/editor/code-view-dialog.component.js.map +1 -1
  17. package/src/editor/editor.component.js +52 -21
  18. package/src/editor/editor.component.js.map +1 -1
  19. package/src/editor/editor.component.min.js +1 -1
  20. package/src/editor/editor.component.ts +58 -19
  21. package/src/editor/link-dialog.component.js +8 -5
  22. package/src/editor/link-dialog.component.js.map +1 -1
  23. package/src/editor/link-dialog.component.min.js +1 -1
  24. package/src/editor/link-dialog.component.ts +13 -6
  25. package/src/editor/media-dialog.component.js.map +1 -1
  26. package/src/editor/quill-break-blot.plugin.js +38 -0
  27. package/src/editor/quill-break-blot.plugin.js.map +1 -0
  28. package/src/editor/quill-break-blot.plugin.min.js +1 -0
  29. package/src/editor/quill-html-edit.plugin.js +164 -0
  30. package/src/editor/quill-html-edit.plugin.js.map +1 -0
  31. package/src/editor/quill-html-edit.plugin.min.js +1 -0
  32. package/src/editor/quill-image-format.plugin.js +50 -0
  33. package/src/editor/quill-image-format.plugin.js.map +1 -0
  34. package/src/editor/quill-image-format.plugin.min.js +1 -0
  35. package/src/editor/quill-input-button.plugin.js +98 -0
  36. package/src/editor/quill-input-button.plugin.js.map +1 -0
  37. package/src/editor/quill-input-button.plugin.min.js +1 -0
  38. package/src/froala/editor/froala-editor.directive.js +328 -0
  39. package/src/froala/editor/froala-editor.directive.js.map +1 -0
  40. package/src/froala/editor/froala-editor.directive.min.js +1 -0
  41. package/src/froala/editor/froala-editor.module.js +37 -0
  42. package/src/froala/editor/froala-editor.module.js.map +1 -0
  43. package/src/froala/editor/froala-editor.module.min.js +1 -0
  44. package/src/froala/editor/index.js +22 -0
  45. package/src/froala/editor/index.js.map +1 -0
  46. package/src/froala/editor/index.min.js +1 -0
  47. package/src/froala/plugins/citationManager.css +23 -0
  48. package/src/froala/plugins/citationManager.css.map +1 -0
  49. package/src/froala/plugins/citationManager.js +102 -0
  50. package/src/froala/plugins/citationManager.js.map +1 -0
  51. package/src/froala/plugins/citationManager.min.css +1 -0
  52. package/src/froala/plugins/citationManager.min.js +1 -0
  53. package/src/froala/plugins/citationManager.scss +22 -0
  54. package/src/froala/plugins/citationManager.ts +132 -0
  55. package/src/froala/plugins/image_manager.js +364 -0
  56. package/src/froala/plugins/image_manager.js.map +1 -0
  57. package/src/froala/plugins/image_manager.min.js +1 -0
  58. package/src/froala/plugins/inputButton.js +52 -3
  59. package/src/froala/plugins/inputButton.js.map +1 -1
  60. package/src/froala/plugins/inputButton.min.js +1 -1
  61. package/src/froala/plugins/inputButton.ts +69 -178
  62. package/src/froala/plugins/linkManager.js +24 -15
  63. package/src/froala/plugins/linkManager.js.map +1 -1
  64. package/src/froala/plugins/linkManager.min.js +1 -1
  65. package/src/froala/plugins/linkManager.ts +37 -20
  66. package/src/froala/view/froala-view.directive.js +49 -0
  67. package/src/froala/view/froala-view.directive.js.map +1 -0
  68. package/src/froala/view/froala-view.directive.min.js +1 -0
  69. package/src/froala/view/froala-view.module.js +37 -0
  70. package/src/froala/view/froala-view.module.js.map +1 -0
  71. package/src/froala/view/froala-view.module.min.js +1 -0
  72. package/src/froala/view/index.js +22 -0
  73. package/src/froala/view/index.js.map +1 -0
  74. package/src/froala/view/index.min.js +1 -0
  75. package/src/material.js.map +1 -1
  76. package/src/media-selector/media-selector.component.js.map +1 -1
  77. package/src/root/root.component.js +43 -0
  78. package/src/root/root.component.js.map +1 -0
  79. package/src/root/root.component.min.js +1 -0
  80. package/src/selector/selector.component.js.map +1 -1
  81. package/src/test/test.directive.js.map +1 -1
  82. package/src/tree/tree-dialog.component.js.map +1 -1
  83. package/src/tree/tree-dialog.component.ts +0 -5
  84. package/src/tree/tree-node.component.js.map +1 -1
  85. package/src/tree/tree.component.js.map +1 -1
  86. package/src/changeset-viewer/changeset-viewer-dialog.component.js +0 -62
  87. package/src/changeset-viewer/changeset-viewer-dialog.component.js.map +0 -1
  88. package/src/changeset-viewer/changeset-viewer-dialog.component.min.js +0 -1
  89. package/src/changeset-viewer/changeset-viewer-dialog.css +0 -2
  90. package/src/changeset-viewer/changeset-viewer-dialog.css.map +0 -1
  91. package/src/changeset-viewer/changeset-viewer-dialog.min.css +0 -0
  92. package/src/changeset-viewer/changeset-viewer.component.css +0 -4
  93. package/src/changeset-viewer/changeset-viewer.component.css.map +0 -1
  94. package/src/changeset-viewer/changeset-viewer.component.js +0 -127
  95. package/src/changeset-viewer/changeset-viewer.component.js.map +0 -1
  96. package/src/changeset-viewer/changeset-viewer.component.min.css +0 -1
  97. 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 (!lodash_1.default.isString(data)) {
56
- console.warn(`${this.name}.trigger():`, data, 'is not a data string.');
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.editor.html.insert(data);
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":";;;;;;;;;;;;;;YAaA,oBAAA,MAAa,iBAAiB;gBAY1B,YAAY,OAAY;oBANxB,UAAK,GAAG,KAAK,CAAA;oBACb,SAAI,GAAG,aAAa,CAAA;oBACpB,cAAS,GAAG,cAAc,CAAA;oBAMtB,IAAI,CAAC,GAAG,GAAG,gBAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAA;oBACtC,iBAAO,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;oBAElC,IAAI,CAAC,KAAK,GAAG,OAAO,IAAI,OAAO,CAAC,KAAK,CAAA;oBAGrC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;wBACzC,OAAO,GAAG,EAAE,CAAA;qBACf;oBACD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAA;oBACrC,IAAI,CAAC,SAAS,GAAG,OAAO,CA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AAO,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,n;e&&e.id;return{setters:[function(t){s=t},function(t){n=t}],execute:function(){t("InputButtonPlugin",class{constructor(t){this.debug=!1,this.name="inputButton",this.eventName="input-button",this.uid=n.default.uniqueId("input_button_"),s.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}findUID(t){return"uid"in t.dataset?t.dataset.uid:this.findUID(t.parentElement)}getInstance(t){if(t in s.Stratus.Instances)return s.Stratus.Instances[t]}onClick(t){const e=this.findUID(t),s=this.getInstance(e);s&&(this.updateSnapshot(),s.trigger(this.eventName,null,this))}trigger(t,e,s){this.debug&&console.log(`${this.name}.trigger():`,t,e,s),n.default.isString(e)?this.editor?"insert"===t?this.restoreSnapshot()&&(this.editor.html.insert(e),this.updateSnapshot()):console.warn(`${this.name}.trigger():`,t,"event is not supported."):console.warn(`${this.name}.trigger(): unable to inject html without a set editor.`):console.warn(`${this.name}.trigger():`,e,"is not a data string.")}restoreSnapshot(){return 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(){this.snapshot=this.editor.snapshot.get()}})}}});
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
- // FIXME: The snapshot is specific to Froala
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: any, callee: TriggerInterface) {
69
- // This allows us to handle data on the return
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 (!_.isString(data)) {
75
- console.warn(`${this.name}.trigger():`, data, 'is not a data string.')
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
- // FIXME: Everything below is specific to the Froala API
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
- // FIXME: This is specific to the Froala API
137
+ if (!this.maintainSnapshot) {
138
+ return true
139
+ }
110
140
  this.snapshot = this.editor.snapshot.get()
111
141
  }
112
142
 
113
- /**
114
- * Insert link into the editor.
115
- */
116
- // insertLink(href: any, text: any, attrs: any) {
117
- // if (typeof attrs == 'undefined') attrs = {};
118
- // if (this.editor.events.trigger('link.beforeInsert', [href, text, attrs]) === false) return false; // Get image if we have one selected.
119
- //
120
- // let $current_image = this.editor.image ? this.editor.image.get() : null;
121
- //
122
- // if (!$current_image && this.editor.el.tagName != 'A') {
123
- // this.editor.selection.restore();
124
- // this.editor.popups.hide('link.insert');
125
- // } else if (this.editor.el.tagName == 'A') {
126
- // this.editor.$el.focus();
127
- // }
128
- //
129
- // let original_href = href; // Convert email address.
130
- //
131
- // if (this.editor.opts.linkConvertEmailAddress) {
132
- // if (this.editor.helpers.isEmail(href) && !/^mailto:.*/i.test(href)) {
133
- // href = "mailto:".concat(href);
134
- // }
135
- // } // Check if is local path.
136
- //
137
- //
138
- // let local_path = /^([A-Za-z]:(\\){1,2}|[A-Za-z]:((\\){1,2}[^\\]+)+)(\\)?$/i; // Add autoprefix.
139
- //
140
- // if (this.editor.opts.linkAutoPrefix !== '' && !new RegExp('^(' + FE.LinkProtocols.join('|') + '):.', 'i').test(href) && !/^data:image.*/i.test(href) && !/^(https?:|ftps?:|file:|)\/\//i.test(href) && !local_path.test(href)) {
141
- // // Do prefix only if starting character is not absolute.
142
- // if (['/', '{', '[', '#', '(', '.'].indexOf((href || '')[0]) < 0) {
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, '&amp;').replace(/</, '&lt;', '>', '&gt;')).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, '&amp;')).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.DEFAULTS.imageInsertButtons.push('linkManager'),
48
- froala_editor_1.default.RegisterCommand('linkManager', {
49
- title: 'Insert from Link Library',
50
- undo: false,
51
- focus: false,
52
- modal: true,
53
- callback() {
54
- const debug = false;
55
- if (debug) {
56
- console.log('clicked:', this.linkManager);
57
- }
58
- this.linkManager.onClick();
59
- },
60
- plugin: 'linkManager',
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":";;;;;;;;;;;;;;YASA,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,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,EAAE,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAC,CAAC;gBAC5E,uBAAY,CAAC,UAAU,CAAC,mBAAmB,EAAE,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAC,CAAC,CAAA;YAGhF,uBAAY,CAAC,yBAAyB,CAAC,MAAM,EAAE;gBAE3C,IAAI,EAAE,aAAa;gBAGnB,KAAK,EAAE,0BAA0B;gBAGjC,QAAQ,EAAE,SAAS,mBAAmB;oBAClC,MAAM,KAAK,GAAG,KAAK,CAAA;oBACnB,MAAM,WAAW,GAAG,IAAI,+BAAiB,CAAO;wBAC5C,IAAI,EAAE,cAAc;wBACpB,SAAS,EAAE,cAAc;wBAEzB,MAAM,EAAE,IAAI;wBACZ,MAAM,EAAE,CAAC,IAAU,EAAE,EAAE;4BACnB,uBAAY,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,EAAC,YAAY,EAAE,IAAI,CAAC,KAAK,EAAC,CAAC,CAAA;wBACpF,CAAC;wBACD,iBAAiB,EAAE,IAAI;wBACvB,oBAAoB,EAAE,IAAI;wBAC1B,KAAK;qBACR,CAAC,CAAA;oBACF,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE;wBACV,OAAO,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAA;wBAC7D,OAAM;qBACT;oBACD,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAChC,CAAC;gBAGD,IAAI,EAAE,IAAI;aACb,CAAC,CAAA;QACF,CAAC","file":"linkManager.js"}
@@ -1 +1 @@
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,debug:false})},onClick:function(){n.el?e.onClick(n.el):console.warn("linkManager.onClick(): unable to find element")}}},i.default.DEFAULTS.imageInsertButtons.push("linkManager"),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,debug:!1});this.el?n.onClick(this.el):console.warn("linkManager.onClick(): unable to find element")},undo:!0})}}});
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
- FroalaEditor.RegisterCommand('linkManager', {
66
- title: 'Insert from Link Library',
67
- undo: false,
68
- focus: false,
69
- modal: true,
70
- callback() {
71
- const debug = false
72
- if (debug) {
73
- console.log('clicked:', this.linkManager)
74
- }
75
- this.linkManager.onClick()
76
- },
77
- plugin: 'linkManager',
78
- }),
79
- FroalaEditor.DefineIcon('linkManager', {NAME: 'folder', SVG_KEY: 'insertLink'}),
80
- FroalaEditor.DefineIcon('linkManagerInsert', {NAME: 'plus', SVG_KEY: 'add'}),
81
- FroalaEditor.DefineIcon('linkManagerDelete', {NAME: 'trash', SVG_KEY: 'remove'})
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) {