Skip to content

Commit e34fdd2

Browse files
committed
Merge branch 'MC-1416' of github.com:magento-trigger/magento2-page-builder into MC-1416
2 parents 958deb0 + 4e487c1 commit e34fdd2

File tree

6 files changed

+41
-20
lines changed

6 files changed

+41
-20
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/wysiwyg-factory.js

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

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/wysiwyg.js

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

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type-config.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default interface ContentTypeConfigInterface {
2727
readers: string[];
2828
allowed_parents: string[];
2929
is_visible: boolean;
30-
additional_data: any;
30+
additional_data: AdditionalDataConfigInterface;
3131
}
3232

3333
export interface ContentTypeConfigAppearanceInterface {
@@ -104,3 +104,7 @@ export interface DataMappingTagInterface {
104104
var: string;
105105
converter: string;
106106
}
107+
108+
export interface AdditionalDataConfigInterface {
109+
[key: string]: any;
110+
}

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/wysiwyg-factory.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@
44
*/
55

66
import WysiwygSetup from "mage/adminhtml/wysiwyg/tiny_mce/setup";
7+
import WysiwygInstance from "wysiwygAdapter";
8+
import {AdditionalDataConfigInterface} from "../content-type-config";
79

810
/**
911
* Create new wysiwyg adapter instance
1012
* @param {string} elementId
11-
* @param {object} config
12-
* @returns {WysiwygSetup}
13+
* @param {AdditionalDataConfigInterface} config
14+
* @returns {WysiwygInstance}
1315
* @api
1416
*/
1517
export default function create(
1618
elementId: string,
17-
config: object,
18-
): WysiwygSetup {
19+
config: AdditionalDataConfigInterface,
20+
): WysiwygInstance {
1921
const wysiwygSetup = new WysiwygSetup(elementId, config.adapter);
2022

2123
if (config.additional.mode) {

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/wysiwyg.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import $ from "jquery";
77
import WysiwygSetup from "mage/adminhtml/wysiwyg/tiny_mce/setup";
88
import events from "Magento_PageBuilder/js/events";
99
import _ from "underscore";
10+
import WysiwygInstance from "wysiwygAdapter";
11+
import {AdditionalDataConfigInterface} from "../content-type-config";
1012
import DataStore from "../data-store";
1113
import WysiwygFactory from "./wysiwyg-factory";
1214

@@ -24,7 +26,7 @@ export default class Wysiwyg {
2426
/**
2527
* Wysiwyg adapter instance
2628
*/
27-
private wysiwygAdapter: WysiwygSetup;
29+
private wysiwygAdapter: WysiwygInstance;
2830

2931
/**
3032
* Content type's data store
@@ -39,13 +41,13 @@ export default class Wysiwyg {
3941
/**
4042
* @param {String} contentTypeId
4143
* @param {String} elementId
42-
* @param {Object} config
44+
* @param {AdditionalDataConfigInterface} config
4345
* @param {DataStore} dataStore
4446
*/
4547
constructor(
4648
contentTypeId: string,
4749
elementId: string,
48-
config: object,
50+
config: AdditionalDataConfigInterface,
4951
dataStore: DataStore,
5052
) {
5153
this.contentTypeId = contentTypeId;
@@ -155,13 +157,12 @@ export default class Wysiwyg {
155157
/**
156158
* Prepend specific config with id to encapsulate its targeting by the vendor wysiwyg editor
157159
*
158-
* @param {object} config
159-
* @returns {object} - interpolated configuration
160-
* //todo move in the separate function
160+
* @param {AdditionalDataConfigInterface} config
161+
* @returns {AdditionalDataConfigInterface} - interpolated configuration
161162
*/
162163
private encapsulateConfigBasedOnContentType(config: object)
163164
{
164-
const clonedConfig = Object.assign( {}, config);
165+
const clonedConfig = $.extend(true, {}, config);
165166

166167
if (!clonedConfig.additional.encapsulateSelectorConfigKeys) {
167168
return clonedConfig;

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/types/wysiwyg.d.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,30 @@ interface EventBus {
1010
interface WysiwygSetup {
1111
eventBus: EventBus,
1212
setup(mode: string): void,
13+
wysiwygInstance: WysiwygInstance
14+
}
15+
16+
interface WysiwygInstance {
17+
eventBus: EventBus,
18+
EVENT: any,
1319
getContent(): string,
14-
setContent(content: string): void,
20+
setContent(content: string): void
1521
}
1622

1723
declare var WysiwygSetup: {
1824
prototype: WysiwygSetup;
1925
new (id: string, config: object): WysiwygSetup;
2026
};
2127

28+
declare var WysiwygInstance: {
29+
prototype: WysiwygInstance;
30+
new (id: string, config: object): WysiwygInstance
31+
};
32+
2233
declare module "mage/adminhtml/wysiwyg/tiny_mce/setup" {
2334
export = WysiwygSetup;
2435
}
36+
37+
declare module "wysiwygAdapter" {
38+
export = WysiwygInstance;
39+
}

0 commit comments

Comments
 (0)