mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-08-25 20:28:53 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8663dd51d6 | ||
|
|
215bd4e015 | ||
|
|
758089cbb3 | ||
|
|
6567843927 |
+3
-3
@@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
# test TiddlyWiki5 for tiddlywiki.com
|
# test TiddlyWiki5 for tiddlywiki.com
|
||||||
|
|
||||||
npm install playwright @playwright/test
|
|
||||||
npx playwright install chromium firefox --with-deps
|
|
||||||
|
|
||||||
node ./tiddlywiki.js \
|
node ./tiddlywiki.js \
|
||||||
./editions/test \
|
./editions/test \
|
||||||
--verbose \
|
--verbose \
|
||||||
@@ -13,4 +10,7 @@ node ./tiddlywiki.js \
|
|||||||
--test \
|
--test \
|
||||||
|| exit 1
|
|| exit 1
|
||||||
|
|
||||||
|
npm install playwright @playwright/test
|
||||||
|
npx playwright install chromium firefox --with-deps
|
||||||
|
|
||||||
npx playwright test
|
npx playwright test
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/core/modules/commands/jsrepl.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: command
|
||||||
|
|
||||||
|
Command to launch node.js REPL with access to $tw
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
exports.info = {
|
||||||
|
name: "jsrepl",
|
||||||
|
synchronous: true
|
||||||
|
};
|
||||||
|
|
||||||
|
var Command = function(params,commander,callback) {
|
||||||
|
var self = this;
|
||||||
|
this.params = params;
|
||||||
|
this.commander = commander;
|
||||||
|
this.callback = callback;
|
||||||
|
};
|
||||||
|
|
||||||
|
Command.prototype.execute = function() {
|
||||||
|
var self = this;
|
||||||
|
var repl = require("repl");
|
||||||
|
this.runtime = repl.start({
|
||||||
|
prompt: this.params.length ? this.params[0] : "$tw-jsrepl> ",
|
||||||
|
useColors: true,
|
||||||
|
ignoreUndefined: true
|
||||||
|
});
|
||||||
|
// If REPL is reset (.clear) - context needs resetting
|
||||||
|
this.runtime.on("reset", function() {
|
||||||
|
self.runtime.context.$tw = $tw;
|
||||||
|
});
|
||||||
|
// Initial context settings
|
||||||
|
this.runtime.context.$tw = $tw;
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.Command = Command;
|
||||||
|
|
||||||
|
})();
|
||||||
@@ -194,6 +194,7 @@ Parse any pragmas at the beginning of a block of parse text
|
|||||||
WikiParser.prototype.parsePragmas = function() {
|
WikiParser.prototype.parsePragmas = function() {
|
||||||
var currentTreeBranch = this.tree;
|
var currentTreeBranch = this.tree;
|
||||||
while(true) {
|
while(true) {
|
||||||
|
var savedPos = this.pos;
|
||||||
// Skip whitespace
|
// Skip whitespace
|
||||||
this.skipWhitespace();
|
this.skipWhitespace();
|
||||||
// Check for the end of the text
|
// Check for the end of the text
|
||||||
@@ -204,6 +205,7 @@ WikiParser.prototype.parsePragmas = function() {
|
|||||||
var nextMatch = this.findNextMatch(this.pragmaRules,this.pos);
|
var nextMatch = this.findNextMatch(this.pragmaRules,this.pos);
|
||||||
// If not, just exit
|
// If not, just exit
|
||||||
if(!nextMatch || nextMatch.matchIndex !== this.pos) {
|
if(!nextMatch || nextMatch.matchIndex !== this.pos) {
|
||||||
|
this.pos = savedPos;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Process the pragma rule
|
// Process the pragma rule
|
||||||
|
|||||||
@@ -28,6 +28,18 @@ Inherit from the base widget class
|
|||||||
*/
|
*/
|
||||||
ListWidget.prototype = new Widget();
|
ListWidget.prototype = new Widget();
|
||||||
|
|
||||||
|
ListWidget.prototype.initialise = function(parseTreeNode,options) {
|
||||||
|
// Bail if parseTreeNode is undefined, meaning that the ListWidget constructor was called without any arguments so that it can be subclassed
|
||||||
|
if(parseTreeNode === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// First call parent constructor to set everything else up
|
||||||
|
Widget.prototype.initialise.call(this,parseTreeNode,options);
|
||||||
|
// Now look for <$list-template> and <$list-empty> widgets as immediate child widgets
|
||||||
|
// This is safe to do during initialization because parse trees never change after creation
|
||||||
|
this.findExplicitTemplates();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Render this widget into the DOM
|
Render this widget into the DOM
|
||||||
*/
|
*/
|
||||||
@@ -68,8 +80,6 @@ ListWidget.prototype.execute = function() {
|
|||||||
this.counterName = this.getAttribute("counter");
|
this.counterName = this.getAttribute("counter");
|
||||||
this.storyViewName = this.getAttribute("storyview");
|
this.storyViewName = this.getAttribute("storyview");
|
||||||
this.historyTitle = this.getAttribute("history");
|
this.historyTitle = this.getAttribute("history");
|
||||||
// Look for <$list-template> and <$list-empty> widgets as immediate child widgets
|
|
||||||
this.findExplicitTemplates();
|
|
||||||
// Compose the list elements
|
// Compose the list elements
|
||||||
this.list = this.getTiddlerList();
|
this.list = this.getTiddlerList();
|
||||||
var members = [],
|
var members = [],
|
||||||
@@ -92,6 +102,7 @@ ListWidget.prototype.findExplicitTemplates = function() {
|
|||||||
var self = this;
|
var self = this;
|
||||||
this.explicitListTemplate = null;
|
this.explicitListTemplate = null;
|
||||||
this.explicitEmptyTemplate = null;
|
this.explicitEmptyTemplate = null;
|
||||||
|
this.hasTemplateInBody = false;
|
||||||
var searchChildren = function(childNodes) {
|
var searchChildren = function(childNodes) {
|
||||||
$tw.utils.each(childNodes,function(node) {
|
$tw.utils.each(childNodes,function(node) {
|
||||||
if(node.type === "list-template") {
|
if(node.type === "list-template") {
|
||||||
@@ -100,6 +111,8 @@ ListWidget.prototype.findExplicitTemplates = function() {
|
|||||||
self.explicitEmptyTemplate = node.children;
|
self.explicitEmptyTemplate = node.children;
|
||||||
} else if(node.type === "element" && node.tag === "p") {
|
} else if(node.type === "element" && node.tag === "p") {
|
||||||
searchChildren(node.children);
|
searchChildren(node.children);
|
||||||
|
} else {
|
||||||
|
self.hasTemplateInBody = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -160,11 +173,11 @@ ListWidget.prototype.makeItemTemplate = function(title,index) {
|
|||||||
// Check for a <$list-item> widget
|
// Check for a <$list-item> widget
|
||||||
if(this.explicitListTemplate) {
|
if(this.explicitListTemplate) {
|
||||||
templateTree = this.explicitListTemplate;
|
templateTree = this.explicitListTemplate;
|
||||||
} else if (!this.explicitEmptyTemplate) {
|
} else if(this.hasTemplateInBody) {
|
||||||
templateTree = this.parseTreeNode.children;
|
templateTree = this.parseTreeNode.children;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!templateTree) {
|
if(!templateTree || templateTree.length === 0) {
|
||||||
// Default template is a link to the title
|
// Default template is a link to the title
|
||||||
templateTree = [{type: "element", tag: this.parseTreeNode.isBlock ? "div" : "span", children: [{type: "link", attributes: {to: {type: "string", value: title}}, children: [
|
templateTree = [{type: "element", tag: this.parseTreeNode.isBlock ? "div" : "span", children: [{type: "link", attributes: {to: {type: "string", value: title}}, children: [
|
||||||
{type: "text", text: title}
|
{type: "text", text: title}
|
||||||
@@ -414,4 +427,27 @@ ListItemWidget.prototype.refresh = function(changedTiddlers) {
|
|||||||
|
|
||||||
exports.listitem = ListItemWidget;
|
exports.listitem = ListItemWidget;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Make <$list-template> and <$list-empty> widgets that do nothing
|
||||||
|
*/
|
||||||
|
var ListTemplateWidget = function(parseTreeNode,options) {
|
||||||
|
// Main initialisation inherited from widget.js
|
||||||
|
this.initialise(parseTreeNode,options);
|
||||||
|
};
|
||||||
|
ListTemplateWidget.prototype = new Widget();
|
||||||
|
ListTemplateWidget.prototype.render = function() {}
|
||||||
|
ListTemplateWidget.prototype.refresh = function() { return false; }
|
||||||
|
|
||||||
|
exports["list-template"] = ListTemplateWidget;
|
||||||
|
|
||||||
|
var ListEmptyWidget = function(parseTreeNode,options) {
|
||||||
|
// Main initialisation inherited from widget.js
|
||||||
|
this.initialise(parseTreeNode,options);
|
||||||
|
};
|
||||||
|
ListEmptyWidget.prototype = new Widget();
|
||||||
|
ListEmptyWidget.prototype.render = function() {}
|
||||||
|
ListEmptyWidget.prototype.refresh = function() { return false; }
|
||||||
|
|
||||||
|
exports["list-empty"] = ListEmptyWidget;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user