mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-03 07:13:59 +01:00
Fixing plugin install system and handle Prettier
This commit is contained in:
@@ -18,6 +18,8 @@ var ICEcoder = {
|
||||
minFilesW: 14, // Min width of files pane
|
||||
maxFilesW: 250, // Max width of files pane
|
||||
selectedTab: 0, // The tab that's currently selected
|
||||
selectedTabFileExt: '', // File extension of selected tab
|
||||
selectedTabLangMode: '', // Language mode of selected tab
|
||||
savedPoints: [], // Ints array to indicate save points for docs
|
||||
savedContents: [], // Array of last known saved contents
|
||||
canSwitchTabs: true, // Stops switching of tabs when trying to close
|
||||
@@ -1983,22 +1985,46 @@ var ICEcoder = {
|
||||
// Save a file
|
||||
saveFile: function(saveAs, newFileAutoSave) {
|
||||
let changes, saveType, filePath, pathPrefix;
|
||||
// If we're not 'saving as', establish changes between current and known saved version from array
|
||||
if (false === saveAs) {
|
||||
changes = this.getChangesToSave();
|
||||
if ("undefined" !== typeof prettier && ["js", "json", "ts", "css", "scss", "less", "html", "xml", "yaml", "md", "php"].indexOf(this.selectedTabFileExt) > -1) {
|
||||
switch (this.selectedTabFileExt) {
|
||||
case "js": parser = "babel"; break;
|
||||
case "json": parser = "json"; break;
|
||||
case "ts": parser = "typescript"; break;
|
||||
case "css": parser = "css"; break;
|
||||
case "scss": parser = "scss"; break;
|
||||
case "less": parser = "less"; break;
|
||||
case "html": parser = "html"; break;
|
||||
case "xml": parser = "html"; break;
|
||||
case "yaml": parser = "yaml"; break;
|
||||
case "md": parser = "markdown"; break;
|
||||
case "php": parser = "php"; break;
|
||||
}
|
||||
this.getThisCM().setValue(prettier.format(
|
||||
this.getThisCM().getValue(),
|
||||
{
|
||||
parser: parser,
|
||||
plugins: prettierPlugins
|
||||
}
|
||||
));
|
||||
}
|
||||
setTimeout(function() {
|
||||
// If we're not 'saving as', establish changes between current and known saved version from array
|
||||
if (false === saveAs) {
|
||||
changes = ic.getChangesToSave();
|
||||
}
|
||||
|
||||
saveType = saveAs ? "saveAs" : "save";
|
||||
filePath = this.openFiles[this.selectedTab - 1].replace(iceRoot, "").replace(/\//g, "|");
|
||||
if ("|[NEW]" === filePath && 0 < this.selectedFiles.length) {
|
||||
pathPrefix = this.selectedFiles[0];
|
||||
filePath = -1 == pathPrefix.lastIndexOf(".") || pathPrefix.lastIndexOf(".") < pathPrefix.lastIndexOf("|")
|
||||
? pathPrefix + filePath
|
||||
: "|[NEW]";
|
||||
}
|
||||
filePath = filePath.replace("||", "|");
|
||||
this.serverQueue("add", iceLoc + "/lib/file-control.php?action=save&fileMDT=" + this.openFileMDTs[this.selectedTab - 1] + "&fileVersion=" + this.openFileVersions[this.selectedTab - 1] + "&saveType=" + saveType + "&newFileAutoSave=" + newFileAutoSave + "&tabNum=" + this.selectedTab + "&csrf=" + this.csrf,encodeURIComponent(filePath), changes);
|
||||
this.serverMessage('<b>' + t['Saving'] + '</b><br>' + this.openFiles[this.selectedTab - 1].replace(iceRoot, ""));
|
||||
saveType = saveAs ? "saveAs" : "save";
|
||||
filePath = ic.openFiles[ic.selectedTab - 1].replace(iceRoot, "").replace(/\//g, "|");
|
||||
if ("|[NEW]" === filePath && 0 < ic.selectedFiles.length) {
|
||||
pathPrefix = ic.selectedFiles[0];
|
||||
filePath = -1 == pathPrefix.lastIndexOf(".") || pathPrefix.lastIndexOf(".") < pathPrefix.lastIndexOf("|")
|
||||
? pathPrefix + filePath
|
||||
: "|[NEW]";
|
||||
}
|
||||
filePath = filePath.replace("||", "|");
|
||||
ic.serverQueue("add", iceLoc + "/lib/file-control.php?action=save&fileMDT=" + ic.openFileMDTs[ic.selectedTab - 1] + "&fileVersion=" + ic.openFileVersions[ic.selectedTab - 1] + "&saveType=" + saveType + "&newFileAutoSave=" + newFileAutoSave + "&tabNum=" + ic.selectedTab + "&csrf=" + ic.csrf,encodeURIComponent(filePath), changes);
|
||||
ic.serverMessage('<b>' + t['Saving'] + '</b><br>' + ic.openFiles[ic.selectedTab - 1].replace(iceRoot, ""));
|
||||
}, 0, ic);
|
||||
},
|
||||
|
||||
// Prompt a rename dialog
|
||||
|
||||
@@ -280,7 +280,8 @@ parent.ICEcoder.switchMode = function(mode) {
|
||||
}
|
||||
} else if (cM && fileName) {
|
||||
<?php include(dirname(__FILE__) . "/assets/js/language-modes-partial.js");?>
|
||||
|
||||
parent.ICEcoder.selectedTabFileExt = fileExt;
|
||||
parent.ICEcoder.selectedTabLangMode = mode;
|
||||
if (mode != cM.getOption("mode")) {
|
||||
cM.setOption("mode", mode);
|
||||
cM.setOption("lint", ("js" === fileExt || "json" === fileExt) && parent.ICEcoder.codeAssist ? true : false);
|
||||
|
||||
14
index.php
14
index.php
@@ -86,6 +86,20 @@ $t = $text['index'];
|
||||
}
|
||||
</script>
|
||||
<script language="JavaScript" src="<?php echo $iceURLPath;?>/assets/js/icecoder.js?microtime=<?php echo microtime(true);?>"></script>
|
||||
<?php
|
||||
if (true === file_exists(dirname(__FILE__) . "/plugins/prettier/standalone.js")) {
|
||||
?>
|
||||
<script language="JavaScript" src="<?php echo $iceURLPath;?>/plugins/prettier/standalone.js?microtime=<?php echo microtime(true);?>"></script>
|
||||
<script language="JavaScript" src="<?php echo $iceURLPath;?>/plugins/prettier/parser-babel.js?microtime=<?php echo microtime(true);?>"></script>
|
||||
<script language="JavaScript" src="<?php echo $iceURLPath;?>/plugins/prettier/parser-postcss.js?microtime=<?php echo microtime(true);?>"></script>
|
||||
<script language="JavaScript" src="<?php echo $iceURLPath;?>/plugins/prettier/parser-typescript.js?microtime=<?php echo microtime(true);?>"></script>
|
||||
<script language="JavaScript" src="<?php echo $iceURLPath;?>/plugins/prettier/parser-html.js?microtime=<?php echo microtime(true);?>"></script>
|
||||
<script language="JavaScript" src="<?php echo $iceURLPath;?>/plugins/prettier/parser-markdown.js?microtime=<?php echo microtime(true);?>"></script>
|
||||
<script language="JavaScript" src="<?php echo $iceURLPath;?>/plugins/prettier/parser-yaml.js?microtime=<?php echo microtime(true);?>"></script>
|
||||
<script language="JavaScript" src="<?php echo $iceURLPath;?>/plugins/prettier/parser-php.js?microtime=<?php echo microtime(true);?>"></script>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<script src="<?php echo $iceURLPath;?>/assets/js/mmd.js?microtime=<?php echo microtime(true);?>"></script>
|
||||
<script src="<?php echo $iceURLPath;?>/assets/js/farbtastic.js?microtime=<?php echo microtime(true);?>"></script>
|
||||
<script src="<?php echo $iceURLPath;?>/assets/js/difflib.js?microtime=<?php echo microtime(true);?>"></script>
|
||||
|
||||
@@ -172,7 +172,7 @@ if (false === $demoMode && isset($_SESSION['loggedIn']) && $_SESSION['loggedIn']
|
||||
fclose($fh);
|
||||
// Finally, reload ICEcoder itself if plugin requires it or just the iFrame screen for the user if it doesn't
|
||||
if ("install" === $_GET['action'] && "true" === $pluginsData[$_GET['plugin']]['reload']) {
|
||||
echo "<script>if (confirm('" . $t['ICEcoder needs to...'] . "')) {window.location.reload(true);} else {window.location='plugins-manager.php?updatedPlugins&csrf=' + parent.ICEcoder.csrf;}</script>";
|
||||
echo "<script>if (confirm('" . $t['ICEcoder needs to...'] . "')) {parent.window.location.reload(true);} else {window.location='plugins-manager.php?updatedPlugins&csrf=' + parent.ICEcoder.csrf;}</script>";
|
||||
} else {
|
||||
header("Location: plugins-manager.php?updatedPlugins&csrf=" . $_SESSION["csrf"]);
|
||||
echo "<script>window.location = 'plugins-manager.php?updatedPlugins&csrf=' + ICEcoder.csrf;</script>";
|
||||
|
||||
Reference in New Issue
Block a user