Skip to content

Commit

Permalink
Merge branch 'master' into issue-27910-check-log-level
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgonzalez authored Mar 20, 2024
2 parents 4b62ca2 + ca3eb44 commit 740feba
Show file tree
Hide file tree
Showing 64 changed files with 3,838 additions and 470 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deployment-trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ jobs:
build_run_id: ${{ github.event.workflow_run.id }}
commit_id: ${{ github.event.workflow_run.head_sha }}"
ref: master
snapshot: true
latest: true
do_deploy: ${{ vars.DOCKER_DEPLOY || 'true' }} # default to true, set to disable in fork
docker_io_username: ${{ secrets.DOCKER_USERNAME }}
docker_io_token: ${{ secrets.DOCKER_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-dev-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# every night. For more information about this docker image, see
# https://github.com/dotCMS/core/tree/master/docker/dev-env

name: Build/Push dotCMS docker image (nightly)
name: Build/Push dotCMS Dev Image (nightly)
on:
schedule:
- cron: "18 2 * * *"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<editor [formControlName]="field.variable" [plugins]="plugins()" [toolbar]="toolbar()"> </editor>
<editor
[formControlName]="field.variable"
[plugins]="plugins()"
[toolbar]="toolbar()"
[init]="init"></editor>
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
@use "variables" as *;

:host::ng-deep {
// Hide the promotion button
// This button redirect to the tinyMCE premium page
.tox-promotion {
display: none;
}

.tox-statusbar__branding {
display: none;
}

.tox .tox-statusbar {
border-top: 1px solid $color-palette-gray-400;
}

.tox-tinymce {
border: $field-border-size solid $color-palette-gray-400;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { WYSIWYG_MOCK, createFormGroupDirectiveMock } from '../../utils/mocks';
const ALL_PLUGINS =
'advlist autolink lists link image charmap preview anchor pagebreak searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking save table directionality emoticons template';
const ALL_TOOLBAR_ITEMS =
'paste print textpattern | insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image hr | preview | validation media | forecolor dotimageclipboard backcolor emoticons';
'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent hr';

describe('DotWYSIWYGFieldComponent', () => {
let spectator: Spectator<DotWYSIWYGFieldComponent>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EditorModule, TINYMCE_SCRIPT_SRC } from '@tinymce/tinymce-angular';
import { RawEditorOptions } from 'tinymce';

import { ChangeDetectionStrategy, Component, Input, inject, signal } from '@angular/core';
import { ControlContainer, FormsModule, ReactiveFormsModule } from '@angular/forms';
Expand All @@ -23,10 +24,14 @@ import { DotCMSContentTypeField } from '@dotcms/dotcms-models';
export class DotWYSIWYGFieldComponent {
@Input() field!: DotCMSContentTypeField;

protected readonly init: RawEditorOptions = {
menubar: false
};

protected readonly plugins = signal(
'advlist autolink lists link image charmap preview anchor pagebreak searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking save table directionality emoticons template'
);
protected readonly toolbar = signal(
'paste print textpattern | insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image hr | preview | validation media | forecolor dotimageclipboard backcolor emoticons'
'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent hr'
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -1853,13 +1853,20 @@ describe('EditEmaEditorComponent', () => {
);
});

it('iframe should have reload the page and add the new content', () => {
it('iframe should have reload the page and add the new content, maintaining scroll', () => {
const params = {
language_id: '4',
url: 'index',
'com.dotmarketing.persona.id': DEFAULT_PERSONA.identifier
};

const iframe = spectator.debugElement.query(By.css('[data-testId="iframe"]'));
const scrollSpy = jest
.spyOn(spectator.component.iframe.nativeElement.contentWindow, 'scrollTo')
.mockImplementation(() => jest.fn);

iframe.nativeElement.contentWindow.scrollTo(0, 100); //Scroll down

store.reload({
params,
whenReloaded: () => {
Expand All @@ -1870,12 +1877,11 @@ describe('EditEmaEditorComponent', () => {

jest.runOnlyPendingTimers();

const iframe = spectator.debugElement.query(By.css('[data-testId="iframe"]'));

expect(iframe.nativeElement.src).toBe('http://localhost/'); //When dont have src, the src is the same as the current page
expect(iframe.nativeElement.contentDocument.body.innerHTML).toEqual(
'<div>New Content - Hello World</div>'
);
expect(scrollSpy).toHaveBeenCalledWith(0, 100);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
listenEditorMessages,
listenHoveredContentlet,
pingEditor,
preserveScrollOnIframe,
scrollHandler
} from './listeners';

Expand Down Expand Up @@ -40,6 +41,12 @@ describe('listeners', () => {
expect(addEventListenerSpy).toHaveBeenCalledWith('scroll', expect.any(Function));
});

it('should preserve scroll on iframe', () => {
const addEventListenerSpy = jest.spyOn(window, 'addEventListener');
preserveScrollOnIframe();
expect(addEventListenerSpy).toHaveBeenCalledWith('load', expect.any(Function));
});

it('should listen to content change', () => {
const observeSpy = jest.spyOn(MutationObserver.prototype, 'observe');
listenContentChange();
Expand Down
25 changes: 25 additions & 0 deletions core-web/libs/sdk/client/src/lib/editor/listeners/listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import {
getPageElementBound
} from '../utils/editor.utils';

declare global {
interface Window {
lastScrollYPosition: number;
}
}

/**
* Default reload function that reloads the current window.
*/
Expand Down Expand Up @@ -144,6 +150,7 @@ export function scrollHandler() {
postMessageToEditor({
action: CUSTOMER_ACTIONS.IFRAME_SCROLL
});
window.lastScrollYPosition = window.scrollY;
};

window.addEventListener('scroll', scrollCallback);
Expand All @@ -155,6 +162,24 @@ export function scrollHandler() {
});
}

/**
* Restores the scroll position of the window when an iframe is loaded.
* Only used in VTL Pages.
* @export
*/
export function preserveScrollOnIframe() {
const preserveScrollCallback = () => {
window.scrollTo(0, window.lastScrollYPosition);
};

window.addEventListener('load', preserveScrollCallback);
subscriptions.push({
type: 'listener',
event: 'scroll',
callback: preserveScrollCallback
});
}

/**
* Listens for changes in the content and triggers a customer action when the content changes.
*
Expand Down
12 changes: 11 additions & 1 deletion core-web/libs/sdk/client/src/lib/editor/sdk-editor-vtl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ import {
listenContentChange,
listenEditorMessages,
listenHoveredContentlet,
pingEditor
pingEditor,
preserveScrollOnIframe,
scrollHandler
} from './listeners/listeners';
import { isInsideEditor } from './sdk-editor';

declare global {
interface Window {
lastScrollYPosition: number;
}
}

/**
* This is the main entry point for the SDK VTL.
* This is added to VTL Script in the EditPage
Expand All @@ -19,6 +27,8 @@ import { isInsideEditor } from './sdk-editor';
if (isInsideEditor()) {
pingEditor();
listenEditorMessages();
scrollHandler();
preserveScrollOnIframe();
listenHoveredContentlet();
listenContentChange();
}
2 changes: 1 addition & 1 deletion core-web/libs/sdk/experiments/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"main": "libs/sdk/experiments/src/lib/standalone.ts",
"tsConfig": "libs/sdk/experiments/tsconfig.lib.json",
"project": "libs/sdk/experiments/package.json",
"assets": ["libs/sdk/experiments/README.md"]
"assets": ["libs/sdk/experiments/README.md", "libs/sdk/experiments/package.json"]
}
},
"publish": {
Expand Down
26 changes: 18 additions & 8 deletions core-web/libs/sdk/experiments/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
*/
export const EXPERIMENT_WINDOWS_KEY = 'dotExperiment';

/**
* The key used to store or retrieve the information in the SessionStore
* indicating whether an experiment has already been checked.
*
* @type {string}
*/
export const EXPERIMENT_ALREADY_CHECKED_KEY = 'experimentAlreadyCheck';

/**
* The duration in milliseconds for which data should be stored in the local storage.
*
* @type {number}
* @constant
* @default 86400000 (A day)
*
*/
export const LOCAL_STORAGE_TIME_DURATION_MILLISECONDS = 86400000;

/**
* The name of the experiment script file.
*
Expand Down Expand Up @@ -41,14 +59,6 @@ export const EXPERIMENT_ALLOWED_DATA_ATTRIBUTES = [
*/
export const API_EXPERIMENTS_URL = 'api/v1/experiments/isUserIncluded';

/**
* The name of the experiment database in the IndexDB.
*
* @type {string}
* @constant
*/
export const EXPERIMENT_DB_NAME = 'DotExperimentDB';

/**
* The name of the experiment database store in indexDB.
*
Expand Down
Loading

0 comments on commit 740feba

Please # to comment.