Whats new?
+
+
2.3.1
+
+ - Bugfix - Splitting of code and preview panes is remembered by the editor.
+ - Title of the creation is used for the file name when saving as HTML.
+ - Suggest a feature.
+ - Thank you for being a part of this awesome 4000+ developers community. If you find Web Maker helpful, Please rate Web Maker & share it.
+
+
2.3.0
@@ -304,8 +313,6 @@
- Highlight active line in code panes.
- Bugfix - Fix in generated title of new creation.
- Bugfix - HTML autocompletion is manual triggered now with Ctrl+Space.
- - Suggest a feature.
- - Thank you for being a part of this awesome 4000+ developers community. If you find Web Maker helpful, Please rate Web Maker & share it.
diff --git a/src/script.js b/src/script.js
index b86170b..8b3cede 100644
--- a/src/script.js
+++ b/src/script.js
@@ -10,7 +10,7 @@ TextareaAutoComplete */
/* eslint-enable no-extra-semi */
var scope = scope || {};
- var version = '2.3.0';
+ var version = '2.3.1';
if (window.DEBUG) {
window.scope = scope;
@@ -111,6 +111,18 @@ TextareaAutoComplete */
codeWrapEl.classList.add('is-minimized');
}
}
+ // Returns the sizes of main code & preview panes.
+ function getMainSplitSizesToApply() {
+ var mainSplitSizes;
+ if (currentItem && currentItem.mainSizes) {
+ // For layout mode 3, main panes are reversed using flex-direction.
+ // So we need to apply the saved sizes in reverse order.
+ mainSplitSizes = currentLayoutMode === 3 ? [ currentItem.mainSizes[1], currentItem.mainSizes[0] ] : currentItem.mainSizes;
+ } else {
+ mainSplitSizes = [ 50, 50];
+ }
+ return mainSplitSizes;
+ }
function resetSplitting() {
if (codeSplitInstance) {
@@ -137,12 +149,14 @@ TextareaAutoComplete */
} else {
options.sizes = [ 33.33, 33.33, 33.33 ];
}
- // utils.log('reset spliiting', options.sizes)
+ utils.log('reset splitting', currentItem);
+
codeSplitInstance = Split(['#js-html-code', '#js-css-code', '#js-js-code'], options);
mainSplitInstance = Split(['#js-code-side', '#js-demo-side' ], {
direction: (currentLayoutMode === 2 ? 'vertical' : 'horizontal'),
- minSize: 34,
+ minSize: 150,
gutterSize: 6,
+ sizes: getMainSplitSizesToApply(),
onDragEnd: function () {
// Running preview updation in next call stack, so that error there
// doesn't affect this dragend listener.
@@ -154,7 +168,9 @@ TextareaAutoComplete */
}
function toggleLayout(mode) {
if (currentLayoutMode === mode) {
+ utils.log('setMainsize', currentItem.mainSizes || [ 50, 50 ]);
utils.log('setsize', currentItem.sizes || [ 33.33, 33.33, 33.33 ]);
+ mainSplitInstance.setSizes(getMainSplitSizesToApply());
codeSplitInstance.setSizes(currentItem.sizes || [ 33.33, 33.33, 33.33 ]);
currentLayoutMode = mode;
return;
@@ -219,6 +235,47 @@ TextareaAutoComplete */
}
}
+ // Calculates the sizes of html, css & js code panes.
+ function getCodePaneSizes() {
+ var sizes;
+ var dimensionProperty = currentLayoutMode === 2 ? 'width' : 'height';
+ try {
+ sizes = [
+ +htmlCode.style[dimensionProperty].match(/([\d.]+)%/)[1],
+ +cssCode.style[dimensionProperty].match(/([\d.]+)%/)[1],
+ +jsCode.style[dimensionProperty].match(/([\d.]+)%/)[1]
+ ];
+ } catch (e) {
+ sizes = [ 33.33, 33.33, 33.33 ]
+ } finally {
+
+ /* eslint-disable no-unsafe-finally */
+ return sizes;
+
+ /* eslint-enable no-unsafe-finally */
+ }
+ }
+
+ // Calculates the current sizes of code & preview panes.
+ function getMainPaneSizes() {
+ var sizes;
+ var dimensionProperty = currentLayoutMode === 2 ? 'height' : 'width';
+ try {
+ sizes = [
+ +$('#js-code-side').style[dimensionProperty].match(/([\d.]+)%/)[1],
+ +$('#js-demo-side').style[dimensionProperty].match(/([\d.]+)%/)[1]
+ ];
+ } catch (e) {
+ sizes = [ 50, 50 ]
+ } finally {
+
+ /* eslint-disable no-unsafe-finally */
+ return sizes;
+
+ /* eslint-enable no-unsafe-finally */
+ }
+ }
+
function saveCode(key) {
currentItem.title = titleInput.value;
currentItem.html = scope.cm.html.getValue();
@@ -231,27 +288,13 @@ TextareaAutoComplete */
currentItem.layoutMode = currentLayoutMode;
currentItem.externalLibs = { js: externalJsTextarea.value, css: externalCssTextarea.value };
- // debugger;
- var dimensionProperty = currentLayoutMode === 2 ? 'width' : 'height';
+ currentItem.sizes = getCodePaneSizes();
+ currentItem.mainSizes = getMainPaneSizes();
- var sizes;
- try {
- sizes = [
- +htmlCode.style[dimensionProperty].match(/([\d.]+)%/)[1],
- +cssCode.style[dimensionProperty].match(/([\d.]+)%/)[1],
- +jsCode.style[dimensionProperty].match(/([\d.]+)%/)[1]
- ];
- } catch (e) {
- sizes = [ 33.33, 33.33, 33.33 ]
- } finally {
-
- currentItem.sizes = sizes;
-
- utils.log('saving key', key || currentItem.id, currentItem)
- saveSetting(key || currentItem.id, currentItem, function () {
- alertsService.add('Item saved.');
- });
- }
+ utils.log('saving key', key || currentItem.id, currentItem)
+ saveSetting(key || currentItem.id, currentItem, function () {
+ alertsService.add('Item saved.');
+ });
}
function populateItemsInSavedPane(items) {
@@ -267,7 +310,7 @@ TextareaAutoComplete */
+ '
' + item.title + '
Last updated: ' + utils.getHumanDate(item.updatedOn) + ' ';
}
savedItemsPane.querySelector('#js-saved-items-wrap').innerHTML = html;
toggleSavedItemsPane();
@@ -426,7 +469,6 @@ TextareaAutoComplete */
handleModeRequirements(value);
scope.cm.html.setOption('mode', modes[value].cmMode);
CodeMirror.autoLoadMode(scope.cm.html, modes[value].cmPath || modes[value].cmMode);
- trackEvent('ui', 'updateCodeMode', 'html', value);
}
function updateCssMode(value) {
cssMode = value;
@@ -434,7 +476,6 @@ TextareaAutoComplete */
handleModeRequirements(value);
scope.cm.css.setOption('mode', modes[value].cmMode);
CodeMirror.autoLoadMode(scope.cm.css, modes[value].cmPath || modes[value].cmMode);
- trackEvent('ui', 'updateCodeMode', 'css', value);
}
function updateJsMode(value) {
jsMode = value;
@@ -442,7 +483,6 @@ TextareaAutoComplete */
handleModeRequirements(value);
scope.cm.js.setOption('mode', modes[value].cmMode);
CodeMirror.autoLoadMode(scope.cm.js, modes[value].cmPath || modes[value].cmMode);
- trackEvent('ui', 'updateCodeMode', 'js', value);
// FIXME: Will be saved as part of scope settings
/*
chrome.storage.sync.set({
@@ -734,6 +774,10 @@ TextareaAutoComplete */
var fileName = [ 'web-maker', d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds() ].join('-');
fileName += '.html';
+ if (currentItem.title) {
+ fileName = currentItem.title;
+ }
+
var a = document.createElement('a');
var blob = new Blob([ fileContent ], { type: "text/html;charset=UTF-8" });
a.href = window.URL.createObjectURL(blob);
@@ -999,6 +1043,9 @@ TextareaAutoComplete */
/* eslint-enable camelcase */
};
+ if (!currentItem.title.match(/Untitled\s\d\d*-\d/)) {
+ json.title = currentItem.title;
+ }
json = JSON.stringify(json)
.replace(/"/g, "&​quot;")
.replace(/'/g, "'")
@@ -1060,6 +1107,7 @@ TextareaAutoComplete */
} else if (type === 'css') {
updateCssMode(mode);
}
+ trackEvent('ui', 'updateCodeMode', mode);
}
});
});
@@ -1226,7 +1274,6 @@ TextareaAutoComplete */
});
});
}
- // console.utils.log(result, hasSeenNotifications, version);
if (!result.lastSeenVersion || utils.semverCompare(result.lastSeenVersion, version) === -1) {
notificationsBtn.classList.add('has-new');
hasSeenNotifications = false;