{"version":3,"sources":["webpack://@flarum/markdown/webpack/bootstrap","webpack://@flarum/markdown/external \"flarum.core.compat['extend']\"","webpack://@flarum/markdown/external \"flarum.core.compat['components/TextEditor']\"","webpack://@flarum/markdown/external \"flarum.core.compat['Component']\"","webpack://@flarum/markdown/./node_modules/mdarea/mdarea.min.js","webpack://@flarum/markdown/external \"flarum.core.compat['helpers/icon']\"","webpack://@flarum/markdown/./src/forum/polyfills.js","webpack://@flarum/markdown/./node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","webpack://@flarum/markdown/./src/forum/components/MarkdownToolbar.js","webpack://@flarum/markdown/./node_modules/@babel/runtime/helpers/esm/extends.js","webpack://@flarum/markdown/./src/forum/util/insertText.js","webpack://@flarum/markdown/./src/forum/util/styles.js","webpack://@flarum/markdown/./src/forum/util/apply.js","webpack://@flarum/markdown/./src/forum/components/MarkdownButton.js","webpack://@flarum/markdown/./src/forum/index.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","flarum","core","compat","self","a","test","navigator","platform","f","_","g","y","b","v","K","e","this","_useTab","_useInline","_indent","_reOutdent","_reKey","_handleKey","setElement","RegExp","x","selectionStart","selectionEnd","arguments","length","window","InputEvent","dispatchEvent","constructor","getElement","_elem","removeEventListener","addEventListener","getValue","setValue","getIndent","setIndent","Array","join","replace","isTabUsed","useTab","ignoreTab","isInlineEnabled","enableInline","disableInline","destroy","defaultPrevented","target","substring","ctrlKey","altKey","metaKey","shiftKey","lastIndexOf","h","u","charAt","line","offset","prefix","exec","parseInt","preventDefault","String","startsWith","search","pos","endsWith","this_len","undefined","_inheritsLoose","subClass","superClass","__proto__","modifierKey","userAgent","match","MarkdownToolbar","config","isInitialized","document","getElementById","props","for","shortcut","view","id","data-for","style","display","children","event","button","element","querySelector","click","Component","_extends","assign","source","apply","canInsertText","isMultipleLines","string","trim","split","repeat","wordSelectionStart","text","index","wordSelectionEnd","multiline","breakpoint","newlinesToSurroundSelectedText","textarea","newlinesToAppend","newlinesToPrepend","beforeSelection","slice","afterSelection","breaksBefore","breaksAfter","newlinesBeforeSelection","newlinesAfterSelection","blockStyle","arg","suffix","blockPrefix","blockSuffix","replaceNext","prefixSpace","scanFor","surroundWithNewlines","originalSelectionStart","originalSelectionEnd","selectedText","prefixToUse","suffixToUse","expandedSelectionStart","expandedSelectionEnd","beginsWithPrefix","endsWithSuffix","expandSelectedText","hasReplaceNext","indexOf","ref","replacementText","position","Math","max","min","whitespaceEdges","trimFirst","leadingWhitespace","trailingWhitespace","styleSelectedText","styleArgs","result","orderedList","startOfLine","endOfLine","orderedListRegex","noInitialSelection","textToUnstyle","lines","linesBefore","linesToUnstyle","every","map","lengthDiff","len","results","push","multilineStyle","before","after","contentEditable","execCommand","error","createEvent","initEvent","setSelectionRange","insertText","MarkdownButton","$","tooltip","className","title","data-hotkey","hotkey","onclick","onkeydown","keydown","icon","stylesToApply","toolbar","parentElement","field","dataset","focus","app","initializers","add","extend","TextEditor","textareaId","vdom","attrs","context","editor","MarkdownArea","onunload","items","translator","trans"],"mappings":"2BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,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AAeG,YAAa,WAAYE,QAAS,eAC1I,EAAC,EAAD,CAAgBwD,MAAOF,EAAQ,SAAUQ,KAAK,eAAezG,MAAO,CAAE7B,OAAQ,KAAMmE,OAAQ,cAAeG,YAAa,WAAYE,QAAS,eAC7I,EAAC,EAAD,CAAgBwD,MAAOF,EAAQ,kBAAmBQ,KAAK,iBAAiBzG,MAAO,CAAE7B,OAAQ,KAAMoD,WAAW,EAAMqB,sBAAsB,KACtI,EAAC,EAAD,CAAgBuD,MAAOF,EAAQ,gBAAiBQ,KAAK,iBAAiBzG,MAAO,CAAE7B,OAAQ,MAAOoD,WAAW,EAAM+C,aAAa,MAE7H","file":"forum.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 6);\n","module.exports = flarum.core.compat['extend'];","module.exports = flarum.core.compat['components/TextEditor'];","module.exports = flarum.core.compat['Component'];","!function(e,t){\"function\"==typeof define&&define.amd?define([],t):\"object\"==typeof module&&module.exports?module.exports=t():e.MarkdownArea=t()}(\"undefined\"!=typeof self?self:this,function(){var a=/mac|iphone|ipad|ipod/i.test(navigator.platform)?\"metaKey\":\"ctrlKey\",o=/^[\"'`*_[({<>})\\]]$/,f=/[*_]/,_=/^[ \\t]*(?:(?:[-+*]|\\d+\\.)[ \\t]+(?:\\[[ x]][ \\t]+)?|>[ \\t]*)*(?::[ \\t]*)?/,c=/(?:[-+*]|\\d+\\.)[ \\t]+(?:\\[[ x]][ \\t]+)?$/,g=/[-+*\\[\\]x\\d.]/g,y=/[^ \\t]/g,p=/(\\d+)\\.(?=[ \\t]+$)/,m=/(?:(?:^[ \\t]+)?(?:[-+*]|\\d+\\.|[>:])(?:[ \\t]+\\[[ x]])?[ \\t]*|^[ \\t]+)$/,d=/^(?!$)/gm,b={\"`\":/^``$/m,\"~\":/^~~$/m},v={\"[\":\"]\",\"(\":\")\",\"{\":\"}\",\"<\":\">\"},K={\"]\":\"[\",\")\":\"(\",\"}\":\"{\",\">\":\"<\"};function e(e){this._useTab=!0,this._useInline=!0,this._indent=\" \",this._reOutdent=/^[ ]{4}/gm,this._reKey=t(!0,!0),this._handleKey=this._handleKey.bind(this),this.setElement(e)}function t(e,t){return new RegExp(\"^(?:Enter\"+(e?\"|Tab\":\"\")+\"|[io\"+(t?\"\\\"'`*_([{<>}\\\\])\":\"\")+\"])$\")}function x(e,t,n,i){if(e.value=t,e.selectionStart=n,e.selectionEnd=3 this.length) {\n this_len = this.length;\n }\n return this.substring(this_len - search.length, this_len) === search;\n };\n}\n","export default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}","import Component from 'flarum/Component';\n\nconst modifierKey = navigator.userAgent.match(/Macintosh/) ? 'Meta' : 'Control';\n\nexport default class MarkdownToolbar extends Component {\n config(isInitialized) {\n if (isInitialized) return;\n\n const field = document.getElementById(this.props.for);\n\n field.addEventListener('keydown', this.shortcut.bind(this));\n }\n\n view() {\n return
\n {this.props.children}\n
;\n }\n\n shortcut(event) {\n if ((event.metaKey && modifierKey === 'Meta') || (event.ctrlKey && modifierKey === 'Control')) {\n const button = this.element.querySelector(`[data-hotkey=\"${event.key}\"]`);\n\n if (button) {\n button.click();\n event.preventDefault()\n }\n }\n }\n}\n","export default function _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}","/*\n * Original Copyright GitHub, Inc. Licensed under the MIT License.\n * See license text at https://github.com/github/markdown-toolbar-element/blob/master/LICENSE.\n */\n\nexport let canInsertText = null;\n\nexport default (textarea, { text, selectionStart, selectionEnd }) => {\n const originalSelectionStart = textarea.selectionStart;\n const before = textarea.value.slice(0, originalSelectionStart);\n const after = textarea.value.slice(textarea.selectionEnd);\n\n if (canInsertText === null || canInsertText === true) {\n textarea.contentEditable = 'true';\n try {\n canInsertText = document.execCommand('insertText', false, text);\n }\n catch (error) {\n canInsertText = false;\n }\n textarea.contentEditable = 'false';\n }\n if (canInsertText && !textarea.value.slice(0, textarea.selectionStart).endsWith(text)) {\n canInsertText = false;\n }\n if (!canInsertText) {\n try {\n document.execCommand('ms-beginUndoUnit');\n }\n catch (e) {\n // Do nothing.\n }\n textarea.value = before + text + after;\n try {\n document.execCommand('ms-endUndoUnit');\n }\n catch (e) {\n // Do nothing.\n }\n\n // fire custom event, works on IE\n const event = document.createEvent('Event');\n\n event.initEvent('input', true, true);\n\n textarea.dispatchEvent(event);\n }\n if (selectionStart != null && selectionEnd != null) {\n textarea.setSelectionRange(selectionStart, selectionEnd);\n }\n else {\n textarea.setSelectionRange(originalSelectionStart, textarea.selectionEnd);\n }\n};\n","/*\n * Original Copyright GitHub, Inc. Licensed under the MIT License.\n * See license text at https://github.com/github/markdown-toolbar-element/blob/master/LICENSE.\n */\n\nexport function isMultipleLines(string) {\n return string.trim().split('\\n').length > 1;\n}\n\nexport function repeat(string, n) {\n return Array(n + 1).join(string);\n}\n\nexport function wordSelectionStart(text, i) {\n let index = i;\n\n while (text[index] && text[index - 1] != null && !text[index - 1].match(/\\s/)) {\n index--;\n }\n\n return index;\n}\n\nexport function wordSelectionEnd(text, i, multiline) {\n let index = i;\n const breakpoint = multiline ? /\\n/ : /\\s/;\n\n while (text[index] && !text[index].match(breakpoint)) {\n index++;\n }\n\n return index;\n}\n\nexport function expandSelectedText(textarea, prefixToUse, suffixToUse) {\n let multiline = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n\n if (textarea.selectionStart === textarea.selectionEnd) {\n textarea.selectionStart = wordSelectionStart(textarea.value, textarea.selectionStart);\n textarea.selectionEnd = wordSelectionEnd(textarea.value, textarea.selectionEnd, multiline);\n } else {\n const expandedSelectionStart = textarea.selectionStart - prefixToUse.length;\n const expandedSelectionEnd = textarea.selectionEnd + suffixToUse.length;\n const beginsWithPrefix = textarea.value.slice(expandedSelectionStart, textarea.selectionStart) === prefixToUse;\n const endsWithSuffix = textarea.value.slice(textarea.selectionEnd, expandedSelectionEnd) === suffixToUse;\n\n if (beginsWithPrefix && endsWithSuffix) {\n textarea.selectionStart = expandedSelectionStart;\n textarea.selectionEnd = expandedSelectionEnd;\n }\n }\n\n return textarea.value.slice(textarea.selectionStart, textarea.selectionEnd);\n}\n\nexport function newlinesToSurroundSelectedText(textarea) {\n const beforeSelection = textarea.value.slice(0, textarea.selectionStart);\n const afterSelection = textarea.value.slice(textarea.selectionEnd);\n const breaksBefore = beforeSelection.match(/\\n*$/);\n const breaksAfter = afterSelection.match(/^\\n*/);\n const newlinesBeforeSelection = breaksBefore ? breaksBefore[0].length : 0;\n const newlinesAfterSelection = breaksAfter ? breaksAfter[0].length : 0;\n let newlinesToAppend;\n let newlinesToPrepend;\n\n if (beforeSelection.match(/\\S/) && newlinesBeforeSelection < 2) {\n newlinesToAppend = repeat('\\n', 2 - newlinesBeforeSelection);\n }\n\n if (afterSelection.match(/\\S/) && newlinesAfterSelection < 2) {\n newlinesToPrepend = repeat('\\n', 2 - newlinesAfterSelection);\n }\n\n if (newlinesToAppend == null) {\n newlinesToAppend = '';\n }\n\n if (newlinesToPrepend == null) {\n newlinesToPrepend = '';\n }\n\n return {\n newlinesToAppend,\n newlinesToPrepend\n };\n}\n\nexport const blockStyle = (textarea, arg) => {\n let newlinesToAppend;\n let newlinesToPrepend;\n const { prefix, suffix, blockPrefix, blockSuffix, replaceNext, prefixSpace, scanFor, surroundWithNewlines } = arg;\n const originalSelectionStart = textarea.selectionStart;\n const originalSelectionEnd = textarea.selectionEnd;\n let selectedText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd);\n let prefixToUse = isMultipleLines(selectedText) && blockPrefix.length > 0 ? `${blockPrefix}\\n` : prefix;\n let suffixToUse = isMultipleLines(selectedText) && blockSuffix.length > 0 ? `\\n${blockSuffix}` : suffix;\n\n if (prefixSpace) {\n const beforeSelection = textarea.value[textarea.selectionStart - 1];\n if (textarea.selectionStart !== 0 && beforeSelection != null && !beforeSelection.match(/\\s/)) {\n prefixToUse = ` ${prefixToUse}`;\n }\n }\n\n selectedText = expandSelectedText(textarea, prefixToUse, suffixToUse, arg.multiline);\n let selectionStart = textarea.selectionStart;\n let selectionEnd = textarea.selectionEnd;\n const hasReplaceNext = replaceNext.length > 0 && suffixToUse.indexOf(replaceNext) > -1 && selectedText.length > 0;\n\n if (surroundWithNewlines) {\n const ref = newlinesToSurroundSelectedText(textarea);\n newlinesToAppend = ref.newlinesToAppend;\n newlinesToPrepend = ref.newlinesToPrepend;\n prefixToUse = newlinesToAppend + prefix;\n suffixToUse += newlinesToPrepend;\n }\n\n if (selectedText.startsWith(prefixToUse) && selectedText.endsWith(suffixToUse)) {\n const replacementText = selectedText.slice(prefixToUse.length, selectedText.length - suffixToUse.length);\n if (originalSelectionStart === originalSelectionEnd) {\n let position = originalSelectionStart - prefixToUse.length;\n position = Math.max(position, selectionStart);\n position = Math.min(position, selectionStart + replacementText.length);\n selectionStart = selectionEnd = position;\n }\n else {\n selectionEnd = selectionStart + replacementText.length;\n }\n return { text: replacementText, selectionStart, selectionEnd };\n }\n else if (!hasReplaceNext) {\n let replacementText = prefixToUse + selectedText + suffixToUse;\n selectionStart = originalSelectionStart + prefixToUse.length;\n selectionEnd = originalSelectionEnd + prefixToUse.length;\n const whitespaceEdges = selectedText.match(/^\\s*|\\s*$/g);\n if (arg.trimFirst && whitespaceEdges) {\n const leadingWhitespace = whitespaceEdges[0] || '';\n const trailingWhitespace = whitespaceEdges[1] || '';\n replacementText = leadingWhitespace + prefixToUse + selectedText.trim() + suffixToUse + trailingWhitespace;\n selectionStart += leadingWhitespace.length;\n selectionEnd -= trailingWhitespace.length;\n }\n return { text: replacementText, selectionStart, selectionEnd };\n }\n else if (scanFor.length > 0 && selectedText.match(scanFor)) {\n suffixToUse = suffixToUse.replace(replaceNext, selectedText);\n const replacementText = prefixToUse + suffixToUse;\n selectionStart = selectionEnd = selectionStart + prefixToUse.length;\n return { text: replacementText, selectionStart, selectionEnd };\n }\n else {\n const replacementText = prefixToUse + selectedText + suffixToUse;\n selectionStart = selectionStart + prefixToUse.length + selectedText.length + suffixToUse.indexOf(replaceNext);\n selectionEnd = selectionStart + replaceNext.length;\n return { text: replacementText, selectionStart, selectionEnd };\n }\n}\n\nexport const multilineStyle = (textarea, arg) => {\n const { prefix, suffix, surroundWithNewlines } = arg;\n let text = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd);\n let selectionStart = textarea.selectionStart;\n let selectionEnd = textarea.selectionEnd;\n const lines = text.split('\\n');\n const undoStyle = lines.every(line => line.startsWith(prefix) && line.endsWith(suffix));\n if (undoStyle) {\n text = lines.map(line => line.slice(prefix.length, line.length - suffix.length)).join('\\n');\n selectionEnd = selectionStart + text.length;\n }\n else {\n text = lines.map(line => prefix + line + suffix).join('\\n');\n if (surroundWithNewlines) {\n const { newlinesToAppend, newlinesToPrepend } = newlinesToSurroundSelectedText(textarea);\n selectionStart += newlinesToAppend.length;\n selectionEnd = selectionStart + text.length;\n text = newlinesToAppend + text + newlinesToPrepend;\n }\n }\n return { text, selectionStart, selectionEnd };\n}\n\nexport const orderedList = (textarea) => {\n const orderedListRegex = /^\\d+\\.\\s+/;\n const noInitialSelection = textarea.selectionStart === textarea.selectionEnd;\n let selectionEnd;\n let selectionStart;\n let text = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd);\n let textToUnstyle = text;\n let lines = text.split('\\n');\n let startOfLine, endOfLine;\n if (noInitialSelection) {\n const linesBefore = textarea.value.slice(0, textarea.selectionStart).split(/\\n/);\n startOfLine = textarea.selectionStart - linesBefore[linesBefore.length - 1].length;\n endOfLine = wordSelectionEnd(textarea.value, textarea.selectionStart, true);\n textToUnstyle = textarea.value.slice(startOfLine, endOfLine);\n }\n const linesToUnstyle = textToUnstyle.split('\\n');\n const undoStyling = linesToUnstyle.every(line => orderedListRegex.test(line));\n if (undoStyling) {\n lines = linesToUnstyle.map(line => line.replace(orderedListRegex, ''));\n text = lines.join('\\n');\n if (noInitialSelection && startOfLine && endOfLine) {\n const lengthDiff = linesToUnstyle[0].length - lines[0].length;\n selectionStart = selectionEnd = textarea.selectionStart - lengthDiff;\n textarea.selectionStart = startOfLine;\n textarea.selectionEnd = endOfLine;\n }\n }\n else {\n lines = (function () {\n let i;\n let len;\n let index;\n const results = [];\n for (index = i = 0, len = lines.length; i < len; index = ++i) {\n const line = lines[index];\n results.push(`${index + 1}. ${line}`);\n }\n return results;\n })();\n text = lines.join('\\n');\n const { newlinesToAppend, newlinesToPrepend } = newlinesToSurroundSelectedText(textarea);\n selectionStart = textarea.selectionStart + newlinesToAppend.length;\n selectionEnd = selectionStart + text.length;\n if (noInitialSelection)\n selectionStart = selectionEnd;\n text = newlinesToAppend + text + newlinesToPrepend;\n }\n return { text, selectionStart, selectionEnd };\n}\n","/*\n * Original Copyright GitHub, Inc. Licensed under the MIT License.\n * See license text at https://github.com/github/markdown-toolbar-element/blob/master/LICENSE.\n */\n\nimport insertText from './insertText';\nimport { blockStyle, isMultipleLines, multilineStyle, orderedList } from './styles';\n\nexport const styleSelectedText = (textarea, styleArgs) => {\n const text = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd);\n let result;\n if (styleArgs.orderedList) {\n result = orderedList(textarea);\n }\n else if (styleArgs.multiline && isMultipleLines(text)) {\n result = multilineStyle(textarea, styleArgs);\n }\n else {\n result = blockStyle(textarea, styleArgs);\n }\n\n insertText(textarea, result);\n};\n\nexport default (button, stylesToApply) => {\n const toolbar = button.parentElement;\n\n const defaults = {\n prefix: '',\n suffix: '',\n blockPrefix: '',\n blockSuffix: '',\n multiline: false,\n replaceNext: '',\n prefixSpace: false,\n scanFor: '',\n surroundWithNewlines: false,\n orderedList: false,\n trimFirst: false\n };\n\n const style = Object.assign({}, defaults, stylesToApply);\n\n const field = document.getElementById(toolbar.dataset.for);\n\n if (field) {\n field.focus();\n styleSelectedText(field, style);\n }\n}\n","import Component from 'flarum/Component';\nimport icon from 'flarum/helpers/icon';\nimport apply from '../util/apply';\n\nconst modifierKey = navigator.userAgent.match(/Macintosh/) ? '⌘' : 'ctrl';\n\nexport default class MarkdownButton extends Component {\n config(isInitialized) {\n if (isInitialized) return;\n\n this.$().tooltip();\n }\n\n view() {\n return ;\n }\n\n keydown(event) {\n if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n this.click();\n }\n }\n\n click() {\n return apply(this.element, this.props.style);\n }\n\n title() {\n let tooltip = this.props.title;\n\n if (this.props.hotkey) tooltip += ` <${modifierKey}-${this.props.hotkey}>`;\n\n return tooltip;\n }\n}\n","/*!\n * Includes modified code from GitHub Markdown Toolbar Element\n * https://github.com/github/markdown-toolbar-element/\n *\n * Original Copyright GitHub, Inc.\n * Released under the MIT license\n * https://github.com/github/markdown-toolbar-element/blob/master/LICENSE\n */\n\nimport { extend } from 'flarum/extend';\nimport TextEditor from 'flarum/components/TextEditor';\nimport MarkdownArea from 'mdarea';\n\nimport './polyfills';\nimport MarkdownToolbar from './components/MarkdownToolbar';\nimport MarkdownButton from './components/MarkdownButton';\n\napp.initializers.add('flarum-markdown', function(app) {\n\n let index = 1;\n\n extend(TextEditor.prototype, 'init', function() {\n this.textareaId = 'textarea'+(index++);\n });\n\n extend(TextEditor.prototype, 'view', function(vdom) {\n vdom.children[0].attrs.id = this.textareaId;\n });\n\n extend(TextEditor.prototype, 'configTextarea', function(value, element, isInitialized, context) {\n if (isInitialized) return;\n\n const editor = new MarkdownArea(element);\n editor.disableInline();\n editor.ignoreTab();\n\n context.onunload = function() {\n editor.destroy();\n };\n });\n\n extend(TextEditor.prototype, 'toolbarItems', function(items) {\n const tooltip = name => app.translator.trans(`flarum-markdown.forum.composer.${name}_tooltip`);\n\n items.add('markdown', (\n \n \n \n \n ', multiline: true, surroundWithNewlines: true }} />\n \n \n \n \n \n \n ), 100);\n });\n});\n"],"sourceRoot":""}