1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-03-06 19:48:10 +00:00

Merge branch 'master' into parameterised-transclusions

This commit is contained in:
jeremy@jermolene.com 2022-10-18 17:23:57 +01:00
commit 32710ef9e6
38 changed files with 155 additions and 20 deletions

View File

@ -87,7 +87,7 @@ function FramedEngine(options) {
$tw.utils.addEventListeners(this.domNode,[
{name: "click",handlerObject: this,handlerMethod: "handleClickEvent"},
{name: "input",handlerObject: this,handlerMethod: "handleInputEvent"},
{name: "keydown",handlerObject: this.widget,handlerMethod: "handleKeydownEvent"},
{name: "keydown",handlerObject: this,handlerMethod: "handleKeydownEvent"},
{name: "focus",handlerObject: this,handlerMethod: "handleFocusEvent"}
]);
// Add drag and drop event listeners if fileDrop is enabled
@ -192,6 +192,17 @@ FramedEngine.prototype.handleFocusEvent = function(event) {
}
};
/*
Handle a keydown event
*/
FramedEngine.prototype.handleKeydownEvent = function(event) {
if ($tw.keyboardManager.handleKeydownEvent(event, {onlyPriority: true})) {
return true;
}
return this.widget.handleKeydownEvent(event);
};
/*
Handle a click
*/

View File

