Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
biaogebusy committed Jan 5, 2025
2 parents 4abcef6 + e1c734d commit cb28690
Show file tree
Hide file tree
Showing 46 changed files with 1,167 additions and 463 deletions.
6 changes: 0 additions & 6 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
API_URL,
BRANDING,
CORE_CONFIG,
MEDIA_ASSETS,
DEBUG_ANIMATE,
NOTIFY_CONTENT,
IS_BUILDER_MODE,
Expand All @@ -34,7 +33,6 @@ import {
debugAnimateFactory,
isBuilderModeFactory,
langFactory,
mediaAssetsFactory,
notifyFactory,
themeFactory,
userFactory,
Expand Down Expand Up @@ -114,10 +112,6 @@ import { CookieService } from 'ngx-cookie-service';
useFactory: isBuilderModeFactory,
deps: [Router],
},
{
provide: MEDIA_ASSETS,
useFactory: mediaAssetsFactory,
},
provideHttpClient(withInterceptorsFromDi()),
],
})
Expand Down
7 changes: 7 additions & 0 deletions src/app/core/branding/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class HeaderComponent implements OnInit, AfterViewInit {
sticky = signal(false);
showBanner = signal(false);
headerMode: any;
isBuilderMode = false;
@ViewChild('header', { read: ElementRef }) header: ElementRef;
@ViewChild('menu', { read: ElementRef }) menu: ElementRef;
destroy$: Subject<boolean> = new Subject<boolean>();
Expand All @@ -53,7 +54,13 @@ export class HeaderComponent implements OnInit, AfterViewInit {

ngAfterViewInit(): void {
if (this.screenService.isPlatformBrowser()) {
this.isBuilderMode$.pipe(takeUntilDestroyed(this.destoryRef)).subscribe(state => {
this.isBuilderMode = state;
});
this.screenState.scroll$.pipe(takeUntilDestroyed(this.destoryRef)).subscribe(() => {
if (this.isBuilderMode) {
return;
}
if (this.menu) {
this.sticky.set(this.screenService.isElementOutTopViewport(this.menu.nativeElement));
}
Expand Down
2 changes: 0 additions & 2 deletions src/app/core/directive/contentedit.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ export class ContenteditDirective implements AfterViewInit, OnInit {
if (clipboardData) {
const plainText = clipboardData.getData('text/plain');

const targetElement = event.target;

// 保存当前选区(光标位置)
const selection = window.getSelection();
if (!selection) {
Expand Down
18 changes: 15 additions & 3 deletions src/app/core/factory/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { ComponentService } from '@core/service/component.service';
import { inject } from '@angular/core';
import { IBuilderConfig } from '@core/interface/IBuilder';
import { BuilderService } from '@core/service/builder.service';
import { UtilitiesService } from '@core/service/utilities.service';

export const THEMKEY = 'themeMode';
export const DEBUG_ANIMATE_KEY = 'debugAnimate';
Expand Down Expand Up @@ -65,14 +66,18 @@ export function builderFullScreenFactory(
}

export function builderCurrentPageFactory(): Observable<IPage | object | boolean> {
const router = inject(Router);
const versionKey = 'version';
const currentPage$ = new BehaviorSubject<IPage | object | boolean>(false);
const storage = inject(LocalStorageService);
const builderService = inject(BuilderService);
const localVersion = storage.retrieve(versionKey);

if (localVersion) {
const currentPage = localVersion.find((page: IPage) => page.current === true);
builderService.checkIsLatestPage(currentPage);
if (router.url.includes(BUILDERPATH)) {
builderService.checkIsLatestPage(currentPage);
}
currentPage$.next(currentPage);
}

Expand Down Expand Up @@ -249,14 +254,21 @@ export function mediaAssetsFactory(): Observable<IManageAssets | boolean> {
const api = '/api/v2/media';
const nodeService = inject(NodeService);
const contentState = inject(ContentState);
const util = inject(UtilitiesService);
const assets$ = new BehaviorSubject<IManageAssets | boolean>(false);

// on form search change
contentState.mediaAssetsFormChange$.subscribe((value: any) => {
const params = nodeService.getApiParams({ ...value, noCache: true });
const params = nodeService.getApiParams({ ...value });
nodeService.fetch(api, params).subscribe(res => {
assets$.next({
rows: res.rows,
rows: res.rows.map((item: any) => {
const type = util.getFileType(item.source);
return {
...item,
src: type === 'svg' ? item.source : item.thumb,
};
}),
pager: nodeService.handlerPager(res.pager, res.rows.length),
});
});
Expand Down
10 changes: 0 additions & 10 deletions src/app/core/interface/IAppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ export interface ICoreConfig {
params: {
reqRoles: string[];
};
api: {
[key: string]: string;
};
widgetPicker: {
help: {
tooltip: string;
link: string;
};
};
generater: FormlyFieldConfig[];
};
access: {
check: true;
Expand Down
12 changes: 12 additions & 0 deletions src/app/core/interface/IBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ export interface IBuilderConfig {
delay: number;
steps: any[];
};
generater: FormlyFieldConfig[];
api: {
create: string;
update: string;
translate: string;
};
widgetPicker: {
help: {
tooltip: string;
link: string;
};
};
}

export interface IBuilderComponent {
Expand Down
2 changes: 2 additions & 0 deletions src/app/core/interface/widgets/IBtn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface IBtn {
drawerIframe?: boolean;
disabled?: boolean;
pill?: boolean;
iconPosition?: string;
containerClasses?: string;
}

export interface IBtnVideo {
Expand Down
31 changes: 15 additions & 16 deletions src/app/core/service/builder.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Inject, Injectable, inject } from '@angular/core';
import { ApiService } from './api.service';
import { CORE_CONFIG, USER } from '@core/token/token-providers';
import type { ICoreConfig, IPage, IPageForJSONAPI } from '@core/interface/IAppConfig';
import { BUILDER_CONFIG, USER } from '@core/token/token-providers';
import type { IPage, IPageForJSONAPI } from '@core/interface/IAppConfig';
import { Observable, Subject, of, throwError } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import type { IUser } from '@core/interface/IUser';
Expand All @@ -15,6 +15,7 @@ import { MatDialog } from '@angular/material/dialog';
import { DialogComponent } from '@uiux/widgets/dialog/dialog.component';
import { ContentService } from './content.service';
import { isArray } from 'lodash-es';
import { IBuilderConfig } from '@core/interface/IBuilder';

@Injectable({
providedIn: 'root',
Expand All @@ -27,14 +28,18 @@ export class BuilderService extends ApiService {
nodeService = inject(NodeService);
contentService = inject(ContentService);
user: IUser;
builderConfig: IBuilderConfig;
constructor(
@Inject(CORE_CONFIG) private coreConfig: ICoreConfig,
@Inject(USER) private user$: Observable<IUser>
@Inject(USER) private user$: Observable<IUser>,
@Inject(BUILDER_CONFIG) private builderConfig$: Observable<IBuilderConfig>
) {
super();
this.user$.subscribe(user => {
this.user = user;
});
this.builderConfig$.subscribe(config => {
this.builderConfig = config;
});
}

getApiLang(langcode?: string): string {
Expand Down Expand Up @@ -160,10 +165,8 @@ export class BuilderService extends ApiService {

createLandingPage(page: IPage): Observable<any> {
const {
builder: {
api: { create },
},
} = this.coreConfig;
api: { create },
} = this.builderConfig;
const { csrf_token } = this.user;
this.builder.loading$.next(true);
return this.http
Expand Down Expand Up @@ -191,10 +194,8 @@ export class BuilderService extends ApiService {
prefix = `/${lang}`;
}
const {
builder: {
api: { update },
},
} = this.coreConfig;
api: { update },
} = this.builderConfig;
const { csrf_token } = this.user;
this.builder.loading$.next(true);
return this.http
Expand Down Expand Up @@ -250,10 +251,8 @@ export class BuilderService extends ApiService {
addTranslation(page: IPage): Observable<any> {
const { nid, target, langcode } = page;
const {
builder: {
api: { translate },
},
} = this.coreConfig;
api: { translate },
} = this.builderConfig;
const { csrf_token } = this.user;
return this.http.post(
`${this.apiUrl}${translate}/add/${nid}/${langcode}/${target}`,
Expand Down
6 changes: 5 additions & 1 deletion src/app/core/service/utilities.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ export class UtilitiesService {
}
const url = href.toLowerCase();
const pdfReg = /^.+(\.pdf)/;
const svgReg = /^.+(\.svg)/;
const txtReg = /^.+(\.txt)/;
const wordReg = /^.+(\.doc|\.docx)/;
const excelReg = /^.+(\.xls|\.xlsx)/;
const jpgReg = /^.+(\.png|\.jpg|\.jpeg|\.bmp|\.gif|\.webp|\.svg)/;
const jpgReg = /^.+(\.png|\.jpg|\.jpeg|\.bmp|\.gif|\.webp)/;
if (pdfReg.test(url)) {
return 'pdf';
}
if (svgReg.test(url)) {
return 'svg';
}
if (txtReg.test(url)) {
return 'txt';
}
Expand Down
18 changes: 16 additions & 2 deletions src/app/modules/builder/builder.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,23 @@ import { BuilderPageComponent } from './sidebar/builder-page/builder-page.compon
import { BuilderListComponent } from './main/builder-list/builder-list.component';
import { SwitchPreviewComponent } from './toolbar/switch-preview/switch-preview.component';
import { BaseModule } from '@uiux/base/base.module';
import { BUILDER_CURRENT_PAGE, WIDGETS, UIUX, BUILDER_CONFIG } from '@core/token/token-providers';
import {
BUILDER_CURRENT_PAGE,
WIDGETS,
UIUX,
BUILDER_CONFIG,
MEDIA_ASSETS,
} from '@core/token/token-providers';
import { uiux } from './data/uiux-for-builder';
import { PreviewComponent } from './preview/preview.component';
import { BuilderToolbarComponent } from './toolbar/builder-toolbar/builder-toolbar.component';
import { BtnGeneraterComponent } from './toolbar/btn-generater/btn-generater.component';
import { BuilderVersionComponent } from './sidebar/builder-version/builder-version.component';
import { builderCurrentPageFactory, getBuilderConfig } from '@core/factory/factory';
import {
builderCurrentPageFactory,
getBuilderConfig,
mediaAssetsFactory,
} from '@core/factory/factory';
import { LocalStorageService } from 'ngx-webstorage';
import { InlineEditComponent } from './main/inline-editor/inline-editor.component';
import { LayoutBuilderComponent } from './layout-builder/layout-builder.component';
Expand Down Expand Up @@ -105,6 +115,10 @@ const components = [
provide: BUILDER_CURRENT_PAGE,
useFactory: builderCurrentPageFactory,
},
{
provide: MEDIA_ASSETS,
useFactory: mediaAssetsFactory,
},
],
exports: [...components],
})
Expand Down
Loading

0 comments on commit cb28690

Please sign in to comment.