Skip to content

Instantly share code, notes, and snippets.

@rohinomiya
Created October 20, 2014 23:57
Show Gist options
  • Save rohinomiya/e98a801f357a21cae2cd to your computer and use it in GitHub Desktop.
Save rohinomiya/e98a801f357a21cae2cd to your computer and use it in GitHub Desktop.
Textwell_expandselection.js
var next_action = null;
// next_action = 'tweet';
var text = T.text;
var pattern = '\n';
var j = text.indexOf(pattern, T.range.loc + T.range.len );
var i = text.lastIndexOf(pattern, T.range.loc - 1);
i = (i === -1) ? 0 : i + pattern.length;
j = (j === -1) ? text.length : j + 1;
T('replaceRange', {
text: text,
replacingRange: {
loc: 0,
len: text.length
},
selectingRange: {
loc: i,
len: j - i
},
nextAction: next_action
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment