Skip to content

Commit

Permalink
Merge pull request #35 from Fliplet/release/ID-3065-lfd-v2-phase-1
Browse files Browse the repository at this point in the history
Release 20240507
  • Loading branch information
tonytlwu authored May 7, 2024
2 parents bbd1d79 + 39d82d8 commit 425437d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
5 changes: 5 additions & 0 deletions css/build.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@
.fl-wysiwyg-text {
word-break: break-word;
}

fl-list-repeater-row.readonly .fl-text-placeholder {
opacity: 0;
visibility: hidden;
}
37 changes: 25 additions & 12 deletions js/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
var PLACEHOLDER_CLASS = 'fl-text-placeholder';
var WIDGET_INSTANCE_SELECTOR = '[data-fl-widget-instance]';
var debounceSave = _.debounce(saveChanges, 500, { leading: true });
var debounceRenderEvent = _.debounce(function() {
if (mode === 'interact') {
Fliplet.Hooks.run('componentEvent', {
type: 'render',
target: new Fliplet.Interact.ComponentNode($el)
});
}
}, 200);
var mode = Fliplet.Env.get('mode');
var isDev = Fliplet.Env.get('development');
var isInitialized = false;
Expand All @@ -23,7 +31,7 @@
function cleanUpContent(content) {
var $content = typeof content !== 'undefined'
? $('<div></div>').append(content)
: $(document.body);
: $el;

// Remove any existing markers
$content.find('.' + MIRROR_ELEMENT_CLASS).removeClass(MIRROR_ELEMENT_CLASS);
Expand Down Expand Up @@ -66,7 +74,7 @@
var cleanedUpContent = cleanUpContent(data.html);

// Remove placeholder content
if (cleanedUpContent === cleanUpContent(contentTemplate())) {
if (cleanedUpContent === cleanUpContent(contentTemplate({ mode }))) {
data.html = '';
}

Expand Down Expand Up @@ -113,11 +121,6 @@
});

_.assignIn(widgetData, data);

// Update content in other instances of this field
if ($el.parents('fl-list-repeater-row').length) {
$('fl-list-repeater-row.readonly [data-fl-widget-instance][data-id="' + widgetData.id + '"] [data-widget-name="text"]').html(lastSavedHtml);
}
});
});
}
Expand Down Expand Up @@ -273,6 +276,8 @@

// Save changes
debounceSave();
// Trigger render event
debounceRenderEvent();
});

ed.on('input', function() {
Expand All @@ -284,6 +289,8 @@

// Save changes
debounceSave();
// Trigger render event
debounceRenderEvent();
});

ed.on('focus', function() {
Expand Down Expand Up @@ -315,6 +322,8 @@

// Save changes
debounceSave();
// Trigger render event
debounceRenderEvent();
});

ed.on('nodeChange', function(e) {
Expand All @@ -340,9 +349,9 @@
Fliplet.Studio.emit('tinymce', {
message: 'tinymceNodeChange',
payload: {
html: e.parents.length ?
e.parents[e.parents.length - 1].outerHTML :
e.element.outerHTML,
html: e.parents.length
? e.parents[e.parents.length - 1].outerHTML
: e.element.outerHTML,
styles: [
'.' + MIRROR_ELEMENT_CLASS + ' {',
'\tfont-family: ' + fontFamily + ';',
Expand All @@ -358,6 +367,8 @@

// Save changes
debounceSave();
// Trigger render event
// debounceRenderEvent();
});
}
});
Expand All @@ -366,7 +377,7 @@

function registerHandlebarsHelpers() {
Handlebars.registerHelper('isInteractable', function(options) {
var result = mode === 'interact' || isDev;
var result = options.data.root.mode === 'interact' || isDev;

if (result === false) {
return options.inverse(this);
Expand All @@ -377,7 +388,7 @@
}

function insertPlaceholder() {
var contentHTML = contentTemplate();
var contentHTML = contentTemplate({ mode });

$el.html(contentHTML);
}
Expand All @@ -394,6 +405,8 @@

cleanUpContent();

Fliplet.Widget.initializeChildren($el.get(0));

if (!isDev) {
return;
}
Expand Down

0 comments on commit 425437d

Please sign in to comment.