mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-07 14:23:53 +00:00
Merge branch 'master' into parameterised-transclusions
This commit is contained in:
commit
fddaa9fdb1
13
boot/boot.js
13
boot/boot.js
@ -1230,13 +1230,16 @@ $tw.Wiki = function(options) {
|
|||||||
this.getTiddler = function(title) {
|
this.getTiddler = function(title) {
|
||||||
if(title) {
|
if(title) {
|
||||||
var t = tiddlers[title];
|
var t = tiddlers[title];
|
||||||
if(t instanceof $tw.Tiddler) {
|
if(t !== undefined) {
|
||||||
return t;
|
return t;
|
||||||
} else if(title !== undefined && shadowTiddlers[title]) {
|
} else {
|
||||||
return shadowTiddlers[title].tiddler;
|
var s = shadowTiddlers[title];
|
||||||
|
if(s !== undefined) {
|
||||||
|
return s.tiddler;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get an array of all tiddler titles
|
// Get an array of all tiddler titles
|
||||||
@ -2416,7 +2419,7 @@ $tw.boot.initStartup = function(options) {
|
|||||||
$tw.utils.registerFileType("application/epub+zip","base64",".epub");
|
$tw.utils.registerFileType("application/epub+zip","base64",".epub");
|
||||||
$tw.utils.registerFileType("application/octet-stream","base64",".octet-stream");
|
$tw.utils.registerFileType("application/octet-stream","base64",".octet-stream");
|
||||||
// Create the wiki store for the app
|
// Create the wiki store for the app
|
||||||
$tw.wiki = new $tw.Wiki();
|
$tw.wiki = new $tw.Wiki($tw.safeMode && {enableIndexers: []});
|
||||||
// Install built in tiddler fields modules
|
// Install built in tiddler fields modules
|
||||||
$tw.Tiddler.fieldModules = $tw.modules.getModulesByTypeAsHashmap("tiddlerfield");
|
$tw.Tiddler.fieldModules = $tw.modules.getModulesByTypeAsHashmap("tiddlerfield");
|
||||||
// Install the tiddler deserializer modules
|
// Install the tiddler deserializer modules
|
||||||
|
@ -117,7 +117,7 @@ WikiParser.prototype.loadRemoteTiddler = function(url) {
|
|||||||
*/
|
*/
|
||||||
WikiParser.prototype.setupRules = function(proto,configPrefix) {
|
WikiParser.prototype.setupRules = function(proto,configPrefix) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if(!$tw.safemode) {
|
if(!$tw.safeMode) {
|
||||||
$tw.utils.each(proto,function(object,name) {
|
$tw.utils.each(proto,function(object,name) {
|
||||||
if(self.wiki.getTiddlerText(configPrefix + name,"enable") !== "enable") {
|
if(self.wiki.getTiddlerText(configPrefix + name,"enable") !== "enable") {
|
||||||
delete proto[name];
|
delete proto[name];
|
||||||
|
@ -42,7 +42,7 @@ var TW_TextNode = function(text) {
|
|||||||
this.textContent = text + "";
|
this.textContent = text + "";
|
||||||
};
|
};
|
||||||
|
|
||||||
TW_TextNode.prototype = Object.create(TW_Node.prototype);
|
Object.setPrototypeOf(TW_TextNode,TW_Node.prototype);
|
||||||
|
|
||||||
Object.defineProperty(TW_TextNode.prototype, "nodeType", {
|
Object.defineProperty(TW_TextNode.prototype, "nodeType", {
|
||||||
get: function() {
|
get: function() {
|
||||||
@ -67,7 +67,7 @@ var TW_Element = function(tag,namespace) {
|
|||||||
this.namespaceURI = namespace || "http://www.w3.org/1999/xhtml";
|
this.namespaceURI = namespace || "http://www.w3.org/1999/xhtml";
|
||||||
};
|
};
|
||||||
|
|
||||||
TW_Element.prototype = Object.create(TW_Node.prototype);
|
Object.setPrototypeOf(TW_Element,TW_Node.prototype);
|
||||||
|
|
||||||
Object.defineProperty(TW_Element.prototype, "style", {
|
Object.defineProperty(TW_Element.prototype, "style", {
|
||||||
get: function() {
|
get: function() {
|
||||||
|
@ -66,14 +66,14 @@ CheckboxWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
CheckboxWidget.prototype.getValue = function() {
|
CheckboxWidget.prototype.getValue = function() {
|
||||||
var tiddler = this.wiki.getTiddler(this.checkboxTitle);
|
var tiddler = this.wiki.getTiddler(this.checkboxTitle);
|
||||||
if(tiddler || this.checkboxFilter) {
|
if(tiddler || this.checkboxFilter) {
|
||||||
if(this.checkboxTag) {
|
if(tiddler && this.checkboxTag) {
|
||||||
if(this.checkboxInvertTag === "yes") {
|
if(this.checkboxInvertTag === "yes") {
|
||||||
return !tiddler.hasTag(this.checkboxTag);
|
return !tiddler.hasTag(this.checkboxTag);
|
||||||
} else {
|
} else {
|
||||||
return tiddler.hasTag(this.checkboxTag);
|
return tiddler.hasTag(this.checkboxTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.checkboxField || this.checkboxIndex) {
|
if(tiddler && (this.checkboxField || this.checkboxIndex)) {
|
||||||
// Same logic applies to fields and indexes
|
// Same logic applies to fields and indexes
|
||||||
var value;
|
var value;
|
||||||
if(this.checkboxField) {
|
if(this.checkboxField) {
|
||||||
@ -206,11 +206,18 @@ CheckboxWidget.prototype.handleChangeEvent = function(event) {
|
|||||||
}
|
}
|
||||||
// Set the list field (or index) if specified
|
// Set the list field (or index) if specified
|
||||||
if(this.checkboxListField || this.checkboxListIndex) {
|
if(this.checkboxListField || this.checkboxListIndex) {
|
||||||
var listContents, oldPos, newPos;
|
var fieldContents, listContents, oldPos, newPos;
|
||||||
if(this.checkboxListField) {
|
if(this.checkboxListField) {
|
||||||
listContents = tiddler.getFieldList(this.checkboxListField);
|
fieldContents = tiddler ? tiddler.fields[this.checkboxListField] : undefined;
|
||||||
} else {
|
} else {
|
||||||
listContents = $tw.utils.parseStringArray(this.wiki.extractTiddlerDataItem(this.checkboxTitle,this.checkboxListIndex) || "") || [];
|
fieldContents = this.wiki.extractTiddlerDataItem(this.checkboxTitle,this.checkboxListIndex);
|
||||||
|
}
|
||||||
|
if($tw.utils.isArray(fieldContents)) {
|
||||||
|
// Make a copy so we can modify it without changing original that's refrenced elsewhere
|
||||||
|
listContents = fieldContents.slice(0);
|
||||||
|
} else {
|
||||||
|
listContents = $tw.utils.parseStringArray(fieldContents) || [];
|
||||||
|
// No need to copy since parseStringArray returns a fresh array, not refrenced elsewhere
|
||||||
}
|
}
|
||||||
oldPos = notValue ? listContents.indexOf(notValue) : -1;
|
oldPos = notValue ? listContents.indexOf(notValue) : -1;
|
||||||
newPos = value ? listContents.indexOf(value) : -1;
|
newPos = value ? listContents.indexOf(value) : -1;
|
||||||
|
@ -39,7 +39,10 @@ Compute the internal state of the widget
|
|||||||
ImportVariablesWidget.prototype.execute = function(tiddlerList) {
|
ImportVariablesWidget.prototype.execute = function(tiddlerList) {
|
||||||
var widgetPointer = this;
|
var widgetPointer = this;
|
||||||
// Got to flush all the accumulated variables
|
// Got to flush all the accumulated variables
|
||||||
this.variables = new this.variablesConstructor();
|
this.variables = Object.create(null);
|
||||||
|
if(this.parentWidget) {
|
||||||
|
Object.setPrototypeOf(this.variables,this.parentWidget.variables);
|
||||||
|
}
|
||||||
// Get our parameters
|
// Get our parameters
|
||||||
this.filter = this.getAttribute("filter");
|
this.filter = this.getAttribute("filter");
|
||||||
// Compute the filter
|
// Compute the filter
|
||||||
|
@ -41,9 +41,10 @@ Widget.prototype.initialise = function(parseTreeNode,options) {
|
|||||||
this.parseTreeNode = parseTreeNode;
|
this.parseTreeNode = parseTreeNode;
|
||||||
this.wiki = options.wiki;
|
this.wiki = options.wiki;
|
||||||
this.parentWidget = options.parentWidget;
|
this.parentWidget = options.parentWidget;
|
||||||
this.variablesConstructor = function() {};
|
this.variables = Object.create(null);
|
||||||
this.variablesConstructor.prototype = this.parentWidget ? this.parentWidget.variables : {};
|
if(this.parentWidget) {
|
||||||
this.variables = new this.variablesConstructor();
|
Object.setPrototypeOf(this.variables,this.parentWidget.variables);
|
||||||
|
}
|
||||||
this.document = options.document;
|
this.document = options.document;
|
||||||
this.attributes = {};
|
this.attributes = {};
|
||||||
this.children = [];
|
this.children = [];
|
||||||
|
@ -234,6 +234,38 @@ Tests the checkbox widget thoroughly.
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// https://github.com/Jermolene/TiddlyWiki5/issues/6871
|
||||||
|
const listModeTestsWithListField = (
|
||||||
|
listModeTests
|
||||||
|
.filter(data => data.widgetText.includes("listField='colors'"))
|
||||||
|
.map(data => {
|
||||||
|
const newData = {
|
||||||
|
...data,
|
||||||
|
tiddlers: data.tiddlers.map(tiddler => ({...tiddler, list: tiddler.colors, colors: undefined})),
|
||||||
|
widgetText: data.widgetText.replace("listField='colors'", "listField='list'"),
|
||||||
|
expectedChange: {
|
||||||
|
"Colors": { list: data.expectedChange.Colors.colors.split(' ') }
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return newData;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
const listModeTestsWithTagsField = (
|
||||||
|
listModeTests
|
||||||
|
.filter(data => data.widgetText.includes("listField='colors'"))
|
||||||
|
.map(data => {
|
||||||
|
const newData = {
|
||||||
|
...data,
|
||||||
|
tiddlers: data.tiddlers.map(tiddler => ({...tiddler, tags: tiddler.colors, colors: undefined})),
|
||||||
|
widgetText: data.widgetText.replace("listField='colors'", "listField='tags'"),
|
||||||
|
expectedChange: {
|
||||||
|
"Colors": { tags: data.expectedChange.Colors.colors.split(' ') }
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return newData;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
const indexListModeTests = listModeTests.map(data => {
|
const indexListModeTests = listModeTests.map(data => {
|
||||||
const newData = {...data};
|
const newData = {...data};
|
||||||
const newName = data.testName.replace('list mode', 'index list mode');
|
const newName = data.testName.replace('list mode', 'index list mode');
|
||||||
@ -453,6 +485,8 @@ Tests the checkbox widget thoroughly.
|
|||||||
const checkboxTestData = fieldModeTests.concat(
|
const checkboxTestData = fieldModeTests.concat(
|
||||||
indexModeTests,
|
indexModeTests,
|
||||||
listModeTests,
|
listModeTests,
|
||||||
|
listModeTestsWithListField,
|
||||||
|
listModeTestsWithTagsField,
|
||||||
indexListModeTests,
|
indexListModeTests,
|
||||||
filterModeTests,
|
filterModeTests,
|
||||||
);
|
);
|
||||||
@ -495,7 +529,7 @@ Tests the checkbox widget thoroughly.
|
|||||||
for (const fieldName of Object.keys(change)) {
|
for (const fieldName of Object.keys(change)) {
|
||||||
const expectedValue = change[fieldName];
|
const expectedValue = change[fieldName];
|
||||||
const fieldValue = tiddler.fields[fieldName];
|
const fieldValue = tiddler.fields[fieldName];
|
||||||
expect(fieldValue).toBe(expectedValue);
|
expect(fieldValue).toEqual(expectedValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -70,6 +70,7 @@ That renders as:
|
|||||||
That renders as:
|
That renders as:
|
||||||
|
|
||||||
<$macrocall $name="__src__"/>
|
<$macrocall $name="__src__"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user