EditHelp

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

Note: a feature based on this recipe was included in the PmWiki core in version 2.2.119, and can be enabled in config.php with this line:
$EnableEditAutoText = 1;
If you enable the core feature, please disable the current recipe.

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:

  • Ctrl+I : italic text (wraps the selection in double apostrophes)
  • Ctrl+B : bold text (wraps the selection in triple apostrophes)
  • Ctrl+K : link/unlink (if there are any double brackets in the selection, removes them, otherwise wraps the selection in double brackets)
  • 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
  • Ctrl+L : convert selection to lowercase
  • Ctrl+Shift+L : convert selection to uppercase
  • Ctrl+Shift+ArrowUp : move current line or selected lines up
  • Ctrl+Shift+ArrowDown : move current line or selected lines down

Demo: the recipe is enabled on any page on pmwiki.org, you can test it for example in Main.WikiSandbox.

These edit help functions were first written for a "Structured sections editor" recipe in February 2016 (currently abandoned), 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

For PmWiki 2.2.119 or newer, add to config.php:
$EnableEditAutoText = 1;

Older PmWiki versions (only an older version is available):

  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, retype Enter, or 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

  • 20191003 added to PmWiki 2.2.119. For subsequent updates please see ChangeLog.
  • 20160317 First public release, ready to be tested.

See also

  • PmSyntax (Syntax highlighting for the PmWiki documentation and edit form) is compatible with this recipe.
  • 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.
  • Worse (is better) Simple WYSIWYG editing for PmWiki

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.