123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- 'use strict';
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- /**
- * Default formats.
- */
- var Formats = {
- /**
- * Bold text.
- *
- * @example
- * editor.format('bold');
- * assert(textarea.value == '**Hello World**')
- */
- bold: {
- prefix: '**',
- suffix: '**'
- },
- /**
- * Italic text.
- *
- * @example
- * editor.format('italic');
- * assert(textarea.value == '_Hello World_')
- */
- italic: {
- prefix: '_',
- suffix: '_'
- },
- /**
- * Strikethrough text.
- *
- * @example
- * editor.format('strikethrough');
- * assert(textarea.value == '~~Hello World~~')
- */
- strikethrough: {
- prefix: '~~',
- suffix: '~~'
- },
- /**
- * Insert link.
- *
- * @example
- * editor.format('link', '/example');
- * assert(textarea.value == '[Hello World](/example)')
- */
- link: {
- prefix: {
- value: '[',
- pattern: '\\[',
- antipattern: '\\!\\['
- },
- suffix: {
- value: function value(text, n, url) {
- return '](' + url + ')';
- },
- pattern: '\\]\\([^()]*?\\)'
- }
- },
- /**
- * Insert image.
- *
- * @example
- * editor.format('image', '/example.png');
- * assert(textarea.value == '![Hello World](/example.png)')
- */
- image: {
- prefix: '![',
- suffix: {
- value: function value(text, n, url) {
- return '](' + url + ')';
- },
- pattern: '\\]\\([^()]*?\\)'
- }
- },
- /**
- * Header 1.
- *
- * @example
- * editor.format('header1');
- * assert(textarea.value == '# Hello World')
- */
- header1: {
- prefix: {
- value: '# ',
- pattern: '# ',
- antipattern: '[#]{2,} '
- }
- },
- /**
- * Header 2.
- *
- * @example
- * editor.format('header2');
- * assert(textarea.value == '## Hello World')
- */
- header2: {
- prefix: {
- value: '## ',
- pattern: '## ',
- antipattern: '[#]{3,} '
- }
- },
- /**
- * Header 3.
- *
- * @example
- * editor.format('header3');
- * assert(textarea.value == '### Hello World')
- */
- header3: {
- prefix: {
- value: '### ',
- pattern: '### ',
- antipattern: '[#]{4,} '
- }
- },
- /**
- * Header 4.
- *
- * @example
- * editor.format('header4');
- * assert(textarea.value == '#### Hello World')
- */
- header4: {
- prefix: {
- value: '#### ',
- pattern: '#### ',
- antipattern: '[#]{5,} '
- }
- },
- /**
- * Header 5.
- *
- * @example
- * editor.format('header5');
- * assert(textarea.value == '##### Hello World')
- */
- header5: {
- prefix: {
- value: '##### ',
- pattern: '##### ',
- antipattern: '[#]{6,} '
- }
- },
- /**
- * Header 6.
- *
- * @example
- * editor.format('header6');
- * assert(textarea.value == '###### Hello World')
- */
- header6: {
- prefix: {
- value: '###### ',
- pattern: '###### ',
- antipattern: '[#]{7,} '
- }
- },
- /**
- * Insert code block.
- *
- * @example
- * editor.format('code');
- * assert(textarea.value == '```\nHello World\n```')
- */
- code: {
- block: true,
- prefix: '```\n',
- suffix: '\n```'
- },
- /**
- * Ordered list.
- *
- * @example
- * editor.format('orderedList');
- * assert(textarea.value == '1. Hello World')
- */
- orderedList: {
- block: true,
- multiline: true,
- prefix: {
- value: function value(line, n) {
- return n + '. ';
- },
- pattern: '[0-9]+\\. '
- }
- },
- /**
- * Unordered list.
- *
- * @example
- * editor.format('unorderedList');
- * assert(textarea.value == '- Hello World')
- */
- unorderedList: {
- block: true,
- multiline: true,
- prefix: '- '
- },
- /**
- * Task list.
- *
- * @example
- * editor.format('taskList');
- * assert(textarea.value == '- [ ] Hello World')
- */
- taskList: {
- block: true,
- multiline: true,
- prefix: {
- value: '- [ ] ',
- pattern: '- \\[[x ]{1}\\] '
- }
- },
- /**
- * Blockquote.
- *
- * @example
- * editor.format('blockquote');
- * assert(textarea.value == '> Hello World')
- */
- blockquote: {
- block: true,
- multiline: true,
- prefix: '> '
- }
- };
- exports.default = Formats;
|