remove special build version for bookmarklet
This commit is contained in:
parent
ffe22ce2be
commit
fcb3331d69
3 changed files with 79 additions and 135 deletions
|
|
@ -69,8 +69,6 @@ function main(args) {
|
||||||
ace();
|
ace();
|
||||||
} else if (type == "demo") {
|
} else if (type == "demo") {
|
||||||
demo();
|
demo();
|
||||||
} else if (type == "bm") {
|
|
||||||
bookmarklet();
|
|
||||||
} else if (type == "full") {
|
} else if (type == "full") {
|
||||||
demo(ace());
|
demo(ace());
|
||||||
bookmarklet();
|
bookmarklet();
|
||||||
|
|
@ -98,7 +96,6 @@ function main(args) {
|
||||||
console.log(" minimal Places necessary Ace files out in build dir; uses configuration flags below [default]");
|
console.log(" minimal Places necessary Ace files out in build dir; uses configuration flags below [default]");
|
||||||
console.log(" normal Runs four Ace builds--minimal, minimal-noconflict, minimal-min, and minimal-noconflict-min");
|
console.log(" normal Runs four Ace builds--minimal, minimal-noconflict, minimal-min, and minimal-noconflict-min");
|
||||||
console.log(" demo Runs demo build of Ace");
|
console.log(" demo Runs demo build of Ace");
|
||||||
console.log(" bm Runs bookmarklet build of Ace");
|
|
||||||
console.log(" full all of above");
|
console.log(" full all of above");
|
||||||
console.log(" highlighter ");
|
console.log(" highlighter ");
|
||||||
console.log("args:");
|
console.log("args:");
|
||||||
|
|
@ -113,30 +110,6 @@ function main(args) {
|
||||||
console.log(" output generated in " + type + __dirname + "/" + BUILD_DIR)
|
console.log(" output generated in " + type + __dirname + "/" + BUILD_DIR)
|
||||||
}
|
}
|
||||||
|
|
||||||
function bookmarklet() {
|
|
||||||
var targetDir = BUILD_DIR + "/textarea";
|
|
||||||
copy({
|
|
||||||
source: "build_support/editor_textarea.html",
|
|
||||||
dest: targetDir + '/editor.html'
|
|
||||||
});
|
|
||||||
copy({
|
|
||||||
source: "build_support/style.css",
|
|
||||||
dest: targetDir + '/style.css'
|
|
||||||
});
|
|
||||||
|
|
||||||
buildAce({
|
|
||||||
targetDir: targetDir + "/src",
|
|
||||||
ns: "__ace_shadowed__",
|
|
||||||
exportModule: "ace/ext/textarea",
|
|
||||||
compress: false,
|
|
||||||
noconflict: true,
|
|
||||||
suffix: "",
|
|
||||||
name: "ace-bookmarklet",
|
|
||||||
workers: [],
|
|
||||||
keybindings: []
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function ace() {
|
function ace() {
|
||||||
console.log('# ace ---------');
|
console.log('# ace ---------');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ function foo() {
|
||||||
var bar = true;
|
var bar = true;
|
||||||
}</textarea><br>
|
}</textarea><br>
|
||||||
SourceUrl: <br>
|
SourceUrl: <br>
|
||||||
<input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace-builds/textarea/src/"></input><br>
|
<input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace-builds/src-noconflict"></input><br>
|
||||||
<button id="buBuild">Build Link</button> <br> <a href="#"></a>
|
<button id="buBuild">Build Link</button> <br> <a href="#"></a>
|
||||||
<a href="https://github.com/ajaxorg/ace/">
|
<a href="https://github.com/ajaxorg/ace/">
|
||||||
<div class="fork_on_github" ></div>
|
<div class="fork_on_github" ></div>
|
||||||
|
|
@ -49,63 +49,60 @@ function foo() {
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
function inject(callback) {
|
function inject(options, callback) {
|
||||||
var baseUrl = "src/";
|
var baseUrl = options.baseUrl || "../../src-noconflict";
|
||||||
|
|
||||||
var load = window.__ace_loader__ = function(path, module, callback) {
|
var load = function(path, callback) {
|
||||||
var head = document.getElementsByTagName('head')[0];
|
var head = document.getElementsByTagName('head')[0];
|
||||||
var s = document.createElement('script');
|
var s = document.createElement('script');
|
||||||
|
|
||||||
s.src = baseUrl + path;
|
s.src = baseUrl + "/" + path;
|
||||||
head.appendChild(s);
|
head.appendChild(s);
|
||||||
|
|
||||||
s.onload = function() {
|
s.onload = s.onreadystatechange = function(_, isAbort) {
|
||||||
window.__ace_shadowed__.require([module], callback);
|
if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
|
||||||
|
s = s.onload = s.onreadystatechange = null;
|
||||||
|
if (!isAbort)
|
||||||
|
callback();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
load('ace-bookmarklet.js', "ace/ext/textarea", function() {
|
load("ace.js", function() {
|
||||||
var ace = window.__ace_shadowed__;
|
ace.config.loadModule("ace/ext/textarea", function() {
|
||||||
|
var event = ace.require("ace/lib/event");
|
||||||
ace.options.mode = "javascript";
|
var areas = document.getElementsByTagName("textarea");
|
||||||
var Event = ace.require("ace/lib/event");
|
for (var i = 0; i < areas.length; i++) {
|
||||||
var areas = document.getElementsByTagName("textarea");
|
event.addListener(areas[i], "click", function(e) {
|
||||||
for (var i = 0; i < areas.length; i++) {
|
if (e.detail == 3) {
|
||||||
Event.addListener(areas[i], "click", function(e) {
|
ace.transformTextarea(e.target, options.ace);
|
||||||
if (e.detail == 3) {
|
}
|
||||||
ace.transformTextarea(e.target, load);
|
});
|
||||||
}
|
}
|
||||||
});
|
callback && callback();
|
||||||
}
|
});
|
||||||
callback && callback();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call the inject function to load the ace files.
|
// Call the inject function to load the ace files.
|
||||||
var textAce;
|
var textAce;
|
||||||
inject(function () {
|
inject({}, function () {
|
||||||
// Transform the textarea on the page into an ace editor.
|
// Transform the textarea on the page into an ace editor.
|
||||||
var ace = window.__ace_shadowed__;
|
|
||||||
var t = document.querySelector("textarea");
|
var t = document.querySelector("textarea");
|
||||||
textAce = ace.transformTextarea(t, window.__ace_loader__);
|
textAce = ace.require("ace/ext/textarea").transformTextarea(t);
|
||||||
setTimeout(function(){textAce.setDisplaySettings(true)});
|
setTimeout(function(){textAce.setDisplaySettings(true)});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
document.getElementById("buBuild").onclick = function() {
|
document.getElementById("buBuild").onclick = function() {
|
||||||
var injectSrc = inject.toString().split("\n").join("");
|
var injectSrc = inject.toString().split("\n").join("");
|
||||||
injectSrc = injectSrc.replace('baseUrl = "src/"', 'baseUrl="' + document.getElementById("srcURL").value + '"');
|
|
||||||
|
|
||||||
var aceOptions = textAce.getOptions();
|
|
||||||
var opt = [];
|
|
||||||
for (var option in aceOptions) {
|
|
||||||
opt.push(option + ":'" + aceOptions[option] + "'");
|
|
||||||
}
|
|
||||||
injectSrc = injectSrc.replace('ace.options.mode = "javascript"', 'ace.options = { ' + opt.join(",") + ' }');
|
|
||||||
injectSrc = injectSrc.replace(/\s+/g, " ");
|
injectSrc = injectSrc.replace(/\s+/g, " ");
|
||||||
|
|
||||||
|
var options = textAce.getOptions();
|
||||||
|
options.baseUrl = document.getElementById("srcURL").value;
|
||||||
|
|
||||||
var a = document.querySelector("a");
|
var a = document.querySelector("a");
|
||||||
a.href = "javascript:(" + injectSrc + ")()";
|
a.href = "javascript:(" + injectSrc + ")(" + JSON.stringify(options) + ")";
|
||||||
a.innerHTML = "Ace Bookmarklet Link";
|
a.innerHTML = "Ace Bookmarklet Link";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,7 +155,7 @@ function setupContainer(element, getValue) {
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.transformTextarea = function(element, loader) {
|
exports.transformTextarea = function(element, options) {
|
||||||
var session;
|
var session;
|
||||||
var container = setupContainer(element, function() {
|
var container = setupContainer(element, function() {
|
||||||
return session.getValue();
|
return session.getValue();
|
||||||
|
|
@ -215,9 +215,8 @@ exports.transformTextarea = function(element, loader) {
|
||||||
applyStyles(settingDiv, settingDivStyles);
|
applyStyles(settingDiv, settingDivStyles);
|
||||||
container.appendChild(settingDiv);
|
container.appendChild(settingDiv);
|
||||||
|
|
||||||
|
options = options || exports.defaultOptions;
|
||||||
// Power up ace on the textarea:
|
// Power up ace on the textarea:
|
||||||
var options = {};
|
|
||||||
|
|
||||||
var editor = ace.edit(editorDiv);
|
var editor = ace.edit(editorDiv);
|
||||||
session = editor.getSession();
|
session = editor.getSession();
|
||||||
|
|
||||||
|
|
@ -228,10 +227,10 @@ exports.transformTextarea = function(element, loader) {
|
||||||
container.appendChild(settingOpener);
|
container.appendChild(settingOpener);
|
||||||
|
|
||||||
// Create the API.
|
// Create the API.
|
||||||
setupApi(editor, editorDiv, settingDiv, ace, options, loader);
|
setupApi(editor, editorDiv, settingDiv, ace, options, load);
|
||||||
|
|
||||||
// Create the setting's panel.
|
// Create the setting's panel.
|
||||||
setupSettingPanel(settingDiv, settingOpener, editor, options);
|
setupSettingPanel(settingDiv, settingOpener, editor);
|
||||||
|
|
||||||
var state = "";
|
var state = "";
|
||||||
event.addListener(settingOpener, "mousemove", function(e) {
|
event.addListener(settingOpener, "mousemove", function(e) {
|
||||||
|
|
@ -296,37 +295,15 @@ function setupApi(editor, editorDiv, settingDiv, ace, options, loader) {
|
||||||
};
|
};
|
||||||
|
|
||||||
editor.$setOption = editor.setOption;
|
editor.$setOption = editor.setOption;
|
||||||
|
editor.$getOption = editor.getOption;
|
||||||
editor.setOption = function(key, value) {
|
editor.setOption = function(key, value) {
|
||||||
if (options[key] == value) return;
|
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "mode":
|
case "mode":
|
||||||
if (value != "text") {
|
editor.$setOption("mode", "ace/mode/" + value)
|
||||||
// Load the required mode file. Files get loaded only once.
|
|
||||||
loader("mode-" + value + ".js", "ace/mode/" + value, function() {
|
|
||||||
var aceMode = require("../mode/" + value).Mode;
|
|
||||||
session.setMode(new aceMode());
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
session.setMode(new (require("../mode/text").Mode));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "theme":
|
case "theme":
|
||||||
if (value != "textmate") {
|
editor.$setOption("theme", "ace/theme/" + value)
|
||||||
// Load the required theme file. Files get loaded only once.
|
|
||||||
loader("theme-" + value + ".js", "ace/theme/" + value, function() {
|
|
||||||
editor.setTheme("ace/theme/" + value);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
editor.setTheme("ace/theme/textmate");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "fontSize":
|
|
||||||
editorDiv.style.fontSize = value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "keybindings":
|
case "keybindings":
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case "vim":
|
case "vim":
|
||||||
|
|
@ -341,58 +318,55 @@ function setupApi(editor, editorDiv, settingDiv, ace, options, loader) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "softWrap":
|
case "softWrap":
|
||||||
switch (value) {
|
case "fontSize":
|
||||||
case "off":
|
editor.$setOption(key, value);
|
||||||
session.setUseWrapMode(false);
|
|
||||||
renderer.setPrintMarginColumn(80);
|
|
||||||
break;
|
|
||||||
case "40":
|
|
||||||
session.setUseWrapMode(true);
|
|
||||||
session.setWrapLimitRange(40, 40);
|
|
||||||
renderer.setPrintMarginColumn(40);
|
|
||||||
break;
|
|
||||||
case "80":
|
|
||||||
session.setUseWrapMode(true);
|
|
||||||
session.setWrapLimitRange(80, 80);
|
|
||||||
renderer.setPrintMarginColumn(80);
|
|
||||||
break;
|
|
||||||
case "free":
|
|
||||||
session.setUseWrapMode(true);
|
|
||||||
session.setWrapLimitRange(null, null);
|
|
||||||
renderer.setPrintMarginColumn(80);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
editor.$setOption(key, toBool(value));
|
editor.$setOption(key, toBool(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
options[key] = value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
editor.getOption = function(key) {
|
editor.getOption = function(key) {
|
||||||
return options[key];
|
switch (key) {
|
||||||
|
case "mode":
|
||||||
|
return editor.$getOption("mode").substr("ace/mode/".length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "theme":
|
||||||
|
return editor.$getOption("theme").substr("ace/theme/".length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "keybindings":
|
||||||
|
var value = editor.getKeyboardHandler()
|
||||||
|
switch (value && value.$id) {
|
||||||
|
case "ace/keyboard/vim":
|
||||||
|
return "vim";
|
||||||
|
case "ace/keyboard/emacs":
|
||||||
|
return "emacs";
|
||||||
|
default:
|
||||||
|
return "ace";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return editor.$getOption(key);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
editor.getOptions = function() {
|
editor.setOptions(options);
|
||||||
return options;
|
|
||||||
};
|
|
||||||
|
|
||||||
editor.setOptions(exports.options);
|
|
||||||
|
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupSettingPanel(settingDiv, settingOpener, editor, options) {
|
function setupSettingPanel(settingDiv, settingOpener, editor) {
|
||||||
var BOOL = null;
|
var BOOL = null;
|
||||||
|
|
||||||
var desc = {
|
var desc = {
|
||||||
mode: "Mode:",
|
mode: "Mode:",
|
||||||
gutter: "Display Gutter:",
|
wrap: "Soft Wrap:",
|
||||||
theme: "Theme:",
|
theme: "Theme:",
|
||||||
fontSize: "Font Size:",
|
fontSize: "Font Size:",
|
||||||
softWrap: "Soft Wrap:",
|
showGutter: "Display Gutter:",
|
||||||
keybindings: "Keyboard",
|
keybindings: "Keyboard",
|
||||||
showPrintMargin: "Show Print Margin:",
|
showPrintMargin: "Show Print Margin:",
|
||||||
useSoftTabs: "Use Soft Tabs:",
|
useSoftTabs: "Use Soft Tabs:",
|
||||||
|
|
@ -445,7 +419,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
|
||||||
twilight: "Twilight",
|
twilight: "Twilight",
|
||||||
vibrant_ink: "Vibrant Ink"
|
vibrant_ink: "Vibrant Ink"
|
||||||
},
|
},
|
||||||
gutter: BOOL,
|
showGutter: BOOL,
|
||||||
fontSize: {
|
fontSize: {
|
||||||
"10px": "10px",
|
"10px": "10px",
|
||||||
"11px": "11px",
|
"11px": "11px",
|
||||||
|
|
@ -453,7 +427,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
|
||||||
"14px": "14px",
|
"14px": "14px",
|
||||||
"16px": "16px"
|
"16px": "16px"
|
||||||
},
|
},
|
||||||
softWrap: {
|
wrap: {
|
||||||
off: "Off",
|
off: "Off",
|
||||||
40: "40",
|
40: "40",
|
||||||
80: "80",
|
80: "80",
|
||||||
|
|
@ -476,7 +450,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
builder.push(
|
builder.push(
|
||||||
"<input type='checkbox' title='", option, "' ",
|
"<input type='checkbox' title='", option, "' ",
|
||||||
cValue == "true" ? "checked='true'" : "",
|
cValue + "" == "true" ? "checked='true'" : "",
|
||||||
"'></input>"
|
"'></input>"
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|
@ -496,10 +470,10 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
|
||||||
builder.push("</select>");
|
builder.push("</select>");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var option in options) {
|
for (var option in exports.defaultOptions) {
|
||||||
table.push("<tr><td>", desc[option], "</td>");
|
table.push("<tr><td>", desc[option], "</td>");
|
||||||
table.push("<td>");
|
table.push("<td>");
|
||||||
renderOption(table, option, optionValues[option], options[option]);
|
renderOption(table, option, optionValues[option], editor.getOption(option));
|
||||||
table.push("</td></tr>");
|
table.push("</td></tr>");
|
||||||
}
|
}
|
||||||
table.push("</table>");
|
table.push("</table>");
|
||||||
|
|
@ -532,12 +506,12 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default startup options.
|
// Default startup options.
|
||||||
exports.options = {
|
exports.defaultOptions = {
|
||||||
mode: "text",
|
mode: "javascript",
|
||||||
theme: "textmate",
|
theme: "textmate",
|
||||||
gutter: "false",
|
wrap: "off",
|
||||||
fontSize: "12px",
|
fontSize: "12px",
|
||||||
softWrap: "off",
|
showGutter: "false",
|
||||||
keybindings: "ace",
|
keybindings: "ace",
|
||||||
showPrintMargin: "false",
|
showPrintMargin: "false",
|
||||||
useSoftTabs: "true",
|
useSoftTabs: "true",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue