@thecodeblogs/blog 0.20.2 → 0.20.3

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.
@@ -4,7 +4,7 @@ import { Injectable, EventEmitter, PLATFORM_ID, Inject, SecurityContext, Compone
4
4
  import * as i1 from '@angular/common/http';
5
5
  import { HttpParams } from '@angular/common/http';
6
6
  import { map, debounceTime } from 'rxjs/operators';
7
- import { Subject, of, Subscription } from 'rxjs';
7
+ import { Subject, of, debounceTime as debounceTime$1, Subscription } from 'rxjs';
8
8
  import * as i6 from '@angular/common';
9
9
  import { isPlatformBrowser, NgIf, CommonModule } from '@angular/common';
10
10
  import * as i2 from 'ngx-device-detector';
@@ -45,11 +45,12 @@ import { provideNativeDateAdapter, MatNativeDateModule } from '@angular/material
45
45
  import * as i1$3 from '@angular/router';
46
46
  import { NavigationEnd, RouterModule } from '@angular/router';
47
47
  import * as i12 from '@angular/cdk/text-field';
48
+ import * as i6$2 from '@angular/material/progress-spinner';
49
+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
50
+ import { QuillEditorComponent } from 'ngx-quill';
48
51
  import { trigger, state, transition, style, animate } from '@angular/animations';
49
52
  import * as i4$1 from '@angular/cdk/drag-drop';
50
53
  import { DragDropModule } from '@angular/cdk/drag-drop';
51
- import * as i6$2 from '@angular/material/progress-spinner';
52
- import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
53
54
  import * as i2$1 from '@angular/material/sidenav';
54
55
  import { MatSidenavModule } from '@angular/material/sidenav';
55
56
  import * as i9$1 from '@angular/material/list';
@@ -1278,30 +1279,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImpor
1278
1279
  type: Input
1279
1280
  }] } });
1280
1281
 
1281
- class StaticHtmlComponent {
1282
- constructor(staticHtmlService, domSanitizer) {
1283
- this.staticHtmlService = staticHtmlService;
1284
- this.domSanitizer = domSanitizer;
1285
- }
1286
- refreshContent() {
1287
- this.innerHtml = this.domSanitizer.bypassSecurityTrustHtml(this.staticHtmlService.mapStaticHtml(this.value, false));
1288
- }
1289
- ngOnChanges(changes) {
1290
- this.refreshContent();
1291
- }
1292
- ngOnInit() {
1293
- this.refreshContent();
1294
- }
1295
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: StaticHtmlComponent, deps: [{ token: StaticHtmlService }, { token: i1$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component }); }
1296
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.3", type: StaticHtmlComponent, isStandalone: true, selector: "app-static-html", inputs: { value: "value" }, usesOnChanges: true, ngImport: i0, template: "<div [innerHtml]=\"innerHtml\">\n</div>\n", styles: [""] }); }
1297
- }
1298
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: StaticHtmlComponent, decorators: [{
1299
- type: Component,
1300
- args: [{ selector: 'app-static-html', template: "<div [innerHtml]=\"innerHtml\">\n</div>\n" }]
1301
- }], ctorParameters: () => [{ type: StaticHtmlService }, { type: i1$1.DomSanitizer }], propDecorators: { value: [{
1302
- type: Input
1303
- }] } });
1304
-
1305
1282
  class TimeAgoPipe {
1306
1283
  constructor(changeDetectorRef, ngZone) {
1307
1284
  this.changeDetectorRef = changeDetectorRef;
@@ -1400,6 +1377,165 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImpor
1400
1377
  }]
1401
1378
  }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.NgZone }] });
1402
1379
 