@ -141,6 +141,7 @@ function KeyboardManager(options) {
this.shortcutKeysList = [], // Stores the shortcut-key descriptors
this.shortcutActionList = [], // Stores the corresponding action strings
this.shortcutParsedList = []; // Stores the parsed key descriptors
this.shortcutPriorityList = []; // Stores the parsed shortcut priority
this.lookupNames = ["shortcuts"];
this.lookupNames.push($tw.platform.isMac ? "shortcuts-mac" : "shortcuts-not-mac")
this.lookupNames.push($tw.platform.isWindows ? "shortcuts-windows" : "shortcuts-not-windows");
@ -318,12 +319,23 @@ KeyboardManager.prototype.updateShortcutLists = function(tiddlerList) {
this.shortcutKeysList[i] = tiddlerFields.key !== undefined ? tiddlerFields.key : undefined;
this.shortcutActionList[i] = tiddlerFields.text;
this.shortcutParsedList[i] = this.shortcutKeysList[i] !== undefined ? this.parseKeyDescriptors(this.shortcutKeysList[i]) : undefined;
this.shortcutPriorityList[i] = tiddlerFields.priority === "yes" ? true : false;
}
};
KeyboardManager.prototype.handleKeydownEvent = function(event) {
/*
event: the keyboard event object
options:
onlyPriority: true if only priority global shortcuts should be invoked
*/
KeyboardManager.prototype.handleKeydownEvent = function(event, options) {
options = options || {};
var key, action;
for(var i=0; i<this.shortcutTiddlers.length; i++) {
if(options.onlyPriority && this.shortcutPriorityList[i] !== true) {
continue;
}
if(this.shortcutParsedList[i] !== undefined && this.checkKeyDescriptors(event,this.shortcutParsedList[i])) {
key = this.shortcutParsedList[i];
action = this.shortcutActionList[i];

View File

@ -41,9 +41,6 @@ exports.parse = function() {
var node = {
type: "element",
tag: "span",
attributes: {
"class": {type: "string", value: "tc-inline-style"}
},
children: tree
};
if(classString) {
@ -52,6 +49,9 @@ exports.parse = function() {
if(stylesString) {
$tw.utils.addAttributeToParseTreeNode(node,"style",stylesString);
}
if(!classString && !stylesString) {
$tw.utils.addClassToParseTreeNode(node,"tc-inline-style");
}
return [node];
};

View File

@ -65,11 +65,9 @@ exports.addClassToParseTreeNode = function(node,classString) {
// If the class attribute does not exist, we must create it first.
attribute = {name: "class", type: "string", value: ""};
node.attributes["class"] = attribute;
if(node.orderedAttributes) {
// If there are orderedAttributes, we've got to add them there too.
node.orderedAttributes = node.orderedAttributes || [];
node.orderedAttributes.push(attribute);
}
}
if(attribute.type === "string") {
if(attribute.value !== "") {
classes = attribute.value.split(" ");
@ -88,11 +86,9 @@ exports.addStyleToParseTreeNode = function(node,name,value) {
if(!attribute) {
attribute = {name: "style", type: "string", value: ""};
node.attributes.style = attribute;
if(node.orderedAttributes) {
// If there are orderedAttributes, we've got to add them there too.
node.orderedAttributes = node.orderedAttributes || [];
node.orderedAttributes.push(attribute);
}
}
if(attribute.type === "string") {
attribute.value += name + ":" + value + ";";
}

View File

@ -53,6 +53,10 @@ KeyboardWidget.prototype.render = function(parent,nextSibling) {
};
KeyboardWidget.prototype.handleChangeEvent = function(event) {
if ($tw.keyboardManager.handleKeydownEvent(event, {onlyPriority: true})) {
return true;
}
var keyInfo = $tw.keyboardManager.getMatchingKeyDescriptor(event,this.keyInfoArray);
if(keyInfo) {
var handled = this.invokeActions(this,event);

View File

@ -175,6 +175,11 @@ SelectWidget.prototype.refresh = function(changedTiddlers) {
return true;
// If the target tiddler value has changed, just update setting and refresh the children
} else {
if(changedAttributes.class) {
this.selectClass = this.getAttribute("class");
this.getSelectDomNode().setAttribute("class",this.selectClass);
}
var childrenRefreshed = this.refreshChildren(changedTiddlers);
if(changedTiddlers[this.selectTitle] || childrenRefreshed) {
this.setSelectValue();

View File

@ -34,6 +34,8 @@ external-link-foreground-hover: inherit
external-link-foreground-visited: #0000aa
external-link-foreground: #0000ee
foreground: #333333
highlight-background: #ffff00
highlight-foreground: #000000
message-background: #ecf2ff
message-border: #cfd6e6
message-foreground: #547599

View File

@ -34,6 +34,8 @@ external-link-foreground-hover: inherit
external-link-foreground-visited: #0000aa
external-link-foreground: #0000ee
foreground: #333353
highlight-background: #ffff00
highlight-foreground: #000000
message-background: #ecf2ff
message-border: #cfd6e6
message-foreground: #547599

View File

@ -34,6 +34,8 @@ external-link-foreground-hover: inherit
external-link-foreground-visited: #0000aa
external-link-foreground: #0000ee
foreground: #333333
highlight-background: #ffff00
highlight-foreground: #000000
message-background: #ecf2ff
message-border: #cfd6e6
message-foreground: #547599

View File

@ -34,6 +34,8 @@ external-link-foreground-hover: inherit
external-link-foreground-visited: #00a
external-link-foreground: #00e
foreground: #000
highlight-background: #ffff00
highlight-foreground: #000000
message-background: <<colour foreground>>
message-border: <<colour background>>
message-foreground: <<colour background>>

View File

@ -34,6 +34,8 @@ external-link-foreground-hover: inherit
external-link-foreground-visited: #00a
external-link-foreground: #00e
foreground: #fff
highlight-background: #ffff00
highlight-foreground: #000000
message-background: <<colour foreground>>
message-border: <<colour background>>
message-foreground: <<colour background>>

View File

@ -32,6 +32,8 @@ external-link-foreground-hover:
external-link-foreground-visited: #BF5AF2
external-link-foreground: #32D74B
foreground: #FFFFFF
highlight-background: #ffff78
highlight-foreground: #000000
menubar-background: #464646
menubar-foreground: #ffffff
message-background: <<colour background>>

View File

@ -36,6 +36,8 @@ external-link-foreground-hover: inherit
external-link-foreground-visited: #0000aa
external-link-foreground: #0000ee
foreground: #333333
highlight-background: #ffff00
highlight-foreground: #000000
message-background: #ecf2ff
message-border: #cfd6e6
message-foreground: #547599

View File

@ -40,6 +40,8 @@ external-link-foreground-hover: inherit
external-link-foreground-visited: #313163
external-link-foreground: #555592
foreground: #2D2A23
highlight-background: #ffff00
highlight-foreground: #000000
menubar-background: #CDC2A6
menubar-foreground: #5A5446
message-background: #ECE5CF

View File

@ -41,6 +41,8 @@ external-link-foreground-hover: inherit
external-link-foreground-visited: #d3869b
external-link-foreground: #8ec07c
foreground: #fbf1c7
highlight-background: #ffff79
highlight-foreground: #000000
menubar-background: #504945
menubar-foreground: <<colour foreground>>
message-background: #83a598

View File

@ -41,6 +41,8 @@ external-link-foreground-hover: inherit
external-link-foreground-visited: #5E81AC
external-link-foreground: #8FBCBB
foreground: #d8dee9
highlight-background: #ffff78
highlight-foreground: #000000
menubar-background: #2E3440
menubar-foreground: #d8dee9
message-background: #2E3440

View File

@ -34,6 +34,8 @@ external-link-foreground-hover: inherit
external-link-foreground-visited: #0000aa
external-link-foreground: #0000ee
foreground: #333333
highlight-background: #ffff00
highlight-foreground: #000000
message-background: #ecf2ff
message-border: #cfd6e6
message-foreground: #547599

View File

@ -131,6 +131,8 @@ external-link-background-hover: inherit
external-link-background-visited: inherit
external-link-background: inherit
external-link-foreground-hover: inherit
highlight-background: #ffff00
highlight-foreground: #000000
message-border: #cfd6e6
modal-border: #999999
select-tag-background:

View File

@ -35,6 +35,8 @@ external-link-foreground: #268bd2
external-link-foreground-hover:
external-link-foreground-visited: #268bd2
foreground: #839496
highlight-background: #ffff78
highlight-foreground: #000000
message-background: #002b36
message-border: #586e75
message-foreground: #839496

View File

@ -35,6 +35,8 @@ external-link-foreground: #268bd2
external-link-foreground-hover: inherit
external-link-foreground-visited: #268bd2
foreground: #657b83
highlight-background: #ffff00
highlight-foreground: #000000
message-background: #fdf6e3
message-border: #93a1a1
message-foreground: #657b83

View File

@ -34,6 +34,8 @@ external-link-foreground-hover:
external-link-foreground-visited:
external-link-foreground:
foreground: rgba(0, 0, 0, 0.87)
highlight-background: #ffff00
highlight-foreground: #000000
message-background: <<colour background>>
message-border: <<colour very-muted-foreground>>
message-foreground: rgba(0, 0, 0, 0.54)

View File

@ -34,6 +34,8 @@ external-link-foreground-hover:
external-link-foreground-visited: #7c318c
external-link-foreground: #9e3eb3
foreground: rgba(255, 255, 255, 0.7)
highlight-background: #ffff78
highlight-foreground: #000000
message-background: <<colour background>>
message-border: <<colour very-muted-foreground>>
message-foreground: rgba(255, 255, 255, 0.54)

View File

@ -43,6 +43,8 @@ external-link-foreground: rgb(179, 179, 255)
external-link-foreground-hover: inherit
external-link-foreground-visited: rgb(153, 153, 255)
foreground: rgb(179, 179, 179)
highlight-background: #ffff78
highlight-foreground: #000000
message-background: <<colour tag-foreground>>
message-border: #96ccff
message-foreground: <<colour tag-background>>

View File

@ -42,6 +42,8 @@ external-link-foreground-hover: inherit
external-link-foreground-visited: #0000aa
external-link-foreground: #0000ee
foreground: #333333
highlight-background: #ffff00
highlight-foreground: #000000
message-background: #ecf2ff
message-border: #cfd6e6
message-foreground: #547599

View File

@ -117,7 +117,7 @@ C'est un exemple de tiddler. Voir [[Macros Table des matières (Exemples)|Table-
<table class="doc-bad-example">
<tbody>
<tr class="evenRow">
<td><span class="tc-inline-style" style="font-size:1.5em;">&#9888;</span> Attention&nbsp;:<br> Ne faites pas comme ça !</td>
<td><span style="font-size:1.5em;">&#9888;</span> Attention&nbsp;:<br> Ne faites pas comme ça !</td>
<td>
$eg$

View File

@ -1,6 +1,6 @@
caption: 5.2.4
created: 20220924141149286
modified: 20220924141149286
created: 20221017165036377
modified: 20221017165036377
tags: ReleaseNotes
title: Release 5.2.4
type: text/vnd.tiddlywiki
@ -16,6 +16,8 @@ type: text/vnd.tiddlywiki
Improvements to the following translations:
* Chinese
* Polish
* Spanish
* Japanese
Improvements to the translation features of TiddlyWiki:
@ -32,6 +34,9 @@ Improvements to the translation features of TiddlyWiki:
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/d62a16ee464fb9984b766b48504829a1a3eb143b">> problem with long presses on tiddler links triggering a preview on iOS/iPadOS
* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/pull/6910">> consistency of button and input elements across browsers
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/d825f1c875f5e46158c9c41c8c66471138c162d1">> edit preview to use the [[View Template Body Cascade]]
* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/pull/6970">> detection of infinite recursion errors in widgets and filters
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/36896c3db8c9678c0385a561996248a6f00a45ff">> opening a tiddler in a new window to use the [[View Template Body Cascade]]
* <<.link-badge-extended "https://github.com/Jermolene/TiddlyWiki5/pull/6877">> default styles for [[styled runs|Styles and Classes in WikiText]]
! Widget Improvements
@ -47,12 +52,14 @@ Improvements to the translation features of TiddlyWiki:
* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/6936">> new operators for reading and formatting JSON data: [[jsonget Operator]], [[jsonindexes Operator]], [[jsontype Operator]] and [[format Operator]]
* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/commit/c5d3d4c26e8fe27f272dda004aec27d6b66c4f60">> safe mode to disable wiki store indexers
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/166a1565843878083fb1eba47c73b8e67b78400d">> safe mode to prevent globally disabling parser rules
* <<.link-badge-removed "https://github.com/Jermolene/TiddlyWiki5/commit/1df4c29d73073788ba3859668112e8bb46171a6c">> restriction of the LetWidget being unable to create variables whose names begin with a dollar sign
* <<.link-badge-extended "https://github.com/Jermolene/TiddlyWiki5/pull/6735">> keyboard shortcut handling to allow to global shortcuts to override all other shortcuts
! Bug Fixes
*
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/commit/fb34df84ed41882c1c2a6ff54f0e908b43ef95a3">> "new image" keyboard shortcut not to assign journal tags
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/6987">> SelectWidget class to update if it uses a filter
! Developer Improvements

View File

@ -0,0 +1,27 @@
title: Filters/FakeVariables
description: Test for https://github.com/Jermolene/TiddlyWiki5/issues/6303
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
<$list variable="var" filter="[[existing variable should have output]] :filter[[..currentTiddler]is[variable]]">
<p><<var>></p>
</$list>
<$list variable="var" filter="[[non-existing variable should not have output]] :filter[[nonExistingVariable]is[variable]]">
<p><<var>></p>
</$list>
<$list variable="var" filter="[[existing variable negated should not have output]] :filter[[..currentTiddler]!is[variable]]">
<p><<var>></p>
</$list>
<$list variable="var" filter="[[non-existing variable negated should have output]] :filter[[nonExistingVariable]!is[variable]]">
<p><<var>></p>
</$list>
+
title: ExpectedResult
<p><p>existing variable should have output</p></p><p></p><p></p><p><p>non-existing variable negated should have output</p></p>

View File

@ -63,6 +63,22 @@ describe("WikiText tests", function() {
expect(wiki.renderText("text/html","text/vnd-tiddlywiki","@@color:red;\n<div>\n\nContent</div>\n@@")).toBe("<div style=\"color:red;\"><p>Content</p></div>");
expect(wiki.renderText("text/html","text/vnd-tiddlywiki","@@color:red;\n---\n@@")).toBe("<hr style=\"color:red;\">");
});
it("handles inline style wikitext notation", function() {
expect(wiki.renderText("text/html","text/vnd-tiddlywiki",
"some @@highlighted@@ text")).toBe('<p>some <span class="tc-inline-style">highlighted</span> text</p>');
expect(wiki.renderText("text/html","text/vnd-tiddlywiki",
"some @@color:green;.tc-inline-style 1 style and 1 class@@ text")).toBe('<p>some <span class=" tc-inline-style " style="color:green;">1 style and 1 class</span> text</p>');
expect(wiki.renderText("text/html","text/vnd-tiddlywiki",
"some @@background-color:red;red@@ text")).toBe('<p>some <span style="background-color:red;">red</span> text</p>');
expect(wiki.renderText("text/html","text/vnd-tiddlywiki",
"some @@.myClass class@@ text")).toBe('<p>some <span class=" myClass ">class</span> text</p>');
expect(wiki.renderText("text/html","text/vnd-tiddlywiki",
"some @@.myClass.secondClass 2 classes@@ text")).toBe('<p>some <span class=" myClass secondClass ">2 classes</span> text</p>');
expect(wiki.renderText("text/html","text/vnd-tiddlywiki",
"some @@background:red;.myClass style and class@@ text")).toBe('<p>some <span class=" myClass " style="background:red;">style and class</span> text</p>');
expect(wiki.renderText("text/html","text/vnd-tiddlywiki",
"some @@background:red;color:white;.myClass 2 style and 1 class@@ text")).toBe('<p>some <span class=" myClass " style="background:red;color:white;">2 style and 1 class</span> text</p>');
});
});
})();

View File

@ -2,4 +2,6 @@ title: RenderTiddlerCommand
tags: Commands
caption: rendertiddler
<<.deprecated-since "5.1.15" "RenderCommand">>.
{{$:/language/Help/rendertiddler}}

View File

@ -2,4 +2,6 @@ title: RenderTiddlersCommand
tags: Commands
caption: rendertiddlers
<<.deprecated-since "5.1.15" "RenderCommand">>.
{{$:/language/Help/rendertiddlers}}

View File

@ -4,4 +4,6 @@ created: 20131218121606089
modified: 20131218121606089
caption: savetiddler
<<.deprecated-since "5.1.15" "SaveCommand">>.
{{$:/language/Help/savetiddler}}

View File

@ -4,4 +4,6 @@ created: 20140609121606089
modified: 20140609121606089
caption: savetiddlers
<<.deprecated-since "5.1.15" "SaveCommand">>.
{{$:/language/Help/savetiddlers}}

View File

@ -7,6 +7,8 @@ A ''Keyboard Shortcut Tiddler'' is made of three parts:
* The ''field'' `key` with a [[Keyboard Shortcut Descriptor]] as its ''value''
* Actions in its ''text'' field
<<.tip """<<.from-version "5.2.4">> By default <<.wlink KeyboardWidget>> and text editor shortcuts take priority, which can be circumvented by setting the ''field'' `priority` to `yes`.""">>
If the [[Keyboard Shortcut Descriptor]] has the form `((my-shortcut))` it's a ''reference'' to a ''configuration Tiddler'' that stores the corresponding [[Keyboard Shortcut|KeyboardShortcuts]]
In order to make a ''shortcut'' editable through the <<.controlpanel-tab KeyboardShortcuts>> Tab in the $:/ControlPanel it's sufficient to create a tiddler `$:/config/ShortcutInfo/my-shortcut`, where the ''suffix'' is the ''reference'' used for the [[Keyboard Shortcut|KeyboardShortcuts]]

View File

@ -66,6 +66,8 @@ In the [[Keyboard Shortcuts Tab|$:/core/ui/ControlPanel/KeyboardShortcuts]] the
!! Using global Keyboard Shortcuts
> See [[Keyboard Shortcut Tiddler]] for detailed information about creating new global keyboard shortcuts.
> The actions for ''global'' keyboard shortcuts are stored in the ''text'' field of tiddlers tagged with <<tag $:/tags/KeyboardShortcut>>
> The ''key field'' connects an action-tiddler with the corresponding shortcut through the `((my-shortcut))` syntax, called [[Keyboard Shortcut Descriptor]]

View File

@ -117,7 +117,7 @@ This is an example tiddler. See [[Table-of-Contents Macros (Examples)]].
<table class="doc-bad-example">
<tbody>
<tr class="evenRow">
<td><span class="tc-inline-style" style="font-size:1.5em;">&#9888;</span> Warning:<br> Don't do it this way!</td>
<td><span style="font-size:1.5em;">&#9888;</span> Warning:<br> Don't do it this way!</td>
<td>
$eg$

View File

@ -36,7 +36,7 @@ This example requires the following CSS definitions from [[$:/_tw5.com-styles]]:
This wiki text shows how to display a list within the scrollable widget:
<<wikitext-example-without-html "<$scrollable class='tc-scrollable-demo'>
<$list filter='[!is[system]]'>
<$list filter='[tag[Reference]]'>
<$view field='title'/>: <$list filter='[all[current]links[]sort[title]]' storyview='pop'>
<$link><$view field='title'/></$link>

View File

@ -186,6 +186,10 @@ function CodeMirrorEngine(options) {
return false;
});
this.cm.on("keydown",function(cm,event) {
if ($tw.keyboardManager.handleKeydownEvent(event, {onlyPriority: true})) {
return true;
}
return self.widget.handleKeydownEvent.call(self.widget,event);
});
this.cm.on("focus",function(cm,event) {

View File

@ -290,6 +290,11 @@ kbd {
color: <<colour selection-foreground>>;
}
.tc-inline-style {
background: <<colour highlight-background>>;
color: <<colour highlight-foreground>>;
}
form.tc-form-inline {
display: inline;
}