Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update grapesjs compatibility (Mautic 4) #50

Open
wants to merge 49 commits into
base: 4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
95c617a
Add compatibility with CKEditor 5
mollux Oct 3, 2023
ac11df5
Save button works well
volha-pivavarchyk Oct 3, 2023
b038211
Build dist files
volha-pivavarchyk Oct 4, 2023
681d5b1
fix breaking change grapesjs 0.20.1, for registering custom components
LordRembo Jan 19, 2024
58c214b
rebuild
LordRembo Jan 19, 2024
04c218e
run prettier
LordRembo Jan 22, 2024
38fee2b
Merge pull request #44 from mollux/ckeditor5
escopecz Jan 24, 2024
5d460ca
Merge branch 'ckeditor5' into 5.x
mollux Jan 27, 2024
2c31f3d
fix breaking change grapesjs 0.20.1, for registering custom components
LordRembo Jan 19, 2024
f431238
rebuild
LordRembo Jan 19, 2024
4b0c951
run prettier
LordRembo Jan 22, 2024
f160354
add fallback if no list of fonts found, use options instead
LordRembo Jan 29, 2024
0bd56ab
remove duplicates
LordRembo Jan 29, 2024
aef624a
if no list of fonts found, use the 'options' property instead
LordRembo Jan 30, 2024
6148098
rebuild
LordRembo Jan 30, 2024
b1ee678
Merge pull request #45 from volha-pivavarchyk/fix/save-buton-always-s…
mollux Jan 31, 2024
6527a27
fix breaking change grapesjs 0.20.1, for registering custom components
LordRembo Jan 19, 2024
bddac06
rebuild
LordRembo Jan 19, 2024
53af154
run prettier
LordRembo Jan 22, 2024
d43ae89
add fallback if no list of fonts found, use options instead
LordRembo Jan 29, 2024
9b50ba6
remove duplicates
LordRembo Jan 29, 2024
0c35e22
Merge branch 'update-grapesjs-compatibility-m5' of github.com:LordRem…
LordRembo Jan 31, 2024
7c4b893
fix issue with non-existing node being appended when builder loads
LordRembo Mar 22, 2024
25b627c
rebuild
LordRembo Mar 22, 2024
bc86dab
replace font icons by svgs from custom blocks
LordRembo Mar 22, 2024
c592112
rebuild
LordRembo Mar 22, 2024
5cc1128
override button icons in top bar of the Editor
LordRembo Mar 22, 2024
9c9713a
rebuild
LordRembo Mar 22, 2024
1c2a461
undo our previous conditionals and just use the correct class for the…
LordRembo Mar 22, 2024
c3d9822
move the general constants together, for the Settings Sector logic, i…
LordRembo Mar 22, 2024
c2599b8
rebuild
LordRembo Mar 22, 2024
c9eab80
reformat the stopDynamicContentPopup function to fix linting
LordRembo Mar 29, 2024
fb67e3e
correction in syntax
LordRembo Mar 29, 2024
f4ee355
move isComponent check to where it should be + improve condition check
LordRembo Mar 29, 2024
720a1da
move comment to correct place
LordRembo Mar 29, 2024
ede518b
replace Dynamic Content icon with an svg to be consistent with the ot…
LordRembo Apr 5, 2024
ac2f4c0
fix spelling of function name to add Dynamic content block
LordRembo Apr 8, 2024
4b6f8d4
Fix for block getting removed when Editor opens
LordRembo Apr 8, 2024
6218ab7
put back merging of default model properties with the dynamic content…
LordRembo Apr 8, 2024
334bf3e
load default block styling for dynamic content block instead of tryin…
LordRembo Apr 8, 2024
df78c9d
Fix for block getting removed when Editor opens
LordRembo Apr 8, 2024
84ea898
move todos to the correct part of the code
LordRembo Apr 8, 2024
764feb2
don't try to remove item that does not exist
LordRembo Apr 8, 2024
e69c7d4
reformat onRender function for clarity
LordRembo Apr 8, 2024
c9f2aa1
format logger variable back to old way of writing but prevent linting…
LordRembo Apr 8, 2024
524ca93
make the preview block render in full width so it visually matches th…
LordRembo Apr 8, 2024
253d1d6
rebuild
LordRembo Apr 8, 2024
faeed09
Merge branch 'update-grapesjs-compatibility-m5' into update-grapesjs-…
LordRembo Apr 18, 2024
6927ea8
rebuild
LordRembo Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions dist/blocks.js
Original file line number Diff line number Diff line change
@@ -1,114 +1,126 @@
import DynamicContentBlocks from './dynamicContent/dynamicContent.blocks';
import ContentService from './content.service';
import ButtonBlock from './buttonBlock';
import PanelsMjml from './panels/panels.mjml';
import BlocksMjml from './blocks/blocks.mjml';
export default ((editor, opts = {}) => {
const bm = editor.BlockManager;
const blocks = bm.getAll();
const mode = ContentService.getMode(editor);

if (mode === ContentService.modeEmailMjml) {
const panelMjml = new PanelsMjml(editor);
const blockMjml = new BlocksMjml(editor);
panelMjml.restylePanels();
blockMjml.addBlocks();
}
} // a add button block for landing page


// a add button block for landing page
if (mode === ContentService.modePageHtml) {
const buttonBlock = new ButtonBlock(editor);
buttonBlock.addButtonBlock();
} else {
// Add Dynamic Content block only for email modes
const dcb = new DynamicContentBlocks(editor, opts);
dcb.addDynamciContentBlock();
}
dcb.addDynamicContentBlock();
} // Add icon to mj-hero


