allura-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Brondsema" <d...@brondsema.net>
Subject [allura:tickets] #7983 In editor, pasting should be auto-wrapped
Date Fri, 04 Sep 2015 14:24:45 GMT



---

** [tickets:#7983] In editor, pasting should be auto-wrapped**

**Status:** open
**Milestone:** unreleased
**Labels:** markdown-editor ux 
**Created:** Fri Sep 04, 2015 02:24 PM UTC by Dave Brondsema
**Last Updated:** Fri Sep 04, 2015 02:24 PM UTC
**Owner:** nobody


When pasting a large chunk of text into the markdown editor, it often would be useful to automatically
wrap it with `~~~~` or indent it.  People who paste code snippets or log lines would benefit
from this, especially if they are not familiar with markdown and don't realize it needs to
be in a code block to avoid `__foo__` from getting formatted etc.  I think this would help
alleviate problems expressed in https://sourceforge.net/p/forge/feature-requests/134/

However, that won't be appropriate all the time, since some people could paste large amounts
of regular text or even markdown formatting (e.g. restructuring a wiki page).  Turning it
into a code block won't be helpful.  We'll need some sort of UI to make this work well.  I
am thinking that we show a notification after it happens, and tell the user how they can click
the code snippet button to undo it.  We can also save a cookie/sessionStorage setting to not
do it again. 

Here's an autoindent snippet proof-of-concept:

~~~~
cm = editor.codemirror;

// based on https://github.com/codemirror/CodeMirror/issues/2120
cm.on("change", function(cm, change) {
  if (change.origin != "paste" || change.text.length < 2) {
    return;
  }
  var spaces = cm.options.tabSize;
  cm.operation(function() {
    for (var line = change.from.line, end = CodeMirror.changeEnd(change).line; line <=
end; ++line) {
      cm.indentLine(line, spaces);
    }
  });
});
~~~~


---

Sent from forge-allura.apache.org because dev@allura.apache.org is subscribed to https://forge-allura.apache.org/p/allura/tickets/

To unsubscribe from further messages, a project admin can change settings at https://forge-allura.apache.org/p/allura/admin/tickets/options.
 Or, if this is a mailing list, you can unsubscribe from the mailing list.
Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message