Action

Double space

Posted by dchar, Last update over 6 years ago

Double space a draft or a selection.

Steps

  • script

    // double space
    
    (() => {
    
      const getLines = () => {
        const e = editor;
        const t =
          e.getSelectedRange()[1] > 0 ?
          e.getTextInRange(...e.getSelectedLineRange()) :
          e.getText();
        return t.split('\n');
      };
    
      const setLines = (l) => {
        const t = l.join('\n') + '\n';
        const e = editor;
        if (e.getSelectedRange()[1] > 0) {
          const sel = e.getSelectedLineRange();
          e.setTextInRange(...sel, t);
          e.setSelectedRange(sel[0], t.length);
        } else {
          e.setText(t);
        }
      };
    
      const double = (l) => {
        return l.filter(l => l.trim())
          .reduce((xs, l) => { xs.push(l, ''); return xs; }, []);
      };
    
      setLines(double(getLines()));
    
    })();

Options

  • After Success Nothing
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.