WYSIWYG Markdown Editor

Edits Markdown visually and saves plain Markdown files. It runs inside StandaloneEditor with the flavour WYSIWYGMarkDown, in the same way as the Simple HTML and Markdown editors. Open any file with ?pageName=/Some/Page&fileName=notes.md.

Views

A file that is opened and saved without visual edits is saved exactly as it was written. Visual edits regenerate the Markdown in a standard layout (see below). If a file contains something visual editing would change, a warning says so when it opens and again on the first visual edit. Use Source to edit such files safely.

Supported Markdown

CommonMark plus GitHub-style tables and strikethrough, rendered with markdown-it and written back with turndown (see /OpenForum/Javascript/MarkDown).

FeatureWritten as
Headings 1 to 4# Heading to #### Heading
Bold, italic, strikethrough, inline code**bold**, *italic*, ~~struck~~, `code`
Lists, nested lists- item, 1. item, nested items indented to match
Links and images[text](url), ![alt text](url)
Quotes and rules> quote, ---
Code blocksFenced with three backticks and an optional language
TablesGitHub tables with a header row; a line break inside a cell is kept as <br>
HTML commentsKept as they are
kbd, sup, sub, u, mark, ins, abbr, details, summary, iframe, video, audioKept as HTML, since Markdown has no syntax for them

Not supported in the visual view: footnotes (they become plain text), and other raw HTML, which is simplified to its Markdown equivalent. Images that are uploaded or pasted are stored inside the file as data URLs.

Pasting from Word, Google Docs or web pages converts the content to Markdown. Colours, fonts and layout are removed, and a note says so. Pasting into a code block always pastes plain text.

Keyboard shortcuts

KeysAction
Ctrl+B, Ctrl+I, Ctrl+Shift+X, Ctrl+EBold, italic, strikethrough, inline code
Ctrl+Alt+1 to 4Heading level 1 to 4 (press again to remove)
Ctrl+Shift+8, Ctrl+Shift+7, Ctrl+Shift+9Bullet list, numbered list, quote
Ctrl+KInsert or edit a link
Ctrl+Z, Ctrl+Y or Ctrl+Shift+ZUndo, redo
Tab, Shift+TabNext or previous table cell (Tab in the last cell adds a row)
Ctrl+EnterStart a new paragraph after a code block, table or quote
Arrow keys, Home, EndMove along the toolbar when it has focus; Escape returns to the text

Embedding in your own app

Embed the editor with StandaloneEditor, as the Journal does with the Simple HTML editor. A working example with its own interface, autosave and a word count is at /OpenForum/Editor/Editors/WYSIWYGMarkDownEditor/Example.

OpenForum.includeScript("/OpenForum/Editor/Editors/StandaloneEditor.js");

var myEditor = new StandaloneEditor({
  flavour: "WYSIWYGMarkDown",
  elementId: "MyEditorHost",
  editingPageName: "/MyApp/Notes",
  editingFileName: "notes.md",
  editorPage: "/MyApp/",
  ui: "/MyApp/my-editor-ui.html.fragment",
  autoSave: true,
  canSetPageTitle: false
});
OptionUse
flavourWYSIWYGMarkDown
elementIdThe element the editor is placed in.
editingPageName, editingFileNameThe file to edit.
editorPageAlways set this to your own page. Without it, StandaloneEditor reopens the last file edited with this flavour on any page in the browser, ignoring editingPageName and editingFileName, and autosave then writes to that file.
uiYour own page fragment instead of the standard File, Desktop and Actions bar. It must contain an element with id="editor&editorId;". Copy the confirmRetrieveModal from the example too: without it, unsaved changes kept in the browser can't be offered back after a crash or reload. In the fragment, &editor; is replaced with the editor object, for example for a Save button.
autoSaveSaves every 10 seconds while there are changes. This is one page-wide setting shared by every StandaloneEditor on the page.
canSetPageTitleSet to false so the browser tab title isn't changed.
editorsPageOnly for testing a Development copy of the editor: where editor scripts are loaded from.