Compare commits
17 Commits
7cc5cbaac3
...
v0.2.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 1929760e82 | |||
| 167e5c4f65 | |||
| 40c9ca38b9 | |||
| 6bb99f6e0e | |||
| 53fee00315 | |||
| c508caab7b | |||
| e90a1bb6ec | |||
| 27f023964f | |||
| b43c8db305 | |||
| e3fc28e440 | |||
| c9638403ab | |||
| 02ae9c6745 | |||
| c8cb378123 | |||
| 47060bcb2d | |||
| fb3acd5182 | |||
| cb1d7e24b7 | |||
| 0d6a56c9a3 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -43,6 +43,7 @@ Thumbs.db
|
|||||||
|
|
||||||
|
|
||||||
.nx/cache
|
.nx/cache
|
||||||
|
.nx/workspace-data
|
||||||
|
|
||||||
# env
|
# env
|
||||||
*.env*
|
*.env*
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# Add files here to ignore them from prettier formatting
|
# Add files here to ignore them from prettier formatting
|
||||||
/dist
|
/dist
|
||||||
/coverage
|
/coverage
|
||||||
/.nx/cache
|
/.nx/cache
|
||||||
|
/.nx/workspace-data
|
||||||
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -6,7 +6,8 @@
|
|||||||
"**/CVS": true,
|
"**/CVS": true,
|
||||||
"**/.DS_Store": true,
|
"**/.DS_Store": true,
|
||||||
"**/Thumbs.db": true,
|
"**/Thumbs.db": true,
|
||||||
"**/node_modules": true,
|
// "**/node_modules": true,
|
||||||
"**/.angular": true
|
"**/.angular": true
|
||||||
}
|
},
|
||||||
|
"editor.formatOnSave": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<header>
|
<header>
|
||||||
<app-panel></app-panel>
|
<app-panel></app-panel>
|
||||||
</header>
|
</header>
|
||||||
<main class="main">
|
<main>
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
.main {
|
main {
|
||||||
display: block;
|
overflow-y: auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: calc(100% - 2rem);
|
height: calc(100% - 2rem);
|
||||||
background-image: url("../assets/img/wallpaper.png");
|
background-image: url("../assets/img/wallpaper.png");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from "@angular/router";
|
||||||
import { PanelComponent } from "./modules/panel/panel.component";
|
import { PanelComponent } from "./modules/panel/panel.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Routes } from "@angular/router";
|
import { Routes } from "@angular/router";
|
||||||
import { MainPageComponent } from './pages/main/main.component';
|
import { MainPageComponent } from './pages/main/main.component';
|
||||||
import { SecondComponent } from './pages/second/second.component';
|
import { NitroplusComponent } from './pages/nitroplus-translator/nitroplus-translator.component';
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{
|
{
|
||||||
@@ -11,8 +11,8 @@ export const routes: Routes = [
|
|||||||
component: MainPageComponent
|
component: MainPageComponent
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'second',
|
path: 'translator',
|
||||||
component: SecondComponent
|
component: NitroplusComponent
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,7 +3,15 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 3rem;
|
width: 5rem;
|
||||||
height: 3rem;
|
height: 6rem;
|
||||||
color: white;
|
color: white;
|
||||||
|
font-size: 0.7rem;
|
||||||
|
user-select: none;
|
||||||
|
padding: 1rem;
|
||||||
|
border-radius: 10px;
|
||||||
|
transition: 0.2s ease-in-out;
|
||||||
|
&:hover {
|
||||||
|
background-color: rgba(25, 17, 19, 0.7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ export class DesktopIconComponent {
|
|||||||
@Input() image: string = '';
|
@Input() image: string = '';
|
||||||
@Input() alt: string = '';
|
@Input() alt: string = '';
|
||||||
@Input() name: string = '';
|
@Input() name: string = '';
|
||||||
|
@Input({required: false}) click: ()=>void = ()=>{};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
<desktop-icon alt='test' name='test' image='../../../assets/svg/logo-gitea.svg'></desktop-icon>
|
<div class="icons">
|
||||||
|
<a routerLink='/translator'><desktop-icon alt='translator' name='Translator' image='../../../assets/svg/logo-gitea.svg'></desktop-icon></a>
|
||||||
|
</div>
|
||||||
<app-modal></app-modal>
|
<app-modal></app-modal>
|
||||||
<app-dock></app-dock>
|
<app-dock></app-dock>
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
.icons {
|
||||||
|
margin: 2rem 3rem;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
|
import { RouterLink } from '@angular/router';
|
||||||
import { DesktopIconComponent } from '../../modules/desktop-icon/desktop-icon.component';
|
import { DesktopIconComponent } from '../../modules/desktop-icon/desktop-icon.component';
|
||||||
import { DockComponent } from '../../modules/dock/dock.component';
|
import { DockComponent } from '../../modules/dock/dock.component';
|
||||||
import { ModalComponent } from '../../modules/modal/modal.component';
|
import { ModalComponent } from '../../modules/modal/modal.component';
|
||||||
@@ -8,7 +9,7 @@ import { ModalComponent } from '../../modules/modal/modal.component';
|
|||||||
selector: 'app-main-page',
|
selector: 'app-main-page',
|
||||||
templateUrl: './main.component.html',
|
templateUrl: './main.component.html',
|
||||||
styleUrls: ['./main.component.less'],
|
styleUrls: ['./main.component.less'],
|
||||||
imports: [DockComponent, ModalComponent, CommonModule, DesktopIconComponent],
|
imports: [DockComponent, ModalComponent, CommonModule, DesktopIconComponent, RouterLink],
|
||||||
standalone: true
|
standalone: true
|
||||||
})
|
})
|
||||||
export class MainPageComponent {}
|
export class MainPageComponent {}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
@if (elements_data.length) {
|
||||||
|
<h1>{{ "ROW_COUNT_LABEL" | translate }}: {{ elements_data.length }}</h1>
|
||||||
|
<h2>{{ "FILE_NAME_LABEL" | translate }}: {{ fileName }}</h2>
|
||||||
|
}
|
||||||
|
<div id="elements">
|
||||||
|
@for (item of elements_data; track $index) {
|
||||||
|
<app-translate-block #translateBlock [index]="$index" [item]="item"></app-translate-block>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#elements {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 3rem;
|
||||||
|
align-items: center;
|
||||||
|
margin-inline: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2 {
|
||||||
|
color: #efdee0;
|
||||||
|
text-align: center;
|
||||||
|
margin: 1rem 2rem;
|
||||||
|
}
|
||||||
|
app-translate-block {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { CommonModule } from "@angular/common";
|
||||||
|
import { AfterViewInit, Component, Input, QueryList, ViewChildren } from "@angular/core";
|
||||||
|
import { TranslationPipe } from "../../../../pipes/translation.pipe";
|
||||||
|
import { NpsFile, TranslateData } from "../../dto/translate_data.dto";
|
||||||
|
import { TranslateBlockComponent } from "../translate_block/translate_block.component";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: "app-text-list",
|
||||||
|
templateUrl: "./text_list.component.html",
|
||||||
|
styleUrls: ["./text_list.component.scss"],
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule, TranslateBlockComponent, TranslationPipe],
|
||||||
|
})
|
||||||
|
export class TextListComponent implements AfterViewInit {
|
||||||
|
@ViewChildren("translateBlock") translate_blocks: QueryList<TranslateBlockComponent> | null =
|
||||||
|
null;
|
||||||
|
fileName = "";
|
||||||
|
elements_data: TranslateData[] = [];
|
||||||
|
@Input() set elements(el: TranslateData[]) {
|
||||||
|
this.elements_data = el;
|
||||||
|
localStorage.setItem("translations", JSON.stringify(this.elements_data));
|
||||||
|
this.ngAfterViewInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
get elements() {
|
||||||
|
return this.elements_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngAfterViewInit(): void {
|
||||||
|
const data = localStorage.getItem("original_file");
|
||||||
|
if (data) {
|
||||||
|
const file: NpsFile = JSON.parse(data);
|
||||||
|
this.fileName = file.file_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<div class="element">
|
||||||
|
<h2>{{ index + 1 }}</h2>
|
||||||
|
<div class="fields">
|
||||||
|
<h2>{{ item.name }}</h2>
|
||||||
|
<nwui-textarea [contenteditable]="false">{{ item.english_text }}</nwui-textarea>
|
||||||
|
<nwui-textarea
|
||||||
|
#translatedText
|
||||||
|
[contenteditable]="isEditing"
|
||||||
|
(leave)="saveTranslate($event)"
|
||||||
|
[disabled]="!isEditing"
|
||||||
|
>{{ item.translated_text }}</nwui-textarea
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="btns">
|
||||||
|
<nwui-button (click)="sendToGoogleTranslate()" [disabled]="translateLoading">{{
|
||||||
|
"TRANSLATE_BTN" | translate
|
||||||
|
}}</nwui-button>
|
||||||
|
<nwui-button (click)="isEditing = !isEditing" [disabled]="isEditing">{{
|
||||||
|
"EDIT_BTN" | translate
|
||||||
|
}}</nwui-button>
|
||||||
|
<nwui-button (click)="clear()" [disabled]="!item.translated_text.length">{{
|
||||||
|
"CLEAR_ROW_BTN" | translate
|
||||||
|
}}</nwui-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
.element {
|
||||||
|
display: flex;
|
||||||
|
background-color: #413738;
|
||||||
|
padding: 3rem 5rem;
|
||||||
|
border-radius: 30px;
|
||||||
|
flex-direction: row;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 1200px;
|
||||||
|
align-items: center;
|
||||||
|
gap: 2rem;
|
||||||
|
justify-content: space-between;
|
||||||
|
h2 {
|
||||||
|
color: #efdee0;
|
||||||
|
}
|
||||||
|
.fields {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1rem;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 1200px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.element {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.btns {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1rem;
|
||||||
|
align-items: center;
|
||||||
|
padding-inline: 1rem;
|
||||||
|
nwui-button {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
import { CommonModule } from "@angular/common";
|
||||||
|
import { Component, Input, OnInit, ViewChild } from "@angular/core";
|
||||||
|
import { NWUIButtonComponent, NWUITextAreaComponent } from "@nwaifu-ui";
|
||||||
|
import { TranslationPipe } from "../../../../pipes/translation.pipe";
|
||||||
|
import { LocalStorageKeys } from "../../consts";
|
||||||
|
import { TranslateData } from "../../dto/translate_data.dto";
|
||||||
|
import { ETranslateService } from "../../services/translate.enums";
|
||||||
|
import { TranslateService } from "../../services/translate.service";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: "app-translate-block",
|
||||||
|
templateUrl: "./translate_block.component.html",
|
||||||
|
styleUrls: ["./translate_block.component.scss"],
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule, NWUIButtonComponent, NWUITextAreaComponent, TranslationPipe],
|
||||||
|
providers: [TranslateService],
|
||||||
|
})
|
||||||
|
export class TranslateBlockComponent implements OnInit {
|
||||||
|
@ViewChild("translatedText") translatedText: NWUITextAreaComponent | null = null;
|
||||||
|
@Input({ required: true }) item: TranslateData = {
|
||||||
|
english_text: "",
|
||||||
|
translated_text: "",
|
||||||
|
name: "",
|
||||||
|
};
|
||||||
|
@Input({ required: true }) index = 0;
|
||||||
|
translateLoading = false;
|
||||||
|
isEditing = false;
|
||||||
|
|
||||||
|
saveChanges() {
|
||||||
|
const data: TranslateData[] = JSON.parse(
|
||||||
|
localStorage.getItem(LocalStorageKeys.TRANSLATIONS) ?? "[]",
|
||||||
|
);
|
||||||
|
if (!data.length) {
|
||||||
|
alert("No data");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data[this.index] = this.item;
|
||||||
|
localStorage.setItem("translations", JSON.stringify(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.isEditing = this.item.translated_text === "";
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(private translateService: TranslateService) {}
|
||||||
|
|
||||||
|
private sendToTranslate(service: ETranslateService = ETranslateService.GOOGLE) {
|
||||||
|
this.translateLoading = true;
|
||||||
|
this.translateService.translate(this.item.english_text, service).subscribe((text) => {
|
||||||
|
if (this.translatedText)
|
||||||
|
if (this.translatedText.ref) this.translatedText.ref.nativeElement.textContent = text;
|
||||||
|
this.item.translated_text = text;
|
||||||
|
this.isEditing = false;
|
||||||
|
this.translateLoading = false;
|
||||||
|
this.saveChanges();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
sendToGoogleTranslate() {
|
||||||
|
this.sendToTranslate(ETranslateService.GOOGLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
sendToDeeplTranslate() {
|
||||||
|
this.sendToTranslate(ETranslateService.DEEPL);
|
||||||
|
}
|
||||||
|
|
||||||
|
sendToPromptTranslate() {
|
||||||
|
this.sendToTranslate(ETranslateService.PROMPT);
|
||||||
|
}
|
||||||
|
|
||||||
|
saveTranslate(text: string) {
|
||||||
|
this.isEditing = false;
|
||||||
|
if (this.translatedText)
|
||||||
|
if (this.translatedText.ref) this.translatedText.ref.nativeElement.textContent = "";
|
||||||
|
this.item.translated_text = text;
|
||||||
|
this.saveChanges();
|
||||||
|
}
|
||||||
|
clear() {
|
||||||
|
this.item.translated_text = "";
|
||||||
|
this.isEditing = true;
|
||||||
|
if (this.translatedText)
|
||||||
|
if (this.translatedText.ref) this.translatedText.ref.nativeElement.textContent = "";
|
||||||
|
this.saveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export enum LocalStorageKeys {
|
||||||
|
TRANSLATIONS = 'translations',
|
||||||
|
ORIGINAL_FILE = 'original_file',
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
export interface TranslateData {
|
||||||
|
english_text: string;
|
||||||
|
translated_text: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
export interface NpsFile {
|
||||||
|
file_name: string;
|
||||||
|
original_text: string;
|
||||||
|
translated_text?: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { LocalStorageKeys } from '../consts';
|
||||||
|
import { NpsFile } from '../dto/translate_data.dto';
|
||||||
|
|
||||||
|
export function saveOriginalFile(file: NpsFile) {
|
||||||
|
localStorage.setItem(LocalStorageKeys.ORIGINAL_FILE, JSON.stringify(file));
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import { TranslateData } from "../dto/translate_data.dto";
|
||||||
|
|
||||||
|
export function parse(text: string): TranslateData[] {
|
||||||
|
// Find all TEXT attr data
|
||||||
|
const result: TranslateData[] = [];
|
||||||
|
const re = /^(?!\/\/)<[^>]*TEXT="(?<textAttr>[^>"]+)"[^>]*>/gim;
|
||||||
|
for (const match of text.matchAll(re)) {
|
||||||
|
console.log(match);
|
||||||
|
if (match.groups?.["textAttr"])
|
||||||
|
result.push({
|
||||||
|
english_text: match.groups?.["textAttr"],
|
||||||
|
translated_text: "",
|
||||||
|
name: "Choice (without name)",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const name_re = /<voice name="(?<name>[^"]+)"[^>]*>(?<text>[\s\S]*?)(?=<voice|$)/gi;
|
||||||
|
|
||||||
|
for (const match of text.matchAll(name_re)) {
|
||||||
|
if (match.groups?.["name"] && match.groups?.["text"]) {
|
||||||
|
const name_text = match.groups?.["text"];
|
||||||
|
const name = match.groups?.["name"];
|
||||||
|
const re = /<[^>]*>|\/\/.*|\s*\n\s*/gm;
|
||||||
|
name_text
|
||||||
|
.split(re)
|
||||||
|
.filter((line) => line.length > 0)
|
||||||
|
.map((line) => line.trim())
|
||||||
|
.forEach((line) => {
|
||||||
|
result.push({ english_text: line, translated_text: "", name: name });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<div class="btns">
|
||||||
|
<div id="op_btns">
|
||||||
|
<nwui-button (click)="fileInput.click()">
|
||||||
|
<span><i class="lni lni-upload"></i> {{ "UPLOAD_BTN" | translate }}</span>
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
(change)="submitFile($event)"
|
||||||
|
accept=".nps"
|
||||||
|
#fileInput
|
||||||
|
style="display: none"
|
||||||
|
/>
|
||||||
|
</nwui-button>
|
||||||
|
<nwui-button (click)="onSaveClicked()">
|
||||||
|
<span><i class="lni lni-save"></i> {{ "SAVE_BTN" | translate }}</span>
|
||||||
|
</nwui-button>
|
||||||
|
@if (this.elements.length) {
|
||||||
|
<nwui-button (click)="clearAllTranslations()" [disabled]="!has_translations">
|
||||||
|
<span><i class="lni lni-trash-can"></i> {{ "CLEAR_TRANSLATIONS_BTN" | translate }}</span>
|
||||||
|
</nwui-button>
|
||||||
|
<nwui-button (click)="getAllTranslations()">
|
||||||
|
<span><i class="lni lni-google"></i> {{ "TRANSLATE_ALL_BTN" | translate }}</span>
|
||||||
|
</nwui-button>
|
||||||
|
<nwui-button (click)="onClearClicked()">
|
||||||
|
<span><i class="lni lni-trash-can"></i> {{ "CLEAR_BTN" | translate }}</span>
|
||||||
|
</nwui-button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<button id="close_win" (click)="onCloseClicked()"><i class="lni lni-close"></i></button>
|
||||||
|
</div>
|
||||||
|
<app-text-list [elements]="elements"></app-text-list>
|
||||||
|
<nwui-button class="to-top-btn" (click)="scrollToTop()"
|
||||||
|
><i class="lni lni-arrow-up"></i
|
||||||
|
></nwui-button>
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
.btns {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
scrollbar-color: #413738;
|
||||||
|
nwui-button {
|
||||||
|
margin: 2rem;
|
||||||
|
}
|
||||||
|
#op_btns {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
#close_win {
|
||||||
|
color: var(--white);
|
||||||
|
font-weight: 600;
|
||||||
|
margin-inline: 2rem;
|
||||||
|
background-color: #413738;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0.5rem;
|
||||||
|
border-radius: 50px;
|
||||||
|
transition: 0.2s linear;
|
||||||
|
i {
|
||||||
|
transition: 0.3s linear;
|
||||||
|
}
|
||||||
|
&:hover {
|
||||||
|
background-color: #5b3f45;
|
||||||
|
transform: scale(1.1);
|
||||||
|
i {
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
:host {
|
||||||
|
background-color: #191113;
|
||||||
|
display: block;
|
||||||
|
min-height: calc(100vh - 2rem);
|
||||||
|
scrollbar-color: #413738;
|
||||||
|
}
|
||||||
|
.to-top-btn {
|
||||||
|
position: fixed;
|
||||||
|
width: 2rem;
|
||||||
|
left: 2rem;
|
||||||
|
bottom: -5rem;
|
||||||
|
transition: bottom 0.3s ease-in-out;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
bottom: 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
import { CommonModule } from "@angular/common";
|
||||||
|
import { AfterViewInit, Component, OnInit, ViewChild } from "@angular/core";
|
||||||
|
import { Router } from "@angular/router";
|
||||||
|
import { NWUIButtonComponent } from "@nwaifu-ui";
|
||||||
|
import { fromEvent, map } from "rxjs";
|
||||||
|
import { TranslationPipe } from "../../pipes/translation.pipe";
|
||||||
|
import { TextListComponent } from "./components/text_list/text_list.component";
|
||||||
|
import { LocalStorageKeys } from "./consts";
|
||||||
|
import { NpsFile, TranslateData } from "./dto/translate_data.dto";
|
||||||
|
import { saveOriginalFile } from "./lib/file_tools";
|
||||||
|
import { parse } from "./lib/parser";
|
||||||
|
@Component({
|
||||||
|
standalone: true,
|
||||||
|
imports: [TextListComponent, CommonModule, NWUIButtonComponent, TranslationPipe],
|
||||||
|
selector: "app-nitroplus",
|
||||||
|
templateUrl: "./nitroplus-translator.component.html",
|
||||||
|
styleUrl: "./nitroplus-translator.component.less",
|
||||||
|
})
|
||||||
|
export class NitroplusComponent implements OnInit, AfterViewInit {
|
||||||
|
title = "NitroPlusTranslator";
|
||||||
|
elements: TranslateData[] = [];
|
||||||
|
@ViewChild("fileInput") fileInput: HTMLInputElement | null = null;
|
||||||
|
@ViewChild(TextListComponent) text_list: TextListComponent | null = null;
|
||||||
|
|
||||||
|
constructor(private readonly router: Router) {}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
const data = localStorage.getItem(LocalStorageKeys.TRANSLATIONS);
|
||||||
|
if (data) {
|
||||||
|
try {
|
||||||
|
this.elements = JSON.parse(data);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
alert("Error while loading");
|
||||||
|
localStorage.removeItem(LocalStorageKeys.TRANSLATIONS);
|
||||||
|
this.elements = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngAfterViewInit(): void {
|
||||||
|
const container = document.querySelector("main");
|
||||||
|
if (container) {
|
||||||
|
fromEvent(container, "scroll")
|
||||||
|
.pipe(map(() => container.scrollTop > 100))
|
||||||
|
.subscribe((val) => {
|
||||||
|
if (val) document.querySelector(".to-top-btn")?.classList.add("active");
|
||||||
|
else document.querySelector(".to-top-btn")?.classList.remove("active");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scrollToTop() {
|
||||||
|
const container = document.querySelector("main");
|
||||||
|
if (container) {
|
||||||
|
container.scrollTo({ top: 0, behavior: "smooth" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
submitFile($event: Event) {
|
||||||
|
const target = $event.target as HTMLInputElement;
|
||||||
|
if (target.files) {
|
||||||
|
const file = target.files[0];
|
||||||
|
if (file) {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = () => {
|
||||||
|
if (reader.result) {
|
||||||
|
this.onFileLoaded(reader.result.toString());
|
||||||
|
const original_file: NpsFile = {
|
||||||
|
file_name: file.name,
|
||||||
|
original_text: reader.result.toString(),
|
||||||
|
};
|
||||||
|
saveOriginalFile(original_file);
|
||||||
|
target.value = "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
reader.readAsText(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onFileLoaded(text: string) {
|
||||||
|
const parsed = parse(text);
|
||||||
|
this.elements = parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
onClearClicked() {
|
||||||
|
this.elements = [];
|
||||||
|
localStorage.removeItem(LocalStorageKeys.TRANSLATIONS);
|
||||||
|
}
|
||||||
|
|
||||||
|
onSaveClicked() {
|
||||||
|
const original_file: NpsFile = JSON.parse(
|
||||||
|
localStorage.getItem(LocalStorageKeys.ORIGINAL_FILE) ??
|
||||||
|
'{"file_name":"", "original_text":""}',
|
||||||
|
);
|
||||||
|
if (original_file.file_name && original_file.original_text) {
|
||||||
|
const data: TranslateData[] = JSON.parse(
|
||||||
|
localStorage.getItem(LocalStorageKeys.TRANSLATIONS) ?? "[]",
|
||||||
|
);
|
||||||
|
if (!data.length) {
|
||||||
|
alert("No data");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
original_file.translated_text = original_file.original_text;
|
||||||
|
data.forEach((el) => {
|
||||||
|
original_file.translated_text = original_file.translated_text?.replace(
|
||||||
|
el.english_text,
|
||||||
|
el.translated_text,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const element = document.createElement("a");
|
||||||
|
const file = new Blob([original_file.translated_text], { type: "text/plain" });
|
||||||
|
element.href = URL.createObjectURL(file);
|
||||||
|
element.download = original_file.file_name;
|
||||||
|
element.click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Dialog windows for clear op
|
||||||
|
clearAllTranslations() {
|
||||||
|
if (this.text_list)
|
||||||
|
if (this.text_list.translate_blocks) {
|
||||||
|
this.text_list.translate_blocks
|
||||||
|
.filter((item) => item.item.translated_text)
|
||||||
|
.forEach((item) => item.clear());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getAllTranslations() {
|
||||||
|
if (this.text_list)
|
||||||
|
if (this.text_list.translate_blocks)
|
||||||
|
this.text_list.translate_blocks.forEach((item) => item.sendToGoogleTranslate());
|
||||||
|
}
|
||||||
|
|
||||||
|
get has_translations(): boolean {
|
||||||
|
return this.elements.some((i) => i.translated_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
onCloseClicked() {
|
||||||
|
this.router.navigate(["/"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export type GoogleTranslateResponse = Array<Array<string>>;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export enum ETranslateService {
|
||||||
|
GOOGLE = 'google',
|
||||||
|
DEEPL = 'deepl',
|
||||||
|
PROMPT = 'prompt',
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable, map } from 'rxjs';
|
||||||
|
import { GoogleTranslateResponse } from './translate.dto';
|
||||||
|
import { ETranslateService } from './translate.enums';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class TranslateService {
|
||||||
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
|
private googleTranslate(text: string): Observable<string> {
|
||||||
|
return this.http
|
||||||
|
.get<GoogleTranslateResponse>(
|
||||||
|
'https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=ru&dt=t&q=' + encodeURIComponent(text),
|
||||||
|
)
|
||||||
|
.pipe(
|
||||||
|
map((response) => {
|
||||||
|
let result = '';
|
||||||
|
response[0].forEach((el) => {
|
||||||
|
result += el[0] + ' ';
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
translate(text: string, service: ETranslateService = ETranslateService.GOOGLE): Observable<string> {
|
||||||
|
switch (service) {
|
||||||
|
case ETranslateService.GOOGLE:
|
||||||
|
return this.googleTranslate(text);
|
||||||
|
default:
|
||||||
|
return this.googleTranslate(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
<h1>Test</h1>
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import { CommonModule } from '@angular/common';
|
|
||||||
import { Component } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-second',
|
|
||||||
templateUrl: './second.component.html',
|
|
||||||
styleUrls: ['./second.component.less'],
|
|
||||||
standalone: true,
|
|
||||||
imports: [CommonModule]
|
|
||||||
})
|
|
||||||
export class SecondComponent {
|
|
||||||
}
|
|
||||||
@@ -5,5 +5,15 @@
|
|||||||
"TELEGRAM_LABEL": "Telegram channel",
|
"TELEGRAM_LABEL": "Telegram channel",
|
||||||
"GITHUB_LABEL": "Admin's Github",
|
"GITHUB_LABEL": "Admin's Github",
|
||||||
"GITEA_LABEL": "Neuro LLC Gitea",
|
"GITEA_LABEL": "Neuro LLC Gitea",
|
||||||
"SOURCE_CODE_TITLE": "Source code"
|
"SOURCE_CODE_TITLE": "Source code",
|
||||||
|
"UPLOAD_BTN": "Upload",
|
||||||
|
"SAVE_BTN": "Save",
|
||||||
|
"CLEAR_TRANSLATIONS_BTN": "Clear translations",
|
||||||
|
"CLEAR_BTN": "Clear",
|
||||||
|
"ROW_COUNT_LABEL": "Row count",
|
||||||
|
"FILE_NAME_LABEL": "File name",
|
||||||
|
"TRANSLATE_BTN": "Translate",
|
||||||
|
"EDIT_BTN": "Edit",
|
||||||
|
"CLEAR_ROW_BTN": "Clear",
|
||||||
|
"TRANSLATE_ALL_BTN": "Translate all"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,15 @@
|
|||||||
"TELEGRAM_LABEL": "Telegramチャンネル",
|
"TELEGRAM_LABEL": "Telegramチャンネル",
|
||||||
"GITHUB_LABEL": "管理者Github",
|
"GITHUB_LABEL": "管理者Github",
|
||||||
"GITEA_LABEL": "Neuro LLC Gitea",
|
"GITEA_LABEL": "Neuro LLC Gitea",
|
||||||
"SOURCE_CODE_TITLE": "ソースコード"
|
"SOURCE_CODE_TITLE": "ソースコード",
|
||||||
|
"UPLOAD_BTN": "アップロード",
|
||||||
|
"SAVE_BTN": "保存",
|
||||||
|
"CLEAR_TRANSLATIONS_BTN": "翻訳をクリア",
|
||||||
|
"CLEAR_BTN": "クリア",
|
||||||
|
"ROW_COUNT_LABEL": "行数",
|
||||||
|
"FILE_NAME_LABEL": "ファイル名",
|
||||||
|
"TRANSLATE_BTN": "翻訳",
|
||||||
|
"EDIT_BTN": "編集",
|
||||||
|
"CLEAR_ROW_BTN": "クリア",
|
||||||
|
"TRANSLATE_ALL_BTN": "すべて翻訳"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,15 @@
|
|||||||
"TELEGRAM_LABEL": "Телеграм канал",
|
"TELEGRAM_LABEL": "Телеграм канал",
|
||||||
"GITHUB_LABEL": "Github админа",
|
"GITHUB_LABEL": "Github админа",
|
||||||
"GITEA_LABEL": "Neuro LLC Gitea",
|
"GITEA_LABEL": "Neuro LLC Gitea",
|
||||||
"SOURCE_CODE_TITLE": "Исходный код"
|
"SOURCE_CODE_TITLE": "Исходный код",
|
||||||
|
"UPLOAD_BTN": "Загрузить",
|
||||||
|
"SAVE_BTN": "Сохранить",
|
||||||
|
"CLEAR_TRANSLATIONS_BTN": "Очистить переводы",
|
||||||
|
"CLEAR_BTN": "Очистить",
|
||||||
|
"ROW_COUNT_LABEL": "Количество строк",
|
||||||
|
"FILE_NAME_LABEL": "Имя файла",
|
||||||
|
"TRANSLATE_BTN": "Перевести",
|
||||||
|
"EDIT_BTN": "Редактировать",
|
||||||
|
"CLEAR_ROW_BTN": "Очистить",
|
||||||
|
"TRANSLATE_ALL_BTN": "Перевести все"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<base href="/" />
|
<base href="/" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||||
|
<link href="https://cdn.lineicons.com/4.0/lineicons.css" rel="stylesheet" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<app-root></app-root>
|
<app-root></app-root>
|
||||||
|
|||||||
@@ -25,15 +25,10 @@
|
|||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
html {
|
html, body {
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100vh;
|
height: 100%;
|
||||||
position: absolute;
|
position: relative;
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
}
|
}
|
||||||
ngneat-dialog {
|
ngneat-dialog {
|
||||||
.ngneat-dialog-backdrop {
|
.ngneat-dialog-backdrop {
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "./tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "../../dist/out-tsc",
|
"outDir": "../../dist/out-tsc",
|
||||||
"types": []
|
"types": []
|
||||||
},
|
},
|
||||||
"files": ["src/main.ts"],
|
"files": ["src/main.ts"],
|
||||||
"include": ["src/**/*.d.ts"]
|
"include": ["src/**/*.d.ts"],
|
||||||
|
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
6
apps/NwaifuWeb/tsconfig.editor.json
Normal file
6
apps/NwaifuWeb/tsconfig.editor.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"include": ["src/**/*.ts"],
|
||||||
|
"compilerOptions": {},
|
||||||
|
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
|
||||||
|
}
|
||||||
33
apps/NwaifuWeb/tsconfig.json
Normal file
33
apps/NwaifuWeb/tsconfig.json
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2022",
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"strict": true,
|
||||||
|
"noImplicitOverride": true,
|
||||||
|
"noPropertyAccessFromIndexSignature": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"noFallthroughCasesInSwitch": true
|
||||||
|
},
|
||||||
|
"files": [],
|
||||||
|
"include": [],
|
||||||
|
"angularCompilerOptions": {
|
||||||
|
"enableI18nLegacyMessageIdFormat": false,
|
||||||
|
"strictInjectionParameters": true,
|
||||||
|
"strictInputAccessModifiers": true,
|
||||||
|
"strictTemplates": true
|
||||||
|
},
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.app.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.editor.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.spec.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
64
migrations.json
Normal file
64
migrations.json
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"migrations": [
|
||||||
|
{
|
||||||
|
"cli": "nx",
|
||||||
|
"version": "19.2.0-beta.2",
|
||||||
|
"description": "Updates the default workspace data directory to .nx/workspace-data",
|
||||||
|
"implementation": "./src/migrations/update-19-2-0/move-workspace-data-directory",
|
||||||
|
"package": "nx",
|
||||||
|
"name": "19-2-0-move-graph-cache-directory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cli": "nx",
|
||||||
|
"version": "19.2.2-beta.0",
|
||||||
|
"description": "Updates the nx wrapper.",
|
||||||
|
"implementation": "./src/migrations/update-17-3-0/update-nxw",
|
||||||
|
"package": "nx",
|
||||||
|
"name": "19-2-2-update-nx-wrapper"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "19.2.4-beta.0",
|
||||||
|
"description": "Set project name in nx.json explicitly",
|
||||||
|
"implementation": "./src/migrations/update-19-2-4/set-project-name",
|
||||||
|
"x-repair-skip": true,
|
||||||
|
"package": "nx",
|
||||||
|
"name": "19-2-4-set-project-name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cli": "nx",
|
||||||
|
"version": "19.1.0-beta.2",
|
||||||
|
"requires": {
|
||||||
|
"@angular/core": ">=18.0.0"
|
||||||
|
},
|
||||||
|
"description": "Update the @angular/cli package version to ~18.0.0.",
|
||||||
|
"factory": "./src/migrations/update-19-1-0/update-angular-cli",
|
||||||
|
"package": "@nx/angular",
|
||||||
|
"name": "update-angular-cli-version-18-0-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cli": "nx",
|
||||||
|
"version": "19.2.1-beta.0",
|
||||||
|
"requires": {
|
||||||
|
"@angular-eslint/eslint-plugin": ">=18.0.0"
|
||||||
|
},
|
||||||
|
"description": "Installs the '@typescript-eslint/utils' package when having installed '@angular-eslint/eslint-plugin' or '@angular-eslint/eslint-plugin-template' with version >=18.0.0.",
|
||||||
|
"factory": "./src/migrations/update-19-2-1/add-typescript-eslint-utils",
|
||||||
|
"package": "@nx/angular",
|
||||||
|
"name": "add-typescript-eslint-utils"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "18.0.0",
|
||||||
|
"description": "Updates two-way bindings that have an invalid expression to use the longform expression instead.",
|
||||||
|
"factory": "./migrations/invalid-two-way-bindings/bundle",
|
||||||
|
"package": "@angular/core",
|
||||||
|
"name": "invalid-two-way-bindings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "18.0.0",
|
||||||
|
"description": "Replace deprecated HTTP related modules with provider functions",
|
||||||
|
"factory": "./migrations/http-providers/bundle",
|
||||||
|
"package": "@angular/core",
|
||||||
|
"name": "migration-http-providers"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
46
nwaifu-ui/.eslintrc.json
Normal file
46
nwaifu-ui/.eslintrc.json
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"../.eslintrc.json"
|
||||||
|
],
|
||||||
|
"ignorePatterns": [
|
||||||
|
"!**/*"
|
||||||
|
],
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"*.ts"
|
||||||
|
],
|
||||||
|
"extends": [
|
||||||
|
"plugin:@nx/angular",
|
||||||
|
"plugin:@angular-eslint/template/process-inline-templates"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"@angular-eslint/directive-selector": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"type": "attribute",
|
||||||
|
"prefix": "nwui",
|
||||||
|
"style": "camelCase"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@angular-eslint/component-selector": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"type": "element",
|
||||||
|
"prefix": "nwui",
|
||||||
|
"style": "kebab-case"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"*.html"
|
||||||
|
],
|
||||||
|
"extends": [
|
||||||
|
"plugin:@nx/angular-template"
|
||||||
|
],
|
||||||
|
"rules": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
7
nwaifu-ui/README.md
Normal file
7
nwaifu-ui/README.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# nwaifu-ui
|
||||||
|
|
||||||
|
This library was generated with [Nx](https://nx.dev).
|
||||||
|
|
||||||
|
## Running unit tests
|
||||||
|
|
||||||
|
Run `nx test nwaifu-ui` to execute the unit tests.
|
||||||
9
nwaifu-ui/project.json
Normal file
9
nwaifu-ui/project.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"name": "nwaifu-ui",
|
||||||
|
"$schema": "../node_modules/nx/schemas/project-schema.json",
|
||||||
|
"sourceRoot": "nwaifu-ui/src",
|
||||||
|
"prefix": "nwui",
|
||||||
|
"projectType": "library",
|
||||||
|
"tags": [],
|
||||||
|
"targets": {}
|
||||||
|
}
|
||||||
1
nwaifu-ui/src/index.ts
Normal file
1
nwaifu-ui/src/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './lib';
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<button [disabled]="disabled" [type]="type"><ng-content></ng-content></button>
|
||||||
28
nwaifu-ui/src/lib/components/button/button.component.scss
Normal file
28
nwaifu-ui/src/lib/components/button/button.component.scss
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
button {
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: #5b3f45;
|
||||||
|
word-break: keep-all;
|
||||||
|
padding: 1em 1.5em;
|
||||||
|
color: #f5f6fa;
|
||||||
|
border-radius: 15px;
|
||||||
|
transition: ease-in-out 0.2s;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
&:hover,
|
||||||
|
&:active {
|
||||||
|
transform: scale(1.2);
|
||||||
|
}
|
||||||
|
&:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
&:hover,
|
||||||
|
&:active {
|
||||||
|
cursor: not-allowed;
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
nwaifu-ui/src/lib/components/button/button.component.ts
Normal file
15
nwaifu-ui/src/lib/components/button/button.component.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'nwui-button',
|
||||||
|
templateUrl: './button.component.html',
|
||||||
|
styleUrls: ['./button.component.scss'],
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule],
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
|
})
|
||||||
|
export class NWUIButtonComponent {
|
||||||
|
@Input() disabled = false;
|
||||||
|
@Input() type = 'button';
|
||||||
|
}
|
||||||
1
nwaifu-ui/src/lib/components/button/index.ts
Normal file
1
nwaifu-ui/src/lib/components/button/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './button.component';
|
||||||
2
nwaifu-ui/src/lib/components/index.ts
Normal file
2
nwaifu-ui/src/lib/components/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './button';
|
||||||
|
export * from './textarea';
|
||||||
1
nwaifu-ui/src/lib/components/textarea/index.ts
Normal file
1
nwaifu-ui/src/lib/components/textarea/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './textarea.component';
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<div [attr.contenteditable]="contenteditable" [className]="className" #ref (blur)="leaveFn()">
|
||||||
|
@if(!value) {
|
||||||
|
<ng-content></ng-content>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
.nwui-textarea {
|
||||||
|
border-radius: 8px;
|
||||||
|
height: auto;
|
||||||
|
color: #efdee0;
|
||||||
|
outline: none;
|
||||||
|
padding-inline: 2rem 1rem;
|
||||||
|
background-color: transparent;
|
||||||
|
border: 2px solid #e4bdc3;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: inherit;
|
||||||
|
min-height: 3rem;
|
||||||
|
line-height: 3rem;
|
||||||
|
&:focus {
|
||||||
|
border: 2px solid #efdee0;
|
||||||
|
}
|
||||||
|
&.disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
35
nwaifu-ui/src/lib/components/textarea/textarea.component.ts
Normal file
35
nwaifu-ui/src/lib/components/textarea/textarea.component.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'nwui-textarea',
|
||||||
|
imports: [CommonModule],
|
||||||
|
standalone: true,
|
||||||
|
styleUrls: ['./textarea.component.scss'],
|
||||||
|
templateUrl: './textarea.component.html',
|
||||||
|
// changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
|
})
|
||||||
|
export class NWUITextAreaComponent implements AfterViewInit {
|
||||||
|
@Input() disabled = false;
|
||||||
|
@Input() value = '';
|
||||||
|
@Input() contenteditable = true;
|
||||||
|
@Output() leave = new EventEmitter<string>();
|
||||||
|
@ViewChild('ref') ref: ElementRef<HTMLDivElement> | null = null;
|
||||||
|
|
||||||
|
get className(): string {
|
||||||
|
return `nwui-textarea ${this.disabled && !this.contenteditable ? 'disabled' : ''}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
leaveFn() {
|
||||||
|
if (this.ref) {
|
||||||
|
const target = this.ref.nativeElement;
|
||||||
|
const text = target.textContent || '';
|
||||||
|
if (this.leave) this.leave.emit(text);
|
||||||
|
target.textContent = text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ngAfterViewInit(): void {
|
||||||
|
if (this.ref && this.value) this.ref.nativeElement.textContent = this.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
1
nwaifu-ui/src/lib/index.ts
Normal file
1
nwaifu-ui/src/lib/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './components';
|
||||||
27
nwaifu-ui/tsconfig.json
Normal file
27
nwaifu-ui/tsconfig.json
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es2022",
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"strict": true,
|
||||||
|
"noImplicitOverride": true,
|
||||||
|
"noPropertyAccessFromIndexSignature": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"esModuleInterop": true
|
||||||
|
},
|
||||||
|
"files": [],
|
||||||
|
"include": [],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.lib.json"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"extends": "../tsconfig.base.json",
|
||||||
|
"angularCompilerOptions": {
|
||||||
|
"enableI18nLegacyMessageIdFormat": false,
|
||||||
|
"strictInjectionParameters": true,
|
||||||
|
"strictInputAccessModifiers": true,
|
||||||
|
"strictTemplates": true
|
||||||
|
}
|
||||||
|
}
|
||||||
12
nwaifu-ui/tsconfig.lib.json
Normal file
12
nwaifu-ui/tsconfig.lib.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../dist/out-tsc",
|
||||||
|
"declaration": true,
|
||||||
|
"declarationMap": true,
|
||||||
|
"inlineSources": true,
|
||||||
|
"types": []
|
||||||
|
},
|
||||||
|
"exclude": ["src/**/*.spec.ts", "src/test-setup.ts", "jest.config.ts", "src/**/*.test.ts"],
|
||||||
|
"include": ["src/**/*.ts"]
|
||||||
|
}
|
||||||
61
package.json
61
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nwaifu-web",
|
"name": "nwaifu-web",
|
||||||
"version": "0.0.1",
|
"version": "0.2.3",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "nx serve NwaifuWeb",
|
"start": "nx serve NwaifuWeb",
|
||||||
@@ -11,44 +11,47 @@
|
|||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^17.2.0",
|
"@angular/animations": "18.0.3",
|
||||||
"@angular/common": "^17.2.0",
|
"@angular/common": "18.0.3",
|
||||||
"@angular/compiler": "^17.2.0",
|
"@angular/compiler": "18.0.3",
|
||||||
"@angular/core": "^17.2.0",
|
"@angular/core": "18.0.3",
|
||||||
"@angular/forms": "^17.2.0",
|
"@angular/forms": "18.0.3",
|
||||||
"@angular/platform-browser": "^17.2.0",
|
"@angular/platform-browser": "18.0.3",
|
||||||
"@angular/platform-browser-dynamic": "^17.2.0",
|
"@angular/platform-browser-dynamic": "18.0.3",
|
||||||
"@angular/router": "^17.2.0",
|
"@angular/router": "18.0.3",
|
||||||
"@fortawesome/angular-fontawesome": "0.14.1",
|
"@fortawesome/angular-fontawesome": "0.14.1",
|
||||||
"@fortawesome/fontawesome-svg-core": "^6.4.2",
|
"@fortawesome/fontawesome-svg-core": "^6.4.2",
|
||||||
"@fortawesome/free-brands-svg-icons": "^6.4.2",
|
"@fortawesome/free-brands-svg-icons": "^6.4.2",
|
||||||
"@fortawesome/free-regular-svg-icons": "^6.4.2",
|
"@fortawesome/free-regular-svg-icons": "^6.4.2",
|
||||||
"@fortawesome/free-solid-svg-icons": "^6.4.2",
|
"@fortawesome/free-solid-svg-icons": "^6.4.2",
|
||||||
"@ngneat/dialog": "5.0.0",
|
"@ngneat/dialog": "5.0.0",
|
||||||
|
"@nx/eslint-plugin": "^19.3.0",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
"zone.js": "~0.14.3"
|
"zone.js": "~0.14.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "^17.2.2",
|
"@angular-devkit/build-angular": "18.0.5",
|
||||||
"@angular-devkit/core": "^17.2.2",
|
"@angular-devkit/core": "18.0.5",
|
||||||
"@angular-devkit/schematics": "^17.2.2",
|
"@angular-devkit/schematics": "18.0.5",
|
||||||
"@angular-eslint/eslint-plugin": "17.2.1",
|
"@angular-eslint/eslint-plugin": "18.0.1",
|
||||||
"@angular-eslint/eslint-plugin-template": "17.2.1",
|
"@angular-eslint/eslint-plugin-template": "18.0.1",
|
||||||
"@angular-eslint/template-parser": "17.2.1",
|
"@angular-eslint/template-parser": "18.0.1",
|
||||||
"@angular/cli": "^17.2.2",
|
"@angular/cli": "~18.0.0",
|
||||||
"@angular/compiler-cli": "^17.2.0",
|
"@angular/compiler-cli": "18.0.3",
|
||||||
"@nx/angular": "19.0.2",
|
"@nx/angular": "19.3.0",
|
||||||
"@nx/eslint": "19.0.2",
|
"@nx/eslint": "19.3.0",
|
||||||
"@nx/js": "19.0.2",
|
"@nx/js": "19.3.0",
|
||||||
"@nx/workspace": "19.0.2",
|
"@nx/workspace": "19.3.0",
|
||||||
"@schematics/angular": "^17.2.2",
|
"@schematics/angular": "18.0.5",
|
||||||
"@swc-node/register": "~1.8.0",
|
"@swc-node/register": "1.9.2",
|
||||||
"@swc/core": "~1.3.85",
|
"@swc/core": "1.5.7",
|
||||||
"@swc/helpers": "~0.5.2",
|
"@swc/helpers": "0.5.11",
|
||||||
|
"@types/bun": "latest",
|
||||||
"@types/jasmine": "~5.1.0",
|
"@types/jasmine": "~5.1.0",
|
||||||
"@typescript-eslint/eslint-plugin": "6.19.0",
|
"@typescript-eslint/eslint-plugin": "6.19.0",
|
||||||
"@typescript-eslint/parser": "6.19.0",
|
"@typescript-eslint/parser": "6.19.0",
|
||||||
|
"@typescript-eslint/utils": "^8.0.0-alpha.28",
|
||||||
"autoprefixer": "^10.4.18",
|
"autoprefixer": "^10.4.18",
|
||||||
"eslint": "~8.57.0",
|
"eslint": "~8.57.0",
|
||||||
"jasmine-core": "~5.1.0",
|
"jasmine-core": "~5.1.0",
|
||||||
@@ -57,10 +60,10 @@
|
|||||||
"karma-coverage": "~2.2.0",
|
"karma-coverage": "~2.2.0",
|
||||||
"karma-jasmine": "~5.1.0",
|
"karma-jasmine": "~5.1.0",
|
||||||
"karma-jasmine-html-reporter": "~2.1.0",
|
"karma-jasmine-html-reporter": "~2.1.0",
|
||||||
"nx": "19.0.2",
|
"nx": "19.3.0",
|
||||||
"postcss": "^8.4.35",
|
"postcss": "^8.4.38",
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^3.3.2",
|
||||||
"tailwindcss": "^3.4.1",
|
"tailwindcss": "^3.4.1",
|
||||||
"typescript": "~5.3.2"
|
"typescript": "~5.4.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15912
pnpm-lock.yaml
generated
15912
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,33 +1,24 @@
|
|||||||
{
|
{
|
||||||
"compileOnSave": false,
|
"compileOnSave": false,
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./dist/out-tsc",
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
"strict": true,
|
|
||||||
"noImplicitOverride": true,
|
|
||||||
"noPropertyAccessFromIndexSignature": true,
|
|
||||||
"noImplicitReturns": true,
|
|
||||||
"noFallthroughCasesInSwitch": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"declaration": false,
|
"declaration": false,
|
||||||
|
"moduleResolution": "Node",
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"moduleResolution": "node",
|
|
||||||
"importHelpers": true,
|
"importHelpers": true,
|
||||||
"target": "ES2022",
|
"target": "ES2015",
|
||||||
"module": "ES2022",
|
"module": "ESNext",
|
||||||
"useDefineForClassFields": false,
|
"lib": ["es2020", "dom"],
|
||||||
"lib": ["ES2022", "dom"],
|
"skipLibCheck": true,
|
||||||
"paths": {},
|
"skipDefaultLibCheck": true,
|
||||||
|
"paths": {
|
||||||
|
"@nwaifu-ui": [
|
||||||
|
"nwaifu-ui/src/index.ts"
|
||||||
|
]
|
||||||
|
},
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"rootDir": "."
|
"rootDir": "."
|
||||||
},
|
},
|
||||||
"angularCompilerOptions": {
|
|
||||||
"enableI18nLegacyMessageIdFormat": false,
|
|
||||||
"strictInjectionParameters": true,
|
|
||||||
"strictInputAccessModifiers": true,
|
|
||||||
"strictTemplates": true
|
|
||||||
},
|
|
||||||
"exclude": ["node_modules", "tmp"]
|
"exclude": ["node_modules", "tmp"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user