@stratusjs/angular 0.5.5 → 0.5.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.
@@ -217,10 +217,10 @@ const has = (object: object, path: string) => _.has(object, path) && !_.isEmpty(
217
217
  export class EditorComponent extends RootComponent implements OnInit, TriggerInterface { // implements OnInit, OnChanges
218
218
 
219
219
  // Basic Component Settings
220
- title = moduleName + '_component'
220
+ title = `${moduleName}_component`
221
221
  uid: string
222
222
  dev = !!cookie('env')
223
- debug: true
223
+ debug = !!cookie(`debug_${moduleName}`)
224
224
  editor: 'froala'|'angular-editor'|'quill' = 'froala'
225
225
 
226
226
  // Registry Attributes
@@ -274,14 +274,15 @@ export class EditorComponent extends RootComponent implements OnInit, TriggerInt
274
274
  dataString: new FormControl(),
275
275
  })
276
276
  dataChangeLog: string[] = []
277
- dataString = ''
277
+ incomingData = ''
278
+ outgoingData = ''
278
279
 
279
280
  // Debounce Saving Controls
280
281
  debounceSave = true
281
282
  debounceTime = 5000
282
283
 
283
284
  // Model Saving Controls
284
- forceSave = true
285
+ forceSave = false
285
286
 
286
287
  // Child Components
287
288
  froalaEditorDirective: FroalaEditorDirective
@@ -393,15 +394,6 @@ export class EditorComponent extends RootComponent implements OnInit, TriggerInt
393
394
  }
394
395
  /* */
395
396
 
396
- // Froala 2 Buttons (For Reference)
397
- // 'insertOrderedList', 'insertUnorderedList', 'createLink', 'table'
398
- froalaButtons: string[] = [
399
- 'bold', 'italic', 'underline', 'strikeThrough', 'subscript', 'superscript', '|', 'formatBlock',
400
- 'blockStyle', 'inlineStyle', 'paragraphStyle', 'paragraphFormat', 'align', 'formatOL',
401
- 'formatUL', 'outdent', 'indent', '|', 'insertLink', 'insertImage', 'insertVideo', 'insertFile',
402
- 'insertTable', '|', 'undo', 'redo', 'removeFormat', 'wordPaste', 'help', 'html', 'fullscreen'
403
- ]
404
-
405
397
  froalaStandardButtons = {
406
398
  moreText: [
407
399
  'bold',
@@ -481,6 +473,10 @@ export class EditorComponent extends RootComponent implements OnInit, TriggerInt
481
473
  // console.log('initialized:', editor.html.get(), editor, froalaEditorDirective)
482
474
  this.froalaEditorDirective = froalaEditorDirective
483
475
  },
476
+ // blur: this.onBlur,
477
+ blur: (event: FocusEvent) => this.onBlur(event),
478
+ // FIXME: Froala doesn't support focus events, so this never fires...
479
+ focus: (event: FocusEvent) => this.onFocus(event),
484
480
  // bound to Froala Editor
485
481
  // contentChanged () {
486
482
  // const editor = this
@@ -506,13 +502,13 @@ export class EditorComponent extends RootComponent implements OnInit, TriggerInt
506
502
  wrap_line_length: 0
507
503
  },
508
504
  // fromTextArea