// Add icon to mj-hero
if (typeof bm.get('mj-hero') !== 'undefined') {
bm.get('mj-hero').set({
attributes: {
class: 'gjs-fonts gjs-f-hero'
}
});
}
} // Delete mj-wrapper


// Delete mj-wrapper
if (typeof bm.get('mj-wrapper') !== 'undefined') {
bm.remove('mj-wrapper');
}
} // All block inside Blocks category


// All block inside Blocks category
blocks.forEach(block => {
block.set({
category: Mautic.translate('grapesjsbuilder.categoryBlockLabel')
});
});

/*
* Custom block inside Sections category
*/

// MJML columns

if (typeof bm.get('mj-1-column') !== 'undefined') {
bm.get('mj-1-column').set({
label: Mautic.translate('grapesjsbuilder.components.names.oneColumn'),
category: Mautic.translate('grapesjsbuilder.categorySectionLabel')
});
}

if (typeof bm.get('mj-2-columns') !== 'undefined') {
bm.get('mj-2-columns').set({
label: Mautic.translate('grapesjsbuilder.components.names.twoColumn'),
category: Mautic.translate('grapesjsbuilder.categorySectionLabel')
});
}

if (typeof bm.get('mj-3-columns') !== 'undefined') {
bm.get('mj-3-columns').set({
label: Mautic.translate('grapesjsbuilder.components.names.threeColumn'),
category: Mautic.translate('grapesjsbuilder.categorySectionLabel')
});
}

if (typeof bm.get('mj-37-columns') !== 'undefined') {
bm.get('mj-37-columns').set({
category: Mautic.translate('grapesjsbuilder.categorySectionLabel')
});
}
} // Newsletter columns


// Newsletter columns
if (typeof bm.get('sect100') !== 'undefined') {
bm.get('sect100').set({
category: Mautic.translate('grapesjsbuilder.categorySectionLabel')
});
}

if (typeof bm.get('sect50') !== 'undefined') {
bm.get('sect50').set({
category: Mautic.translate('grapesjsbuilder.categorySectionLabel')
});
}

if (typeof bm.get('sect30') !== 'undefined') {
bm.get('sect30').set({
category: Mautic.translate('grapesjsbuilder.categorySectionLabel')
});
}

if (typeof bm.get('sect37') !== 'undefined') {
bm.get('sect37').set({
category: Mautic.translate('grapesjsbuilder.categorySectionLabel')
});
}
} // Webpage columns


// Webpage columns
if (typeof bm.get('column1') !== 'undefined') {
bm.get('column1').set({
category: Mautic.translate('grapesjsbuilder.categorySectionLabel')
});
}

if (typeof bm.get('column2') !== 'undefined') {
bm.get('column2').set({
category: Mautic.translate('grapesjsbuilder.categorySectionLabel')
});
}

if (typeof bm.get('column3') !== 'undefined') {
bm.get('column3').set({
category: Mautic.translate('grapesjsbuilder.categorySectionLabel')
});
}

