EditHelp

Summary: Easier editing with automatic detection and insertion of some wiki markups
Version: 20160317
Prerequisites: JavaScript, recent browser
Status: Experimental
Maintainer: Petko
License: Attribution
Categories: Editing, PHP55, PHP72
Users: (view? / edit)
Discussion: EditHelp-Talk

Description

The recipe enables automatic insertion of some start-of-line wiki markups.

When a user writes wiki markup, a bulleted list is entered with the sign * before the line. When the user presses "Enter/Return", the script will examine the line and if it starts with *, it will automatically insert a * before the new line, similar to how office suites insert list items. This way the user needs to simply type the text of the new list item.

In a similar fashion, the following start-of-line markups are recognized and re-inserted automatically when the user presses "Enter":

  • *, **, ***, ... unordered/bulleted list
  • #, ##, ###, ... numbered list
  • : definition list
  •   (space) preformatted text
  • ->, -->, -<, --<, ... indented and hanging text
  • || simple table row

The above automatic insertions are particularly useful on touch screen devices where it is more difficult to type punctuation.

Additionally, the following keyboard shortcuts might be appreciated by advanced editors with full keyboards:

  • Shift+Enter : \\ line break (press and hold down the "Shift" key, press "Enter", then release "Enter" and release "Shift")
  • Ctrl+Enter : [[<<]] line break "clear"
  • Ctrl+Shift+Enter : ~~~~ author's signature

Demo: the recipe is enabled on this page, on the Talk page, and on the Users? page.

These edit help functions were first written for a "Structured sections editor" recipe in February 2016 (currently under development/testing), but felt so natural and easy to use (a user described them as "exhilarating/addictive"), that I decided to port them to the regular PmWiki text editor. Enjoy!

Installation

  1. Place edithelp.js in your pmwiki/pub directory.
  2. Add to local/(farm)config.php such a line:
      if($action == 'edit') 
        $HTMLFooterFmt['edithelp'] = '<script type="text/javascript" src="$FarmPubDirUrl/edithelp.js"></script>';

Configuration

Nothing can be configured at the moment.

Usage

In a wiki page, when editing a list item, a definition list, an indented/hanging text, or a simple table, press Enter/Return. The start-of-line markup will re-appear automatically on the new line.

If the markup from the previous line should not be repeated, simply delete it from the new line (backspace key) and type your text.

Notes

  • A recent browser with JavaScript enabled is needed for the recipe to work.
  • The recipe is likely incompatible with CodeMirror or with any of the WYSIWYG attempts.

Change log / Release notes

  • 20160317 First public release, ready to be tested.

See also

  • The CodeMirror recipe also provides automatic insertion of list items, and more. Unfortunately, middle-click-paste does not work with it so I cannot use it.

Contributors

Recipe written and maintained by Petko.

Comments

See discussion at EditHelp-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.