509
- codeMirror: !cookie('codemirror') ? null : {
505
+ codeMirror: {
510
506
  fromTextArea: (el: HTMLTextAreaElement, opts: LooseObject) => {
511
507
  // Note: We're instantiating a Bridge Class to act as an intermediate for Froala's legacy implementation.
512
508
  return new CodeMirrorBridge({
513
509
  extensions: [
514
- // basicSetup,
515
- minimalSetup,
510
+ basicSetup,
511
+ // minimalSetup,
516
512
  html({
517
513
  // extraTags: [
518
514
  // 'sa-editor'
@@ -522,6 +518,7 @@ export class EditorComponent extends RootComponent implements OnInit, TriggerInt
522
518
  // ],
523
519
  }),
524
520
  // TODO: Make this an optional extension, based on options
521
+ // This is included in basicSetup
525
522
  // EditorView.lineWrapping
526
523
  ]
527
524
  }).fromTextArea(el, opts)
@@ -1089,7 +1086,7 @@ export class EditorComponent extends RootComponent implements OnInit, TriggerInt
1089
1086
  this.hydrate(elementRef, sanitizer, keys<EditorComponent>())
1090
1087
 
1091
1088
  // Data Connections
1092
- // TODO: Spelunk through this code to determine why I keep getting an empty component...
1089
+ // TODO: Spelunk through this code to determine why I am getting an empty component on occasion...
1093
1090
  this.fetchData()
1094
1091
  .then(data => {
1095
1092
  if (!data || !(data instanceof EventManager)) {
@@ -1181,11 +1178,16 @@ export class EditorComponent extends RootComponent implements OnInit, TriggerInt
1181
1178
  this.model.changedExternal = true
1182
1179
  this.model.trigger('change')
1183
1180
  })
1181
+ // Pipe for outgoingData
1182
+ dataControl.valueChanges.forEach(
1183
+ (value: string) => this.outgoingData = value
1184
+ )
1184
1185
  } else {
1185
1186
  dataControl.valueChanges.forEach(
1186
1187
  (value: string) => this.modelSave(value)
1187
1188
  )
1188
1189
  }
1190
+ // Detect and list duplicates
1189
1191
  if (this.dev) {
1190
1192
  this.listDuplicates(this.froalaConfig)
1191
1193
  }
@@ -1227,7 +1229,13 @@ export class EditorComponent extends RootComponent implements OnInit, TriggerInt
1227
1229
  this.property,
1228
1230
  this.normalizeOut(innerHTML || value)
1229
1231
  )
1230
- this.model.changedExternal = false
1232
+
1233
+ // Remove the changedExternal flag if using debounceSave
1234
+ if (this.debounceSave) {
1235
+ this.model.changedExternal = false
1236
+ }
1237
+
1238
+ // If enabled, Force Save on Persisted Models
1231
1239
  if (this.forceSave && !_.isEmpty(this.model.getIdentifier())) {
1232
1240
  this.model.save()
1233
1241
  }
@@ -1395,7 +1403,7 @@ export class EditorComponent extends RootComponent implements OnInit, TriggerInt
1395
1403
  }, 250)
1396
1404
  return
1397
1405
  }
1398
- const prevString = _.clone(this.dataString)
1406
+ const prevString = _.clone(this.incomingData)
1399
1407
  const dataString = this.dataRef()
1400
1408
  // ensure changes have occurred
1401
1409
  if (prevString === dataString) {
@@ -1429,7 +1437,7 @@ export class EditorComponent extends RootComponent implements OnInit, TriggerInt
1429
1437
  if (!this.model) {
1430
1438
  return ''
1431
1439
  }
1432
- return this.dataString = this.normalizeIn(
1440
+ return this.incomingData = this.normalizeIn(
1433
1441
  this.model.get(this.property)
1434
1442
  )
1435
1443
  }
@@ -1465,24 +1473,33 @@ export class EditorComponent extends RootComponent implements OnInit, TriggerInt
1465
1473
  }
1466
1474
 
1467
1475
  // changedEditor(event: EditorChangeContent | EditorChangeSelection) {
1468
- changedEditor(event: any) {
1476
+ changedEditor(event: Event) {
1469
1477
  console.log('editor-change:', event)
1470
1478
  }
1471
1479
 
1472
- onChangeEvent($event: any) {
1473
- console.log('change:', $event)
1480
+ onChangeEvent(event: Event) {
1481
+ console.log('change:', event)
1474
1482
  }
1475
1483
 
1476
- onFocus($event: any) {
1477
- // console.log('focus:', $event)
1484
+ onFocus(event: FocusEvent) {
1485
+ if (this.dev && this.debug) {
1486
+ console.warn(`[onFocus] triggered on ${this.uid}`)
1487
+ }
1478
1488
  this.focused = true
1479
1489
  this.blurred = false
1480
1490
  }
1481
1491
 
1482
- onBlur($event: any) {
1483
- // console.log('blur:', $event)
1492
+ onBlur(event: FocusEvent) {
1493
+ if (this.dev && this.debug) {
1494
+ console.warn(`[onBlur] triggered on ${this.uid}`)
1495
+ }
1484
1496
  this.focused = false
1485
1497
  this.blurred = true
1498
+ // Handle debounce triggers
1499
+ if (!this.debounceSave) {
1500
+ return
1501
+ }
1502
+ this.modelSave(this.outgoingData)
1486
1503
  }
1487
1504
 
1488
1505
  bypassHTML(html: string) {