MCPcopy
hub / github.com/OscarGodson/EpicEditor

github.com/OscarGodson/EpicEditor @0.2.3 sqlite

repository ↗ · DeepWiki ↗ · release 0.2.3 ↗
144 symbols 382 edges 30 files 33 documented · 23%
README

EpicEditor

An Embeddable JavaScript Markdown Editor

EpicEditor is an embeddable JavaScript Markdown editor with split fullscreen editing, live previewing, automatic draft saving, offline support, and more. For developers, it offers a robust API, can be easily themed, and allows you to swap out the bundled Markdown parser with anything you throw at it.

Why

Because, WYSIWYGs suck. Markdown is quickly becoming the replacement. GitHub, Stackoverflow, and even blogging apps like Posterous are now supporting Markdown. EpicEditor allows you to create a Markdown editor with a single line of JavaScript:

var editor = new EpicEditor().load();

Quick Start

EpicEditor is easy to implement. Add the script and assets to your page, provide a target container and call load().

Step 1: Download

Download the latest release or clone the repo:

$ git clone git@github.com:OscarGodson/EpicEditor

Step 2: Create your container element






Alternately, wrap an existing textarea to load the contents into th EpicEditor instance.



<textarea id="my-edit-area"></textarea>


Step 3: Add the epiceditor.js file

<script src="https://github.com/OscarGodson/EpicEditor/raw/0.2.3/epiceditor.min.js"></script>

Step 4: Init EpicEditor

var editor = new EpicEditor().load();

API

EpicEditor([options])

The EpicEditor constructor creates a new editor instance. Customize the instance by passing the options parameter. The example below uses all options and their defaults:

var opts = {
  container: 'epiceditor',
  textarea: null,
  basePath: 'epiceditor',
  clientSideStorage: true,
  localStorageName: 'epiceditor',
  useNativeFullscreen: true,
  parser: marked,
  file: {
    name: 'epiceditor',
    defaultContent: '',
    autoSave: 100
  },
  theme: {
    base: '/themes/base/epiceditor.css',
    preview: '/themes/preview/preview-dark.css',
    editor: '/themes/editor/epic-dark.css'
  },
  button: {
    preview: true,
    fullscreen: true,
    bar: "auto"
  },
  focusOnLoad: false,
  shortcut: {
    modifier: 18,
    fullscreen: 70,
    preview: 80
  },
  string: {
    togglePreview: 'Toggle Preview Mode',
    toggleEdit: 'Toggle Edit Mode',
    toggleFullscreen: 'Enter Fullscreen'
  },
  autogrow: false
}
var editor = new EpicEditor(opts);

Options