1380
+ class EntryWysiwygComponent {
1381
+ static { this.CURRENT_ENTRY_KEY = EntryCreatorComponent.CURRENT_ENTRY_KEY; }
1382
+ static { this.DEFAULT_NEW_ENTRY_TITLE = EntryCreatorComponent.DEFAULT_NEW_ENTRY_TITLE; }
1383
+ constructor(router, entryService, tagService, identityService, dialog, sanitizer, fb) {
1384
+ this.router = router;
1385
+ this.entryService = entryService;
1386
+ this.tagService = tagService;
1387
+ this.identityService = identityService;
1388
+ this.dialog = dialog;
1389
+ this.sanitizer = sanitizer;
1390
+ this.fb = fb;
1391
+ this.CURRENT_ENTRY_KEY = EntryWysiwygComponent.CURRENT_ENTRY_KEY;
1392
+ this.DEFAULT_NEW_ENTRY_TITLE = EntryWysiwygComponent.DEFAULT_NEW_ENTRY_TITLE;
1393
+ this.all_tags = ['Angular', 'Bash', 'MacOS', 'Typescript', 'NPM', 'Databases'];
1394
+ this.format = 'html';
1395
+ this.entry = null;
1396
+ this.customScheduleTime = '';
1397
+ this.today = new Date();
1398
+ this.form = this.fb.group({
1399
+ html: new FormControl(''),
1400
+ });
1401
+ const scheduledDate = new Date();
1402
+ this.customScheduleTime = scheduledDate.getHours() + ':' + scheduledDate.getMinutes() + ' AM';
1403
+ }
1404
+ refreshTags() {
1405
+ this.tagService.get().subscribe((response) => {
1406
+ this.all_tags = map$1(response.results, (t) => t.label);
1407
+ /*
1408
+ this.filtered_tags = this.tagCtrl.valueChanges.pipe(
1409
+ startWith(null),
1410
+ map((tag: string | null) => tag ? this._filter(tag) : this.all_tags.slice()));
1411
+ */
1412
+ });
1413
+ }
1414
+ ngOnInit() {
1415
+ this.refreshTags();
1416
+ this.identityService.getMe().subscribe((me) => {
1417
+ this.me = me;
1418
+ });
1419
+ const savedEntry = localStorage.getItem(EntryCreatorComponent.CURRENT_ENTRY_KEY);
1420
+ if (savedEntry) {
1421
+ this.entry = new Entry(JSON.parse(savedEntry));
1422
+ const newValue = {
1423
+ 'html': this.entryService.convertBlogToHtmlFormat(this.entry)
1424
+ };
1425
+ this.form.patchValue(newValue);
1426
+ }
1427
+ else {
1428
+ this.seeEntries();
1429
+ }
1430
+ this.form.get('html').valueChanges
1431
+ .pipe(debounceTime$1(500))
1432
+ .subscribe(value => {
1433
+ var blogPost = value;
1434
+ this.entry = this.entryService.convertHtmlToBlogFormat(this.entry, blogPost);
1435
+ this.entryService.currentlyEditedEntry.next(this.entry);
1436
+ localStorage.setItem(EntryCreatorComponent.CURRENT_ENTRY_KEY, JSON.stringify(this.entry));
1437
+ });
1438
+ }
1439
+ seeEntries() {
1440
+ const dialogRef = this.dialog.open(EntrySelectorDialogComponent, {
1441
+ width: '800px',
1442
+ data: { name: 'test', animal: 'test' }
1443
+ });
1444
+ dialogRef.afterClosed().subscribe((id) => {
1445
+ if (id) {
1446
+ this.entryService.getUnpublishedById(id).subscribe((result) => {
1447
+ const entry = result;
1448
+ this.entryService.currentlyEditedEntry.next(entry);
1449
+ localStorage.setItem(EntryCreatorComponent.CURRENT_ENTRY_KEY, JSON.stringify(entry));
1450
+ this.entry = entry;
1451
+ const newValue = {
1452
+ 'html': this.entryService.convertBlogToHtmlFormat(this.entry)
1453
+ };
1454
+ this.form.patchValue(newValue);
1455
+ });
1456
+ }
1457
+ });
1458
+ }
1459
+ startNew() {
1460
+ const finish = confirm('Are you sure your finished? The JSON and entry displayed will be removed. Make sure you have already copied it.');
1461
+ if (finish) {
1462
+ this.entry = new Entry();
1463
+ this.entry.title = EntryCreatorComponent.DEFAULT_NEW_ENTRY_TITLE;
1464
+ this.entry.published = false;
1465
+ this.entry.version = 1;
1466
+ this.entryService.currentlyEditedEntry.next(this.entry);
1467
+ localStorage.setItem(EntryCreatorComponent.CURRENT_ENTRY_KEY, JSON.stringify(this.entry));
1468
+ this.entryService.create(this.entry).subscribe((next) => {
1469
+ const newValue = {
1470
+ 'html': this.entryService.convertBlogToHtmlFormat(next)
1471
+ };
1472
+ this.form.patchValue(newValue);
1473
+ });
1474
+ }
1475
+ }
1476
+ postPublishCallback() {
1477
+ this.entryService.currentlyEditedEntry.next(null);
1478
+ this.entry = null;
1479
+ this.seeEntries();
1480
+ localStorage.removeItem(EntryCreatorComponent.CURRENT_ENTRY_KEY);
1481
+ this.form.patchValue({ 'html': '' });
1482
+ }
1483
+ publish() {
1484
+ const publish = confirm('Are you sure you want to publish? Once an article is published it is available to everyone.');
1485
+ if (publish) {
1486
+ this.entry.published = true;
1487
+ this.entry.publish_date = new Date();
1488
+ this.entry.edit_date = new Date();
1489
+ this.entryService.updateUnpublishedEntry(this.entry).subscribe(this.postPublishCallback.bind(this));
1490
+ }
1491
+ }
1492
+ routeTo(path) {
1493
+ this.router.navigateByUrl(path).then(() => {
1494
+ });
1495
+ }
1496
+ displayAlert(something) {
1497
+ alert(something);
1498
+ }
1499
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: EntryWysiwygComponent, deps: [{ token: i1$3.Router }, { token: EntryService }, { token: TagService }, { token: IdentityService }, { token: i1$2.MatDialog }, { token: i1$1.DomSanitizer }, { token: i7.FormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
1500
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.3", type: EntryWysiwygComponent, isStandalone: true, selector: "lib-entry-wysiwyg", providers: [provideNativeDateAdapter()], ngImport: i0, template: "<div class=\"container\" style=\"padding: 20px;\">\n <div style=\"padding: 10px;\">\n <button\n style=\"width: 100%;\"\n mat-raised-button\n (click)=\"routeTo('create(left-col:create//right-col:create)')\">V1</button>\n </div>\n <div>\n <div *ngIf=\"entry\">\n <h2>{{entry?.title}}</h2>\n\n <h3>Posted {{entry?.create_date.toString() | timeAgo}} on {{entry?.create_date?.getMonth() + 1}}/{{entry?.create_date?.getDate()}}/{{entry?.create_date?.getFullYear()}}</h3>\n <h5 *ngIf=\"entry?.showEditInformation()\">Article was last edited {{entry?.edit_date.toString() | timeAgo}}</h5>\n <br>\n <p *ngIf=\"entry?.tags?.length > 0\">Tags: <span *ngFor=\"let tag of entry?.tags; let last = last\">{{tag}}<ng-container *ngIf=\"!last\"> |\n </ng-container></span><span *ngIf=\"entry?.views\">, {{entry._friendly_views}} views</span></p>\n </div>\n\n <div style=\"width: 100%; padding: 10px;\">\n <button\n style=\"width: 24%; margin: 5px;\"\n mat-raised-button\n (click)=\"publish()\"\n >Publish</button>\n\n <button\n style=\"width: 24%; margin: 5px;\"\n mat-raised-button\n (click)=\"seeEntries()\"\n >Entries</button>\n\n <button\n style=\"width: 24%; margin: 5px;\"\n mat-raised-button\n (click)=\"displayAlert('One day...')\"\n >Advanced</button>\n\n <button\n style=\"width: 24%; margin: 5px;\"\n mat-raised-button\n (click)=\"startNew()\"\n >New</button>\n </div>\n </div>\n\n <form [formGroup]=\"form\">\n <quill-editor\n style=\"width: 100%;\"\n format=\"{{format}}\"\n formControlName=\"html\"\n theme=\"bubble\"\n ></quill-editor>\n </form>\n</div>\n", styles: [".create-container{margin-left:auto;margin-right:auto;width:80%}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i6.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i7.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i7.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i7.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i7.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i7.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i5.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "component", type: QuillEditorComponent, selector: "quill-editor" }, { kind: "pipe", type: TimeAgoPipe, name: "timeAgo" }] }); }
1501
+ }
1502
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: EntryWysiwygComponent, decorators: [{
1503
+ type: Component,
1504
+ args: [{ selector: 'lib-entry-wysiwyg', providers: [provideNativeDateAdapter()], imports: [
1505
+ CommonModule,
1506
+ FormsModule,
1507
+ ReactiveFormsModule,
1508
+ MatProgressSpinnerModule,
1509
+ MatButtonModule,
1510
+ QuillEditorComponent,
1511
+ TimeAgoPipe,
1512
+ ], template: "<div class=\"container\" style=\"padding: 20px;\">\n <div style=\"padding: 10px;\">\n <button\n style=\"width: 100%;\"\n mat-raised-button\n (click)=\"routeTo('create(left-col:create//right-col:create)')\">V1</button>\n </div>\n <div>\n <div *ngIf=\"entry\">\n <h2>{{entry?.title}}</h2>\n\n <h3>Posted {{entry?.create_date.toString() | timeAgo}} on {{entry?.create_date?.getMonth() + 1}}/{{entry?.create_date?.getDate()}}/{{entry?.create_date?.getFullYear()}}</h3>\n <h5 *ngIf=\"entry?.showEditInformation()\">Article was last edited {{entry?.edit_date.toString() | timeAgo}}</h5>\n <br>\n <p *ngIf=\"entry?.tags?.length > 0\">Tags: <span *ngFor=\"let tag of entry?.tags; let last = last\">{{tag}}<ng-container *ngIf=\"!last\"> |\n </ng-container></span><span *ngIf=\"entry?.views\">, {{entry._friendly_views}} views</span></p>\n </div>\n\n <div style=\"width: 100%; padding: 10px;\">\n <button\n style=\"width: 24%; margin: 5px;\"\n mat-raised-button\n (click)=\"publish()\"\n >Publish</button>\n\n <button\n style=\"width: 24%; margin: 5px;\"\n mat-raised-button\n (click)=\"seeEntries()\"\n >Entries</button>\n\n <button\n style=\"width: 24%; margin: 5px;\"\n mat-raised-button\n (click)=\"displayAlert('One day...')\"\n >Advanced</button>\n\n <button\n style=\"width: 24%; margin: 5px;\"\n mat-raised-button\n (click)=\"startNew()\"\n >New</button>\n </div>\n </div>\n\n <form [formGroup]=\"form\">\n <quill-editor\n style=\"width: 100%;\"\n format=\"{{format}}\"\n formControlName=\"html\"\n theme=\"bubble\"\n ></quill-editor>\n </form>\n</div>\n", styles: [".create-container{margin-left:auto;margin-right:auto;width:80%}\n"] }]
1513
+ }], ctorParameters: () => [{ type: i1$3.Router }, { type: EntryService }, { type: TagService }, { type: IdentityService }, { type: i1$2.MatDialog }, { type: i1$1.DomSanitizer }, { type: i7.FormBuilder }] });
1514
+
1515
+ class StaticHtmlComponent {
1516
+ constructor(staticHtmlService, domSanitizer) {
1517
+ this.staticHtmlService = staticHtmlService;
1518
+ this.domSanitizer = domSanitizer;
1519
+ }
1520
+ refreshContent() {
1521
+ this.innerHtml = this.domSanitizer.bypassSecurityTrustHtml(this.staticHtmlService.mapStaticHtml(this.value, false));
1522
+ }
1523
+ ngOnChanges(changes) {
1524
+ this.refreshContent();
1525
+ }
1526
+ ngOnInit() {
1527
+ this.refreshContent();
1528
+ }
1529
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: StaticHtmlComponent, deps: [{ token: StaticHtmlService }, { token: i1$1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component }); }
1530
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.3", type: StaticHtmlComponent, isStandalone: true, selector: "app-static-html", inputs: { value: "value" }, usesOnChanges: true, ngImport: i0, template: "<div [innerHtml]=\"innerHtml\">\n</div>\n", styles: [""] }); }
1531
+ }
1532
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: StaticHtmlComponent, decorators: [{
1533
+ type: Component,
1534
+ args: [{ selector: 'app-static-html', template: "<div [innerHtml]=\"innerHtml\">\n</div>\n" }]
1535
+ }], ctorParameters: () => [{ type: StaticHtmlService }, { type: i1$1.DomSanitizer }], propDecorators: { value: [{
1536
+ type: Input
1537
+ }] } });
1538
+
1403
1539
  class EntryRendererComponent {
1404
1540
  constructor(prismService, ngZone, identityService, commentService, router, entryService) {
1405
1541
  this.prismService = prismService;
@@ -2232,5 +2368,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImpor
2232
2368
  * Generated bundle index. Do not edit.
2233
2369
  */
2234
2370
 
2235
- export { Base, CommentService, Content, ContentType, CoreEvent, CoreEventType, CoreModule, DjangoRestFrameworkEndpointService, Entry, EntryCreatorComponent, EntryRendererComponent, EntryRendererWrapperComponent, EntrySelectorDialogComponent, EntryService, EntrySummaryComponent, Guid, IdentityService, Interaction, InteractionService, JsonRendererComponent, LandingPageComponent, LinkyPipe, ListResponse, MainComponent, MediaUploadModalComponent, OutlineViewComponent, PrismService, Routes, Section, SideNavigationComponent, StaticHtmlComponent, StaticHtmlService, TagService, TimeAgoPipe, Upload, UploadService, Utility, View, ViewService, VisitorProfile, VisitorProfileService };
2371
+ export { Base, CommentService, Content, ContentType, CoreEvent, CoreEventType, CoreModule, DjangoRestFrameworkEndpointService, Entry, EntryCreatorComponent, EntryRendererComponent, EntryRendererWrapperComponent, EntrySelectorDialogComponent, EntryService, EntrySummaryComponent, EntryWysiwygComponent, Guid, IdentityService, Interaction, InteractionService, JsonRendererComponent, LandingPageComponent, LinkyPipe, ListResponse, MainComponent, MediaUploadModalComponent, OutlineViewComponent, PrismService, Routes, Section, SideNavigationComponent, StaticHtmlComponent, StaticHtmlService, TagService, TimeAgoPipe, Upload, UploadService, Utility, View, ViewService, VisitorProfile, VisitorProfileService };
2236
2372
  //# sourceMappingURL=thecodeblogs-blog.mjs.map