Permalink
Browse files

Rich text editor can now handle variables in hash tables.

  • Loading branch information...
1 parent b3f9119 commit d44f65f6a2e6d0d7474c752ce70fc24d270a81ac @amolenaar amolenaar committed Feb 13, 2014
Showing with 20 additions and 2 deletions.
  1. +10 −0 src/fitnesse/resources/wysiwyg/wikitext-spec.js
  2. +10 −2 src/fitnesse/resources/wysiwyg/wysiwyg.js
View
10 src/fitnesse/resources/wysiwyg/wikitext-spec.js
@@ -372,6 +372,16 @@ describe("parser and formatter", function () {
var wikitext = "| test | !{$contactId1:id1,$contactId2:id2} |";
generate(dom, wikitext);
});
+ it("hashtable with variable", function() {
+ var dom = element("table",
+ element("tbody",
+ element("tr",
+ element("td", " test "),
+ element("td", " ", element("tt", { class: "hashtable" }, "$contactId1:${ID1},$contactId2:id2"), " "))));
+
+ var wikitext = "| test | !{$contactId1:${ID1},$contactId2:id2} |";
+ generate(dom, wikitext);
+ });
it("bold italic", function() {
var dom = element("p", element("b", element("i", "bold italic")));
View
12 src/fitnesse/resources/wysiwyg/wysiwyg.js
@@ -1575,7 +1575,8 @@ Wysiwyg.prototype.selectionChanged = function () {
wikiInlineRules.push("![-<{(\\[]"); // 7. escaped (open)
wikiInlineRules.push("[->)\\]]!|\\}"); // 8. escaped (close)
wikiInlineRules.push(_wikiTextLink); // 9. Wiki link
- wikiInlineRules.push(_wikiPageName); // 10. WikiPageName
+ wikiInlineRules.push(_wikiPageName); // 10. WikiPage name
+ wikiInlineRules.push("\\${[^}]+}"); // 11. Variable
var wikiRules = [];
// -1. header
@@ -1924,6 +1925,10 @@ Wysiwyg.prototype.wikitextToFragment = function (wikitext, contentDocument) {
}
}
+ function handleVariable(value) {
+ holder.appendChild(contentDocument.createTextNode(matchText));
+ }
+
function handleList(value) {
var match = /^(\s*)([*1-9-])\s/.exec(value);
var className, depth, start;
@@ -2246,10 +2251,13 @@ Wysiwyg.prototype.wikitextToFragment = function (wikitext, contentDocument) {
if (inEscapedTable() || inEscapedText() || inCodeBlock()) { break; }
handleLinks(matchText);
continue;
- case 10: // WikiPageName
+ case 10: // WikiPage name
if (inEscapedTable() || inEscapedText() || inCodeBlock()) { break; }
handleWikiPageName(matchText);
continue;
+ case 11: // Variable
+ handleVariable(matchText);
+ continue;
case -1: // header
currentHeader = handleHeader(matchText);
if (currentHeader) {

0 comments on commit d44f65f

Please sign in to comment.