/*! * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ * * Version: 5.7.0 (2021-02-10) * */ !function(n){var a={};function l(e){if(a[e])return a[e].exports;var t=a[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=n,l.c=a,l.d=function(e,t,n){l.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},l.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},l.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return l.d(t,"a",t),t},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.p="",l(l.s="./src/js/plugins/fullpage/plugin.js")}({"./src/js/plugins/fullpage/plugin.js":function(module,exports){eval("/**\n * Copyright (c) Tiny Technologies, Inc. All rights reserved.\n * Licensed under the LGPL or a commercial license.\n * For LGPL see License.txt in the project root for license information.\n * For commercial licenses see https://www.tiny.cloud/\n *\n * Version: 5.7.0 (2021-02-10)\n */\n (function () {\n 'use strict';\n\n var Cell = function (initial) {\n var value = initial;\n var get = function () {\n return value;\n };\n var set = function (v) {\n value = v;\n };\n return {\n get: get,\n set: set\n };\n };\n\n var global = tinymce.util.Tools.resolve('tinymce.PluginManager');\n\n var __assign = function () {\n __assign = Object.assign || function __assign(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s)\n if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n };\n\n var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');\n\n var global$2 = tinymce.util.Tools.resolve('tinymce.html.DomParser');\n\n var global$3 = tinymce.util.Tools.resolve('tinymce.html.Node');\n\n var global$4 = tinymce.util.Tools.resolve('tinymce.html.Serializer');\n\n var shouldHideInSourceView = function (editor) {\n return editor.getParam('fullpage_hide_in_source_view');\n };\n var getDefaultXmlPi = function (editor) {\n return editor.getParam('fullpage_default_xml_pi');\n };\n var getDefaultEncoding = function (editor) {\n return editor.getParam('fullpage_default_encoding');\n };\n var getDefaultFontFamily = function (editor) {\n return editor.getParam('fullpage_default_font_family');\n };\n var getDefaultFontSize = function (editor) {\n return editor.getParam('fullpage_default_font_size');\n };\n var getDefaultTextColor = function (editor) {\n return editor.getParam('fullpage_default_text_color');\n };\n var getDefaultTitle = function (editor) {\n return editor.getParam('fullpage_default_title');\n };\n var getDefaultDocType = function (editor) {\n return editor.getParam('fullpage_default_doctype', '');\n };\n var getProtect = function (editor) {\n return editor.getParam('protect');\n };\n\n var parseHeader = function (head) {\n return global$2({\n validate: false,\n root_name: '#document'\n }).parse(head, { format: 'xhtml' });\n };\n var htmlToData = function (editor, head) {\n var headerFragment = parseHeader(head);\n var data = {};\n var elm, matches;\n var getAttr = function (elm, name) {\n var value = elm.attr(name);\n return value || '';\n };\n data.fontface = getDefaultFontFamily(editor);\n data.fontsize = getDefaultFontSize(editor);\n elm = headerFragment.firstChild;\n if (elm.type === 7) {\n data.xml_pi = true;\n matches = /encoding=\"([^\"]+)\"/.exec(elm.value);\n if (matches) {\n data.docencoding = matches[1];\n }\n }\n elm = headerFragment.getAll('#doctype')[0];\n if (elm) {\n data.doctype = '';\n }\n elm = headerFragment.getAll('title')[0];\n if (elm && elm.firstChild) {\n data.title = elm.firstChild.value;\n }\n global$1.each(headerFragment.getAll('meta'), function (meta) {\n var name = meta.attr('name');\n var httpEquiv = meta.attr('http-equiv');\n var matches;\n if (name) {\n data[name.toLowerCase()] = meta.attr('content');\n } else if (httpEquiv === 'Content-Type') {\n matches = /charset\\s*=\\s*(.*)\\s*/gi.exec(meta.attr('content'));\n if (matches) {\n data.docencoding = matches[1];\n }\n }\n });\n elm = headerFragment.getAll('html')[0];\n if (elm) {\n data.langcode = getAttr(elm, 'lang') || getAttr(elm, 'xml:lang');\n }\n data.stylesheets = [];\n global$1.each(headerFragment.getAll('link'), function (link) {\n if (link.attr('rel') === 'stylesheet') {\n data.stylesheets.push(link.attr('href'));\n }\n });\n elm = headerFragment.getAll('body')[0];\n if (elm) {\n data.langdir = getAttr(elm, 'dir');\n data.style = getAttr(elm, 'style');\n data.visited_color = getAttr(elm, 'vlink');\n data.link_color = getAttr(elm, 'link');\n data.active_color = getAttr(elm, 'alink');\n }\n return data;\n };\n var dataToHtml = function (editor, data, head) {\n var headElement, elm, value;\n var dom = editor.dom;\n var setAttr = function (elm, name, value) {\n elm.attr(name, value ? value : undefined);\n };\n var addHeadNode = function (node) {\n if (headElement.firstChild) {\n headElement.insert(node, headElement.firstChild);\n } else {\n headElement.append(node);\n }\n };\n var headerFragment = parseHeader(head);\n headElement = headerFragment.getAll('head')[0];\n if (!headElement) {\n elm = headerFragment.getAll('html')[0];\n headElement = new global$3('head', 1);\n if (elm.firstChild) {\n elm.insert(headElement, elm.firstChild, true);\n } else {\n elm.append(headElement);\n }\n }\n elm = headerFragment.firstChild;\n if (data.xml_pi) {\n value = 'version=\"1.0\"';\n if (data.docencoding) {\n value += ' encoding=\"' + data.docencoding + '\"';\n }\n if (elm.type !== 7) {\n elm = new global$3('xml', 7);\n headerFragment.insert(elm, headerFragment.firstChild, true);\n }\n elm.value = value;\n } else if (elm && elm.type === 7) {\n elm.remove();\n }\n elm = headerFragment.getAll('#doctype')[0];\n if (data.doctype) {\n if (!elm) {\n elm = new global$3('#doctype', 10);\n if (data.xml_pi) {\n headerFragment.insert(elm, headerFragment.firstChild);\n } else {\n addHeadNode(elm);\n }\n }\n elm.value = data.doctype.substring(9, data.doctype.length - 1);\n } else if (elm) {\n elm.remove();\n }\n elm = null;\n global$1.each(headerFragment.getAll('meta'), function (meta) {\n if (meta.attr('http-equiv') === 'Content-Type') {\n elm = meta;\n }\n });\n if (data.docencoding) {\n if (!elm) {\n elm = new global$3('meta', 1);\n elm.attr('http-equiv', 'Content-Type');\n elm.shortEnded = true;\n addHeadNode(elm);\n }\n elm.attr('content', 'text/html; charset=' + data.docencoding);\n } else if (elm) {\n elm.remove();\n }\n elm = headerFragment.getAll('title')[0];\n if (data.title) {\n if (!elm) {\n elm = new global$3('title', 1);\n addHeadNode(elm);\n } else {\n elm.empty();\n }\n elm.append(new global$3('#text', 3)).value = data.title;\n } else if (elm) {\n elm.remove();\n }\n global$1.each('keywords,description,author,copyright,robots'.split(','), function (name) {\n var nodes = headerFragment.getAll('meta');\n var i, meta;\n var value = data[name];\n for (i = 0; i < nodes.length; i++) {\n meta = nodes[i];\n if (meta.attr('name') === name) {\n if (value) {\n meta.attr('content', value);\n } else {\n meta.remove();\n }\n return;\n }\n }\n if (value) {\n elm = new global$3('meta', 1);\n elm.attr('name', name);\n elm.attr('content', value);\n elm.shortEnded = true;\n addHeadNode(elm);\n }\n });\n var currentStyleSheetsMap = {};\n global$1.each(headerFragment.getAll('link'), function (stylesheet) {\n if (stylesheet.attr('rel') === 'stylesheet') {\n currentStyleSheetsMap[stylesheet.attr('href')] = stylesheet;\n }\n });\n global$1.each(data.stylesheets, function (stylesheet) {\n if (!currentStyleSheetsMap[stylesheet]) {\n elm = new global$3('link', 1);\n elm.attr({\n rel: 'stylesheet',\n text: 'text/css',\n href: stylesheet\n });\n elm.shortEnded = true;\n addHeadNode(elm);\n }\n delete currentStyleSheetsMap[stylesheet];\n });\n global$1.each(currentStyleSheetsMap, function (stylesheet) {\n stylesheet.remove();\n });\n elm = headerFragment.getAll('body')[0];\n if (elm) {\n setAttr(elm, 'dir', data.langdir);\n setAttr(elm, 'style', data.style);\n setAttr(elm, 'vlink', data.visited_color);\n setAttr(elm, 'link', data.link_color);\n setAttr(elm, 'alink', data.active_color);\n dom.setAttribs(editor.getBody(), {\n style: data.style,\n dir: data.dir,\n vLink: data.visited_color,\n link: data.link_color,\n aLink: data.active_color\n });\n }\n elm = headerFragment.getAll('html')[0];\n if (elm) {\n setAttr(elm, 'lang', data.langcode);\n setAttr(elm, 'xml:lang', data.langcode);\n }\n if (!headElement.firstChild) {\n headElement.remove();\n }\n var html = global$4({\n validate: false,\n indent: true,\n indent_before: 'head,html,body,meta,title,script,link,style',\n indent_after: 'head,html,body,meta,title,script,link,style'\n }).serialize(headerFragment);\n return html.substring(0, html.indexOf(''));\n };\n\n var open = function (editor, headState) {\n var data = htmlToData(editor, headState.get());\n var defaultData = {\n title: '',\n keywords: '',\n description: '',\n robots: '',\n author: '',\n docencoding: ''\n };\n var initialData = __assign(__assign({}, defaultData), data);\n editor.windowManager.open({\n title: 'Metadata and Document Properties',\n size: 'normal',\n body: {\n type: 'panel',\n items: [\n {\n name: 'title',\n type: 'input',\n label: 'Title'\n },\n {\n name: 'keywords',\n type: 'input',\n label: 'Keywords'\n },\n {\n name: 'description',\n type: 'input',\n label: 'Description'\n },\n {\n name: 'robots',\n type: 'input',\n label: 'Robots'\n },\n {\n name: 'author',\n type: 'input',\n label: 'Author'\n },\n {\n name: 'docencoding',\n type: 'input',\n label: 'Encoding'\n }\n ]\n },\n buttons: [\n {\n type: 'cancel',\n name: 'cancel',\n text: 'Cancel'\n },\n {\n type: 'submit',\n name: 'save',\n text: 'Save',\n primary: true\n }\n ],\n initialData: initialData,\n onSubmit: function (api) {\n var nuData = api.getData();\n var headHtml = dataToHtml(editor, global$1.extend(data, nuData), headState.get());\n headState.set(headHtml);\n api.close();\n }\n });\n };\n\n var register = function (editor, headState) {\n editor.addCommand('mceFullPageProperties', function () {\n open(editor, headState);\n });\n };\n\n var protectHtml = function (protect, html) {\n global$1.each(protect, function (pattern) {\n html = html.replace(pattern, function (str) {\n return '\x3c!--mce:protected ' + escape(str) + '--\x3e';\n });\n });\n return html;\n };\n var unprotectHtml = function (html) {\n return html.replace(/\x3c!--mce:protected ([\\s\\S]*?)--\x3e/g, function (a, m) {\n return unescape(m);\n });\n };\n\n var each = global$1.each;\n var low = function (s) {\n return s.replace(/<\\/?[A-Z]+/g, function (a) {\n return a.toLowerCase();\n });\n };\n var handleSetContent = function (editor, headState, footState, evt) {\n var startPos, endPos, content, styles = '';\n var dom = editor.dom;\n if (evt.selection) {\n return;\n }\n content = protectHtml(getProtect(editor), evt.content);\n if (evt.format === 'raw' && headState.get()) {\n return;\n }\n if (evt.source_view && shouldHideInSourceView(editor)) {\n return;\n }\n if (content.length === 0 && !evt.source_view) {\n content = global$1.trim(headState.get()) + '\\n' + global$1.trim(content) + '\\n' + global$1.trim(footState.get());\n }\n content = content.replace(/<(\\/?)BODY/gi, '<$1body');\n startPos = content.indexOf('', startPos);\n headState.set(low(content.substring(0, startPos + 1)));\n endPos = content.indexOf('\\n');\n }\n var headerFragment = parseHeader(headState.get());\n each(headerFragment.getAll('style'), function (node) {\n if (node.firstChild) {\n styles += node.firstChild.value;\n }\n });\n var bodyElm = headerFragment.getAll('body')[0];\n if (bodyElm) {\n dom.setAttribs(editor.getBody(), {\n style: bodyElm.attr('style') || '',\n dir: bodyElm.attr('dir') || '',\n vLink: bodyElm.attr('vlink') || '',\n link: bodyElm.attr('link') || '',\n aLink: bodyElm.attr('alink') || ''\n });\n }\n dom.remove('fullpage_styles');\n var headElm = editor.getDoc().getElementsByTagName('head')[0];\n if (styles) {\n var styleElm = dom.add(headElm, 'style', { id: 'fullpage_styles' });\n styleElm.appendChild(document.createTextNode(styles));\n }\n var currentStyleSheetsMap = {};\n global$1.each(headElm.getElementsByTagName('link'), function (stylesheet) {\n if (stylesheet.rel === 'stylesheet' && stylesheet.getAttribute('data-mce-fullpage')) {\n currentStyleSheetsMap[stylesheet.href] = stylesheet;\n }\n });\n global$1.each(headerFragment.getAll('link'), function (stylesheet) {\n var href = stylesheet.attr('href');\n if (!href) {\n return true;\n }\n if (!currentStyleSheetsMap[href] && stylesheet.attr('rel') === 'stylesheet') {\n dom.add(headElm, 'link', {\n 'rel': 'stylesheet',\n 'text': 'text/css',\n href: href,\n 'data-mce-fullpage': '1'\n });\n }\n delete currentStyleSheetsMap[href];\n });\n global$1.each(currentStyleSheetsMap, function (stylesheet) {\n stylesheet.parentNode.removeChild(stylesheet);\n });\n };\n var getDefaultHeader = function (editor) {\n var header = '', value, styles = '';\n if (getDefaultXmlPi(editor)) {\n var piEncoding = getDefaultEncoding(editor);\n header += '\\n';\n }\n header += getDefaultDocType(editor);\n header += '\\n\\n\\n';\n if (value = getDefaultTitle(editor)) {\n header += '' + value + '\\n';\n }\n if (value = getDefaultEncoding(editor)) {\n header += '\\n';\n }\n if (value = getDefaultFontFamily(editor)) {\n styles += 'font-family: ' + value + ';';\n }\n if (value = getDefaultFontSize(editor)) {\n styles += 'font-size: ' + value + ';';\n }\n if (value = getDefaultTextColor(editor)) {\n styles += 'color: ' + value + ';';\n }\n header += '\\n\\n';\n return header;\n };\n var handleGetContent = function (editor, head, foot, evt) {\n if (evt.format === 'html' && !evt.selection && (!evt.source_view || !shouldHideInSourceView(editor))) {\n evt.content = unprotectHtml(global$1.trim(head) + '\\n' + global$1.trim(evt.content) + '\\n' + global$1.trim(foot));\n }\n };\n var setup = function (editor, headState, footState) {\n editor.on('BeforeSetContent', function (evt) {\n handleSetContent(editor, headState, footState, evt);\n });\n editor.on('GetContent', function (evt) {\n handleGetContent(editor, headState.get(), footState.get(), evt);\n });\n };\n\n var register$1 = function (editor) {\n editor.ui.registry.addButton('fullpage', {\n tooltip: 'Metadata and document properties',\n icon: 'document-properties',\n onAction: function () {\n editor.execCommand('mceFullPageProperties');\n }\n });\n editor.ui.registry.addMenuItem('fullpage', {\n text: 'Metadata and document properties',\n icon: 'document-properties',\n onAction: function () {\n editor.execCommand('mceFullPageProperties');\n }\n });\n };\n\n function Plugin () {\n global.add('fullpage', function (editor) {\n var headState = Cell(''), footState = Cell('');\n register(editor, headState);\n register$1(editor);\n setup(editor, headState, footState);\n });\n }\n\n Plugin();\n\n}());\n\n\n//# sourceURL=webpack:///./src/js/plugins/fullpage/plugin.js?")}});