| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /*\ | ||
| title: $:/core/modules/editor/operations/text/replace-all.js | ||
| type: application/javascript | ||
| module-type: texteditoroperation | ||
| Text editor operation to replace the entire text | ||
| \*/ | ||
| (function(){ | ||
|
|
||
| /*jslint node: true, browser: true */ | ||
| /*global $tw: false */ | ||
| "use strict"; | ||
|
|
||
| exports["replace-all"] = function(event,operation) { | ||
| operation.cutStart = 0; | ||
| operation.cutEnd = operation.text.length; | ||
| operation.replacement = event.paramObject.text; | ||
| operation.newSelStart = 0; | ||
| operation.newSelEnd = operation.replacement.length; | ||
| }; | ||
|
|
||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /*\ | ||
| title: $:/core/modules/editor/operations/text/replace-selection.js | ||
| type: application/javascript | ||
| module-type: texteditoroperation | ||
| Text editor operation to replace the selection | ||
| \*/ | ||
| (function(){ | ||
|
|
||
| /*jslint node: true, browser: true */ | ||
| /*global $tw: false */ | ||
| "use strict"; | ||
|
|
||
| exports["replace-selection"] = function(event,operation) { | ||
| operation.replacement = event.paramObject.text; | ||
| operation.cutStart = operation.selStart; | ||
| operation.cutEnd = operation.selEnd; | ||
| operation.newSelStart = operation.selStart; | ||
| operation.newSelEnd = operation.selStart + operation.replacement.length; | ||
| }; | ||
|
|
||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /*\ | ||
| title: $:/core/modules/editor/operations/text/wrap-lines.js | ||
| type: application/javascript | ||
| module-type: texteditoroperation | ||
| Text editor operation to wrap the selected lines with a prefix and suffix | ||
| \*/ | ||
| (function(){ | ||
|
|
||
| /*jslint node: true, browser: true */ | ||
| /*global $tw: false */ | ||
| "use strict"; | ||
|
|
||
| exports["wrap-lines"] = function(event,operation) { | ||
| // Cut just past the preceding line break, or the start of the text | ||
| operation.cutStart = $tw.utils.findPrecedingLineBreak(operation.text,operation.selStart); | ||
| // Cut to just past the following line break, or to the end of the text | ||
| operation.cutEnd = $tw.utils.findFollowingLineBreak(operation.text,operation.selEnd); | ||
| // Add the prefix and suffix | ||
| operation.replacement = event.paramObject.prefix + "\n" + | ||
| operation.text.substring(operation.cutStart,operation.cutEnd) + "\n" + | ||
| event.paramObject.suffix + "\n"; | ||
| operation.newSelStart = operation.cutStart + event.paramObject.prefix.length + 1; | ||
| operation.newSelEnd = operation.newSelStart + (operation.cutEnd - operation.cutStart); | ||
| }; | ||
|
|
||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /*\ | ||
| title: $:/core/modules/editor/operations/text/wrap-selection.js | ||
| type: application/javascript | ||
| module-type: texteditoroperation | ||
| Text editor operation to wrap the selection with the specified prefix and suffix | ||
| \*/ | ||
| (function(){ | ||
|
|
||
| /*jslint node: true, browser: true */ | ||
| /*global $tw: false */ | ||
| "use strict"; | ||
|
|
||
| exports["wrap-selection"] = function(event,operation) { | ||
| if(operation.selStart === operation.selEnd) { | ||
| // No selection; check if we're within the prefix/suffix | ||
| if(operation.text.substring(operation.selStart - event.paramObject.prefix.length,operation.selStart + event.paramObject.suffix.length) === event.paramObject.prefix + event.paramObject.suffix) { | ||
| // Remove the prefix and suffix unless they comprise the entire text | ||
| if(operation.selStart > event.paramObject.prefix.length || (operation.selEnd + event.paramObject.suffix.length) < operation.text.length ) { | ||
| operation.cutStart = operation.selStart - event.paramObject.prefix.length; | ||
| operation.cutEnd = operation.selEnd + event.paramObject.suffix.length; | ||
| operation.replacement = ""; | ||
| operation.newSelStart = operation.cutStart; | ||
| operation.newSelEnd = operation.newSelStart; | ||
| } | ||
| } else { | ||
| // Wrap the cursor instead | ||
| operation.cutStart = operation.selStart; | ||
| operation.cutEnd = operation.selEnd; | ||
| operation.replacement = event.paramObject.prefix + event.paramObject.suffix; | ||
| operation.newSelStart = operation.selStart + event.paramObject.prefix.length; | ||
| operation.newSelEnd = operation.newSelStart; | ||
| } | ||
| } else if(operation.text.substring(operation.selStart,operation.selStart + event.paramObject.prefix.length) === event.paramObject.prefix && operation.text.substring(operation.selEnd - event.paramObject.suffix.length,operation.selEnd) === event.paramObject.suffix) { | ||
| // Prefix and suffix are already present, so remove them | ||
| operation.cutStart = operation.selStart; | ||
| operation.cutEnd = operation.selEnd; | ||
| operation.replacement = operation.selection.substring(event.paramObject.prefix.length,operation.selection.length - event.paramObject.suffix.length); | ||
| operation.newSelStart = operation.selStart; | ||
| operation.newSelEnd = operation.selStart + operation.replacement.length; | ||
| } else { | ||
| // Add the prefix and suffix | ||
| operation.cutStart = operation.selStart; | ||
| operation.cutEnd = operation.selEnd; | ||
| operation.replacement = event.paramObject.prefix + operation.selection + event.paramObject.suffix; | ||
| operation.newSelStart = operation.selStart; | ||
| operation.newSelEnd = operation.selStart + operation.replacement.length; | ||
| } | ||
| }; | ||
|
|
||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,279 @@ | ||
| /*\ | ||
| title: $:/core/modules/keyboard.js | ||
| type: application/javascript | ||
| module-type: global | ||
| Keyboard handling utilities | ||
| \*/ | ||
| (function(){ | ||
|
|
||
| /*jslint node: true, browser: true */ | ||
| /*global $tw: false */ | ||
| "use strict"; | ||
|
|
||
| var namedKeys = { | ||
| "cancel": 3, | ||
| "help": 6, | ||
| "backspace": 8, | ||
| "tab": 9, | ||
| "clear": 12, | ||
| "return": 13, | ||
| "enter": 13, | ||
| "pause": 19, | ||
| "escape": 27, | ||
| "space": 32, | ||
| "page_up": 33, | ||
| "page_down": 34, | ||
| "end": 35, | ||
| "home": 36, | ||
| "left": 37, | ||
| "up": 38, | ||
| "right": 39, | ||
| "down": 40, | ||
| "printscreen": 44, | ||
| "insert": 45, | ||
| "delete": 46, | ||
| "0": 48, | ||
| "1": 49, | ||
| "2": 50, | ||
| "3": 51, | ||
| "4": 52, | ||
| "5": 53, | ||
| "6": 54, | ||
| "7": 55, | ||
| "8": 56, | ||
| "9": 57, | ||
| "firefoxsemicolon": 59, | ||
| "firefoxequals": 61, | ||
| "a": 65, | ||
| "b": 66, | ||
| "c": 67, | ||
| "d": 68, | ||
| "e": 69, | ||
| "f": 70, | ||
| "g": 71, | ||
| "h": 72, | ||
| "i": 73, | ||
| "j": 74, | ||
| "k": 75, | ||
| "l": 76, | ||
| "m": 77, | ||
| "n": 78, | ||
| "o": 79, | ||
| "p": 80, | ||
| "q": 81, | ||
| "r": 82, | ||
| "s": 83, | ||
| "t": 84, | ||
| "u": 85, | ||
| "v": 86, | ||
| "w": 87, | ||
| "x": 88, | ||
| "y": 89, | ||
| "z": 90, | ||
| "numpad0": 96, | ||
| "numpad1": 97, | ||
| "numpad2": 98, | ||
| "numpad3": 99, | ||
| "numpad4": 100, | ||
| "numpad5": 101, | ||
| "numpad6": 102, | ||
| "numpad7": 103, | ||
| "numpad8": 104, | ||
| "numpad9": 105, | ||
| "multiply": 106, | ||
| "add": 107, | ||
| "separator": 108, | ||
| "subtract": 109, | ||
| "decimal": 110, | ||
| "divide": 111, | ||
| "f1": 112, | ||
| "f2": 113, | ||
| "f3": 114, | ||
| "f4": 115, | ||
| "f5": 116, | ||
| "f6": 117, | ||
| "f7": 118, | ||
| "f8": 119, | ||
| "f9": 120, | ||
| "f10": 121, | ||
| "f11": 122, | ||
| "f12": 123, | ||
| "f13": 124, | ||
| "f14": 125, | ||
| "f15": 126, | ||
| "f16": 127, | ||
| "f17": 128, | ||
| "f18": 129, | ||
| "f19": 130, | ||
| "f20": 131, | ||
| "f21": 132, | ||
| "f22": 133, | ||
| "f23": 134, | ||
| "f24": 135, | ||
| "firefoxminus": 173, | ||
| "semicolon": 186, | ||
| "equals": 187, | ||
| "comma": 188, | ||
| "dash": 189, | ||
| "period": 190, | ||
| "slash": 191, | ||
| "backquote": 192, | ||
| "openbracket": 219, | ||
| "backslash": 220, | ||
| "closebracket": 221, | ||
| "quote": 222 | ||
| }; | ||
|
|
||
| function KeyboardManager(options) { | ||
| var self = this; | ||
| options = options || ""; | ||
| // Save the named key hashmap | ||
| this.namedKeys = namedKeys; | ||
| // Create a reverse mapping of code to keyname | ||
| this.keyNames = []; | ||
| $tw.utils.each(namedKeys,function(keyCode,name) { | ||
| self.keyNames[keyCode] = name.substr(0,1).toUpperCase() + name.substr(1); | ||
| }); | ||
| // Save the platform-specific name of the "meta" key | ||
| this.metaKeyName = $tw.platform.isMac ? "cmd-" : "win-"; | ||
| } | ||
|
|
||
| /* | ||
| Return an array of keycodes for the modifier keys ctrl, shift, alt, meta | ||
| */ | ||
| KeyboardManager.prototype.getModifierKeys = function() { | ||
| return [ | ||
| 16, // Shift | ||
| 17, // Ctrl | ||
| 18, // Alt | ||
| 20, // CAPS LOCK | ||
| 91, // Meta (left) | ||
| 93, // Meta (right) | ||
| 224 // Meta (Firefox) | ||
| ] | ||
| }; | ||
|
|
||
| /* | ||
| Parses a key descriptor into the structure: | ||
| { | ||
| keyCode: numeric keycode | ||
| shiftKey: boolean | ||
| altKey: boolean | ||
| ctrlKey: boolean | ||
| metaKey: boolean | ||
| } | ||
| Key descriptors have the following format: | ||
| ctrl+enter | ||
| ctrl+shift+alt+A | ||
| */ | ||
| KeyboardManager.prototype.parseKeyDescriptor = function(keyDescriptor) { | ||
| var components = keyDescriptor.split(/\+|\-/), | ||
| info = { | ||
| keyCode: 0, | ||
| shiftKey: false, | ||
| altKey: false, | ||
| ctrlKey: false, | ||
| metaKey: false | ||
| }; | ||
| for(var t=0; t<components.length; t++) { | ||
| var s = components[t].toLowerCase(), | ||
| c = s.charCodeAt(0); | ||
| // Look for modifier keys | ||
| if(s === "ctrl") { | ||
| info.ctrlKey = true; | ||
| } else if(s === "shift") { | ||
| info.shiftKey = true; | ||
| } else if(s === "alt") { | ||
| info.altKey = true; | ||
| } else if(s === "meta" || s === "cmd" || s === "win") { | ||
| info.metaKey = true; | ||
| } | ||
| // Replace named keys with their code | ||
| if(this.namedKeys[s]) { | ||
| info.keyCode = this.namedKeys[s]; | ||
| } | ||
| } | ||
| if(info.keyCode) { | ||
| return info; | ||
| } else { | ||
| return null; | ||
| } | ||
| }; | ||
|
|
||
| /* | ||
| Parse a list of key descriptors into an array of keyInfo objects. The key descriptors can be passed as an array of strings or a space separated string | ||
| */ | ||
| KeyboardManager.prototype.parseKeyDescriptors = function(keyDescriptors,options) { | ||
| var self = this; | ||
| options = options || {}; | ||
| options.stack = options.stack || []; | ||
| var wiki = options.wiki || $tw.wiki; | ||
| if(typeof keyDescriptors === "string" && keyDescriptors === "") { | ||
| return []; | ||
| } | ||
| if(!$tw.utils.isArray(keyDescriptors)) { | ||
| keyDescriptors = keyDescriptors.split(" "); | ||
| } | ||
| var result = []; | ||
| $tw.utils.each(keyDescriptors,function(keyDescriptor) { | ||
| // Look for a named shortcut | ||
| if(keyDescriptor.substr(0,2) === "((" && keyDescriptor.substr(-2,2) === "))") { | ||
| if(options.stack.indexOf(keyDescriptor) === -1) { | ||
| options.stack.push(keyDescriptor); | ||
| var name = keyDescriptor.substring(2,keyDescriptor.length - 2), | ||
| lookupName = function(configName) { | ||
| var keyDescriptors = wiki.getTiddlerText("$:/config/" + configName + "/" + name); | ||
| if(keyDescriptors) { | ||
| result.push.apply(result,self.parseKeyDescriptors(keyDescriptors,options)); | ||
| } | ||
| }; | ||
| lookupName("shortcuts"); | ||
| lookupName($tw.platform.isMac ? "shortcuts-mac" : "shortcuts-not-mac"); | ||
| lookupName($tw.platform.isWindows ? "shortcuts-windows" : "shortcuts-not-windows"); | ||
| lookupName($tw.platform.isLinux ? "shortcuts-linux" : "shortcuts-not-linux"); | ||
| } | ||
| } else { | ||
| result.push(self.parseKeyDescriptor(keyDescriptor)); | ||
| } | ||
| }); | ||
| return result; | ||
| }; | ||
|
|
||
| KeyboardManager.prototype.getPrintableShortcuts = function(keyInfoArray) { | ||
| var self = this, | ||
| result = []; | ||
| $tw.utils.each(keyInfoArray,function(keyInfo) { | ||
| if(keyInfo) { | ||
| result.push((keyInfo.ctrlKey ? "ctrl-" : "") + | ||
| (keyInfo.shiftKey ? "shift-" : "") + | ||
| (keyInfo.altKey ? "alt-" : "") + | ||
| (keyInfo.metaKey ? self.metaKeyName : "") + | ||
| (self.keyNames[keyInfo.keyCode])); | ||
| } | ||
| }); | ||
| return result; | ||
| } | ||
|
|
||
| KeyboardManager.prototype.checkKeyDescriptor = function(event,keyInfo) { | ||
| return keyInfo && | ||
| event.keyCode === keyInfo.keyCode && | ||
| event.shiftKey === keyInfo.shiftKey && | ||
| event.altKey === keyInfo.altKey && | ||
| event.ctrlKey === keyInfo.ctrlKey && | ||
| event.metaKey === keyInfo.metaKey; | ||
| }; | ||
|
|
||
| KeyboardManager.prototype.checkKeyDescriptors = function(event,keyInfoArray) { | ||
| for(var t=0; t<keyInfoArray.length; t++) { | ||
| if(this.checkKeyDescriptor(event,keyInfoArray[t])) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| }; | ||
|
|
||
| exports.KeyboardManager = KeyboardManager; | ||
|
|
||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /*\ | ||
| title: $:/core/modules/macros/displayshortcuts.js | ||
| type: application/javascript | ||
| module-type: macro | ||
| Macro to display a list of keyboard shortcuts in human readable form. Notably, it resolves named shortcuts like `((bold))` to the underlying keystrokes. | ||
| \*/ | ||
| (function(){ | ||
|
|
||
| /*jslint node: true, browser: true */ | ||
| /*global $tw: false */ | ||
| "use strict"; | ||
|
|
||
| /* | ||
| Information about this macro | ||
| */ | ||
|
|
||
| exports.name = "displayshortcuts"; | ||
|
|
||
| exports.params = [ | ||
| {name: "shortcuts"}, | ||
| {name: "prefix"}, | ||
| {name: "separator"}, | ||
| {name: "suffix"} | ||
| ]; | ||
|
|
||
| /* | ||
| Run the macro | ||
| */ | ||
| exports.run = function(shortcuts,prefix,separator,suffix) { | ||
| var shortcutArray = $tw.keyboardManager.getPrintableShortcuts($tw.keyboardManager.parseKeyDescriptors(shortcuts,{ | ||
| wiki: this.wiki | ||
| })); | ||
| if(shortcutArray.length > 0) { | ||
| shortcutArray.sort(function(a,b) { | ||
| return a.toLowerCase().localeCompare(b.toLowerCase()); | ||
| }) | ||
| return prefix + shortcutArray.join(separator) + suffix; | ||
| } else { | ||
| return ""; | ||
| } | ||
| }; | ||
|
|
||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /*\ | ||
| title: $:/core/modules/savers/put.js | ||
| type: application/javascript | ||
| module-type: saver | ||
| Saves wiki by performing a PUT request to the server | ||
| Works with any server which accepts a PUT request | ||
| to the current URL, such as a WebDAV server. | ||
| \*/ | ||
| (function(){ | ||
|
|
||
| /*jslint node: true, browser: true */ | ||
| /*global $tw: false */ | ||
| "use strict"; | ||
|
|
||
| /* | ||
| Select the appropriate saver module and set it up | ||
| */ | ||
| var PutSaver = function(wiki) { | ||
| this.wiki = wiki; | ||
| var self = this; | ||
| // Async server probe. Until probe finishes, save will fail fast | ||
| // See also https://github.com/Jermolene/TiddlyWiki5/issues/2276 | ||
| var req = new XMLHttpRequest(); | ||
| req.open("OPTIONS",encodeURI(document.location.protocol + "//" + document.location.hostname + ":" + document.location.port + document.location.pathname)); | ||
| req.onload = function() { | ||
| // Check DAV header http://www.webdav.org/specs/rfc2518.html#rfc.section.9.1 | ||
| self.serverAcceptsPuts = (this.status === 200 && !!this.getResponseHeader('dav')); | ||
| }; | ||
| req.send(); | ||
| }; | ||
|
|
||
| PutSaver.prototype.save = function(text,method,callback) { | ||
| if (!this.serverAcceptsPuts) { | ||
| return false; | ||
| } | ||
| var req = new XMLHttpRequest(); | ||
| // TODO: store/check ETags if supported by server, to protect against overwrites | ||
| // Prompt: Do you want to save over this? Y/N | ||
| // Merging would be ideal, and may be possible using future generic merge flow | ||
| req.onload = function() { | ||
| if (this.status === 200 || this.status === 201) { | ||
| callback(null); // success | ||
| } | ||
| else { | ||
| callback(this.responseText); // fail | ||
| } | ||
| }; | ||
| req.open("PUT", encodeURI(window.location.href)); | ||
| req.setRequestHeader("Content-Type", "text/html;charset=UTF-8"); | ||
| req.send(text); | ||
| return true; | ||
| }; | ||
|
|
||
| /* | ||
| Information about this saver | ||
| */ | ||
| PutSaver.prototype.info = { | ||
| name: "put", | ||
| priority: 2000, | ||
| capabilities: ["save", "autosave"] | ||
| }; | ||
|
|
||
| /* | ||
| Static method that returns true if this saver is capable of working | ||
| */ | ||
| exports.canSave = function(wiki) { | ||
| return /^https?:/.test(location.protocol); | ||
| }; | ||
|
|
||
| /* | ||
| Create an instance of this saver | ||
| */ | ||
| exports.create = function(wiki) { | ||
| return new PutSaver(wiki); | ||
| }; | ||
|
|
||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| /*\ | ||
| title: $:/core/modules/widgets/edit-shortcut.js | ||
| type: application/javascript | ||
| module-type: widget | ||
| Widget to display an editable keyboard shortcut | ||
| \*/ | ||
| (function(){ | ||
|
|
||
| /*jslint node: true, browser: true */ | ||
| /*global $tw: false */ | ||
| "use strict"; | ||
|
|
||
| var Widget = require("$:/core/modules/widgets/widget.js").widget; | ||
|
|
||
| var EditShortcutWidget = function(parseTreeNode,options) { | ||
| this.initialise(parseTreeNode,options); | ||
| }; | ||
|
|
||
| /* | ||
| Inherit from the base widget class | ||
| */ | ||
| EditShortcutWidget.prototype = new Widget(); | ||
|
|
||
| /* | ||
| Render this widget into the DOM | ||
| */ | ||
| EditShortcutWidget.prototype.render = function(parent,nextSibling) { | ||
| this.parentDomNode = parent; | ||
| this.computeAttributes(); | ||
| this.execute(); | ||
| this.inputNode = this.document.createElement("input"); | ||
| // Assign classes | ||
| if(this.shortcutClass) { | ||
| this.inputNode.className = this.shortcutClass; | ||
| } | ||
| // Assign other attributes | ||
| if(this.shortcutStyle) { | ||
| this.inputNode.setAttribute("style",this.shortcutStyle); | ||
| } | ||
| if(this.shortcutTooltip) { | ||
| this.inputNode.setAttribute("title",this.shortcutTooltip); | ||
| } | ||
| if(this.shortcutPlaceholder) { | ||
| this.inputNode.setAttribute("placeholder",this.shortcutPlaceholder); | ||
| } | ||
| if(this.shortcutAriaLabel) { | ||
| this.inputNode.setAttribute("aria-label",this.shortcutAriaLabel); | ||
| } | ||
| // Assign the current shortcut | ||
| this.updateInputNode(); | ||
| // Add event handlers | ||
| $tw.utils.addEventListeners(this.inputNode,[ | ||
| {name: "keydown", handlerObject: this, handlerMethod: "handleKeydownEvent"} | ||
| ]); | ||
| // Link into the DOM | ||
| parent.insertBefore(this.inputNode,nextSibling); | ||
| this.domNodes.push(this.inputNode); | ||
| }; | ||
|
|
||
| /* | ||
| Compute the internal state of the widget | ||
| */ | ||
| EditShortcutWidget.prototype.execute = function() { | ||
| this.shortcutTiddler = this.getAttribute("tiddler"); | ||
| this.shortcutField = this.getAttribute("field"); | ||
| this.shortcutIndex = this.getAttribute("index"); | ||
| this.shortcutPlaceholder = this.getAttribute("placeholder"); | ||
| this.shortcutDefault = this.getAttribute("default",""); | ||
| this.shortcutClass = this.getAttribute("class"); | ||
| this.shortcutStyle = this.getAttribute("style"); | ||
| this.shortcutTooltip = this.getAttribute("tooltip"); | ||
| this.shortcutAriaLabel = this.getAttribute("aria-label"); | ||
| }; | ||
|
|
||
| /* | ||
| Update the value of the input node | ||
| */ | ||
| EditShortcutWidget.prototype.updateInputNode = function() { | ||
| if(this.shortcutField) { | ||
| var tiddler = this.wiki.getTiddler(this.shortcutTiddler); | ||
| if(tiddler && $tw.utils.hop(tiddler.fields,this.shortcutField)) { | ||
| this.inputNode.value = tiddler.getFieldString(this.shortcutField); | ||
| } else { | ||
| this.inputNode.value = this.shortcutDefault; | ||
| } | ||
| } else if(this.shortcutIndex) { | ||
| this.inputNode.value = this.wiki.extractTiddlerDataItem(this.shortcutTiddler,this.shortcutIndex,this.shortcutDefault); | ||
| } else { | ||
| this.inputNode.value = this.wiki.getTiddlerText(this.shortcutTiddler,this.shortcutDefault); | ||
| } | ||
| }; | ||
|
|
||
| /* | ||
| Handle a dom "keydown" event | ||
| */ | ||
| EditShortcutWidget.prototype.handleKeydownEvent = function(event) { | ||
| // Ignore shift, ctrl, meta, alt | ||
| if(event.keyCode && $tw.keyboardManager.getModifierKeys().indexOf(event.keyCode) === -1) { | ||
| // Get the shortcut text representation | ||
| var value = $tw.keyboardManager.getPrintableShortcuts([{ | ||
| ctrlKey: event.ctrlKey, | ||
| shiftKey: event.shiftKey, | ||
| altKey: event.altKey, | ||
| metaKey: event.metaKey, | ||
| keyCode: event.keyCode | ||
| }]); | ||
| if(value.length > 0) { | ||
| this.wiki.setText(this.shortcutTiddler,this.shortcutField,this.shortcutIndex,value[0]); | ||
| } | ||
| // Ignore the keydown if it was already handled | ||
| event.preventDefault(); | ||
| event.stopPropagation(); | ||
| return true; | ||
| } else { | ||
| return false; | ||
| } | ||
| }; | ||
|
|
||
| /* | ||
| Selectively refreshes the widget if needed. Returns true if the widget needed re-rendering | ||
| */ | ||
| EditShortcutWidget.prototype.refresh = function(changedTiddlers) { | ||
| var changedAttributes = this.computeAttributes(); | ||
| if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.placeholder || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.style || changedAttributes.tooltip || changedAttributes["aria-label"]) { | ||
| this.refreshSelf(); | ||
| return true; | ||
| } else if(changedTiddlers[this.shortcutTiddler]) { | ||
| this.updateInputNode(); | ||
| return true; | ||
| } else { | ||
| return false; | ||
| } | ||
| }; | ||
|
|
||
| exports["edit-shortcut"] = EditShortcutWidget; | ||
|
|
||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| /*\ | ||
| title: $:/core/modules/widgets/wikify.js | ||
| type: application/javascript | ||
| module-type: widget | ||
| Widget to wikify text into a variable | ||
| \*/ | ||
| (function(){ | ||
|
|
||
| /*jslint node: true, browser: true */ | ||
| /*global $tw: false */ | ||
| "use strict"; | ||
|
|
||
| var Widget = require("$:/core/modules/widgets/widget.js").widget; | ||
|
|
||
| var WikifyWidget = function(parseTreeNode,options) { | ||
| this.initialise(parseTreeNode,options); | ||
| }; | ||
|
|
||
| /* | ||
| Inherit from the base widget class | ||
| */ | ||
| WikifyWidget.prototype = new Widget(); | ||
|
|
||
| /* | ||
| Render this widget into the DOM | ||
| */ | ||
| WikifyWidget.prototype.render = function(parent,nextSibling) { | ||
| this.parentDomNode = parent; | ||
| this.computeAttributes(); | ||
| this.execute(); | ||
| this.renderChildren(parent,nextSibling); | ||
| }; | ||
|
|
||
| /* | ||
| Compute the internal state of the widget | ||
| */ | ||
| WikifyWidget.prototype.execute = function() { | ||
| // Get our parameters | ||
| this.wikifyName = this.getAttribute("name"); | ||
| this.wikifyText = this.getAttribute("text"); | ||
| this.wikifyType = this.getAttribute("type"); | ||
| this.wikifyMode = this.getAttribute("mode","block"); | ||
| this.wikifyOutput = this.getAttribute("output","text"); | ||
| // Create the parse tree | ||
| this.wikifyParser = this.wiki.parseText(this.wikifyType,this.wikifyText,{ | ||
| parseAsInline: this.wikifyMode === "inline" | ||
| }); | ||
| // Create the widget tree | ||
| this.wikifyWidgetNode = this.wiki.makeWidget(this.wikifyParser,{ | ||
| document: $tw.fakeDocument, | ||
| parentWidget: this | ||
| }); | ||
| // Render the widget tree to the container | ||
| this.wikifyContainer = $tw.fakeDocument.createElement("div"); | ||
| this.wikifyWidgetNode.render(this.wikifyContainer,null); | ||
| this.wikifyResult = this.getResult(); | ||
| // Set context variable | ||
| this.setVariable(this.wikifyName,this.wikifyResult); | ||
| // Construct the child widgets | ||
| this.makeChildWidgets(); | ||
| }; | ||
|
|
||
| /* | ||
| Return the result string | ||
| */ | ||
| WikifyWidget.prototype.getResult = function() { | ||
| var result; | ||
| switch(this.wikifyOutput) { | ||
| case "text": | ||
| result = this.wikifyContainer.textContent; | ||
| break; | ||
| case "html": | ||
| result = this.wikifyContainer.innerHTML; | ||
| break; | ||
| case "parsetree": | ||
| result = JSON.stringify(this.wikifyParser.tree,0,$tw.config.preferences.jsonSpaces); | ||
| break; | ||
| case "widgettree": | ||
| result = JSON.stringify(this.getWidgetTree(),0,$tw.config.preferences.jsonSpaces); | ||
| break; | ||
| } | ||
| return result; | ||
| }; | ||
|
|
||
| /* | ||
| Return a string of the widget tree | ||
| */ | ||
| WikifyWidget.prototype.getWidgetTree = function() { | ||
| var copyNode = function(widgetNode,resultNode) { | ||
| var type = widgetNode.parseTreeNode.type; | ||
| resultNode.type = type; | ||
| switch(type) { | ||
| case "element": | ||
| resultNode.tag = widgetNode.parseTreeNode.tag; | ||
| break; | ||
| case "text": | ||
| resultNode.text = widgetNode.parseTreeNode.text; | ||
| break; | ||
| } | ||
| if(Object.keys(widgetNode.attributes || {}).length > 0) { | ||
| resultNode.attributes = {}; | ||
| $tw.utils.each(widgetNode.attributes,function(attr,attrName) { | ||
| resultNode.attributes[attrName] = widgetNode.getAttribute(attrName); | ||
| }); | ||
| } | ||
| if(Object.keys(widgetNode.children || {}).length > 0) { | ||
| resultNode.children = []; | ||
| $tw.utils.each(widgetNode.children,function(widgetChildNode) { | ||
| var node = {}; | ||
| resultNode.children.push(node); | ||
| copyNode(widgetChildNode,node); | ||
| }); | ||
| } | ||
| }, | ||
| results = {}; | ||
| copyNode(this.wikifyWidgetNode,results); | ||
| return results; | ||
| }; | ||
|
|
||
| /* | ||
| Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering | ||
| */ | ||
| WikifyWidget.prototype.refresh = function(changedTiddlers) { | ||
| var changedAttributes = this.computeAttributes(); | ||
| // Refresh ourselves entirely if any of our attributes have changed | ||
| if(changedAttributes.name || changedAttributes.text || changedAttributes.type || changedAttributes.mode || changedAttributes.output) { | ||
| this.refreshSelf(); | ||
| return true; | ||
| } else { | ||
| // Refresh the widget tree | ||
| if(this.wikifyWidgetNode.refresh(changedTiddlers)) { | ||
| // Check if there was any change | ||
| var result = this.getResult(); | ||
| if(result !== this.wikifyResult) { | ||
| // If so, save the change | ||
| this.wikifyResult = result; | ||
| this.setVariable(this.wikifyName,this.wikifyResult); | ||
| // Refresh each of our child widgets | ||
| $tw.utils.each(this.children,function(childWidget) { | ||
| childWidget.refreshSelf(); | ||
| }); | ||
| return true; | ||
| } | ||
| } | ||
| // Just refresh the children | ||
| return this.refreshChildren(changedTiddlers); | ||
| } | ||
| }; | ||
|
|
||
| exports.wikify = WikifyWidget; | ||
|
|
||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| title: $:/core/templates/raw-static-tiddler | ||
|
|
||
| <!-- | ||
|
|
||
| This template is used for saving tiddlers as static HTML | ||
|
|
||
| --><$view field="text" format="plainwikified" /> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| title: $:/core/ui/AdvancedSearch/Filter/FilterButtons/clear | ||
| tags: $:/tags/AdvancedSearch/FilterButton | ||
|
|
||
| <$reveal state="$:/temp/advancedsearch" type="nomatch" text=""> | ||
| <$button class="tc-btn-invisible"> | ||
| <$action-setfield $tiddler="$:/temp/advancedsearch" $field="text" $value=""/> | ||
| {{$:/core/images/close-button}} | ||
| </$button> | ||
| </$reveal> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| title: $:/core/ui/AdvancedSearch/Filter/FilterButtons/delete | ||
| tags: $:/tags/AdvancedSearch/FilterButton | ||
|
|
||
| <$reveal state="$:/temp/advancedsearch" type="nomatch" text=""> | ||
| <$button popup=<<qualify "$:/state/filterDeleteDropdown">> class="tc-btn-invisible"> | ||
| {{$:/core/images/delete-button}} | ||
| </$button> | ||
| </$reveal> | ||
|
|
||
| <$reveal state=<<qualify "$:/state/filterDeleteDropdown">> type="popup" position="belowleft" animate="yes"> | ||
| <div class="tc-block-dropdown-wrapper"> | ||
| <div class="tc-block-dropdown tc-edit-type-dropdown"> | ||
| <div class="tc-dropdown-item-plain"> | ||
| <$set name="resultCount" value="""<$count filter={{$:/temp/advancedsearch}}/>"""> | ||
| Are you sure you wish to delete <<resultCount>> tiddler(s)? | ||
| </$set> | ||
| </div> | ||
| <div class="tc-dropdown-item-plain"> | ||
| <$button class="tc-btn"> | ||
| <$action-deletetiddler $filter={{$:/temp/advancedsearch}}/> | ||
| Delete these tiddlers | ||
| </$button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </$reveal> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| title: $:/core/ui/AdvancedSearch/Filter/FilterButtons/dropdown | ||
| tags: $:/tags/AdvancedSearch/FilterButton | ||
|
|
||
| <span class="tc-popup-keep"> | ||
| <$button popup=<<qualify "$:/state/filterDropdown">> class="tc-btn-invisible"> | ||
| {{$:/core/images/down-arrow}} | ||
| </$button> | ||
| </span> | ||
|
|
||
| <$reveal state=<<qualify "$:/state/filterDropdown">> type="popup" position="belowleft" animate="yes"> | ||
| <$linkcatcher to="$:/temp/advancedsearch"> | ||
| <div class="tc-block-dropdown-wrapper"> | ||
| <div class="tc-block-dropdown tc-edit-type-dropdown"> | ||
| <$list filter="[all[shadows+tiddlers]tag[$:/tags/Filter]]"><$link to={{!!filter}}><$transclude field="description"/></$link> | ||
| </$list> | ||
| </div> | ||
| </div> | ||
| </$linkcatcher> | ||
| </$reveal> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| title: $:/core/ui/AdvancedSearch/Filter/FilterButtons/export | ||
| tags: $:/tags/AdvancedSearch/FilterButton | ||
|
|
||
| <$reveal state="$:/temp/advancedsearch" type="nomatch" text=""> | ||
| <$macrocall $name="exportButton" exportFilter={{$:/temp/advancedsearch}} lingoBase="$:/language/Buttons/ExportTiddlers/"/> | ||
| </$reveal> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| title: $:/core/ui/ControlPanel/KeyboardShortcuts | ||
| tags: $:/tags/ControlPanel | ||
| caption: {{$:/language/ControlPanel/KeyboardShortcuts/Caption}} | ||
|
|
||
| \define lingo-base() $:/language/ControlPanel/KeyboardShortcuts/ | ||
|
|
||
| \define new-shortcut(title) | ||
| <div class="tc-dropdown-item-plain"> | ||
| <$edit-shortcut tiddler="$title$" placeholder={{$:/language/ControlPanel/KeyboardShortcuts/Add/Prompt}} style="width:auto;"/> <$button> | ||
| <<lingo Add/Caption>> | ||
| <$action-listops | ||
| $tiddler="$(shortcutTitle)$" | ||
| $field="text" | ||
| $subfilter="[{$title$}]" | ||
| /> | ||
| <$action-deletetiddler | ||
| $tiddler="$title$" | ||
| /> | ||
| </$button> | ||
| </div> | ||
| \end | ||
|
|
||
| \define shortcut-list-item(caption) | ||
| <td> | ||
| </td> | ||
| <td style="text-align:right;font-size:0.7em;"> | ||
| <<lingo Platform/$caption$>> | ||
| </td> | ||
| <td> | ||
| <div style="position:relative;"> | ||
| <$button popup=<<qualify "$:/state/dropdown/$(shortcutTitle)$">> class="tc-btn-invisible"> | ||
| {{$:/core/images/edit-button}} | ||
| </$button> | ||
| <$macrocall $name="displayshortcuts" $output="text/html" shortcuts={{$(shortcutTitle)$}} prefix="<kbd>" separator="</kbd> <kbd>" suffix="</kbd>"/> | ||
|
|
||
| <$reveal state=<<qualify "$:/state/dropdown/$(shortcutTitle)$">> type="popup" position="below" animate="yes"> | ||
| <div class="tc-block-dropdown-wrapper"> | ||
| <div class="tc-block-dropdown tc-edit-type-dropdown tc-popup-keep"> | ||
| <$list filter="[list[$(shortcutTitle)$!!text]sort[title]]" variable="shortcut" emptyMessage=""" | ||
| <div class="tc-dropdown-item-plain"> | ||
| //<<lingo NoShortcuts/Caption>>// | ||
| </div> | ||
| """> | ||
| <div class="tc-dropdown-item-plain"> | ||
| <$button class="tc-btn-invisible" tooltip=<<lingo Remove/Hint>>> | ||
| <$action-listops | ||
| $tiddler="$(shortcutTitle)$" | ||
| $field="text" | ||
| $subfilter="+[remove<shortcut>]" | ||
| /> | ||
| × | ||
| </$button> | ||
| <kbd> | ||
| <$macrocall $name="displayshortcuts" $output="text/html" shortcuts=<<shortcut>>/> | ||
| </kbd> | ||
| </div> | ||
| </$list> | ||
| <hr/> | ||
| <$macrocall $name="new-shortcut" title=<<qualify "$:/state/new-shortcut/$(shortcutTitle)$">>/> | ||
| </div> | ||
| </div> | ||
| </$reveal> | ||
| </div> | ||
| </td> | ||
| \end | ||
|
|
||
| \define shortcut-list(caption,prefix) | ||
| <tr> | ||
| <$list filter="[all[tiddlers+shadows][$prefix$$(shortcutName)$]]" variable="shortcutTitle"> | ||
| <<shortcut-list-item "$caption$">> | ||
| </$list> | ||
| </tr> | ||
| \end | ||
|
|
||
| \define shortcut-editor() | ||
| <<shortcut-list "All" "$:/config/shortcuts/">> | ||
| <<shortcut-list "Mac" "$:/config/shortcuts-mac/">> | ||
| <<shortcut-list "NonMac" "$:/config/shortcuts-not-mac/">> | ||
| <<shortcut-list "Linux" "$:/config/shortcuts-linux/">> | ||
| <<shortcut-list "NonLinux" "$:/config/shortcuts-not-linux/">> | ||
| <<shortcut-list "Windows" "$:/config/shortcuts-windows/">> | ||
| <<shortcut-list "NonWindows" "$:/config/shortcuts-not-windows/">> | ||
| \end | ||
|
|
||
| \define shortcut-preview() | ||
| <$macrocall $name="displayshortcuts" $output="text/html" shortcuts={{$(shortcutPrefix)$$(shortcutName)$}} prefix="<kbd>" separator="</kbd> <kbd>" suffix="</kbd>"/> | ||
| \end | ||
|
|
||
| \define shortcut-item-inner() | ||
| <tr> | ||
| <td> | ||
| <$reveal type="nomatch" state=<<dropdownStateTitle>> text="open"> | ||
| <$button class="tc-btn-invisible"> | ||
| <$action-setfield | ||
| $tiddler=<<dropdownStateTitle>> | ||
| $value="open" | ||
| /> | ||
| {{$:/core/images/right-arrow}} | ||
| </$button> | ||
| </$reveal> | ||
| <$reveal type="match" state=<<dropdownStateTitle>> text="open"> | ||
| <$button class="tc-btn-invisible"> | ||
| <$action-setfield | ||
| $tiddler=<<dropdownStateTitle>> | ||
| $value="close" | ||
| /> | ||
| {{$:/core/images/down-arrow}} | ||
| </$button> | ||
| </$reveal> | ||
| ''<$text text=<<shortcutName>>/>'' | ||
| </td> | ||
| <td> | ||
| <$transclude tiddler="$:/config/ShortcutInfo/$(shortcutName)$"/> | ||
| </td> | ||
| <td> | ||
| <$list filter="$:/config/shortcuts/ $:/config/shortcuts-mac/ $:/config/shortcuts-not-mac/ $:/config/shortcuts-linux/ $:/config/shortcuts-not-linux/ $:/config/shortcuts-windows/ $:/config/shortcuts-not-windows/" variable="shortcutPrefix"> | ||
| <<shortcut-preview>> | ||
| </$list> | ||
| </td> | ||
| </tr> | ||
| <$set name="dropdownState" value={{$(dropdownStateTitle)$}}> | ||
| <$list filter="[<dropdownState>prefix[open]]" variable="listItem"> | ||
| <<shortcut-editor>> | ||
| </$list> | ||
| </$set> | ||
| \end | ||
|
|
||
| \define shortcut-item() | ||
| <$set name="dropdownStateTitle" value=<<qualify "$:/state/dropdown/keyboardshortcut/$(shortcutName)$">>> | ||
| <<shortcut-item-inner>> | ||
| </$set> | ||
| \end | ||
|
|
||
| <table> | ||
| <tbody> | ||
| <$list filter="[all[shadows+tiddlers]removeprefix[$:/config/ShortcutInfo/]]" variable="shortcutName"> | ||
| <<shortcut-item>> | ||
| </$list> | ||
| </tbody> | ||
| </table> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| title: $:/core/ui/ControlPanel/Settings/EditorToolbar | ||
| tags: $:/tags/ControlPanel/Settings | ||
| caption: {{$:/language/ControlPanel/Settings/EditorToolbar/Caption}} | ||
|
|
||
| \define lingo-base() $:/language/ControlPanel/Settings/EditorToolbar/ | ||
| <<lingo Hint>> | ||
|
|
||
| <$checkbox tiddler="$:/config/TextEditor/EnableToolbar" field="text" checked="yes" unchecked="no" default="yes"> <$link to="$:/config/TextEditor/EnableToolbar"><<lingo Description>></$link> </$checkbox> | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| title: $:/core/ui/ControlPanel/Settings/MissingLinks | ||
| tags: $:/tags/ControlPanel/Settings | ||
| caption: {{$:/language/ControlPanel/Settings/MissingLinks/Caption}} | ||
|
|
||
| \define lingo-base() $:/language/ControlPanel/Settings/MissingLinks/ | ||
| <<lingo Hint>> | ||
|
|
||
| <$checkbox tiddler="$:/config/MissingLinks" field="text" checked="yes" unchecked="no" default="yes"> <$link to="$:/config/MissingLinks"><<lingo Description>></$link> </$checkbox> | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| title: $:/core/ui/ControlPanel/Toolbars/EditorToolbar | ||
| tags: $:/tags/ControlPanel/Toolbars | ||
| caption: {{$:/language/ControlPanel/Toolbars/EditorToolbar/Caption}} | ||
|
|
||
| \define lingo-base() $:/language/TiddlerInfo/ | ||
|
|
||
| \define config-title() | ||
| $:/config/EditorToolbarButtons/Visibility/$(listItem)$ | ||
| \end | ||
|
|
||
| \define toolbar-button() | ||
| <$checkbox tiddler=<<config-title>> field="text" checked="show" unchecked="hide" default="show"> <$transclude tiddler={{$(listItem)$!!icon}}/> <$transclude tiddler=<<listItem>> field="caption"/> -- <i class="tc-muted"><$transclude tiddler=<<listItem>> field="description"/></i></$checkbox> | ||
| \end | ||
|
|
||
| {{$:/language/ControlPanel/Toolbars/EditorToolbar/Hint}} | ||
|
|
||
| <$list filter="[all[shadows+tiddlers]tag[$:/tags/EditorToolbar]!has[draft.of]]" variable="listItem"> | ||
|
|
||
| <<toolbar-button>> | ||
|
|
||
| </$list> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| title: $:/core/ui/EditTemplate/body/preview/output | ||
| tags: $:/tags/EditPreview | ||
| caption: {{$:/language/EditTemplate/Body/Preview/Type/Output}} | ||
|
|
||
| <$set name="tv-tiddler-preview" value="yes"> | ||
|
|
||
| <$transclude /> | ||
|
|
||
| </$set> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| title: $:/core/ui/EditTemplate/body/editor | ||
|
|
||
| <$edit | ||
|
|
||
| field="text" | ||
| class="tc-edit-texteditor" | ||
| placeholder={{$:/language/EditTemplate/Body/Placeholder}} | ||
|
|
||
| ><$set | ||
|
|
||
| name="targetTiddler" | ||
| value=<<currentTiddler>> | ||
|
|
||
| ><$list | ||
|
|
||
| filter="[all[shadows+tiddlers]tag[$:/tags/EditorToolbar]!has[draft.of]]" | ||
|
|
||
| ><$reveal | ||
|
|
||
| type="nomatch" | ||
| state=<<config-visibility-title>> | ||
| text="hide" | ||
| class="tc-text-editor-toolbar-item-wrapper" | ||
|
|
||
| ><$transclude | ||
|
|
||
| tiddler="$:/core/ui/EditTemplate/body/toolbar/button" | ||
| mode="inline" | ||
|
|
||
| /></$reveal></$list></$set></$edit> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| title: $:/core/ui/EditTemplate/body/toolbar/button | ||
|
|
||
| \define toolbar-button-icon() | ||
| <$list | ||
|
|
||
| filter="[all[current]!has[custom-icon]]" | ||
| variable="no-custom-icon" | ||
|
|
||
| ><$transclude | ||
|
|
||
| tiddler={{!!icon}} | ||
|
|
||
| /></$list> | ||
| \end | ||
|
|
||
| \define toolbar-button-tooltip() | ||
| {{!!description}}<$macrocall $name="displayshortcuts" $output="text/plain" shortcuts={{!!shortcuts}} prefix="` - [" separator="] [" suffix="]`"/> | ||
| \end | ||
|
|
||
| \define toolbar-button() | ||
| <$list | ||
|
|
||
| filter={{!!condition}} | ||
| variable="list-condition" | ||
|
|
||
| ><$wikify | ||
|
|
||
| name="tooltip-text" | ||
| text=<<toolbar-button-tooltip>> | ||
| mode="inline" | ||
| output="text" | ||
|
|
||
| ><$list | ||
|
|
||
| filter="[all[current]!has[dropdown]]" | ||
| variable="no-dropdown" | ||
|
|
||
| ><$button | ||
|
|
||
| class="tc-btn-invisible $(buttonClasses)$" | ||
| tooltip=<<tooltip-text>> | ||
|
|
||
| ><span | ||
|
|
||
| data-tw-keyboard-shortcut={{!!shortcuts}} | ||
|
|
||
| /><<toolbar-button-icon>><$transclude | ||
|
|
||
| tiddler=<<currentTiddler>> | ||
| field="text" | ||
|
|
||
| /></$button></$list><$list | ||
|
|
||
| filter="[all[current]has[dropdown]]" | ||
| variable="dropdown" | ||
|
|
||
| ><$set | ||
|
|
||
| name="dropdown-state" | ||
| value=<<qualify "$:/state/EditorToolbarDropdown">> | ||
|
|
||
| ><$button | ||
|
|
||
| popup=<<dropdown-state>> | ||
| class="tc-popup-keep tc-btn-invisible $(buttonClasses)$" | ||
| selectedClass="tc-selected" | ||
| tooltip=<<tooltip-text>> | ||
|
|
||
| ><span | ||
|
|
||
| data-tw-keyboard-shortcut={{!!shortcuts}} | ||
|
|
||
| /><<toolbar-button-icon>><$transclude | ||
|
|
||
| tiddler=<<currentTiddler>> | ||
| field="text" | ||
|
|
||
| /></$button><$reveal | ||
|
|
||
| state=<<dropdown-state>> | ||
| type="popup" | ||
| position="below" | ||
| animate="yes" | ||
| tag="span" | ||
|
|
||
| ><div | ||
|
|
||
| class="tc-drop-down tc-popup-keep" | ||
|
|
||
| ><$transclude | ||
|
|
||
| tiddler={{!!dropdown}} | ||
| mode="block" | ||
|
|
||
| /></div></$reveal></$set></$list></$wikify></$list> | ||
| \end | ||
|
|
||
| \define toolbar-button-outer() | ||
| <$set | ||
|
|
||
| name="buttonClasses" | ||
| value={{!!button-classes}} | ||
|
|
||
| ><<toolbar-button>></$set> | ||
| \end | ||
|
|
||
| <<toolbar-button-outer>> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,18 @@ | ||
| title: $:/core/ui/EditTemplate/title | ||
| tags: $:/tags/EditTemplate | ||
|
|
||
| <$vars pattern="""[\|\[\]{}]""" bad-chars="""`| [ ] { }`"""> | ||
|
|
||
| <$list filter="[is[current]regexp:draft.title<pattern>]" variable="listItem"> | ||
|
|
||
| <div class="tc-message-box"> | ||
|
|
||
| {{$:/language/EditTemplate/Title/BadCharacterWarning}} | ||
|
|
||
| </div> | ||
|
|
||
| </$list> | ||
|
|
||
| </$vars> | ||
|
|
||
| <$edit-text field="draft.title" class="tc-titlebar tc-edit-texteditor" focus="true"/> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| title: $:/core/ui/EditorToolbar/bold | ||
| tags: $:/tags/EditorToolbar | ||
| icon: $:/core/images/bold | ||
| caption: {{$:/language/Buttons/Bold/Caption}} | ||
| description: {{$:/language/Buttons/Bold/Hint}} | ||
| condition: [<targetTiddler>!has[type]] [<targetTiddler>type[text/vnd.tiddlywiki]] | ||
| shortcuts: ((bold)) | ||
|
|
||
| <$action-sendmessage | ||
| $message="tm-edit-text-operation" | ||
| $param="wrap-selection" | ||
| prefix="''" | ||
| suffix="''" | ||
| /> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| title: $:/core/ui/EditorToolbar/clear-dropdown | ||
|
|
||
| ''{{$:/language/Buttons/Clear/Hint}}'' | ||
|
|
||
| <div class="tc-colour-chooser"> | ||
|
|
||
| <$macrocall $name="colour-picker" actions=""" | ||
|
|
||
| <$action-sendmessage | ||
| $message="tm-edit-bitmap-operation" | ||
| $param="clear" | ||
| colour=<<colour-picker-value>> | ||
| /> | ||
|
|
||
| <$action-deletetiddler | ||
| $tiddler=<<dropdown-state>> | ||
| /> | ||
|
|
||
| """/> | ||
|
|
||
| </div> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| title: $:/core/ui/EditorToolbar/clear | ||
| tags: $:/tags/EditorToolbar | ||
| icon: $:/core/images/erase | ||
| caption: {{$:/language/Buttons/Clear/Caption}} | ||
| description: {{$:/language/Buttons/Clear/Hint}} | ||
| condition: [<targetTiddler>is[image]] | ||
| dropdown: $:/core/ui/EditorToolbar/clear-dropdown | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| title: $:/core/ui/EditorToolbar/editor-height-dropdown | ||
|
|
||
| \define lingo-base() $:/language/Buttons/EditorHeight/ | ||
| ''<<lingo Hint>>'' | ||
|
|
||
| <$radio tiddler="$:/config/TextEditor/EditorHeight/Mode" value="auto"> {{$:/core/images/auto-height}} <<lingo Caption/Auto>></$radio> | ||
|
|
||
| <$radio tiddler="$:/config/TextEditor/EditorHeight/Mode" value="fixed"> {{$:/core/images/fixed-height}} <<lingo Caption/Fixed>> <$edit-text tag="input" tiddler="$:/config/TextEditor/EditorHeight/Height" default="100px"/></$radio> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| title: $:/core/ui/EditorToolbar/editor-height | ||
| tags: $:/tags/EditorToolbar | ||
| icon: $:/core/images/fixed-height | ||
| custom-icon: yes | ||
| caption: {{$:/language/Buttons/EditorHeight/Caption}} | ||
| description: {{$:/language/Buttons/EditorHeight/Hint}} | ||
| condition: [<targetTiddler>!is[image]] | ||
| dropdown: $:/core/ui/EditorToolbar/editor-height-dropdown | ||
|
|
||
| <$reveal tag="span" state="$:/config/TextEditor/EditorHeight/Mode" type="match" text="fixed"> | ||
| {{$:/core/images/fixed-height}} | ||
| </$reveal> | ||
| <$reveal tag="span" state="$:/config/TextEditor/EditorHeight/Mode" type="match" text="auto"> | ||
| {{$:/core/images/auto-height}} | ||
| </$reveal> |