From 70aa8adbbae3247062d5602b9599932421a0ffe8 Mon Sep 17 00:00:00 2001 From: Chris Chen Date: Sun, 2 Nov 2025 09:13:42 -0800 Subject: [PATCH] WIP --- src/app/cell-group/prayer/prayer.component.ts | 2 +- src/app/games/avalon/avalon.component.ts | 2 +- .../avalon/join-game/join-game.component.html | 2 +- .../massive-darkness2.component.html | 6 +- .../md2-html-editor.component.html | 2 +- .../md2-html-editor.component.ts | 124 ++++++++---------- src/app/ui/html-editor/html-editor.model.ts | 4 +- src/assets/styles/md2.scss | 4 +- src/environments/environment.prod.ts | 10 +- src/environments/environment.ts | 6 +- 10 files changed, 76 insertions(+), 86 deletions(-) diff --git a/src/app/cell-group/prayer/prayer.component.ts b/src/app/cell-group/prayer/prayer.component.ts index c5ae26f..7f19427 100644 --- a/src/app/cell-group/prayer/prayer.component.ts +++ b/src/app/cell-group/prayer/prayer.component.ts @@ -95,7 +95,7 @@ export class PrayerComponent extends MyAppBase { // message += "\n======= 備註 =======" + "\n" + comment; // } - // message += "\n請使用方舟晚宴系統新增菜單唷!" + "\n" + "https://happiness.tours/CellGroup/dinner?openExternalBrowser=1" + // message += "\n請使用方舟晚宴系統新增菜單唷!" + "\n" + "https://golife.love/CellGroup/dinner?openExternalBrowser=1" // this.lineService.pushLineMessage(message); }); } diff --git a/src/app/games/avalon/avalon.component.ts b/src/app/games/avalon/avalon.component.ts index b9fec8f..10f8485 100644 --- a/src/app/games/avalon/avalon.component.ts +++ b/src/app/games/avalon/avalon.component.ts @@ -30,7 +30,7 @@ const teamSize: number[][] = [ const fourthQuestNeed2Failed = 7; const SIGNAL_R_URL = (id: string = null) => { return `${environment.signalRUrl}/${id}Hub` } //const SIGNAL_R_URL = (id: string = null) => { return `http://localhost:12071/hub` } -//const SIGNAL_R_URL = (id: string = null) => { return `http://happiness.tours:8088/${id}hub` } +//const SIGNAL_R_URL = (id: string = null) => { return `http://golife.love:8088/${id}hub` } @Component({ selector: 'ngx-avalon', diff --git a/src/app/games/avalon/join-game/join-game.component.html b/src/app/games/avalon/join-game/join-game.component.html index 34a47a5..b219b15 100644 --- a/src/app/games/avalon/join-game/join-game.component.html +++ b/src/app/games/avalon/join-game/join-game.component.html @@ -26,5 +26,5 @@

等待遊戲開始中...

- +
\ No newline at end of file diff --git a/src/app/games/massive-darkness2/massive-darkness2.component.html b/src/app/games/massive-darkness2/massive-darkness2.component.html index 1040cc3..ef90886 100644 --- a/src/app/games/massive-darkness2/massive-darkness2.component.html +++ b/src/app/games/massive-darkness2/massive-darkness2.component.html @@ -10,10 +10,12 @@ - --> -
+
+
+ --> +
diff --git a/src/app/games/massive-darkness2/md2-html-editor/md2-html-editor.component.html b/src/app/games/massive-darkness2/md2-html-editor/md2-html-editor.component.html index 1bc51b9..b394132 100644 --- a/src/app/games/massive-darkness2/md2-html-editor/md2-html-editor.component.html +++ b/src/app/games/massive-darkness2/md2-html-editor/md2-html-editor.component.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/app/games/massive-darkness2/md2-html-editor/md2-html-editor.component.ts b/src/app/games/massive-darkness2/md2-html-editor/md2-html-editor.component.ts index 7b8135f..c9d2aca 100644 --- a/src/app/games/massive-darkness2/md2-html-editor/md2-html-editor.component.ts +++ b/src/app/games/massive-darkness2/md2-html-editor/md2-html-editor.component.ts @@ -1,109 +1,97 @@ -import { Component, ElementRef, EventEmitter, Input, Output, Renderer2 } from '@angular/core'; +import { Component, ElementRef, EventEmitter, Inject, Input, NgZone, Output, PLATFORM_ID, Renderer2 } from '@angular/core'; import { ControlValueAccessor, Validator, AbstractControl, ValidationErrors } from '@angular/forms'; -import { Editor, RawEditorOptions } from 'tinymce'; + import { MsgBoxService } from '../../../services/msg-box.service'; import { DropDownOption } from '../../../entity/dropDownOption'; import { MD2Icon } from '../massive-darkness2.model'; import { first } from 'rxjs/operators'; +import { HtmlEditorSettings } from '../../../ui/html-editor/html-editor.model'; +import { EditorComponent } from '@tinymce/tinymce-angular'; +import { Editor } from 'tinymce'; @Component({ selector: 'md2-html-editor', templateUrl: './md2-html-editor.component.html', styleUrl: './md2-html-editor.component.scss' }) -export class MD2HtmlEditorComponent implements ControlValueAccessor, Validator { - - private _lastBlurValue: string; - - readonly: boolean = false; - isRequired: boolean = false; - - @Input() id? = ''; - @Input() name = ''; - @Input() data: string; - - @Output() focus = new EventEmitter(); - @Output() blur = new EventEmitter(); - - @Input('readonly') - public set input_readonly(value) { - this.readonly = typeof value !== 'undefined' && value !== false; - } - @Input('isRequired') - public set input_isRequired(value) { - this.isRequired = typeof value !== 'undefined' && value !== false; - } +export class MD2HtmlEditorComponent extends EditorComponent implements ControlValueAccessor { + htmlEditorSetting: HtmlEditorSettings = {}; constructor( private msgBoxService: MsgBoxService, - private elementRef: ElementRef, - private renderer: Renderer2) { + elementRef: ElementRef, ngZone: NgZone, @Inject(PLATFORM_ID) platformId: Object) { + super(elementRef, ngZone, platformId); + // this.elementRef is private. Need a duplicate + this._elementRef2 = elementRef; this.htmlEditorSetting.base_url = '/tinymce'; this.htmlEditorSetting.suffix = '.min'; this.htmlEditorSetting['parentComponent'] = this; - this.htmlEditorSetting.plugins = 'lists link image table code'; - this.htmlEditorSetting.toolbar2 = 'customInsertButton' - this.htmlEditorSetting.setup = this.htmlEditorSetup; + this.htmlEditorSetting.plugins = [ + 'noneditable', 'lists', 'link', 'image', 'table', 'code']; + this.htmlEditorSetting.toolbar = ['undo redo | blocks | bold italic | alignleft aligncentre alignright alignjustify | indent outdent | bullist numlist | code customInsertButton']; + this.htmlEditorSetting.content_style = '.MD2Icon{font-family: "Massive Darkness 2", sans-serif !important; font-size: 40px; margin-left:5px} body{font-size: 30px; }'; + this.htmlEditorSetting.noneditable_noneditable_class = 'MD2Icon'; + //this.htmlEditorSetting.o = this.htmlEditorSetup; + this.htmlEditorSetting.setup = (editor) => this.htmlEditorSetup(editor) } - htmlEditorSetting: RawEditorOptions = {}; htmlEditorSetup(editor: Editor) { - let component = this.htmlEditorSetting['parentComponent'] as MD2HtmlEditorComponent; + if (editor) { + let component = this.htmlEditorSetting['parentComponent'] as MD2HtmlEditorComponent; + editor.ui.registry.addButton('customInsertButton', { + icon: 'code-sample', + text: 'MD2 Icon', + onAction: (_) => component.showInsertMD2Icon(this.editor as any) + }); + } - editor.ui.registry.addButton('customInsertButton', { - icon: 'code-sample', - text: 'MD2 Icon', - onAction: (_) => component.showInsertMD2Icon(editor) - }); } showInsertMD2Icon(editor: Editor) { var iconKeys = Object.keys(MD2Icon); iconKeys = iconKeys.slice(iconKeys.length / 2, iconKeys.length - 1); + this.ngZone.run(_ => { + this.msgBoxService.showInputbox('Insert MD2 Icon', '', { inputType: 'dropdown', dropDownOptions: iconKeys.map((k, i) => new DropDownOption(i, k)) }) + .pipe(first()).subscribe(result => { - this.msgBoxService.showInputbox('Insert MD2 Icon', '', { inputType: 'dropdown', dropDownOptions: iconKeys.map(k => new DropDownOption(k, k)) }) - .pipe(first()).subscribe(result => { + editor.insertContent(`${String.fromCharCode(65 + result)}`); + this.writeValue(editor.getContent()); + }); + }); - editor.insertContent(` ${result} `); - this.writeValue(editor.getContent()); - }); } - validate(control: AbstractControl): ValidationErrors { - // if (this.required && (this.value == null || this.value == 0)) { - // return { 'currency': '' }; - // } - return null; + private _elementRef2: ElementRef; + + writeValue(value: string | null): void { + + super.writeValue(value); } - registerOnValidatorChange?(fn: () => void): void { - } - onChange = (value: number) => { }; - onTouched = () => { }; - writeValue(obj: string): void { - this.data = obj; - } - registerOnChange(fn: any): void { - this.onChange = fn; + + registerOnChange(fn: (value: string) => void): void { + super.registerOnChange(fn); } registerOnTouched(fn: any): void { - this.onTouched = fn; + super.registerOnTouched(fn); } - setDisabledState?(isDisabled: boolean): void { - this.readonly = isDisabled; + setDisabledState(isDisabled: boolean): void { + super.setDisabledState(isDisabled); } - - ngOnInit() { + checkDomAttachment(): boolean { + // check if component has been attached to DOM yet + return document.body.contains(this._elementRef2.nativeElement); } - ngAfterViewInit() { - this.renderer.removeAttribute(this.elementRef.nativeElement, 'id') + this.init = this.htmlEditorSetting; + //this.htmlEditorSetup(); + super.ngAfterViewInit(); } - onBlur() { - if (this._lastBlurValue != this.data) { - this._lastBlurValue = this.data; - this.blur.emit(this.data); - } + + + private InitializeEditor() { + this.init = new HtmlEditorSettings({}); + //super.initialise(); } -} \ No newline at end of file +} diff --git a/src/app/ui/html-editor/html-editor.model.ts b/src/app/ui/html-editor/html-editor.model.ts index 969e0d1..add257c 100644 --- a/src/app/ui/html-editor/html-editor.model.ts +++ b/src/app/ui/html-editor/html-editor.model.ts @@ -1,4 +1,4 @@ -import { RawEditorOptions } from "tinymce"; +import { Editor, RawEditorOptions } from "tinymce"; export class HtmlEditorSettings implements RawEditorOptions { parentComponent?: any = null; @@ -34,7 +34,7 @@ export class HtmlEditorSettings implements RawEditorOptions { '.parameterInput:empty:not(:focus):before { content: \' \' attr(data-name) \' (Empty)\'; }'; extended_valid_elements?: string = `parameter[id|style|class]`; - + setup?: any; constructor(config: Partial) { diff --git a/src/assets/styles/md2.scss b/src/assets/styles/md2.scss index ae413b0..818aeae 100644 --- a/src/assets/styles/md2.scss +++ b/src/assets/styles/md2.scss @@ -1,13 +1,13 @@ @font-face { font-family: "Massive Darkness 2"; - src: url("https://api.happiness.tours/Files/Fonts/MassiveDarkness2.otf") format("opentype"); + src: url("https://api.golife.love/Files/Fonts/MassiveDarkness2.otf") format("opentype"); font-weight: normal; font-style: normal; } @font-face { font-family: "DwarvenAxeBBW00-Regular"; - src: url("https://api.happiness.tours/Files/Fonts/MD2Font.ttf") format("opentype"); + src: url("https://api.golife.love/Files/Fonts/MD2Font.ttf") format("opentype"); font-weight: normal; font-style: normal; } diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 3b5de33..7983b1a 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -6,11 +6,11 @@ const LINE_CLIENT_ID = '1657422139'; export const environment = { production: true, - apiUrl: "https://api.happiness.tours", - signalRUrl: "https://api.happiness.tours", - invitationUrl: "https://happiness.tours/invitation/", + apiUrl: "https://api.golife.love", + signalRUrl: "https://api.golife.love", + invitationUrl: "https://golife.love/invitation/", GAPI_CLIENT_ID: "93084169278-tp30i81laf1nu1mpgrc6m2o5sm32e28t.apps.googleusercontent.com", - GAPI_LOGIN_CALL_BACK: "https://happiness.tours/auth/googleLoginCallback", + GAPI_LOGIN_CALL_BACK: "https://golife.love/auth/googleLoginCallback", LINE_CLIENT_ID: LINE_CLIENT_ID, - LINE_LOGIN_URL: `https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id=${LINE_CLIENT_ID}&redirect_uri=https%3A%2F%2Fhappiness.tours%2Fauth%2FlineLogin&state=@STATE&scope=profile%20openid%20email%20%09` + LINE_LOGIN_URL: `https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id=${LINE_CLIENT_ID}&redirect_uri=https%3A%2F%2Fgolife.love%2Fauth%2FlineLogin&state=@STATE&scope=profile%20openid%20email%20%09` }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 86b48e4..fe5d828 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -10,7 +10,7 @@ const urls = [ 'https://localhost:44374',//IIS express "https://localhost:49155",//Docker debug - 'https://api.happiness.tours' + 'https://api.golife.love' ]; const LINE_CLIENT_ID = '1657422139'; const dockerDebug = urls[2]; @@ -22,7 +22,7 @@ export const environment = { GAPI_CLIENT_ID: "93084169278-tp30i81laf1nu1mpgrc6m2o5sm32e28t.apps.googleusercontent.com", GAPI_LOGIN_CALL_BACK: "http://localhost:4200/auth/googleLoginCallback", LINE_CLIENT_ID: LINE_CLIENT_ID, - LINE_LOGIN_URL: `https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id=${LINE_CLIENT_ID}&redirect_uri=https%3A%2F%2Fhappiness.tours%2Fauth%2FlineLogin&state=@STATE&scope=profile%20openid%20email%20%09` + LINE_LOGIN_URL: `https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id=${LINE_CLIENT_ID}&redirect_uri=https%3A%2F%2Fgolife.love%2Fauth%2FlineLogin&state=@STATE&scope=profile%20openid%20email%20%09` }; //lineLogin -//https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id=1657422139&redirect_uri=https%3A%2F%2Fhappiness.tours%2Fauth%2FlineLogin&state=awefwe23321412&scope=profile%20openid%20email%20%09 \ No newline at end of file +//https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id=1657422139&redirect_uri=https%3A%2F%2Fgolife.love%2Fauth%2FlineLogin&state=awefwe23321412&scope=profile%20openid%20email%20%09 \ No newline at end of file