Option Description Default
container The ID (string) or element (object) of the target container in which you want the editor to appear. epiceditor
textarea The ID (string) or element (object) of a textarea you would like to sync the editor's content with. On page load if there is content in the textarea, the editor will use that as its content.
basePath The base path of the directory containing the /themes. epiceditor
clientSideStorage Setting this to false will disable localStorage. true
localStorageName The name to use for the localStorage object. epiceditor
useNativeFullscreen Set to false to always use faux fullscreen (the same as what is used for unsupported browsers). true
parser [Marked](https://github.com/chjj/marked) is the only parser built into EpicEditor, but you can customize or toggle this by passing a parsing function to this option. For example: parser: MyCustomParser.parse marked
focusOnLoad If true, editor will focus on load. false
file.name If no file exists with this name a new one will be made, otherwise the existing will be opened. container ID
file.defaultContent The content to show if no content exists for a file. NOTE: if the textarea option is used, the textarea's value will take precedence over defaultContent.
file.autoSave How often to auto save the file in milliseconds. Set to false to turn it off. 100
theme.base The base styles such as the utility bar with the buttons. themes/base/epiceditor.css
theme.editor The theme for the editor which is the area you type into. themes/editor/epic-dark.css
theme.preview The theme for the previewer. themes/preview/github.css
button If set to false will remove all buttons. All buttons set to true.
button.preview If set to false will remove the preview button. true
button.fullscreen If set to false will remove the fullscreen button. true
button.bar If true or "show", any defined buttons will always be visible. If false or "hide", any defined buttons will never be visible. If "auto", buttons will usually be hidden, but shown if whenever the mouse is moved. "auto"
shortcut.modifier The key to hold while holding the other shortcut keys to trigger a key combo. 18 (alt key)
shortcut.fullscreen The shortcut to open fullscreen. 70 (f key)
shortcut.preview The shortcut to toggle the previewer. 80 (p key)
string.togglePreview The tooltip text that appears when hovering the preview icon. Toggle Preview Mode
string.toggleEdit The tooltip text that appears when hovering the edit icon. Toggle Edit Mode
string.toggleFullscreen The tooltip text that appears when hovering the fullscreen icon. Enter Fullscreen
autogrow Whether to autogrow EpicEditor to fit its contents. If autogrow is desired one can either specify true, meaning to use default autogrow settings, or an object to define custom settings false
autogrow.minHeight The minimum height (in pixels) that the editor should ever shrink to. This may also take a function that returns the desired minHeight if this is not a constant, or a falsey value if no minimum is desired 80
autogrow.maxHeight The maximum height (in pixels) that the editor should ever grow to. This may also take a function that returns the desired maxHeight if this is not a constant, or a falsey value if no maximum is desired false
autogrow.scroll Whether the page should scroll to keep the caret in the same vertical place while autogrowing (recommended for mobile in particular) true

load([callback])

Loads the editor by inserting it into the DOM by creating an iframe. Will trigger the load event, or you can provide a callback.

editor.load(function () {
  console.log("Editor loaded.")
});

unload([callback])

Unloads the editor by removing the iframe. Keeps any options and file contents so you can easily call .load() again. Will trigger the unload event, or you can provide a callback.

editor.unload(function () {
  console.log("Editor unloaded.")
});

getElement(element)

Grabs an editor element for easy DOM manipulation. See the Themes section below for more on the layout of EpicEditor elements.

  • container: The element given at setup in the options.
  • wrapper: The wrapping `

containing the 2 editor and previewer iframes. *wrapperIframe: The iframe containing thewrapperelement. *editor: The #document of the editor iframe (i.e. you could doeditor.getElement('editor').body). *editorIframe: The iframe containing theeditorelement. *previewer: The #document of the previewer iframe (i.e. you could doeditor.getElement('previewer').body). *previewerIframe: The iframe containing thepreviewer` element.

someBtn.onclick = function () {
  console.log(editor.getElement('editor').body.innerHTML); // Returns the editor's content
}

is(state)

Returns a boolean for the requested state. Useful when you need to know if the editor is loaded yet for example. Below is a list of supported states:

  • loaded
  • unloaded
  • edit
  • preview
  • fullscreen
fullscreenBtn.onclick = function () {
  if (!editor.is('loaded')) { return; }
  editor.enterFullscreen();
}

open(filename)

Opens a client side storage file into the editor.

Note: This does not open files on your server or machine (yet). This simply looks in localStorage where EpicEditor stores drafts.

openFileBtn.onclick = function () {
  editor.open('some-file'); // Opens a file when the user clicks this button
}

importFile([filename],[content])

Imports a string of content into a client side storage file. If the file already exists, it will be overwritten. Useful if you want to inject a bunch of content via AJAX. Will also run .open() after import automatically.

Note: This does not import files on your server or machine (yet). This simply looks in localStorage where EpicEditor stores drafts.

importFileBtn.onclick = function () {
  editor.importFile('some-file',"#Imported markdown\nFancy, huh?"); //Imports a file when the user clicks this button
}

exportFile([filename],[type])

Returns the plain text of the client side storage file, or if given a type, will return the content in the specified type. If you leave both parameters null it will return the current document's content in plain text. The supported export file types are:

Note: This does not export files to your server or machine (yet). This simply looks in localStorage where EpicEditor stores drafts.

  • text (default)
  • html
  • json (includes metadata)
  • raw (warning: this is browser specific!)
syncWithServerBtn.onclick = function () {
  var theContent = editor.exportFile();
  saveToServerAjaxCall('/save', {data:theContent}, function () {
    console.log('Data was saved to the database.');
  });
}

rename(oldName, newName)

Renames a client side storage file.

Note: This does not rename files on your server or machine (yet). This simply looks in localStorage where EpicEditor stores drafts.

renameFileBtn.onclick = function () {
  var newName = prompt('What do you want to rename this file to?');
  editor.rename('old-filename.md', newName); //Prompts a user and renames a file on button click
}

save()

Manually saves a file to client side storage (localStorage by default). EpicEditor will save continuously every 100ms by default, but if you set autoSave in the options to false or to longer intervals it's useful to manually save.

Note: This does not save files to your server or machine (yet). This simply looks in localStorage where EpicEditor stores drafts.

saveFileBtn.onclick = function () {
  editor.save();
}

remove(name)

Deletes a client side storage file.

Note: This does not remove files from your server or machine (yet). This simply looks in localStorage where EpicEditor stores drafts.

removeFileBtn.onclick = function () {
  editor.remove('example.md');
}

getFiles([name], [excludeContent])

If no name is given it returns an object containing the names and metadata of all client side storage file objects. If a name is specified it will return just the metadata of that single file object. If excludeContent is true, it will remove the content from the returned object. This is useful when you just want a list of files or get some meta data. If excludeContent is false (default), it'll return a content property per file in plain text format.

Note: This does not get files from your server or machine (yet). This simply looks in localStorage where EpicEditor stores drafts.

var files = editor.getFiles();
for (x in files) {
  console.log('File: ' + x); //Returns the name of each file
};

on(event, handler)

Sets up an event handler (callback) fo

Core symbols most depended-on inside this repo

rnd
called by 22
test/helpers.js
createContainer
called by 22
test/helpers.js
removeContainer
called by 21
test/helpers.js
colorize
called by 15
Jakefile.js
n
called by 15
docs/js/prettify.js
_getStyle
called by 12
src/editor.js
_getStyle
called by 12
epiceditor/js/epiceditor.js
l
called by 11
docs/js/prettify.js

Shape

Function 144

Languages

TypeScript100%

Modules by API surface

docs/js/jquery.min.js42 symbols
epiceditor/js/epiceditor.js31 symbols
src/editor.js23 symbols
epiceditor/js/epiceditor.min.js23 symbols
docs/js/prettify.js13 symbols
test/helpers.js5 symbols
test/test.options.js3 symbols
Jakefile.js2 symbols
test/test.open.js1 symbols
test/test.on.js1 symbols

Dependencies from manifests, versioned

expect.js0.1.2 · 1×
jshint0.7.2 · 1×
marked0.2.7 · 1×
mime1.2.7 · 1×
mocha1.3.2 · 1×
node-watch0.3.x · 1×
uglify-js1.3.3 · 1×

For agents

$ claude mcp add EpicEditor \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact