Skip to content

Commit

Permalink
Resolving merge conflict.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljmcd committed Sep 10, 2024
2 parents 6c52c4d + 40138be commit 57e3ce0
Show file tree
Hide file tree
Showing 303 changed files with 2,318 additions and 1,164 deletions.
4 changes: 2 additions & 2 deletions boot/boot.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions core/language/en-GB/Buttons.multids
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ Excise/Caption/Replace/Link: link
Excise/Caption/Replace/Transclusion: transclusion
Excise/Caption/Tag: Tag new tiddler with the title of this tiddler
Excise/Caption/TiddlerExists: Warning: tiddler already exists
Excise/DefaultTitle: New Excision
Excise/Hint: Excise the selected text into a new tiddler
Heading1/Caption: heading 1
Heading1/Hint: Apply heading level 1 formatting to lines containing selection
Expand Down
1 change: 1 addition & 0 deletions core/language/en-GB/EditTemplate.multids
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Tags/ClearInput/Caption: clear input
Tags/ClearInput/Hint: Clear tag input
Tags/Dropdown/Caption: tag list
Tags/Dropdown/Hint: Show tag list
Tags/EmptyMessage: (no search result)
Title/BadCharacterWarning: Warning: avoid using any of the characters <<bad-chars>> in tiddler titles
Title/Exists/Prompt: Target tiddler already exists
Title/Relink/Prompt: Update ''<$text text=<<fromTitle>>/>'' to ''<$text text=<<toTitle>>/>'' in the //tags// and //list// fields of other tiddlers
Expand Down
2 changes: 2 additions & 0 deletions core/language/en-GB/Search.multids
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Filter/Hint: Search via a [[filter expression|https://tiddlywiki.com/static/Filt
Filter/Matches: //<small><<resultCount>> matches</small>//
Matches: //<small><<resultCount>> matches</small>//
Matches/All: All matches:
Matches/NoMatch: //No match//
Matches/NoResult: //No search result//
Matches/Title: Title matches:
Search: Search
Search/TooShort: Search text too short
Expand Down
6 changes: 3 additions & 3 deletions core/modules/editor/operations/text/excise.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ function isMarkdown(mediaType) {
exports["excise"] = function(event,operation) {
var editTiddler = this.wiki.getTiddler(this.editTitle),
editTiddlerTitle = this.editTitle,
wikiLinks = !isMarkdown(editTiddler.fields.type);

wikiLinks = !isMarkdown(editTiddler.fields.type),
excisionBaseTitle = $tw.language.getString("Buttons/Excise/DefaultTitle");
if(editTiddler && editTiddler.fields["draft.of"]) {
editTiddlerTitle = editTiddler.fields["draft.of"];
}
var excisionTitle = event.paramObject.title || this.wiki.generateNewTitle("New Excision");
var excisionTitle = event.paramObject.title || this.wiki.generateNewTitle(excisionBaseTitle);
this.wiki.addTiddler(new $tw.Tiddler(
this.wiki.getCreationFields(),
this.wiki.getModificationFields(),
Expand Down
136 changes: 112 additions & 24 deletions core/modules/editor/operations/text/wrap-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,125 @@ Text editor operation to wrap the selection with the specified prefix and suffix
"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) {
var o = operation,
prefix = event.paramObject.prefix,
suffix = event.paramObject.suffix,
trimSelection = event.paramObject.trimSelection || "no",
selLength = o.selEnd - o.selStart;

// This function detects, if trailing spaces are part of the selection __and__ if the user wants to handle them
// Returns "yes", "start", "end", "no" (default)
// yes .. there are trailing spaces at both ends
// start .. there are trailing spaces at the start
// end .. there are trailing spaces at the end
// no .. no trailing spaces are taken into account
var trailingSpaceAt = function(sel) {
var _start,
_end,
result;
// trimSelection is a user parameter, which this evaluations takes into account
switch(trimSelection) {
case "end":
result = (sel.trimEnd().length !== selLength) ? "end" : "no";
break;
case "yes":
_start = sel.trimStart().length !== selLength;
_end = sel.trimEnd().length !== selLength;
result = (_start && _end) ? "yes" : (_start) ? "start" : (_end) ? "end" : "no";
break;
case "start":
result = (sel.trimStart().length !== selLength) ? "start" : "no";
break;
default:
result = "no";
break;
}
return result;
}

function togglePrefixSuffix() {
if(o.text.substring(o.selStart - prefix.length, o.selStart + suffix.length) === prefix + suffix) {
// Remove the prefix and suffix
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;
o.cutStart = o.selStart - prefix.length;
o.cutEnd = o.selEnd + suffix.length;
o.replacement = "";
o.newSelStart = o.cutStart;
o.newSelEnd = o.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;
o.cutStart = o.selStart;
o.cutEnd = o.selEnd;
o.replacement = prefix + suffix;
o.newSelStart = o.selStart + prefix.length;
o.newSelEnd = o.newSelStart;
}
}

// options: lenPrefix, lenSuffix
function removePrefixSuffix(options) {
options = options || {};
var _lenPrefix = options.lenPrefix || 0;
var _lenSuffix = options.lenSuffix || 0;

o.cutStart = o.selStart - _lenPrefix;
o.cutEnd = o.selEnd + _lenSuffix;
o.replacement = (_lenPrefix || _lenSuffix) ? o.selection : o.selection.substring(prefix.length, o.selection.length - suffix.length);
o.newSelStart = o.cutStart;
o.newSelEnd = o.cutStart + o.replacement.length;
}

function addPrefixSuffix() {
// remove trailing space if requested
switch(trailingSpaceAt(o.selection)) {
case "no":
// has no trailing spaces
o.cutStart = o.selStart;
o.cutEnd = o.selEnd;
o.replacement = prefix + o.selection + suffix;
o.newSelStart = o.selStart;
o.newSelEnd = o.selStart + o.replacement.length;
break;
case "yes":
// handle both ends
o.cutStart = o.selEnd - (o.selection.trimStart().length);
o.cutEnd = o.selection.trimEnd().length + o.selStart;
o.replacement = prefix + o.selection.trim() + suffix;
o.newSelStart = o.cutStart;
o.newSelEnd = o.cutStart + o.replacement.length;
break;
case "start":
// handle leading
o.cutStart = o.selEnd - (o.selection.trimStart().length);
o.cutEnd = o.selEnd;
o.replacement = prefix + o.selection.trimStart() + suffix;
o.newSelStart = o.cutStart;
o.newSelEnd = o.cutStart + o.replacement.length;
break;
case "end":
// handle trailing
o.cutStart = o.selStart;
o.cutEnd = o.selection.trimEnd().length + o.selStart;
o.replacement = prefix + o.selection.trimEnd() + suffix;
o.newSelStart = o.selStart;
o.newSelEnd = o.selStart + o.replacement.length;
break;
}
} 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) {
}

if(o.selStart === o.selEnd) {
// No selection; Create prefix and suffix. Set cursor in between them: ""|""
togglePrefixSuffix();
} else if(o.text.substring(o.selStart, o.selStart + prefix.length) === prefix &&
o.text.substring(o.selEnd - suffix.length,o.selEnd) === 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;
removePrefixSuffix();
} else if(o.text.substring(o.selStart - prefix.length, o.selStart) === prefix &&
o.text.substring(o.selEnd, o.selEnd + suffix.length) === suffix) {
// Prefix and suffix are present BUT not selected -> remove them
removePrefixSuffix({"lenPrefix": prefix.length, "lenSuffix": suffix.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;
addPrefixSuffix();
}
};

Expand Down
8 changes: 4 additions & 4 deletions core/modules/filters/encodings.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Export our filter functions

exports.decodebase64 = function(source,operator,options) {
var results = [];
var binary = operator.suffixes && operator.suffixes.indexOf("binary") !== -1;
var urlsafe = operator.suffixes && operator.suffixes.indexOf("urlsafe") !== -1;
var binary = operator.suffixes && operator.suffixes[0].indexOf("binary") !== -1;
var urlsafe = operator.suffixes && operator.suffixes[0].indexOf("urlsafe") !== -1;
source(function(tiddler,title) {
results.push($tw.utils.base64Decode(title,binary,urlsafe));
});
Expand All @@ -28,8 +28,8 @@ exports.decodebase64 = function(source,operator,options) {

exports.encodebase64 = function(source,operator,options) {
var results = [];
var binary = operator.suffixes && operator.suffixes.indexOf("binary") !== -1;
var urlsafe = operator.suffixes && operator.suffixes.indexOf("urlsafe") !== -1;
var binary = operator.suffixes && operator.suffixes[0].indexOf("binary") !== -1;
var urlsafe = operator.suffixes && operator.suffixes[0].indexOf("urlsafe") !== -1;
source(function(tiddler,title) {
results.push($tw.utils.base64Encode(title,binary,urlsafe));
});
Expand Down
10 changes: 6 additions & 4 deletions core/modules/macros/unusedtitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@ exports.name = "unusedtitle";
exports.params = [
{name: "baseName"},
{name: "separator"},
{name: "template"}
{name: "template"},
{name: "startCount"}
];

/*
Run the macro
*/
exports.run = function(baseName,separator,template) {
exports.run = function(baseName,separator,template,startCount) {
separator = separator || " ";
startCount = startCount || 0;
if(!baseName) {
baseName = $tw.language.getString("DefaultNewTiddlerTitle");
}
// $tw.wiki.generateNewTitle = function(baseTitle,options)
// options.prefix must be a string!
return this.wiki.generateNewTitle(baseName, {"prefix": separator, "template": template});
// options.prefix must be a string!
return this.wiki.generateNewTitle(baseName, {"prefix": separator, "template": template, "startCount": startCount});
};

})();
4 changes: 2 additions & 2 deletions core/modules/parsers/wikiparser/rules/conditional.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module-type: wikirule
Conditional shortcut syntax
```
This is a <% if [{something}] %>Elephant<% elseif [{else}] %>Pelican<% else %>Crocodile<% endif %>
This is a <%if [{something}] %>Elephant<%elseif [{else}] %>Pelican<%else%>Crocodile<%endif%>
```
\*/
Expand All @@ -27,7 +27,7 @@ exports.init = function(parser) {
};

exports.findNextMatch = function(startPos) {
// Look for the next <% if shortcut
// Look for the next <%if shortcut
this.matchRegExp.lastIndex = startPos;
this.match = this.matchRegExp.exec(this.parser.source);
// If not found then return no match
Expand Down
4 changes: 2 additions & 2 deletions core/modules/savers/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Retrieve ETag if available
*/
var retrieveETag = function(self) {
var headers = {
Accept: "*/*;charset=UTF-8"
Accept: "*/*"
};
$tw.utils.httpRequest({
url: self.uri(),
Expand Down Expand Up @@ -55,7 +55,7 @@ var PutSaver = function(wiki) {
callback: function(err,data,xhr) {
// Check DAV header http://www.webdav.org/specs/rfc2518.html#rfc.section.9.1
if(!err) {
self.serverAcceptsPuts = xhr.status === 200 && !!xhr.getResponseHeader("dav");
self.serverAcceptsPuts = xhr.status >= 200 && xhr.status < 300 && !!xhr.getResponseHeader("dav");
}
}
});
Expand Down
14 changes: 9 additions & 5 deletions core/modules/utils/edition-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ exports.getEditionInfo = function() {
for(var entryIndex=0; entryIndex<entries.length; entryIndex++) {
var entry = entries[entryIndex];
// Check if directories have a valid tiddlywiki.info
if(!editionInfo[entry] && $tw.utils.isDirectory(path.resolve(editionPath,entry))) {
var info = $tw.utils.parseJSONSafe(fs.readFileSync(path.resolve(editionPath,entry,"tiddlywiki.info"),"utf8"),null);
if(info) {
editionInfo[entry] = info;
// Check if the entry is a hidden directory
if((entry.charAt(0) !== ".") && !editionInfo[entry] && $tw.utils.isDirectory(path.resolve(editionPath,entry))) {
var file=path.resolve(editionPath,entry,"tiddlywiki.info");
if(fs.existsSync(file)) {
var info = $tw.utils.parseJSONSafe(fs.readFileSync(file,"utf8"),null);
if(info) {
editionInfo[entry] = info;
}
}
}
}
Expand All @@ -41,4 +45,4 @@ exports.getEditionInfo = function() {
return editionInfo;
};

})();
})();
6 changes: 4 additions & 2 deletions core/modules/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,18 @@ exports.formatTitleString = function(template,options) {
}]
];
while(t.length){
var matchString = "";
var matchString = "",
found = false;
$tw.utils.each(matches, function(m) {
var match = m[0].exec(t);
if(match) {
found = true;
matchString = m[1].call(null,match);
t = t.substr(match[0].length);
return false;
}
});
if(matchString) {
if(found) {
result += matchString;
} else {
result += t.charAt(0);
Expand Down
1 change: 0 additions & 1 deletion core/modules/widgets/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ DataWidget.prototype.computeDataTiddlerValues = function() {
}
} else {
// Apply the item fields to each of the tiddlers
delete item.title; // Do not overwrite the title
if(Object.keys(item).length > 0) {
$tw.utils.each(tiddlers,function(tiddler,index) {
tiddlers[index] = new $tw.Tiddler(tiddler,item);
Expand Down
18 changes: 10 additions & 8 deletions core/modules/widgets/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ KeyboardWidget.prototype.execute = function() {
this.param = this.getAttribute("param","");
this.key = this.getAttribute("key","");
this.tag = this.getAttribute("tag","");
this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key);
if(this.key.substr(0,2) === "((" && this.key.substr(-2,2) === "))") {
this.shortcutTiddlers = [];
var name = this.key.substring(2,this.key.length -2);
$tw.utils.each($tw.keyboardManager.lookupNames,function(platformDescriptor) {
self.shortcutTiddlers.push("$:/config/" + platformDescriptor + "/" + name);
});
if($tw.keyboardManager) {
this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key);
if(this.key.substr(0,2) === "((" && this.key.substr(-2,2) === "))") {
this.shortcutTiddlers = [];
var name = this.key.substring(2,this.key.length -2);
$tw.utils.each($tw.keyboardManager.lookupNames,function(platformDescriptor) {
self.shortcutTiddlers.push("$:/config/" + platformDescriptor + "/" + name);
});
}
}
// Make child widgets
this.makeChildWidgets();
Expand All @@ -126,7 +128,7 @@ KeyboardWidget.prototype.refresh = function(changedTiddlers) {
this.assignDomNodeClasses();
}
// Update the keyInfoArray if one of its shortcut-config-tiddlers has changed
if(this.shortcutTiddlers && $tw.utils.hopArray(changedTiddlers,this.shortcutTiddlers)) {
if(this.shortcutTiddlers && $tw.utils.hopArray(changedTiddlers,this.shortcutTiddlers) && $tw.keyboardManager) {
this.keyInfoArray = $tw.keyboardManager.parseKeyDescriptors(this.key);
}
return this.refreshChildren(changedTiddlers);
Expand Down
Loading

0 comments on commit 57e3ce0

Please sign in to comment.