Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions jspwiki-main/src/main/javascript/Wiki.Snips.JSPWiki.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {

Expand Down Expand Up @@ -666,4 +669,4 @@ Wiki.Snips = {
};
window.addEventListener("load", function() {
Wiki.Snips.loadPlugins();
});
});
9 changes: 6 additions & 3 deletions jspwiki-markdown/src/main/javascript/Wiki.Snips.Markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {

Expand Down Expand Up @@ -656,4 +659,4 @@ Wiki.Snips = {

window.addEventListener("load", function() {
Wiki.Snips.loadPlugins();
});
});
10 changes: 10 additions & 0 deletions jspwiki-war/src/main/scripts/wiki-edit/Snipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ){

Expand Down