Skip to content

Commit 46c47a3

Browse files
committed
Add Visual Editor Service
1 parent 1e5bfce commit 46c47a3

File tree

6 files changed

+26
-21
lines changed

6 files changed

+26
-21
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@localess/angular",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"private": false,
55
"description": "Angular Library for Localess's API. ",
66
"keywords": [

projects/localess-angular/browser/src/services/asset.service.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import {Inject, Injectable} from '@angular/core';
1+
import {inject, Inject, Injectable} from '@angular/core';
22
import {LOCALESS_BROWSER_CONFIG, LocalessBrowserConfig} from "../localess.config";
33
import type {ContentAsset} from "@localess/js-client";
44

55
@Injectable({
66
providedIn: 'root'
77
})
88
export class BrowserAssetService {
9-
10-
constructor(
11-
@Inject(LOCALESS_BROWSER_CONFIG) readonly config: LocalessBrowserConfig
12-
) {
13-
console.log('[Localess]BrowserAssetService', config);
9+
config = inject(LOCALESS_BROWSER_CONFIG)
10+
constructor() {
11+
if (this.config.debug) {
12+
console.log('[Localess]BrowserAssetService', this.config);
13+
}
1414
}
1515

1616
/**

projects/localess-angular/browser/src/services/translation.service.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Inject, Injectable} from '@angular/core';
1+
import {inject, Inject, Injectable} from '@angular/core';
22
import {HttpClient} from '@angular/common/http';
33
import {Observable} from 'rxjs';
44
import {LOCALESS_BROWSER_CONFIG, LocalessBrowserConfig} from "../localess.config";
@@ -8,12 +8,13 @@ import type {Translations} from "@localess/js-client";
88
providedIn: 'root'
99
})
1010
export class BrowserTranslationService {
11-
11+
config = inject(LOCALESS_BROWSER_CONFIG)
1212
constructor(
1313
readonly httpClient: HttpClient,
14-
@Inject(LOCALESS_BROWSER_CONFIG) readonly config: LocalessBrowserConfig
1514
) {
16-
console.log('[Localess]BrowserTranslationService', config);
15+
if (this.config.debug) {
16+
console.log('[Localess]BrowserTranslationService', this.config);
17+
}
1718
}
1819

1920
/**

projects/localess-angular/browser/src/services/visual-editor.service.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,24 @@ export class BrowserVisualEditorService {
1515
platformId = inject(PLATFORM_ID)
1616

1717
constructor() {
18-
console.log('[Localess]BrowserVisualEditorService');
18+
if (this.config.debug) {
19+
console.log('[Localess]BrowserVisualEditorService');
20+
}
1921
}
2022

2123
/**
2224
* Initiate Sync Script Load
2325
*/
2426
init() {
25-
console.log(`[Localess]BrowserVisualEditorService init():${this.platformId}`);
27+
if (this.config.debug) {
28+
console.log(`[Localess]BrowserVisualEditorService init():${this.platformId}`);
29+
}
2630
if (isPlatformBrowser(this.platformId)) {
27-
//if (window.top === window.self) return; // Skip if the page is not loaded in Visual Editor
28-
//const isSyncLoaded = typeof window.localess !== 'undefined';
29-
//if (isSyncLoaded) return; // Skip if Sync is already loaded
30-
//const scriptEl = document.getElementById(JS_SYNC_ID);
31-
//if (scriptEl) return; // Skip if script is already loaded
31+
if (window.top === window.self) return; // Skip if the page is not loaded in Visual Editor
32+
const isSyncLoaded = typeof window.localess !== 'undefined';
33+
if (isSyncLoaded) return; // Skip if Sync is already loaded
34+
const scriptEl = document.getElementById(JS_SYNC_ID);
35+
if (scriptEl) return; // Skip if script is already loaded
3236
const script = document.createElement('script');
3337
script.id = JS_SYNC_ID;
3438
script.type = 'text/javascript';

projects/localess-angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@localess/angular",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"description": "Angular Library for Localess's API. ",
55
"keywords": [
66
"localess",

0 commit comments

Comments
 (0)