if (typeof bm.get('column3-7') !== 'undefined') {
bm.get('column3-7').set({
category: Mautic.translate('grapesjsbuilder.categorySectionLabel')
Expand Down
41 changes: 22 additions & 19 deletions dist/blocks/blocks.mjml.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

export default class BlocksMjml {
constructor(editor) {
_defineProperty(this, "blockManager", void 0);

_defineProperty(this, "editor", void 0);

this.editor = editor;
this.blockManager = editor.BlockManager;
}

addBlocks() {
const sections37 = `<mj-column width="30%"><mj-text>Content 1</mj-text></mj-column>
<mj-column width="70%"><mj-text>Content 2</mj-text></mj-column>`;
this.blockManager.add('mj-37-columns', {
label: Mautic.translate('grapesjsbuilder.components.names.twoColumnThirdSevens'),
category: Mautic.translate('grapesjsbuilder.categorySectionLabel'),
attributes: {
class: 'gjs-fonts gjs-f-b37'
},
content: `<mj-section>${sections37}</mj-section>`
content: `<mj-section>${sections37}</mj-section>`,
media: `<svg viewBox="0 0 24 24">
<path fill="currentColor" d="M2 20h5V4H2v16Zm-1 0V4a1 1 0 0 1 1-1h5a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1ZM10 20h12V4H10v16Zm-1 0V4a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H10a1 1 0 0 1-1-1Z"></path>
</svg>`
});
const textSect = `<mj-column>
<mj-text font-size="18px" font-weight="bold">
Expand All @@ -30,10 +32,10 @@ export default class BlocksMjml {
this.blockManager.add('text-sect', {
label: Mautic.translate('grapesjsbuilder.components.names.textSectionBlkLabel'),
category: Mautic.translate('grapesjsbuilder.reusableDynamicContentBlockLabel'),
attributes: {
class: 'gjs-fonts gjs-f-h1p'
},
content: `<mj-section>${textSect}</mj-section>`
content: `<mj-section>${textSect}</mj-section>`,
media: `<svg viewBox="0 0 24 24">
<path fill="currentColor" d="M20,20H4A2,2 0 0,1 2,18V6A2,2 0 0,1 4,4H20A2,2 0 0,1 22,6V18A2,2 0 0,1 20,20M4,6V18H20V6H4M6,9H18V11H6V9M6,13H16V15H6V13Z" />
</svg>`
});
const gridItem = `<mj-group>
<mj-column>
Expand All @@ -58,10 +60,10 @@ export default class BlocksMjml {
this.blockManager.add('grid-items', {
label: Mautic.translate('grapesjsbuilder.components.names.gridItemsBlkLabel'),
category: Mautic.translate('grapesjsbuilder.reusableDynamicContentBlockLabel'),
attributes: {
class: 'fa fa-th'
},
content: `<mj-section>${gridItem}</mj-section>`
content: `<mj-section>${gridItem}</mj-section>`,
media: `<svg viewBox="0 0 24 24">
<path fill="currentColor" d="M3,11H11V3H3M3,21H11V13H3M13,21H21V13H13M13,3V11H21V3"/>
</svg>`
});
const listItem = `<mj-group>
<mj-column width="30%">
Expand All @@ -79,10 +81,11 @@ export default class BlocksMjml {
this.blockManager.add('list-items', {
label: Mautic.translate('grapesjsbuilder.components.names.listItemsBlkLabel'),
category: Mautic.translate('grapesjsbuilder.reusableDynamicContentBlockLabel'),
attributes: {
class: 'fa fa-th-list'
},
content: `<mj-section>${listItem}</mj-section>`
content: `<mj-section>${listItem}</mj-section>`,
media: `<svg viewBox="0 0 24 24">
<path fill="currentColor" d="M2 14H8V20H2M16 8H10V10H16M2 10H8V4H2M10 4V6H22V4M10 20H16V18H10M10 16H22V14H10"/>
</svg>`
});
}

}
13 changes: 9 additions & 4 deletions dist/buttonBlock.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

export default class ButtonBlock {
constructor(editor) {
_defineProperty(this, "blockManager", void 0);

this.blockManager = editor.BlockManager;
}

addButtonBlock() {
const style = `<style>
.button {
Expand All @@ -29,7 +30,11 @@ export default class ButtonBlock {
class: 'gjs-fonts gjs-f-button'
},
content: `${style}
<a href="#" target="_blank" class="button">Button</a>`
<a href="#" target="_blank" class="button">Button</a>`,
media: `<svg viewBox="0 0 24 24">
<path fill="currentColor" d="M20 20.5C20 21.3 19.3 22 18.5 22H13C12.6 22 12.3 21.9 12 21.6L8 17.4L8.7 16.6C8.9 16.4 9.2 16.3 9.5 16.3H9.7L12 18V9C12 8.4 12.4 8 13 8S14 8.4 14 9V13.5L15.2 13.6L19.1 15.8C19.6 16 20 16.6 20 17.1V20.5M20 2H4C2.9 2 2 2.9 2 4V12C2 13.1 2.9 14 4 14H8V12H4V4H20V12H18V14H20C21.1 14 22 13.1 22 12V4C22 2.9 21.1 2 20 2Z" />
</svg>`
});
}

}
Loading