{"version":3,"names":["cmdItem","cmd","options","passedOptions","label","title","run","prop","enable","select","state","ProseMirror","menu","MenuItem","markItem","markType","active","PF","PFMarkdown","markActive","commands","toggleMark","linkItem","icon","icons","link","dispatch","view","Commands","linkPopup","codeBlockItem","nodeType","code","nodeActive","codePopup","wrapListItem","schemaList","wrapInList","attrs","createCustomMenuItem","itemSpec","schema","createMenuItem","type","item","Array","isArray","marks","strong","em","nodes","bullet_list","bulletList","ordered_list","orderedList","blockquote","wrapItem","paragraph","blockTypeItem","code_block","heading","headings","i","push","level","Dropdown","horizontal_rule","hr","text","css","canInsert","tr","replaceSelectionWith","create","joinUpItem","spec","liftItem","undoItem","redoItem","CreateEditorMenu","menuItems","map","itemList","filter","Boolean"],"sources":["PFMarkdownEditorMenu.js"],"sourcesContent":["/*function canInsert(state, nodeType) {\n\tlet $from = state.selection.$from\n\tfor (let d = $from.depth; d >= 0; d--) {\n\t\tlet index = $from.index(d)\n\t\tif ($from.node(d).canReplaceWith(index, index, nodeType)) return true\n\t}\n\treturn false\n}*/\n\n// Zakomentovano pro pripad ze by bylo treba pridelat vkladani obrazku\n/*function insertImageItem(nodeType) {\n\treturn new MenuItem({\n\t  title: \"Insert image\",\n\t  label: \"Image\",\n\t  enable(state) { return canInsert(state, nodeType) },\n\t  run(state, _, view) {\n\t\tlet {from, to} = state.selection, attrs = null\n\t\tif (state.selection instanceof ProseMirror.state.NodeSelection && state.selection.node.type == nodeType)\n\t\t  attrs = state.selection.node.attrs\n\t\topenPrompt({\n\t\t  title: \"Insert image\",\n\t\t  fields: {\n\t\t\tsrc: new TextField({label: \"Location\", required: true, value: attrs && attrs.src}),\n\t\t\ttitle: new TextField({label: \"Title\", value: attrs && attrs.title}),\n\t\t\talt: new TextField({label: \"Description\",\n\t\t\t\t\t\t\t\tvalue: attrs ? attrs.alt : state.doc.textBetween(from, to, \" \")})\n\t\t  },\n\t\t  callback(attrs) {\n\t\t\tview.dispatch(view.state.tr.replaceSelectionWith(nodeType.createAndFill(attrs)!))\n\t\t\tview.focus()\n\t\t  }\n\t\t})\n\t  }\n\t})\n}*/\n  \nfunction cmdItem(cmd, options) {\n\tlet passedOptions = {\n\t\tlabel: options.title,\n\t\trun: cmd\n\t}\n\tfor (let prop in options) passedOptions[prop] = options[prop]\n\tif (!options.enable && !options.select)\n\t\tpassedOptions[options.enable ? \"enable\" : \"select\"] = state => cmd(state)\n\n\treturn new ProseMirror.menu.MenuItem(passedOptions)\n}\n  \n/*function markActive(state, type) {\n\tlet {from, $from, to, empty} = state.selection\n\tif (empty) return !!type.isInSet(state.storedMarks || $from.marks())\n\telse return state.doc.rangeHasMark(from, to, type)\n}\n\nfunction nodeActive(state, type) {\n\tif (state.selection.empty) return false;\n\n\tconst anchor = state.selection.$anchor;\n\tconst selectedNode = state.doc.nodeAt(anchor.pos);\n\n\treturn selectedNode && selectedNode.type == type;\n}*/\n  \nfunction markItem(markType, options) {\n\tlet passedOptions = {\n\t\tactive(state) { return PF.PFMarkdown.markActive(state, markType) }\n\t}\n\tfor (let prop in options) passedOptions[prop] = options[prop]\n\treturn cmdItem(ProseMirror.commands.toggleMark(markType), passedOptions)\n}\n  \nfunction linkItem(markType) {\n\treturn new ProseMirror.menu.MenuItem({\n\t\ttitle: \"Odkaz\",\n\t\ticon: ProseMirror.menu.icons.link,\n\t\tactive(state) { return PF.PFMarkdown.markActive(state, markType) },\n\t\t/*enable(state) { return !state.selection.empty },*/\n\t\trun(state, dispatch, view) {\n\t\t\tPF.PFMarkdown.Commands.linkPopup(state, dispatch, view);\n\t\t}\n\t});\n}\n\nfunction codeBlockItem(nodeType) {\n\treturn new ProseMirror.menu.MenuItem({\n\t\ttitle: \"Kód\",\n\t\ticon: ProseMirror.menu.icons.code,\n\t\tactive(state) { return PF.PFMarkdown.nodeActive(state, nodeType); },\n\t\t/*enable(state) { return !state.selection.empty },*/\n\t\trun(state, dispatch, view) {\n\t\t\tPF.PFMarkdown.Commands.codePopup(view, state);\n\t\t}\n\t});\n}\n  \nfunction wrapListItem(nodeType, options) {\n\treturn cmdItem(ProseMirror.schemaList.wrapInList(nodeType, options.attrs), options)\n}\n\nfunction createCustomMenuItem(itemSpec, schema) {\n\treturn new ProseMirror.menu.MenuItem({...itemSpec})\n}\n  \nfunction createMenuItem(itemSpec, schema) {\n\tlet type = null;\n\tlet item = null;\n\n\tif (typeof itemSpec === 'object' && !Array.isArray(itemSpec) &&\titemSpec !== null) {\n\t\treturn createCustomMenuItem(itemSpec, schema);\n\t} else if (typeof itemSpec == 'string') {\n\t\tswitch (itemSpec) {\n\t\t\tcase \"bold\":\n\t\t\t\tif (type = schema.marks.strong) {\n\t\t\t\t\treturn markItem(type, {title: \"Tučně\", icon: ProseMirror.menu.icons.strong});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"italic\":\n\t\t\t\tif (type = schema.marks.em) {\n\t\t\t\t\treturn markItem(type, {title: \"Kurzíva\", icon: ProseMirror.menu.icons.em});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t// Bude potrebovat vlastni schema mark, v prosemirror markdownu chybi\n\t\t\t/*case \"strikethrough\":\n\t\t\t\tif (type = schema.marks.em) {\n\t\t\t\t\treturn markItem(type, {title: \"Přeškrtnuté\", icon: {text: '\\uf0cc', css: 'font-family: \"Font Awesome 5 Free\"; font-weight: 900'}});\n\t\t\t\t}\n\t\t\t\tbreak;*/\n\t\t\tcase \"code\":\n\t\t\t\tif (type = schema.marks.code) {\n\t\t\t\t\treturn markItem(type, {title: \"Kód\", icon: ProseMirror.menu.icons.code});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"link\":\n\t\t\t\tif (type = schema.marks.link) {\n\t\t\t\t\treturn linkItem(type);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\n\t\t\tcase \"listBullet\":\n\t\t\t\tif (type = schema.nodes.bullet_list) {\n\t\t\t\t\treturn wrapListItem(type, {\n\t\t\t\t\t\ttitle: \"Seznam s odrážkami\",\n\t\t\t\t\t\ticon: ProseMirror.menu.icons.bulletList\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"listOrdered\":\n\t\t\t\tif (type = schema.nodes.ordered_list) {\n\t\t\t\t\treturn wrapListItem(type, {\n\t\t\t\t\t\ttitle: \"Číslovaný seznam\",\n\t\t\t\t\t\ticon: ProseMirror.menu.icons.orderedList\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\n\t\t\tcase \"blockQuote\":\n\t\t\t\tif (type = schema.nodes.blockquote) {\n\t\t\t\t\treturn ProseMirror.menu.wrapItem(type, {\n\t\t\t\t\t\ttitle: \"Citace\",\n\t\t\t\t\t\ticon: ProseMirror.menu.icons.blockquote\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"paragraph\":\n\t\t\t\tif (type = schema.nodes.paragraph) {\n\t\t\t\t\treturn ProseMirror.menu.blockTypeItem(type, {\n\t\t\t\t\t\ttitle: \"Odstavec\",\n\t\t\t\t\t\tlabel: \"Odstavec\"\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"codeBlock\":\n\t\t\t\tif (type = schema.nodes.code_block) {\n\t\t\t\t\t/*return ProseMirror.menu.blockTypeItem(type, {\n\t\t\t\t\t\ttitle: \"Kód\",\n\t\t\t\t\t\tlabel: \"Kód\"\n\t\t\t\t\t});*/\n\n\t\t\t\t\t// TinyMCE-styl pridani bloku kodu pomoci popupu\n\t\t\t\t\treturn codeBlockItem(type);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\n\t\t\tcase \"heading\":\n\t\t\t\tif (type = schema.nodes.heading) {\n\t\t\t\t\tconst headings = [];\n\t\n\t\t\t\t\tfor (let i = 1; i <= 6; i++) {\n\t\t\t\t\t\theadings.push(ProseMirror.menu.blockTypeItem(type, {\n\t\t\t\t\t\t\ttitle: \"Nadpis \" + i,\n\t\t\t\t\t\t\tlabel: \"Nadpis \" + i,\n\t\t\t\t\t\t\tattrs: {level: i}\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\t\n\t\t\t\t\treturn new ProseMirror.menu.Dropdown(headings, {label: \"Nadpis\"});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\n\t\t\tcase \"horizontalRule\":\n\t\t\t\tif (type = schema.nodes.horizontal_rule) {\n\t\t\t\t\tconst hr = type;\n\t\t\t\t\treturn new ProseMirror.menu.MenuItem({\n\t\t\t\t\t  title: \"Vodorovná čára\",\n\t\t\t\t\t  label: \"Vodorovná čára\",\n\t\t\t\t\t  icon: {text: '\\u2015', css: 'font-weight: 900'},\n\t\t\t\t\t  enable(state) { return PF.PFMarkdown.canInsert(state, hr) },\n\t\t\t\t\t  run(state, dispatch) { dispatch(state.tr.replaceSelectionWith(hr.create())) }\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\n\t\t\tcase \"listJoinUp\":\n\t\t\t\titem = ProseMirror.menu.joinUpItem;\n\t\t\t\titem.spec.title = '';\n\t\t\t\treturn item;\n\t\n\t\t\tcase \"listLift\":\n\t\t\t\titem = ProseMirror.menu.liftItem;\n\t\t\t\treturn item;\n\t\n\t\t\tcase \"undo\":\n\t\t\t\titem = ProseMirror.menu.undoItem;\n\t\t\t\titem.spec.title = 'Vrátit zpět (ctrl-Z)';\n\t\t\t\treturn item;\n\t\n\t\t\tcase \"redo\":\n\t\t\t\titem = ProseMirror.menu.redoItem;\n\t\t\t\titem.spec.title = 'Opakovat (ctrl-Y)';\n\t\t\t\treturn item;\n\t\t}\n\t\n\t\treturn null;\n\t}\n\n\treturn null;\n}\n\nPF.PFMarkdown.CreateEditorMenu = function (menuItems, schema) {\n\treturn menuItems.map(itemList => itemList.map(item => createMenuItem(item, schema)).filter(Boolean));\n}\n\n// Zakladni ProseMirror menu. Je tady nechany jako priklad jak tam pridat dropdown menu a submenu, kdyby nekdy bylo potreba\n/*PF.PFMarkdown.CreateEditorMenuLegacy = function (schema) {\n\tlet r = {}\n\tlet mark = null\n\tif (mark = schema.marks.strong)\n\t  r.toggleStrong = markItem(mark, {title: \"Tučně\", icon: ProseMirror.menu.icons.strong})\n\tif (mark = schema.marks.em)\n\t  r.toggleEm = markItem(mark, {title: \"Kurzíva\", icon: ProseMirror.menu.icons.em})\n\tif (mark = schema.marks.code)\n\t  r.toggleCode = markItem(mark, {title: \"Kód\", icon: ProseMirror.menu.icons.code})\n\tif (mark = schema.marks.link)\n\t  r.toggleLink = linkItem(mark)\n  \n\tlet node = null\n\tif (node = schema.nodes.image)\n\t  r.insertImage = insertImageItem(node)\n\tif (node = schema.nodes.bullet_list)\n\t  r.wrapBulletList = wrapListItem(node, {\n\t\ttitle: \"Seznam s odrážkami\",\n\t\ticon: ProseMirror.menu.icons.bulletList\n\t  })\n\tif (node = schema.nodes.ordered_list)\n\t  r.wrapOrderedList = wrapListItem(node, {\n\t\ttitle: \"Číslovaný seznam\",\n\t\ticon: ProseMirror.menu.icons.orderedList\n\t  })\n\tif (node = schema.nodes.blockquote)\n\t  r.wrapBlockQuote = ProseMirror.menu.wrapItem(node, {\n\t\ttitle: \"Citace\",\n\t\ticon: ProseMirror.menu.icons.blockquote\n\t  })\n\tif (node = schema.nodes.paragraph)\n\t  r.makeParagraph = ProseMirror.menu.blockTypeItem(node, {\n\t\ttitle: \"Odstavec\",\n\t\tlabel: \"Odstavec\"\n\t  })\n\tif (node = schema.nodes.code_block)\n\t  r.makeCodeBlock = ProseMirror.menu.blockTypeItem(node, {\n\t\ttitle: \"Kód\",\n\t\tlabel: \"Kód\"\n\t  })\n\tif (node = schema.nodes.heading)\n\t  for (let i = 1; i <= 10; i++)\n\t\tr[\"makeHead\" + i] = ProseMirror.menu.blockTypeItem(node, {\n\t\t  title: \"Nadpis \" + i,\n\t\t  label: \"Úroveň \" + i,\n\t\t  attrs: {level: i}\n\t\t})\n\tif (node = schema.nodes.horizontal_rule) {\n\t  let hr = node\n\t  r.insertHorizontalRule = new ProseMirror.menu.MenuItem({\n\t\ttitle: \"Vodorovná čára\",\n\t\tlabel: \"Vodorovná čára\",\n\t\tenable(state) { return canInsert(state, hr) },\n\t\trun(state, dispatch) { dispatch(state.tr.replaceSelectionWith(hr.create())) }\n\t  })\n\t}\n  \n\tr.insertMenu = new ProseMirror.menu.Dropdown([r.insertImage, r.insertHorizontalRule].filter(Boolean), {label: \"Insert\"})\n\tr.typeMenu = new ProseMirror.menu.Dropdown([r.makeParagraph, r.makeCodeBlock, r.makeHead1 && new ProseMirror.menu.DropdownSubmenu([\n\t  r.makeHead1, r.makeHead2, r.makeHead3, r.makeHead4, r.makeHead5, r.makeHead6\n\t].filter(Boolean), {label: \"Heading\"})].filter(Boolean), {label: \"Type...\"})\n  \n\tr.inlineMenu = [[r.toggleStrong, r.toggleEm, r.toggleCode, r.toggleLink].filter(Boolean)]\n\tr.blockMenu = [[r.wrapBulletList, r.wrapOrderedList, r.wrapBlockQuote, ProseMirror.menu.joinUpItem,\tProseMirror.menu.liftItem].filter(Boolean)]\n\tr.fullMenu = r.inlineMenu.concat([[r.insertMenu, r.typeMenu]], [[ProseMirror.menu.undoItem, ProseMirror.menu.redoItem]], r.blockMenu)\n\n\treturn r\n}*/"],"mappings":"AAoCA,SAASA,QAAQC,EAAKC,GACrB,IAAIC,EAAgB,CACnBC,MAAOF,EAAQG,MACfC,IAAKL,GAEN,IAAK,IAAIM,KAAQL,EAASC,EAAcI,GAAQL,EAAQK,GAIxD,OAHKL,EAAQM,QAAWN,EAAQO,SAC/BN,EAAcD,EAAQM,OAAS,SAAW,UAAYE,GAAST,EAAIS,IAE7D,IAAIC,YAAYC,KAAKC,SAASV,EACtC,CAiBA,SAASW,SAASC,EAAUb,GAC3B,IAAIC,EAAgB,CACnBa,OAAON,GAAgBO,GAAGC,WAAWC,WAAWT,EAAOK,IAExD,IAAK,IAAIR,KAAQL,EAASC,EAAcI,GAAQL,EAAQK,GACxD,OAAOP,QAAQW,YAAYS,SAASC,WAAWN,GAAWZ,EAC3D,CAEA,SAASmB,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