1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Remarkup - add a quote button

Summary: Fixes T7696.

Test Plan: hit the quote button with no text - it worked. highlighted some text and hit the quote button - it worked. hit the list item button with no text - it worked. hit the list item button with text selected - it worked

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7696

Differential Revision: https://secure.phabricator.com/D13060
This commit is contained in:
Bob Trahan 2015-05-28 15:28:59 -07:00
parent c61b5440e1
commit b2d003d025
3 changed files with 34 additions and 19 deletions

View file

@ -8,7 +8,7 @@
return array(
'names' => array(
'core.pkg.css' => '97a49e3e',
'core.pkg.js' => '0e261ea7',
'core.pkg.js' => 'a5ed8c89',
'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => '30602b8c',
'differential.pkg.js' => '8c98ce21',
@ -459,7 +459,7 @@ return array(
'rsrc/js/core/behavior-object-selector.js' => '49b73b36',
'rsrc/js/core/behavior-oncopy.js' => '2926fff2',
'rsrc/js/core/behavior-phabricator-nav.js' => '14d7a8b8',
'rsrc/js/core/behavior-phabricator-remarkup-assist.js' => 'e32d14ab',
'rsrc/js/core/behavior-phabricator-remarkup-assist.js' => '095ed313',
'rsrc/js/core/behavior-refresh-csrf.js' => '7814b593',
'rsrc/js/core/behavior-remarkup-preview.js' => 'f7379f45',
'rsrc/js/core/behavior-reorder-applications.js' => '76b9fc3e',
@ -610,7 +610,7 @@ return array(
'javelin-behavior-phabricator-notification-example' => '8ce821c5',
'javelin-behavior-phabricator-object-selector' => '49b73b36',
'javelin-behavior-phabricator-oncopy' => '2926fff2',
'javelin-behavior-phabricator-remarkup-assist' => 'e32d14ab',
'javelin-behavior-phabricator-remarkup-assist' => '095ed313',
'javelin-behavior-phabricator-reveal-content' => '60821bc7',
'javelin-behavior-phabricator-search-typeahead' => '048330fa',
'javelin-behavior-phabricator-show-older-transactions' => 'dbbf48b6',
@ -883,6 +883,15 @@ return array(
'javelin-stratcom',
'javelin-vector',
),
'095ed313' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'phabricator-phtize',
'phabricator-textareautils',
'javelin-workflow',
'javelin-vector',
),
'0a3f3021' => array(
'javelin-behavior',
'javelin-stratcom',
@ -1903,15 +1912,6 @@ return array(
'e292eaf4' => array(
'javelin-install',
),
'e32d14ab' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'phabricator-phtize',
'phabricator-textareautils',
'javelin-workflow',
'javelin-vector',
),
'e379b58e' => array(
'javelin-behavior',
'javelin-stratcom',

View file

@ -48,6 +48,7 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
'italic text' => pht('italic text'),
'monospaced text' => pht('monospaced text'),
'List Item' => pht('List Item'),
'Quoted Text' => pht('Quoted Text'),
'data' => pht('data'),
'name' => pht('name'),
'URL' => pht('URL'),
@ -80,6 +81,9 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
'fa-code' => array(
'tip' => pht('Code Block'),
),
'fa-quote-right' => array(
'tip' => pht('Quote'),
),
'fa-table' => array(
'tip' => pht('Table'),
),

View file

@ -93,12 +93,23 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
range.start + l.length + m.length);
}
function prepend_char_to_lines(ch, sel, def) {
if (sel) {
sel = sel.split('\n');
} else {
sel = [def];
}
sel = sel.join('\n' + ch);
return sel;
}
function assist(area, action, root) {
// If the user has some text selected, we'll try to use that (for example,
// if they have a word selected and want to bold it). Otherwise we'll insert
// generic text.
var sel = JX.TextAreaUtils.getSelectionText(area);
var r = JX.TextAreaUtils.getSelectionRange(area);
var ch;
switch (action) {
case 'fa-bold':
@ -120,13 +131,8 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
break;
case 'fa-list-ul':
case 'fa-list-ol':
var ch = (action == 'fa-list-ol') ? ' # ' : ' - ';
if (sel) {
sel = sel.split('\n');
} else {
sel = [pht('List Item')];
}
sel = sel.join('\n' + ch);
ch = (action == 'fa-list-ol') ? ' # ' : ' - ';
sel = prepend_char_to_lines(ch, sel, pht('List Item'));
update(area, ((r.start === 0) ? '' : '\n\n') + ch, sel, '\n\n');
break;
case 'fa-code':
@ -134,6 +140,11 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
var code_prefix = (r.start === 0) ? '' : '\n';
update(area, code_prefix + '```\n', sel, '\n```');
break;
case 'fa-quote-right':
ch = '> ';
sel = prepend_char_to_lines(ch, sel, pht('Quoted Text'));
update(area, ((r.start === 0) ? '' : '\n\n') + ch, sel, '\n\n');
break;
case 'fa-table':
var table_prefix = (r.start === 0 ? '' : '\n\n');
update(area, table_prefix + '| ', sel || pht('data'), ' |');