diff options
Diffstat (limited to 'pub')
-rw-r--r-- | pub/guiedit/pmwiki.syntax.css | 3 | ||||
-rw-r--r-- | pub/guiedit/pmwiki.syntax.js | 4 | ||||
-rw-r--r-- | pub/pmwiki-utils.js | 48 | ||||
-rw-r--r-- | pub/skins/pmwiki-responsive/skin.php | 26 |
4 files changed, 54 insertions, 27 deletions
diff --git a/pub/guiedit/pmwiki.syntax.css b/pub/guiedit/pmwiki.syntax.css index 9a3066f3..e1b641dd 100644 --- a/pub/guiedit/pmwiki.syntax.css +++ b/pub/guiedit/pmwiki.syntax.css @@ -252,6 +252,9 @@ code.pmhlt, .pmhlt code, #htext.pmhlt { word-wrap: break-word; overflow-wrap: break-word; } +#wikiedit #htext * { + line-height: var(--pmsyntax-lineheight); +} #wikiedit #hwrap #htext { display: none; position: absolute; diff --git a/pub/guiedit/pmwiki.syntax.js b/pub/guiedit/pmwiki.syntax.js index 3dbd65a2..57d0f09a 100644 --- a/pub/guiedit/pmwiki.syntax.js +++ b/pub/guiedit/pmwiki.syntax.js @@ -92,7 +92,7 @@ // directives, forms ['form', '!directive>keyword', /(\(:input[^\S\r\n]+)(\S.*?)(:\))/g, - /^((pm)?form|text(area)?|radio|checkbox|select|email|tel|number|defaults?|submit|reset|hidden|password|search|url|date|month|color|datalist|file|image|reset|button|e_\w+|captcha|pmtoken|end)/], + /^((pm)?form|text(area)?|radio|checkbox|select|email|tel|number|defaults?|submit|reset|hidden|password|search|url|date|month|color|datalist|file|image|reset|button|e_\w+|captcha|pmtoken|end|star)/], ['dir0', '*directive', /\(:\w[-\w]* *:\)/g], // simple ['dir1', '!directive', /(\(:\w[-\w]*)(.*?)(:\))/g], // with attributes @@ -112,6 +112,8 @@ // simple tables ['tablecapt', '=table', /^(\|\|!)(.+)(!\|\|)$/mg], + ['tablerwsp1', 'table', /(\+\++)(?=\s*\|\|)/g], + ['tablerwsp2', 'escaped', /\|\|(__+|\^\^+)(?=\|\|)/g, /([_^]+)/], ['tablerow', '!table', /^\|\|.*\|\|.*$/mg, /((?:\|\|)+)(!?)/g], ['tableattr', '!table', /^(\|\|)(.*)($)/mg], diff --git a/pub/pmwiki-utils.js b/pub/pmwiki-utils.js index c15dab6e..0dd8c371 100644 --- a/pub/pmwiki-utils.js +++ b/pub/pmwiki-utils.js @@ -28,6 +28,7 @@ function aE(el, ev, fn) { if(typeof el == 'string') el = dqsa(el); + else if(el instanceof Element) el = [el]; for(var i=0; i<el.length; i++) el[i].addEventListener(ev, fn); } function dqs(str) { return document.querySelector(str); } @@ -36,10 +37,14 @@ function tap(q, fn) { aE(q, 'click', fn); }; function pf(x) {var y = parseFloat(x); return isNaN(y)? 0:y; } function zpad(n) {return (n<10)?"0"+n : n; } - function adjbb(el, html) { el.insertAdjacentHTML('beforebegin', html); } - function adjbe(el, html) { el.insertAdjacentHTML('beforeend', html); } - function adjab(el, html) { el.insertAdjacentHTML('afterbegin', html); } - function adjae(el, html) { el.insertAdjacentHTML('afterend', html); } + function adjany(el, where, what) { + if(what instanceof Element) el.insertAdjacentElement(where, what); + else el.insertAdjacentHTML(where, what); + } + function adjbb(el, what) { adjany(el, 'beforebegin', what); } + function adjbe(el, what) { adjany(el, 'beforeend', what); } + function adjab(el, what) { adjany(el, 'afterbegin', what); } + function adjae(el, what) { adjany(el, 'afterend', what); } function getLS(key, parse) { try { var x = window.localStorage.getItem(key)|| null; @@ -615,12 +620,12 @@ Dropzone.pmareq = areq; } - form.insertAdjacentElement('afterbegin', Dropzone); - aE([Dropzone], 'dragenter', dragenter); - aE([Dropzone], 'dragover', dragenter); - aE([Dropzone], 'dragleave', dragleave); - aE([Dropzone], 'drop', dragdrop); - tap([Dropzone], clickzone); + adjab(form, Dropzone); + aE(Dropzone, 'dragenter', dragenter); + aE(Dropzone, 'dragover', dragenter); + aE(Dropzone, 'dragleave', dragleave); + aE(Dropzone, 'drop', dragdrop); + tap(Dropzone, clickzone); } async function postUpload(file) { @@ -752,11 +757,32 @@ Dropzone.appendChild(a); } + function makeDraggable(par) { + var children = par.children; + if(children.length<2) return; + for(var i=0; i<children.length; i++) { + var child = children[i]; + child.draggable = true; + } + par.style.cursor = "move"; + aE(par, 'dragstart', function(e){ this.dragged_element = e.target; }); + aE(par, 'dragover', function(e){e.preventDefault();}); + aE(par, 'drop', function(e){ + var c = [...this.children], d = this.dragged_element, t = e.target; + if(!d || d==t) return; + var b = c.indexOf(t) < c.indexOf(d) ? t : t.nextSibling; + this.insertBefore(d, b); + }); + } + function init_draggable() { + var els = dqsa('.draggable'); + for(var el of els) makeDraggable(el); + } function ready(){ wikitext = document.getElementById('wikitext'); var fn = [autotoc, inittoggle, PmXMail, localTimes, - highlight_pre, copy_pre, confirmForms, init_dropzone]; + highlight_pre, copy_pre, confirmForms, init_dropzone, init_draggable]; fn.forEach(function(a){a();}); makesortable(); } diff --git a/pub/skins/pmwiki-responsive/skin.php b/pub/skins/pmwiki-responsive/skin.php index 698631be..52e6c389 100644 --- a/pub/skins/pmwiki-responsive/skin.php +++ b/pub/skins/pmwiki-responsive/skin.php @@ -26,20 +26,6 @@ SDV($EnableDarkThemeToggle, 3); # For (:searchbox:), valid semantic HTML5 $SearchBoxInputType = "search"; -# remove deprecated "name=" parameter from anchor tags -if($GLOBALS['VersionNum'] < 2002056) { - # we want the skin to also work with older PmWiki versions - Markup('[[#','<[[','/(?>\\[\\[#([A-Za-z][-.:\\w]*))\\]\\]/e', - "Keep(TrackAnchors('$1') ? '' : \"<a id='$1'></a>\", 'L')"); -} -else { - Markup('[[#','<[[','/(?>\\[\\[#([A-Za-z][-.:\\w]*))\\]\\]/', - "MarkupKeepTrackAnchors"); -} -function MarkupKeepTrackAnchors($m) { - return Keep(TrackAnchors($m[1]) ? '' : "<a id='{$m[1]}'></a>", 'L'); -} - # in HTML5 "clear" is a style not an attribute Markup('[[<<]]','inline','/\\[\\[<<\\]\\]/',"<br class='clearboth' />"); @@ -76,9 +62,19 @@ function SkinFmt($pagename, $args) { return; # Section was disabled by (:noheader:) or (:nofooter:) } + static $pagecache = array(); foreach($args as $p) { $pn = FmtPageName($p, $pagename); - $elm = RetrieveAuthSection($pn, "$section{$section}end"); + if(! isset($pagecache[$pn])) { + $page = RAPC($pn); + $pagecache[$pn] = strval(@$page['text']); + } + if($pagecache[$pn] == "") continue; + $rx = "/\\[\\[$section\\]\\](?: *\n+)?(.*?)\\s*\\[\\[{$section}end\\]\\]/s"; + if(preg_match($rx, $pagecache[$pn], $m)) { + $elm = $m[1]; + } + else continue; if(!$elm) continue; $html = MarkupToHTML($pagename, Qualify($pn, $elm)); |