Changeset 2759
- Timestamp:
- 11/08/07 04:27:23 (1 year ago)
- Files:
-
- tracwysiwygplugin/0.10/tests (added)
- tracwysiwygplugin/0.10/tests/index.html (added)
- tracwysiwygplugin/0.10/tests/testcase.js (added)
- tracwysiwygplugin/0.10/tests/testunit.js (added)
- tracwysiwygplugin/0.10/tests/trac.js (added)
- tracwysiwygplugin/0.10/tracwysiwyg/htdocs/wysiwyg.js (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tracwysiwygplugin/0.10/tracwysiwyg/htdocs/wysiwyg.js
r2732 r2759 5 5 this.textarea = textarea; 6 6 var wikitextToolbar = textarea.previousSibling; 7 if (wikitextToolbar .nodeType != 1 || wikitextToolbar.className != "wikitoolbar") {7 if (wikitextToolbar && (wikitextToolbar.nodeType != 1 || wikitextToolbar.className != "wikitoolbar")) { 8 8 wikitextToolbar = null; 9 9 } … … 1200 1200 } 1201 1201 1202 function handleWikiPageName( value) {1203 createAnchor("wiki:" + value, value);1202 function handleWikiPageName(name, label) { 1203 createAnchor("wiki:" + name, label || name); 1204 1204 } 1205 1205 … … 1608 1608 continue; 1609 1609 case 18: // ["internal free link"] 1610 handleWikiPageName(matchText.slice(1, -1) );1610 handleWikiPageName(matchText.slice(1, -1), matchText.slice(2, -2)); 1611 1611 continue; 1612 1612 case 19: // citation … … 1632 1632 continue; 1633 1633 } 1634 matchText = matchText.replace(/^\s+/, " "); 1634 1635 break; 1635 1636 case 24: // opening table row … … 1657 1658 var tmp; 1658 1659 if (matchFirstIndex == 16) { 1659 tmp = matchText.toLowerCase() == "[[br]]" 1660 ? contentDocument.createElement("br") 1660 tmp = /^!?\[\[br\]\]$/i.test(matchText) 1661 ? (matchText.charCodeAt(0) == 0x21 1662 ? contentDocument.createTextNode(matchText.substring(1)) 1663 : contentDocument.createElement("br")) 1661 1664 : contentDocument.createTextNode(matchText); 1662 1665 } … … 1696 1699 "dl": true, 1697 1700 "dt": " ", 1698 "dd": " ",1701 "dd": " ", 1699 1702 "table": true, 1700 1703 "tbody": true, … … 1716 1719 "hr": true, 1717 1720 "dl": "\n", 1718 "dt": ":: \n",1721 "dt": "::", 1719 1722 "dd": "\n", 1720 1723 "table": "\n", … … 1754 1757 1755 1758 function escapeText(s) { 1756 if (/^!?\[\[/.test(s) && /\]\]$/.test(s)) { 1757 return s != "[[BR]]" ? s : "!" + s; 1759 var match = /^!?\[\[(.+)\]\]$/.exec(s); 1760 if (match) { 1761 return match[1].toLowerCase() != "br" ? s : "!" + s; 1758 1762 } 1759 1763 if (/^&#\d+/.test(s)) { … … 1927 1931 switch (match[1]) { 1928 1932 case "changeset": 1929 usingValue = value == "[" + match[2] + "]" 1930 || /^\d+$/.test(match[2]) && value == "r" + match[2]; 1933 usingValue = value == "[" + match[2] + "]"; 1931 1934 break; 1932 1935 case "log": 1933 usingValue = value == "[" + match[3] + "]" || value == "r" + match[3];1936 usingValue = value == "[" + match[3] + "]"; 1934 1937 break; 1935 1938 case "report": … … 1949 1952 } 1950 1953 if (text === null) { 1951 if (!/ [\]\"\']/.test(value)) {1954 if (!/\]/.test(value) && !/^[\"\']/.test(value)) { 1952 1955 text = "[" + link + " " + value + "]"; 1953 1956 } … … 2019 2022 if ((container.tagName || "").toLowerCase() == "ol") { 2020 2023 var start = container.getAttribute("start") || ""; 2021 if ( /^(?:[0-9]+|[a-zA-Z]|[ivxIVX]{1,5})$/.test(start)) {2024 if (start != "1" && /^(?:[0-9]+|[a-zA-Z]|[ivxIVX]{1,5})$/.test(start)) { 2022 2025 texts.push(start, ". "); 2023 2026 } … … 2066 2069 break; 2067 2070 case "pre": 2068 if (isInlineNode(node.previousSibling)) { 2069 texts.push("\n"); 2070 } 2071 texts.push(/^(?:li|dd)$/i.test(node.parentNode.tagName) ? "\n{{{\n" : "{{{\n"); 2071 texts.push( 2072 /^(?:li|dd)$/i.test(node.parentNode.tagName) || isInlineNode(node.previousSibling) 2073 ? "\n{{{\n" : "{{{\n"); 2072 2074 needEscape = false; 2073 2075 inCodeBlock = true; … … 2172 2174 } 2173 2175 if (text.slice(-1) == "\n") { 2174 text += listDepth > 0 ? string(" ", listDepth + 1) : " ";2176 text += listDepth > 0 ? string(" ", listDepth) : " "; 2175 2177 } 2176 2178 }
