From df2c055695e946d4e12d85398adcdbc58c2fce32 Mon Sep 17 00:00:00 2001 From: Ulf Dittmer <34645700+udittmer@users.noreply.github.com> Date: Mon, 14 Sep 2026 10:35:43 +0200 Subject: [PATCH 1/3] Refine link suggestion regex patterns Updated regex patterns for link suggestions to improve matching behavior. --- jspwiki-main/src/main/javascript/Wiki.Snips.JSPWiki.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jspwiki-main/src/main/javascript/Wiki.Snips.JSPWiki.js b/jspwiki-main/src/main/javascript/Wiki.Snips.JSPWiki.js index 23b9b4e38a..58ffd64853 100644 --- a/jspwiki-main/src/main/javascript/Wiki.Snips.JSPWiki.js +++ b/jspwiki-main/src/main/javascript/Wiki.Snips.JSPWiki.js @@ -397,9 +397,12 @@ Wiki.Snips = { linkPart3:{ + // Dialog must open after the second "|" even when "]" is not typed yet. + // Prefer matching up to "]" when present (attributes may contain spaces); + // otherwise only match non-whitespace so prose after the caret is not swallowed. suggest: { - lback: "\\[(?:[^\\|\\]]+\\|[^\\|\\]]+\\|)([^\\|\\[\\]\\n\\r]*)$", - match: "^[^\\|\\]\\n\\r]*" + lback: "\\[(?:[^\\|\\]]+\\|[^\\|\\]]+\\|)([^\\|\\[\\]\\n\\r]*)$", + match: "^(?:[^\\|\\[\\]\\n\\r]*(?=\\])|[^\\|\\[\\]\\n\\r\\s]*)" }, linkPart3: [ Dialog.Selection, { @@ -666,4 +669,4 @@ Wiki.Snips = { }; window.addEventListener("load", function() { Wiki.Snips.loadPlugins(); -}); \ No newline at end of file +}); From 83a4f4f612832d7807e30c70b4e869c92ffa3481 Mon Sep 17 00:00:00 2001 From: Ulf Dittmer <34645700+udittmer@users.noreply.github.com> Date: Mon, 14 Sep 2026 10:37:19 +0200 Subject: [PATCH 2/3] Refine regex for linkPart3 suggestions Update regex patterns for link suggestions to improve matching behavior. --- .../src/main/javascript/Wiki.Snips.Markdown.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jspwiki-markdown/src/main/javascript/Wiki.Snips.Markdown.js b/jspwiki-markdown/src/main/javascript/Wiki.Snips.Markdown.js index 94ccd7a0bd..b43e0d9025 100644 --- a/jspwiki-markdown/src/main/javascript/Wiki.Snips.Markdown.js +++ b/jspwiki-markdown/src/main/javascript/Wiki.Snips.Markdown.js @@ -397,9 +397,12 @@ Wiki.Snips = { linkPart3:{ + // Dialog must open after the second "|" even when "]" is not typed yet. + // Prefer matching up to "]" when present (attributes may contain spaces); + // otherwise only match non-whitespace so prose after the caret is not swallowed. suggest: { - lback: "\\[(?:[^\\|\\]]+\\|[^\\|\\]]+\\|)([^\\|\\[\\]\\n\\r]*)$", - match: "^[^\\|\\]\\n\\r]*" + lback: "\\[(?:[^\\|\\]]+\\|[^\\|\\]]+\\|)([^\\|\\[\\]\\n\\r]*)$", + match: "^(?:[^\\|\\[\\]\\n\\r]*(?=\\])|[^\\|\\[\\]\\n\\r\\s]*)" }, linkPart3: [ Dialog.Selection, { @@ -656,4 +659,4 @@ Wiki.Snips = { window.addEventListener("load", function() { Wiki.Snips.loadPlugins(); -}); \ No newline at end of file +}); From 7f54fa0b3aa5f9120aeda031e960f01975557814 Mon Sep 17 00:00:00 2001 From: Ulf Dittmer <34645700+udittmer@users.noreply.github.com> Date: Mon, 14 Sep 2026 10:38:59 +0200 Subject: [PATCH 3/3] Add link snippets for 'more' and 'class' in Snipe.js Added new link snippets for 'more' and 'class' in Snipe.js. --- jspwiki-war/src/main/scripts/wiki-edit/Snipe.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/jspwiki-war/src/main/scripts/wiki-edit/Snipe.js b/jspwiki-war/src/main/scripts/wiki-edit/Snipe.js index ee4edb132f..f6369e9f03 100644 --- a/jspwiki-war/src/main/scripts/wiki-edit/Snipe.js +++ b/jspwiki-war/src/main/scripts/wiki-edit/Snipe.js @@ -763,12 +763,22 @@ var Snipe = new Class({ Selection will become "test", and snippet will become "wiki-page" [te$st] => lback = "te", match = "test", snippet ="team-page" Selection will become "st", and snippet will become "am-page" + [link|url|$ more] => lback = "", match = "", snippet = "target='_blank'" + Inserts at the caret; " more" is kept + [link|url|cla$ more] => lback = "cla", match = "cla", snippet = "class='viewer'" + Replaces only "cla"; " more" is kept */ suggestAction: function( txta, snippet, lback, match){ var start = txta.getSelectionRange().start, len = match.length; + // If the forward match stopped early (e.g. at whitespace) but the user + // already typed more in the look-back, replace the whole look-back. + if( len < lback.length ){ + len = lback.length; + } + //console.log("Snipe:suggestAction ",snippet,lback,match ); if( snippet.startsWith( lback ) ){