Rev 1042 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1042 | Rev 1422 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. |
2 | * Copyright (c) Tiny Technologies, Inc. All rights reserved. |
3 | * Licensed under the LGPL or a commercial license. |
3 | * Licensed under the LGPL or a commercial license. |
4 | * For LGPL see License.txt in the project root for license information. |
4 | * For LGPL see License.txt in the project root for license information. |
5 | * For commercial licenses see https://www.tiny.cloud/ |
5 | * For commercial licenses see https://www.tiny.cloud/ |
6 | * |
6 | * |
7 | * Version: 5.10.7 (2022-12-06) |
7 | * Version: 5.10.8 (2023-10-19) |
8 | */ |
8 | */ |
9 | (function () { |
9 | (function () { |
10 | 'use strict'; |
10 | 'use strict'; |
11 | 11 | ||
12 | var typeOf$1 = function (x) { |
12 | var typeOf$1 = function (x) { |
Line 804... | Line 804... | ||
804 | var blank = function (r) { |
804 | var blank = function (r) { |
805 | return function (s) { |
805 | return function (s) { |
806 | return s.replace(r, ''); |
806 | return s.replace(r, ''); |
807 | }; |
807 | }; |
808 | }; |
808 | }; |
809 | var trim$4 = blank(/^\s+|\s+$/g); |
809 | var trim$5 = blank(/^\s+|\s+$/g); |
810 | var lTrim = blank(/^\s+/g); |
810 | var lTrim = blank(/^\s+/g); |
811 | var rTrim = blank(/\s+$/g); |
811 | var rTrim = blank(/\s+$/g); |
812 | var isNotEmpty = function (s) { |
812 | var isNotEmpty = function (s) { |
813 | return s.length > 0; |
813 | return s.length > 0; |
814 | }; |
814 | }; |
Line 1107... | Line 1107... | ||
1107 | isWebView: deviceType.isWebView |
1107 | isWebView: deviceType.isWebView |
1108 | } |
1108 | } |
1109 | }; |
1109 | }; |
1110 | 1110 | ||
1111 | var whiteSpaceRegExp$2 = /^\s*|\s*$/g; |
1111 | var whiteSpaceRegExp$2 = /^\s*|\s*$/g; |
1112 | var trim$3 = function (str) { |
1112 | var trim$4 = function (str) { |
1113 | return str === null || str === undefined ? '' : ('' + str).replace(whiteSpaceRegExp$2, ''); |
1113 | return str === null || str === undefined ? '' : ('' + str).replace(whiteSpaceRegExp$2, ''); |
1114 | }; |
1114 | }; |
1115 | var is$3 = function (obj, type) { |
1115 | var is$3 = function (obj, type) { |
1116 | if (!type) { |
1116 | if (!type) { |
1117 | return obj !== undefined; |
1117 | return obj !== undefined; |
Line 1253... | Line 1253... | ||
1253 | }; |
1253 | }; |
1254 | var explode$4 = function (s, d) { |
1254 | var explode$4 = function (s, d) { |
1255 | if (!s || is$3(s, 'array')) { |
1255 | if (!s || is$3(s, 'array')) { |
1256 | return s; |
1256 | return s; |
1257 | } |
1257 | } |
1258 | return map$1(s.split(d || ','), trim$3); |
1258 | return map$1(s.split(d || ','), trim$4); |
1259 | }; |
1259 | }; |
1260 | var _addCacheSuffix = function (url) { |
1260 | var _addCacheSuffix = function (url) { |
1261 | var cacheSuffix = Env.cacheSuffix; |
1261 | var cacheSuffix = Env.cacheSuffix; |
1262 | if (cacheSuffix) { |
1262 | if (cacheSuffix) { |
1263 | url += (url.indexOf('?') === -1 ? '?' : '&') + cacheSuffix; |
1263 | url += (url.indexOf('?') === -1 ? '?' : '&') + cacheSuffix; |
1264 | } |
1264 | } |
1265 | return url; |
1265 | return url; |
1266 | }; |
1266 | }; |
1267 | var Tools = { |
1267 | var Tools = { |
1268 | trim: trim$3, |
1268 | trim: trim$4, |
1269 | isArray: isArray, |
1269 | isArray: isArray, |
1270 | is: is$3, |
1270 | is: is$3, |
1271 | toArray: toArray$1, |
1271 | toArray: toArray$1, |
1272 | makeMap: makeMap$4, |
1272 | makeMap: makeMap$4, |
1273 | each: each$i, |
1273 | each: each$i, |
Line 3087... | Line 3087... | ||
3087 | return s.replace(/\uFEFF/g, ''); |
3087 | return s.replace(/\uFEFF/g, ''); |
3088 | }; |
3088 | }; |
3089 | 3089 | ||
3090 | var ZWSP$1 = zeroWidth; |
3090 | var ZWSP$1 = zeroWidth; |
3091 | var isZwsp = isZwsp$1; |
3091 | var isZwsp = isZwsp$1; |
3092 | var trim$2 = removeZwsp; |
3092 | var trim$3 = removeZwsp; |
3093 | 3093 | ||
3094 | var isElement$4 = isElement$5; |
3094 | var isElement$4 = isElement$5; |
3095 | var isText$6 = isText$7; |
3095 | var isText$6 = isText$7; |
3096 | var isCaretContainerBlock$1 = function (node) { |
3096 | var isCaretContainerBlock$1 = function (node) { |
3097 | if (isText$6(node)) { |
3097 | if (isText$6(node)) { |
Line 5855... | Line 5855... | ||
5855 | } |
5855 | } |
5856 | } |
5856 | } |
5857 | return -1; |
5857 | return -1; |
5858 | }; |
5858 | }; |
5859 | var whiteSpaceRegExp = /^\s*|\s*$/g; |
5859 | var whiteSpaceRegExp = /^\s*|\s*$/g; |
5860 | var trim$1 = function (str) { |
5860 | var trim$2 = function (str) { |
5861 | return str === null || str === undefined ? '' : ('' + str).replace(whiteSpaceRegExp, ''); |
5861 | return str === null || str === undefined ? '' : ('' + str).replace(whiteSpaceRegExp, ''); |
5862 | }; |
5862 | }; |
5863 | var each$g = function (obj, callback) { |
5863 | var each$g = function (obj, callback) { |
5864 | var length, key, i, value; |
5864 | var length, key, i, value; |
5865 | if (obj) { |
5865 | if (obj) { |
Line 6252... | Line 6252... | ||
6252 | self.each(function (index, node) { |
6252 | self.each(function (index, node) { |
6253 | var classState = hasClass(node, className); |
6253 | var classState = hasClass(node, className); |
6254 | if (classState !== state) { |
6254 | if (classState !== state) { |
6255 | var existingClassName = node.className; |
6255 | var existingClassName = node.className; |
6256 | if (classState) { |
6256 | if (classState) { |
6257 | node.className = trim$1((' ' + existingClassName + ' ').replace(' ' + className + ' ', ' ')); |
6257 | node.className = trim$2((' ' + existingClassName + ' ').replace(' ' + className + ' ', ' ')); |
6258 | } else { |
6258 | } else { |
6259 | node.className += existingClassName ? ' ' + className : className; |
6259 | node.className += existingClassName ? ' ' + className : className; |
6260 | } |
6260 | } |
6261 | } |
6261 | } |
6262 | }); |
6262 | }); |
Line 6375... | Line 6375... | ||
6375 | return Tools.toArray(object); |
6375 | return Tools.toArray(object); |
6376 | }, |
6376 | }, |
6377 | inArray: inArray$1, |
6377 | inArray: inArray$1, |
6378 | isArray: Tools.isArray, |
6378 | isArray: Tools.isArray, |
6379 | each: each$g, |
6379 | each: each$g, |
6380 | trim: trim$1, |
6380 | trim: trim$2, |
6381 | grep: grep$2, |
6381 | grep: grep$2, |
6382 | find: Sizzle, |
6382 | find: Sizzle, |
6383 | expr: Sizzle.selectors, |
6383 | expr: Sizzle.selectors, |
6384 | unique: Sizzle.uniqueSort, |
6384 | unique: Sizzle.uniqueSort, |
6385 | text: Sizzle.getText, |
6385 | text: Sizzle.getText, |
Line 8980... | Line 8980... | ||
8980 | }); |
8980 | }); |
8981 | return { id: id }; |
8981 | return { id: id }; |
8982 | }; |
8982 | }; |
8983 | var getBookmark$2 = function (selection, type, normalized) { |
8983 | var getBookmark$2 = function (selection, type, normalized) { |
8984 | if (type === 2) { |
8984 | if (type === 2) { |
8985 | return getOffsetBookmark(trim$2, normalized, selection); |
8985 | return getOffsetBookmark(trim$3, normalized, selection); |
8986 | } else if (type === 3) { |
8986 | } else if (type === 3) { |
8987 | return getCaretBookmark(selection); |
8987 | return getCaretBookmark(selection); |
8988 | } else if (type) { |
8988 | } else if (type) { |
8989 | return getRangeBookmark(selection); |
8989 | return getRangeBookmark(selection); |
8990 | } else { |
8990 | } else { |
Line 9108... | Line 9108... | ||
9108 | return editor.getParam('indentation', '40px', 'string'); |
9108 | return editor.getParam('indentation', '40px', 'string'); |
9109 | }; |
9109 | }; |
9110 | var getContentCss = function (editor) { |
9110 | var getContentCss = function (editor) { |
9111 | var contentCss = editor.getParam('content_css'); |
9111 | var contentCss = editor.getParam('content_css'); |
9112 | if (isString$1(contentCss)) { |
9112 | if (isString$1(contentCss)) { |
9113 | return map$3(contentCss.split(','), trim$4); |
9113 | return map$3(contentCss.split(','), trim$5); |
9114 | } else if (isArray$1(contentCss)) { |
9114 | } else if (isArray$1(contentCss)) { |
9115 | return contentCss; |
9115 | return contentCss; |
9116 | } else if (contentCss === false || editor.inline) { |
9116 | } else if (contentCss === false || editor.inline) { |
9117 | return []; |
9117 | return []; |
9118 | } else { |
9118 | } else { |
9119 | return ['default']; |
9119 | return ['default']; |
9120 | } |
9120 | } |
9121 | }; |
9121 | }; |
9122 | var getFontCss = function (editor) { |
9122 | var getFontCss = function (editor) { |
9123 | var fontCss = editor.getParam('font_css', []); |
9123 | var fontCss = editor.getParam('font_css', []); |
9124 | return isArray$1(fontCss) ? fontCss : map$3(fontCss.split(','), trim$4); |
9124 | return isArray$1(fontCss) ? fontCss : map$3(fontCss.split(','), trim$5); |
9125 | }; |
9125 | }; |
9126 | var getDirectionality = function (editor) { |
9126 | var getDirectionality = function (editor) { |
9127 | return editor.getParam('directionality', I18n.isRtl() ? 'rtl' : undefined); |
9127 | return editor.getParam('directionality', I18n.isRtl() ? 'rtl' : undefined); |
9128 | }; |
9128 | }; |
9129 | var getInlineBoundarySelector = function (editor) { |
9129 | var getInlineBoundarySelector = function (editor) { |
Line 9240... | Line 9240... | ||
9240 | if (parentNode) { |
9240 | if (parentNode) { |
9241 | parentNode.removeChild(node); |
9241 | parentNode.removeChild(node); |
9242 | } |
9242 | } |
9243 | }; |
9243 | }; |
9244 | var trimCount = function (text) { |
9244 | var trimCount = function (text) { |
9245 | var trimmedText = trim$2(text); |
9245 | var trimmedText = trim$3(text); |
9246 | return { |
9246 | return { |
9247 | count: text.length - trimmedText.length, |
9247 | count: text.length - trimmedText.length, |
9248 | text: trimmedText |
9248 | text: trimmedText |
9249 | }; |
9249 | }; |
9250 | }; |
9250 | }; |
Line 12885... | Line 12885... | ||
12885 | return walk$1(this, null, prev); |
12885 | return walk$1(this, null, prev); |
12886 | }; |
12886 | }; |
12887 | return AstNode; |
12887 | return AstNode; |
12888 | }(); |
12888 | }(); |
12889 | 12889 | ||
12890 | var extractBase64DataUris = function (html) { |
12890 | var getTemporaryNodeSelector = function (tempAttrs) { |
12891 | var dataImageUri = /data:[^;<"'\s]+;base64,([a-z0-9\+\/=\s]+)/gi; |
- | |
12892 | var chunks = []; |
- | |
12893 | var uris = {}; |
- | |
12894 | var prefix = generate('img'); |
- | |
12895 | var matches; |
- | |
12896 | var index = 0; |
- | |
12897 | var count = 0; |
- | |
12898 | while (matches = dataImageUri.exec(html)) { |
12891 | return (tempAttrs.length === 0 ? '' : map$3(tempAttrs, function (attr) { |
12899 | var uri = matches[0]; |
12892 | return '[' + attr + ']'; |
12900 | var imageId = prefix + '_' + count++; |
12893 | }).join(',') + ',') + '[data-mce-bogus="all"]'; |
12901 | uris[imageId] = uri; |
- | |
12902 | if (index < matches.index) { |
- | |
12903 | chunks.push(html.substr(index, matches.index - index)); |
- | |
12904 | } |
- | |
12905 | chunks.push(imageId); |
- | |
12906 | index = matches.index + uri.length; |
- | |
12907 | } |
- | |
12908 | var re = new RegExp(prefix + '_[0-9]+', 'g'); |
- | |
12909 | if (index === 0) { |
- | |
12910 | return { |
- | |
12911 | prefix: prefix, |
- | |
12912 | uris: uris, |
- | |
12913 | html: html, |
- | |
12914 | re: re |
- | |
12915 | }; |
- | |
12916 | } else { |
- | |
12917 | if (index < html.length) { |
- | |
12918 | chunks.push(html.substr(index)); |
- | |
12919 | } |
- | |
12920 | return { |
- | |
12921 | prefix: prefix, |
- | |
12922 | uris: uris, |
- | |
12923 | html: chunks.join(''), |
- | |
12924 | re: re |
- | |
12925 | }; |
- | |
12926 | } |
- | |
12927 | }; |
12894 | }; |
12928 | var restoreDataUris = function (html, result) { |
12895 | var getTemporaryNodes = function (body, tempAttrs) { |
12929 | return html.replace(result.re, function (imageId) { |
- | |
12930 | return get$9(result.uris, imageId).getOr(imageId); |
12896 | return body.querySelectorAll(getTemporaryNodeSelector(tempAttrs)); |
12931 | }); |
- | |
12932 | }; |
12897 | }; |
12933 | var parseDataUri$1 = function (uri) { |
12898 | var createCommentWalker = function (body) { |
12934 | var matches = /data:([^;]+);base64,([a-z0-9\+\/=\s]+)/i.exec(uri); |
- | |
12935 | if (matches) { |
- | |
12936 | return Optional.some({ |
- | |
12937 | type: matches[1], |
- | |
12938 | data: decodeURIComponent(matches[2]) |
- | |
12939 | }); |
- | |
12940 | } else { |
- | |
12941 | return Optional.none(); |
- | |
12942 | } |
- | |
12943 | }; |
- | |
12944 | - | ||
12945 | var each$d = Tools.each, trim = Tools.trim; |
- | |
12946 | var queryParts = 'source protocol authority userInfo user password host port relative path directory file query anchor'.split(' '); |
- | |
12947 | var DEFAULT_PORTS = { |
- | |
12948 | ftp: 21, |
- | |
12949 | http: 80, |
- | |
12950 | https: 443, |
- | |
12951 | mailto: 25 |
- | |
12952 | }; |
- | |
12953 | var safeSvgDataUrlElements = [ |
- | |
12954 | 'img', |
- | |
12955 | 'video' |
- | |
12956 | ]; |
- | |
12957 | var blockSvgDataUris = function (allowSvgDataUrls, tagName) { |
- | |
12958 | if (isNonNullable(allowSvgDataUrls)) { |
- | |
12959 | return !allowSvgDataUrls; |
- | |
12960 | } else { |
- | |
12961 | return isNonNullable(tagName) ? !contains$3(safeSvgDataUrlElements, tagName) : true; |
12899 | return document.createTreeWalker(body, NodeFilter.SHOW_COMMENT, null, false); |
12962 | } |
- | |
12963 | }; |
- | |
12964 | var isInvalidUri = function (settings, uri, tagName) { |
- | |
12965 | if (settings.allow_html_data_urls) { |
- | |
12966 | return false; |
- | |
12967 | } else if (/^data:image\//i.test(uri)) { |
- | |
12968 | return blockSvgDataUris(settings.allow_svg_data_urls, tagName) && /^data:image\/svg\+xml/i.test(uri); |
- | |
12969 | } else { |
- | |
12970 | return /^data:/i.test(uri); |
- | |
12971 | } |
- | |
12972 | }; |
12900 | }; |
12973 | var URI = function () { |
12901 | var hasComments = function (body) { |
12974 | function URI(url, settings) { |
- | |
12975 | url = trim(url); |
- | |
12976 | this.settings = settings || {}; |
- | |
12977 | var baseUri = this.settings.base_uri; |
- | |
12978 | var self = this; |
- | |
12979 | if (/^([\w\-]+):([^\/]{2})/i.test(url) || /^\s*#/.test(url)) { |
- | |
12980 | self.source = url; |
- | |
12981 | return; |
- | |
12982 | } |
- | |
12983 | var isProtocolRelative = url.indexOf('//') === 0; |
12902 | return createCommentWalker(body).nextNode() !== null; |
12984 | if (url.indexOf('/') === 0 && !isProtocolRelative) { |
- | |
12985 | url = (baseUri ? baseUri.protocol || 'http' : 'http') + '://mce_host' + url; |
- | |
12986 | } |
- | |
12987 | if (!/^[\w\-]*:?\/\//.test(url)) { |
- | |
12988 | var baseUrl = this.settings.base_uri ? this.settings.base_uri.path : new URI(document.location.href).directory; |
- | |
12989 | if (this.settings.base_uri && this.settings.base_uri.protocol == '') { |
- | |
12990 | url = '//mce_host' + self.toAbsPath(baseUrl, url); |
- | |
12991 | } else { |
- | |
12992 | var match = /([^#?]*)([#?]?.*)/.exec(url); |
- | |
12993 | url = (baseUri && baseUri.protocol || 'http') + '://mce_host' + self.toAbsPath(baseUrl, match[1]) + match[2]; |
- | |
12994 | } |
- | |
12995 | } |
- | |
12996 | url = url.replace(/@@/g, '(mce_at)'); |
- | |
12997 | var urlMatch = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?(\[[a-zA-Z0-9:.%]+\]|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(url); |
- | |
12998 | each$d(queryParts, function (v, i) { |
- | |
12999 | var part = urlMatch[i]; |
- | |
13000 | if (part) { |
- | |
13001 | part = part.replace(/\(mce_at\)/g, '@@'); |
- | |
13002 | } |
- | |
13003 | self[v] = part; |
- | |
13004 | }); |
- | |
13005 | if (baseUri) { |
- | |
13006 | if (!self.protocol) { |
- | |
13007 | self.protocol = baseUri.protocol; |
- | |
13008 | } |
- | |
13009 | if (!self.userInfo) { |
- | |
13010 | self.userInfo = baseUri.userInfo; |
- | |
13011 | } |
- | |
13012 | if (!self.port && self.host === 'mce_host') { |
- | |
13013 | self.port = baseUri.port; |
- | |
13014 | } |
- | |
13015 | if (!self.host || self.host === 'mce_host') { |
- | |
13016 | self.host = baseUri.host; |
- | |
13017 | } |
- | |
13018 | self.source = ''; |
- | |
13019 | } |
- | |
13020 | if (isProtocolRelative) { |
- | |
13021 | self.protocol = ''; |
- | |
13022 | } |
- | |
13023 | } |
- | |
13024 | URI.parseDataUri = function (uri) { |
- | |
13025 | var type; |
- | |
13026 | var uriComponents = decodeURIComponent(uri).split(','); |
- | |
13027 | var matches = /data:([^;]+)/.exec(uriComponents[0]); |
- | |
13028 | if (matches) { |
- | |
13029 | type = matches[1]; |
- | |
13030 | } |
- | |
13031 | return { |
- | |
13032 | type: type, |
- | |
13033 | data: uriComponents[1] |
- | |
13034 | }; |
- | |
13035 | }; |
12903 | }; |
13036 | URI.isDomSafe = function (uri, context, options) { |
12904 | var hasTemporaryNodes = function (body, tempAttrs) { |
13037 | if (options === void 0) { |
- | |
13038 | options = {}; |
- | |
13039 | } |
- | |
13040 | if (options.allow_script_urls) { |
- | |
13041 | return true; |
- | |
13042 | } else { |
- | |
13043 | var decodedUri = Entities.decode(uri).replace(/[\s\u0000-\u001F]+/g, ''); |
- | |
13044 | try { |
- | |
13045 | decodedUri = decodeURIComponent(decodedUri); |
- | |
13046 | } catch (ex) { |
- | |
13047 | decodedUri = unescape(decodedUri); |
- | |
13048 | } |
- | |
13049 | if (/((java|vb)script|mhtml):/i.test(decodedUri)) { |
- | |
13050 | return false; |
- | |
13051 | } |
- | |
13052 | return !isInvalidUri(options, decodedUri, context); |
12905 | return body.querySelector(getTemporaryNodeSelector(tempAttrs)) !== null; |
13053 | } |
- | |
13054 | }; |
- | |
13055 | URI.getDocumentBaseUrl = function (loc) { |
- | |
13056 | var baseUrl; |
- | |
13057 | if (loc.protocol.indexOf('http') !== 0 && loc.protocol !== 'file:') { |
- | |
13058 | baseUrl = loc.href; |
- | |
13059 | } else { |
- | |
13060 | baseUrl = loc.protocol + '//' + loc.host + loc.pathname; |
- | |
13061 | } |
- | |
13062 | if (/^[^:]+:\/\/\/?[^\/]+\//.test(baseUrl)) { |
- | |
13063 | baseUrl = baseUrl.replace(/[\?#].*$/, '').replace(/[\/\\][^\/]+$/, ''); |
- | |
13064 | if (!/[\/\\]$/.test(baseUrl)) { |
- | |
13065 | baseUrl += '/'; |
- | |
13066 | } |
- | |
13067 | } |
- | |
13068 | return baseUrl; |
- | |
13069 | }; |
- | |
13070 | URI.prototype.setPath = function (path) { |
- | |
13071 | var pathMatch = /^(.*?)\/?(\w+)?$/.exec(path); |
- | |
13072 | this.path = pathMatch[0]; |
- | |
13073 | this.directory = pathMatch[1]; |
- | |
13074 | this.file = pathMatch[2]; |
- | |
13075 | this.source = ''; |
- | |
13076 | this.getURI(); |
- | |
13077 | }; |
- | |
13078 | URI.prototype.toRelative = function (uri) { |
- | |
13079 | var output; |
- | |
13080 | if (uri === './') { |
- | |
13081 | return uri; |
- | |
13082 | } |
- | |
13083 | var relativeUri = new URI(uri, { base_uri: this }); |
- | |
13084 | if (relativeUri.host !== 'mce_host' && this.host !== relativeUri.host && relativeUri.host || this.port !== relativeUri.port || this.protocol !== relativeUri.protocol && relativeUri.protocol !== '') { |
- | |
13085 | return relativeUri.getURI(); |
- | |
13086 | } |
- | |
13087 | var tu = this.getURI(), uu = relativeUri.getURI(); |
- | |
13088 | if (tu === uu || tu.charAt(tu.length - 1) === '/' && tu.substr(0, tu.length - 1) === uu) { |
- | |
13089 | return tu; |
- | |
13090 | } |
- | |
13091 | output = this.toRelPath(this.path, relativeUri.path); |
- | |
13092 | if (relativeUri.query) { |
- | |
13093 | output += '?' + relativeUri.query; |
- | |
13094 | } |
- | |
13095 | if (relativeUri.anchor) { |
- | |
13096 | output += '#' + relativeUri.anchor; |
- | |
13097 | } |
- | |
13098 | return output; |
- | |
13099 | }; |
12906 | }; |
13100 | URI.prototype.toAbsolute = function (uri, noHost) { |
12907 | var trimTemporaryNodes = function (body, tempAttrs) { |
13101 | var absoluteUri = new URI(uri, { base_uri: this }); |
- | |
13102 | return absoluteUri.getURI(noHost && this.isSameOrigin(absoluteUri)); |
- | |
13103 | }; |
- | |
13104 | URI.prototype.isSameOrigin = function (uri) { |
12908 | each$k(getTemporaryNodes(body, tempAttrs), function (elm) { |
13105 | if (this.host == uri.host && this.protocol == uri.protocol) { |
- | |
13106 | if (this.port == uri.port) { |
- | |
13107 | return true; |
- | |
13108 | } |
- | |
13109 | var defaultPort = DEFAULT_PORTS[this.protocol]; |
- | |
13110 | if (defaultPort && (this.port || defaultPort) == (uri.port || defaultPort)) { |
- | |
13111 | return true; |
- | |
13112 | } |
- | |
13113 | } |
- | |
13114 | return false; |
- | |
13115 | }; |
- | |
13116 | URI.prototype.toRelPath = function (base, path) { |
- | |
13117 | var breakPoint = 0, out = '', i, l; |
- | |
13118 | var normalizedBase = base.substring(0, base.lastIndexOf('/')).split('/'); |
- | |
13119 | var items = path.split('/'); |
12909 | var element = SugarElement.fromDom(elm); |
13120 | if (normalizedBase.length >= items.length) { |
- | |
13121 | for (i = 0, l = normalizedBase.length; i < l; i++) { |
- | |
13122 | if (i >= items.length || normalizedBase[i] !== items[i]) { |
12910 | if (get$6(element, 'data-mce-bogus') === 'all') { |
13123 | breakPoint = i + 1; |
- | |
13124 | break; |
- | |
13125 | } |
- | |
13126 | } |
- | |
13127 | } |
- | |
13128 | if (normalizedBase.length < items.length) { |
- | |
13129 | for (i = 0, l = items.length; i < l; i++) { |
- | |
13130 | if (i >= normalizedBase.length || normalizedBase[i] !== items[i]) { |
- | |
13131 | breakPoint = i + 1; |
- | |
13132 | break; |
- | |
13133 | } |
- | |
13134 | } |
- | |
13135 | } |
- | |
13136 | if (breakPoint === 1) { |
- | |
13137 | return path; |
- | |
13138 | } |
- | |
13139 | for (i = 0, l = normalizedBase.length - (breakPoint - 1); i < l; i++) { |
- | |
13140 | out += '../'; |
- | |
13141 | } |
- | |
13142 | for (i = breakPoint - 1, l = items.length; i < l; i++) { |
- | |
13143 | if (i !== breakPoint - 1) { |
- | |
13144 | out += '/' + items[i]; |
- | |
13145 | } else { |
- | |
13146 | out += items[i]; |
12911 | remove$7(element); |
13147 | } |
- | |
13148 | } |
- | |
13149 | return out; |
- | |
13150 | }; |
- | |
13151 | URI.prototype.toAbsPath = function (base, path) { |
- | |
13152 | var i, nb = 0, o = [], outPath; |
- | |
13153 | var tr = /\/$/.test(path) ? '/' : ''; |
- | |
13154 | var normalizedBase = base.split('/'); |
- | |
13155 | var normalizedPath = path.split('/'); |
- | |
13156 | each$d(normalizedBase, function (k) { |
- | |
13157 | if (k) { |
- | |
13158 | o.push(k); |
- | |
13159 | } |
- | |
13160 | }); |
- | |
13161 | normalizedBase = o; |
- | |
13162 | for (i = normalizedPath.length - 1, o = []; i >= 0; i--) { |
- | |
13163 | if (normalizedPath[i].length === 0 || normalizedPath[i] === '.') { |
- | |
13164 | continue; |
- | |
13165 | } |
- | |
13166 | if (normalizedPath[i] === '..') { |
- | |
13167 | nb++; |
- | |
13168 | continue; |
- | |
13169 | } |
- | |
13170 | if (nb > 0) { |
- | |
13171 | nb--; |
- | |
13172 | continue; |
- | |
13173 | } |
- | |
13174 | o.push(normalizedPath[i]); |
- | |
13175 | } |
- | |
13176 | i = normalizedBase.length - nb; |
- | |
13177 | if (i <= 0) { |
- | |
13178 | outPath = reverse(o).join('/'); |
- | |
13179 | } else { |
12912 | } else { |
13180 | outPath = normalizedBase.slice(0, i).join('/') + '/' + reverse(o).join('/'); |
- | |
13181 | } |
- | |
13182 | if (outPath.indexOf('/') !== 0) { |
- | |
13183 | outPath = '/' + outPath; |
- | |
13184 | } |
- | |
13185 | if (tr && outPath.lastIndexOf('/') !== outPath.length - 1) { |
- | |
13186 | outPath += tr; |
- | |
13187 | } |
- | |
13188 | return outPath; |
- | |
13189 | }; |
- | |
13190 | URI.prototype.getURI = function (noProtoHost) { |
12913 | each$k(tempAttrs, function (attr) { |
13191 | if (noProtoHost === void 0) { |
- | |
13192 | noProtoHost = false; |
- | |
13193 | } |
- | |
13194 | var s; |
- | |
13195 | if (!this.source || noProtoHost) { |
- | |
13196 | s = ''; |
- | |
13197 | if (!noProtoHost) { |
- | |
13198 | if (this.protocol) { |
- | |
13199 | s += this.protocol + '://'; |
- | |
13200 | } else { |
- | |
13201 | s += '//'; |
- | |
13202 | } |
- | |
13203 | if (this.userInfo) { |
12914 | if (has$1(element, attr)) { |
13204 | s += this.userInfo + '@'; |
12915 | remove$6(element, attr); |
13205 | } |
- | |
13206 | if (this.host) { |
- | |
13207 | s += this.host; |
- | |
13208 | } |
- | |
13209 | if (this.port) { |
- | |
13210 | s += ':' + this.port; |
- | |
13211 | } |
- | |
13212 | } |
- | |
13213 | if (this.path) { |
- | |
13214 | s += this.path; |
- | |
13215 | } |
- | |
13216 | if (this.query) { |
- | |
13217 | s += '?' + this.query; |
- | |
13218 | } |
- | |
13219 | if (this.anchor) { |
- | |
13220 | s += '#' + this.anchor; |
- | |
13221 | } |
- | |
13222 | this.source = s; |
- | |
13223 | } |
12916 | } |
13224 | return this.source; |
- | |
13225 | }; |
- | |
13226 | return URI; |
- | |
13227 | }(); |
- | |
13228 | - | ||
13229 | var filteredClobberElements = Tools.makeMap('button,fieldset,form,iframe,img,image,input,object,output,select,textarea'); |
- | |
13230 | var isValidPrefixAttrName = function (name) { |
- | |
13231 | return name.indexOf('data-') === 0 || name.indexOf('aria-') === 0; |
- | |
13232 | }; |
- | |
13233 | var lazyTempDocument$1 = cached(function () { |
- | |
13234 | return document.implementation.createHTMLDocument('parser'); |
- | |
13235 | }); |
12917 | }); |
13236 | var findMatchingEndTagIndex = function (schema, html, startIndex) { |
- | |
13237 | var startTagRegExp = /<([!?\/])?([A-Za-z0-9\-_:.]+)/g; |
- | |
13238 | var endTagRegExp = /(?:\s(?:[^'">]+(?:"[^"]*"|'[^']*'))*[^"'>]*(?:"[^">]*|'[^'>]*)?|\s*|\/)>/g; |
- | |
13239 | var shortEndedElements = schema.getShortEndedElements(); |
- | |
13240 | var count = 1, index = startIndex; |
- | |
13241 | while (count !== 0) { |
- | |
13242 | startTagRegExp.lastIndex = index; |
- | |
13243 | while (true) { |
- | |
13244 | var startMatch = startTagRegExp.exec(html); |
- | |
13245 | if (startMatch === null) { |
- | |
13246 | return index; |
- | |
13247 | } else if (startMatch[1] === '!') { |
- | |
13248 | if (startsWith(startMatch[2], '--')) { |
- | |
13249 | index = findCommentEndIndex(html, false, startMatch.index + '!--'.length); |
- | |
13250 | } else { |
- | |
13251 | index = findCommentEndIndex(html, true, startMatch.index + 1); |
- | |
13252 | } |
- | |
13253 | break; |
- | |
13254 | } else { |
- | |
13255 | endTagRegExp.lastIndex = startTagRegExp.lastIndex; |
- | |
13256 | var endMatch = endTagRegExp.exec(html); |
- | |
13257 | if (isNull(endMatch) || endMatch.index !== startTagRegExp.lastIndex) { |
- | |
13258 | continue; |
- | |
13259 | } |
- | |
13260 | if (startMatch[1] === '/') { |
- | |
13261 | count -= 1; |
- | |
13262 | } else if (!has$2(shortEndedElements, startMatch[2])) { |
- | |
13263 | count += 1; |
- | |
13264 | } |
- | |
13265 | index = startTagRegExp.lastIndex + endMatch[0].length; |
- | |
13266 | break; |
- | |
13267 | } |
12918 | } |
13268 | } |
- | |
13269 | } |
- | |
13270 | return index; |
- | |
13271 | }; |
- | |
13272 | var isConditionalComment = function (html, startIndex) { |
- | |
13273 | return /^\s*\[if [\w\W]+\]>.*<!\[endif\](--!?)?>/.test(html.substr(startIndex)); |
- | |
13274 | }; |
- | |
13275 | var findCommentEndIndex = function (html, isBogus, startIndex) { |
- | |
13276 | if (startIndex === void 0) { |
- | |
13277 | startIndex = 0; |
- | |
13278 | } |
- | |
13279 | var lcHtml = html.toLowerCase(); |
- | |
13280 | if (lcHtml.indexOf('[if ', startIndex) !== -1 && isConditionalComment(lcHtml, startIndex)) { |
- | |
13281 | var endIfIndex = lcHtml.indexOf('[endif]', startIndex); |
- | |
13282 | return lcHtml.indexOf('>', endIfIndex); |
- | |
13283 | } else { |
- | |
13284 | if (isBogus) { |
- | |
13285 | var endIndex = lcHtml.indexOf('>', startIndex); |
- | |
13286 | return endIndex !== -1 ? endIndex : lcHtml.length; |
- | |
13287 | } else { |
- | |
13288 | var endCommentRegexp = /--!?>/g; |
- | |
13289 | endCommentRegexp.lastIndex = startIndex; |
- | |
13290 | var match = endCommentRegexp.exec(html); |
- | |
13291 | return match ? match.index + match[0].length : lcHtml.length; |
- | |
13292 | } |
- | |
13293 | } |
- | |
13294 | }; |
- | |
13295 | var checkBogusAttribute = function (regExp, attrString) { |
- | |
13296 | var matches = regExp.exec(attrString); |
- | |
13297 | if (matches) { |
- | |
13298 | var name_1 = matches[1]; |
- | |
13299 | var value = matches[2]; |
- | |
13300 | return typeof name_1 === 'string' && name_1.toLowerCase() === 'data-mce-bogus' ? value : null; |
- | |
13301 | } else { |
- | |
13302 | return null; |
- | |
13303 | } |
- | |
13304 | }; |
- | |
13305 | var SaxParser = function (settings, schema) { |
- | |
13306 | if (schema === void 0) { |
- | |
13307 | schema = Schema(); |
- | |
13308 | } |
- | |
13309 | settings = settings || {}; |
- | |
13310 | var doc = lazyTempDocument$1(); |
- | |
13311 | var form = doc.createElement('form'); |
- | |
13312 | if (settings.fix_self_closing !== false) { |
- | |
13313 | settings.fix_self_closing = true; |
- | |
13314 | } |
- | |
13315 | var comment = settings.comment ? settings.comment : noop; |
- | |
13316 | var cdata = settings.cdata ? settings.cdata : noop; |
- | |
13317 | var text = settings.text ? settings.text : noop; |
- | |
13318 | var start = settings.start ? settings.start : noop; |
- | |
13319 | var end = settings.end ? settings.end : noop; |
- | |
13320 | var pi = settings.pi ? settings.pi : noop; |
- | |
13321 | var doctype = settings.doctype ? settings.doctype : noop; |
- | |
13322 | var parseInternal = function (base64Extract, format) { |
- | |
13323 | if (format === void 0) { |
- | |
13324 | format = 'html'; |
- | |
13325 | } |
- | |
13326 | var html = base64Extract.html; |
- | |
13327 | var matches, index = 0, value, endRegExp; |
- | |
13328 | var stack = []; |
- | |
13329 | var attrList, i, textData, name; |
- | |
13330 | var isInternalElement, isShortEnded; |
- | |
13331 | var elementRule, isValidElement, attr, attribsValue, validAttributesMap, validAttributePatterns; |
- | |
13332 | var attributesRequired, attributesDefault, attributesForced; |
- | |
13333 | var anyAttributesRequired, attrValue, idCount = 0; |
- | |
13334 | var decode = Entities.decode; |
- | |
13335 | var filteredUrlAttrs = Tools.makeMap('src,href,data,background,action,formaction,poster,xlink:href'); |
- | |
13336 | var parsingMode = format === 'html' ? 0 : 1; |
- | |
13337 | var processEndTag = function (name) { |
- | |
13338 | var pos, i; |
- | |
13339 | pos = stack.length; |
- | |
13340 | while (pos--) { |
- | |
13341 | if (stack[pos].name === name) { |
- | |
13342 | break; |
- | |
13343 | } |
- | |
13344 | } |
- | |
13345 | if (pos >= 0) { |
- | |
13346 | for (i = stack.length - 1; i >= pos; i--) { |
- | |
13347 | name = stack[i]; |
- | |
13348 | if (name.valid) { |
- | |
13349 | end(name.name); |
- | |
13350 | } |
- | |
13351 | } |
- | |
13352 | stack.length = pos; |
- | |
13353 | } |
- | |
13354 | }; |
- | |
13355 | var processText = function (value, raw) { |
- | |
13356 | return text(restoreDataUris(value, base64Extract), raw); |
- | |
13357 | }; |
- | |
13358 | var processComment = function (value) { |
- | |
13359 | if (value === '') { |
- | |
13360 | return; |
- | |
13361 | } |
- | |
13362 | if (value.charAt(0) === '>') { |
- | |
13363 | value = ' ' + value; |
- | |
13364 | } |
- | |
13365 | if (!settings.allow_conditional_comments && value.substr(0, 3).toLowerCase() === '[if') { |
- | |
13366 | value = ' ' + value; |
- | |
13367 | } |
- | |
13368 | comment(restoreDataUris(value, base64Extract)); |
- | |
13369 | }; |
- | |
13370 | var processAttr = function (value) { |
- | |
13371 | return restoreDataUris(value, base64Extract); |
- | |
13372 | }; |
- | |
13373 | var processMalformedComment = function (value, startIndex) { |
- | |
13374 | var startTag = value || ''; |
- | |
13375 | var isBogus = !startsWith(startTag, '--'); |
- | |
13376 | var endIndex = findCommentEndIndex(html, isBogus, startIndex); |
- | |
13377 | value = html.substr(startIndex, endIndex - startIndex); |
- | |
13378 | processComment(isBogus ? startTag + value : value); |
- | |
13379 | return endIndex + 1; |
- | |
13380 | }; |
- | |
13381 | var parseAttribute = function (tagName, name, value, val2, val3) { |
- | |
13382 | name = name.toLowerCase(); |
- | |
13383 | value = processAttr(name in fillAttrsMap ? name : decode(value || val2 || val3 || '')); |
- | |
13384 | if (validate && !isInternalElement && isValidPrefixAttrName(name) === false) { |
- | |
13385 | var attrRule = validAttributesMap[name]; |
- | |
13386 | if (!attrRule && validAttributePatterns) { |
- | |
13387 | var i_1 = validAttributePatterns.length; |
- | |
13388 | while (i_1--) { |
- | |
13389 | attrRule = validAttributePatterns[i_1]; |
- | |
13390 | if (attrRule.pattern.test(name)) { |
- | |
13391 | break; |
- | |
13392 | } |
- | |
13393 | } |
- | |
13394 | if (i_1 === -1) { |
- | |
13395 | attrRule = null; |
- | |
13396 | } |
- | |
13397 | } |
- | |
13398 | if (!attrRule) { |
- | |
13399 | return; |
- | |
13400 | } |
- | |
13401 | if (attrRule.validValues && !(value in attrRule.validValues)) { |
- | |
13402 | return; |
- | |
13403 | } |
- | |
13404 | } |
- | |
13405 | var isNameOrId = name === 'name' || name === 'id'; |
- | |
13406 | if (isNameOrId && tagName in filteredClobberElements && (value in doc || value in form)) { |
- | |
13407 | return; |
- | |
13408 | } |
- | |
13409 | if (filteredUrlAttrs[name] && !URI.isDomSafe(value, tagName, settings)) { |
- | |
13410 | return; |
- | |
13411 | } |
- | |
13412 | if (isInternalElement && (name in filteredUrlAttrs || name.indexOf('on') === 0)) { |
- | |
13413 | return; |
- | |
13414 | } |
- | |
13415 | attrList.map[name] = value; |
- | |
13416 | attrList.push({ |
- | |
13417 | name: name, |
- | |
13418 | value: value |
- | |
13419 | }); |
12919 | }); |
13420 | }; |
12920 | }; |
13421 | var tokenRegExp = new RegExp('<(?:' + '(?:!--([\\w\\W]*?)--!?>)|' + '(?:!\\[CDATA\\[([\\w\\W]*?)\\]\\]>)|' + '(?:![Dd][Oo][Cc][Tt][Yy][Pp][Ee]([\\w\\W]*?)>)|' + '(?:!(--)?)|' + '(?:\\?([^\\s\\/<>]+) ?([\\w\\W]*?)[?/]>)|' + '(?:\\/([A-Za-z][A-Za-z0-9\\-_\\:\\.]*)>)|' + '(?:([A-Za-z][A-Za-z0-9\\-_:.]*)(\\s(?:[^\'">]+(?:"[^"]*"|\'[^\']*\'))*[^"\'>]*(?:"[^">]*|\'[^\'>]*)?|\\s*|\\/)>)' + ')', 'g'); |
12921 | var removeCommentsContainingZwsp = function (body) { |
13422 | var attrRegExp = /([\w:\-]+)(?:\s*=\s*(?:(?:\"((?:[^\"])*)\")|(?:\'((?:[^\'])*)\')|([^>\s]+)))?/g; |
- | |
13423 | var shortEndedElements = schema.getShortEndedElements(); |
- | |
13424 | var selfClosing = settings.self_closing_elements || schema.getSelfClosingElements(); |
- | |
13425 | var fillAttrsMap = schema.getBoolAttrs(); |
- | |
13426 | var validate = settings.validate; |
- | |
13427 | var removeInternalElements = settings.remove_internals; |
- | |
13428 | var fixSelfClosing = settings.fix_self_closing; |
- | |
13429 | var specialElements = schema.getSpecialElements(); |
12922 | var walker = createCommentWalker(body); |
13430 | var processHtml = html + '>'; |
- | |
13431 | while (matches = tokenRegExp.exec(processHtml)) { |
- | |
13432 | var matchText = matches[0]; |
- | |
13433 | if (index < matches.index) { |
- | |
13434 | processText(decode(html.substr(index, matches.index - index))); |
- | |
13435 | } |
- | |
13436 | if (value = matches[7]) { |
- | |
13437 | value = value.toLowerCase(); |
12923 | var nextNode = walker.nextNode(); |
13438 | if (value.charAt(0) === ':') { |
12924 | while (nextNode !== null) { |
13439 | value = value.substr(1); |
12925 | var comment = walker.currentNode; |
13440 | } |
- | |
13441 | processEndTag(value); |
- | |
13442 | } else if (value = matches[8]) { |
- | |
13443 | if (matches.index + matchText.length > html.length) { |
- | |
13444 | processText(decode(html.substr(matches.index))); |
- | |
13445 | index = matches.index + matchText.length; |
- | |
13446 | continue; |
- | |
13447 | } |
- | |
13448 | value = value.toLowerCase(); |
12926 | nextNode = walker.nextNode(); |
13449 | if (value.charAt(0) === ':') { |
- | |
13450 | value = value.substr(1); |
- | |
13451 | } |
- | |
13452 | isShortEnded = value in shortEndedElements; |
- | |
13453 | if (fixSelfClosing && selfClosing[value] && stack.length > 0 && stack[stack.length - 1].name === value) { |
- | |
13454 | processEndTag(value); |
- | |
13455 | } |
- | |
13456 | var bogusValue = checkBogusAttribute(attrRegExp, matches[9]); |
- | |
13457 | if (bogusValue !== null) { |
- | |
13458 | if (bogusValue === 'all') { |
- | |
13459 | index = findMatchingEndTagIndex(schema, html, tokenRegExp.lastIndex); |
- | |
13460 | tokenRegExp.lastIndex = index; |
- | |
13461 | continue; |
- | |
13462 | } |
- | |
13463 | isValidElement = false; |
- | |
13464 | } |
- | |
13465 | if (!validate || (elementRule = schema.getElementRule(value))) { |
- | |
13466 | isValidElement = true; |
- | |
13467 | if (validate) { |
- | |
13468 | validAttributesMap = elementRule.attributes; |
- | |
13469 | validAttributePatterns = elementRule.attributePatterns; |
- | |
13470 | } |
- | |
13471 | if (attribsValue = matches[9]) { |
- | |
13472 | isInternalElement = attribsValue.indexOf('data-mce-type') !== -1; |
12927 | if (isString$1(comment.nodeValue) && comment.nodeValue.indexOf(ZWSP$1) !== -1) { |
13473 | if (isInternalElement && removeInternalElements) { |
- | |
13474 | isValidElement = false; |
- | |
13475 | } |
- | |
13476 | attrList = []; |
- | |
13477 | attrList.map = {}; |
- | |
13478 | attribsValue.replace(attrRegExp, function (match, name, val, val2, val3) { |
- | |
13479 | parseAttribute(value, name, val, val2, val3); |
- | |
13480 | return ''; |
- | |
13481 | }); |
- | |
13482 | } else { |
- | |
13483 | attrList = []; |
- | |
13484 | attrList.map = {}; |
- | |
13485 | } |
- | |
13486 | if (validate && !isInternalElement) { |
12928 | remove$7(SugarElement.fromDom(comment)); |
13487 | attributesRequired = elementRule.attributesRequired; |
- | |
13488 | attributesDefault = elementRule.attributesDefault; |
- | |
13489 | attributesForced = elementRule.attributesForced; |
- | |
13490 | anyAttributesRequired = elementRule.removeEmptyAttrs; |
- | |
13491 | if (anyAttributesRequired && !attrList.length) { |
- | |
13492 | isValidElement = false; |
- | |
13493 | } |
- | |
13494 | if (attributesForced) { |
- | |
13495 | i = attributesForced.length; |
- | |
13496 | while (i--) { |
- | |
13497 | attr = attributesForced[i]; |
- | |
13498 | name = attr.name; |
- | |
13499 | attrValue = attr.value; |
- | |
13500 | if (attrValue === '{$uid}') { |
- | |
13501 | attrValue = 'mce_' + idCount++; |
- | |
13502 | } |
- | |
13503 | attrList.map[name] = attrValue; |
- | |
13504 | attrList.push({ |
- | |
13505 | name: name, |
- | |
13506 | value: attrValue |
- | |
13507 | }); |
- | |
13508 | } |
- | |
13509 | } |
- | |
13510 | if (attributesDefault) { |
- | |
13511 | i = attributesDefault.length; |
- | |
13512 | while (i--) { |
- | |
13513 | attr = attributesDefault[i]; |
- | |
13514 | name = attr.name; |
- | |
13515 | if (!(name in attrList.map)) { |
- | |
13516 | attrValue = attr.value; |
- | |
13517 | if (attrValue === '{$uid}') { |
- | |
13518 | attrValue = 'mce_' + idCount++; |
- | |
13519 | } |
- | |
13520 | attrList.map[name] = attrValue; |
- | |
13521 | attrList.push({ |
- | |
13522 | name: name, |
- | |
13523 | value: attrValue |
- | |
13524 | }); |
- | |
13525 | } |
- | |
13526 | } |
- | |
13527 | } |
- | |
13528 | if (attributesRequired) { |
- | |
13529 | i = attributesRequired.length; |
- | |
13530 | while (i--) { |
- | |
13531 | if (attributesRequired[i] in attrList.map) { |
- | |
13532 | break; |
- | |
13533 | } |
- | |
13534 | } |
- | |
13535 | if (i === -1) { |
- | |
13536 | isValidElement = false; |
- | |
13537 | } |
- | |
13538 | } |
- | |
13539 | if (attr = attrList.map['data-mce-bogus']) { |
- | |
13540 | if (attr === 'all') { |
- | |
13541 | index = findMatchingEndTagIndex(schema, html, tokenRegExp.lastIndex); |
- | |
13542 | tokenRegExp.lastIndex = index; |
- | |
13543 | continue; |
- | |
13544 | } |
- | |
13545 | isValidElement = false; |
- | |
13546 | } |
- | |
13547 | } |
- | |
13548 | if (isValidElement) { |
- | |
13549 | start(value, attrList, isShortEnded); |
- | |
13550 | } |
12929 | } |
13551 | } else { |
- | |
13552 | isValidElement = false; |
- | |
13553 | } |
- | |
13554 | if (endRegExp = specialElements[value]) { |
- | |
13555 | endRegExp.lastIndex = index = matches.index + matchText.length; |
- | |
13556 | if (matches = endRegExp.exec(html)) { |
- | |
13557 | if (isValidElement) { |
- | |
13558 | textData = html.substr(index, matches.index - index); |
- | |
13559 | } |
- | |
13560 | index = matches.index + matches[0].length; |
- | |
13561 | } else { |
- | |
13562 | textData = html.substr(index); |
- | |
13563 | index = html.length; |
- | |
13564 | } |
- | |
13565 | if (isValidElement) { |
- | |
13566 | if (textData.length > 0) { |
- | |
13567 | processText(textData, true); |
- | |
13568 | } |
- | |
13569 | end(value); |
- | |
13570 | } |
- | |
13571 | tokenRegExp.lastIndex = index; |
- | |
13572 | continue; |
- | |
13573 | } |
12930 | } |
13574 | if (!isShortEnded) { |
- | |
13575 | if (!attribsValue || attribsValue.indexOf('/') !== attribsValue.length - 1) { |
- | |
13576 | stack.push({ |
- | |
13577 | name: value, |
- | |
13578 | valid: isValidElement |
- | |
13579 | }); |
- | |
13580 | } else if (isValidElement) { |
- | |
13581 | end(value); |
- | |
13582 | } |
- | |
13583 | } |
- | |
13584 | } else if (value = matches[1]) { |
- | |
13585 | processComment(value); |
- | |
13586 | } else if (value = matches[2]) { |
- | |
13587 | var isValidCdataSection = parsingMode === 1 || settings.preserve_cdata || stack.length > 0 && schema.isValidChild(stack[stack.length - 1].name, '#cdata'); |
- | |
13588 | if (isValidCdataSection) { |
- | |
13589 | cdata(value); |
- | |
13590 | } else { |
- | |
13591 | index = processMalformedComment('', matches.index + 2); |
- | |
13592 | tokenRegExp.lastIndex = index; |
- | |
13593 | continue; |
- | |
13594 | } |
- | |
13595 | } else if (value = matches[3]) { |
- | |
13596 | doctype(value); |
- | |
13597 | } else if ((value = matches[4]) || matchText === '<!') { |
- | |
13598 | index = processMalformedComment(value, matches.index + matchText.length); |
- | |
13599 | tokenRegExp.lastIndex = index; |
- | |
13600 | continue; |
- | |
13601 | } else if (value = matches[5]) { |
- | |
13602 | if (parsingMode === 1) { |
- | |
13603 | pi(value, matches[6]); |
- | |
13604 | } else { |
- | |
13605 | index = processMalformedComment('?', matches.index + 2); |
- | |
13606 | tokenRegExp.lastIndex = index; |
- | |
13607 | continue; |
- | |
13608 | } |
- | |
13609 | } |
- | |
13610 | index = matches.index + matchText.length; |
- | |
13611 | } |
- | |
13612 | if (index < html.length) { |
- | |
13613 | processText(decode(html.substr(index))); |
- | |
13614 | } |
- | |
13615 | for (i = stack.length - 1; i >= 0; i--) { |
- | |
13616 | value = stack[i]; |
- | |
13617 | if (value.valid) { |
- | |
13618 | end(value.name); |
- | |
13619 | } |
- | |
13620 | } |
- | |
13621 | }; |
- | |
13622 | var parse = function (html, format) { |
- | |
13623 | if (format === void 0) { |
- | |
13624 | format = 'html'; |
- | |
13625 | } |
- | |
13626 | parseInternal(extractBase64DataUris(html), format); |
- | |
13627 | }; |
- | |
13628 | return { parse: parse }; |
- | |
13629 | }; |
12931 | }; |
13630 | SaxParser.findEndTag = findMatchingEndTagIndex; |
- | |
13631 | - | ||
13632 | var trimHtml = function (tempAttrs, html) { |
12932 | var deepClone = function (body) { |
13633 | var trimContentRegExp = new RegExp(['\\s?(' + tempAttrs.join('|') + ')="[^"]+"'].join('|'), 'gi'); |
- | |
13634 | return html.replace(trimContentRegExp, ''); |
12933 | return body.cloneNode(true); |
13635 | }; |
12934 | }; |
13636 | var trimInternal = function (serializer, html) { |
12935 | var trim$1 = function (body, tempAttrs) { |
13637 | var bogusAllRegExp = /<(\w+) [^>]*data-mce-bogus="all"[^>]*>/g; |
12936 | var trimmed = body; |
13638 | var schema = serializer.schema; |
12937 | if (hasComments(body)) { |
13639 | var content = trimHtml(serializer.getTempAttrs(), html); |
12938 | trimmed = deepClone(body); |
13640 | var shortEndedElements = schema.getShortEndedElements(); |
12939 | removeCommentsContainingZwsp(trimmed); |
13641 | var matches; |
- | |
13642 | while (matches = bogusAllRegExp.exec(content)) { |
12940 | if (hasTemporaryNodes(trimmed, tempAttrs)) { |
13643 | var index = bogusAllRegExp.lastIndex; |
12941 | trimTemporaryNodes(trimmed, tempAttrs); |
13644 | var matchLength = matches[0].length; |
- | |
13645 | var endTagIndex = void 0; |
12942 | } |
13646 | if (shortEndedElements[matches[1]]) { |
12943 | } else if (hasTemporaryNodes(body, tempAttrs)) { |
13647 | endTagIndex = index; |
12944 | trimmed = deepClone(body); |
13648 | } else { |
- | |
13649 | endTagIndex = SaxParser.findEndTag(schema, content, index); |
12945 | trimTemporaryNodes(trimmed, tempAttrs); |
13650 | } |
12946 | } |
13651 | content = content.substring(0, index - matchLength) + content.substring(endTagIndex); |
- | |
13652 | bogusAllRegExp.lastIndex = index - matchLength; |
- | |
13653 | } |
- | |
13654 | return trim$2(content); |
12947 | return trimmed; |
13655 | }; |
12948 | }; |
13656 | var trimExternal = trimInternal; |
- | |
13657 | 12949 | ||
13658 | var trimEmptyContents = function (editor, html) { |
12950 | var trimEmptyContents = function (editor, html) { |
13659 | var blockName = getForcedRootBlock(editor); |
12951 | var blockName = getForcedRootBlock(editor); |
13660 | var emptyRegExp = new RegExp('^(<' + blockName + '[^>]*>( | |\\s|\xA0|<br \\/>|)<\\/' + blockName + '>[\r\n]*|<br \\/>[\r\n]*)$'); |
12952 | var emptyRegExp = new RegExp('^(<' + blockName + '[^>]*>( | |\\s|\xA0|<br \\/>|)<\\/' + blockName + '>[\r\n]*|<br \\/>[\r\n]*)$'); |
13661 | return html.replace(emptyRegExp, ''); |
12953 | return html.replace(emptyRegExp, ''); |
Line 13670... | Line 12962... | ||
13670 | var getContentFromBody = function (editor, args, format, body) { |
12962 | var getContentFromBody = function (editor, args, format, body) { |
13671 | var defaultedArgs = setupArgs$3(args, format); |
12963 | var defaultedArgs = setupArgs$3(args, format); |
13672 | var updatedArgs = args.no_events ? defaultedArgs : editor.fire('BeforeGetContent', defaultedArgs); |
12964 | var updatedArgs = args.no_events ? defaultedArgs : editor.fire('BeforeGetContent', defaultedArgs); |
13673 | var content; |
12965 | var content; |
13674 | if (updatedArgs.format === 'raw') { |
12966 | if (updatedArgs.format === 'raw') { |
13675 | content = Tools.trim(trimExternal(editor.serializer, body.innerHTML)); |
12967 | content = Tools.trim(trim$3(trim$1(body, editor.serializer.getTempAttrs()).innerHTML)); |
13676 | } else if (updatedArgs.format === 'text') { |
12968 | } else if (updatedArgs.format === 'text') { |
13677 | content = editor.dom.isEmpty(body) ? '' : trim$2(body.innerText || body.textContent); |
12969 | content = editor.dom.isEmpty(body) ? '' : trim$3(body.innerText || body.textContent); |
13678 | } else if (updatedArgs.format === 'tree') { |
12970 | } else if (updatedArgs.format === 'tree') { |
13679 | content = editor.serializer.serialize(body, updatedArgs); |
12971 | content = editor.serializer.serialize(body, updatedArgs); |
13680 | } else { |
12972 | } else { |
13681 | content = trimEmptyContents(editor, editor.serializer.serialize(body, updatedArgs)); |
12973 | content = trimEmptyContents(editor, editor.serializer.serialize(body, updatedArgs)); |
13682 | } |
12974 | } |
Line 13698... | Line 12990... | ||
13698 | return Optional.from(editor.getBody()).fold(constant(args.format === 'tree' ? new AstNode('body', 11) : ''), function (body) { |
12990 | return Optional.from(editor.getBody()).fold(constant(args.format === 'tree' ? new AstNode('body', 11) : ''), function (body) { |
13699 | return getContentFromBody(editor, args, format, body); |
12991 | return getContentFromBody(editor, args, format, body); |
13700 | }); |
12992 | }); |
13701 | }; |
12993 | }; |
13702 | 12994 | ||
13703 | var each$c = Tools.each; |
12995 | var each$d = Tools.each; |
13704 | var ElementUtils = function (dom) { |
12996 | var ElementUtils = function (dom) { |
13705 | var compare = function (node1, node2) { |
12997 | var compare = function (node1, node2) { |
13706 | if (node1.nodeName !== node2.nodeName) { |
12998 | if (node1.nodeName !== node2.nodeName) { |
13707 | return false; |
12999 | return false; |
13708 | } |
13000 | } |
13709 | var getAttribs = function (node) { |
13001 | var getAttribs = function (node) { |
13710 | var attribs = {}; |
13002 | var attribs = {}; |
13711 | each$c(dom.getAttribs(node), function (attr) { |
13003 | each$d(dom.getAttribs(node), function (attr) { |
13712 | var name = attr.nodeName.toLowerCase(); |
13004 | var name = attr.nodeName.toLowerCase(); |
13713 | if (name.indexOf('_') !== 0 && name !== 'style' && name.indexOf('data-') !== 0) { |
13005 | if (name.indexOf('_') !== 0 && name !== 'style' && name.indexOf('data-') !== 0) { |
13714 | attribs[name] = dom.getAttrib(node, name); |
13006 | attribs[name] = dom.getAttrib(node, name); |
13715 | } |
13007 | } |
13716 | }); |
13008 | }); |
Line 15887... | Line 15179... | ||
15887 | return isCaretNode(element.dom) && isCaretContainerEmpty(element.dom); |
15179 | return isCaretNode(element.dom) && isCaretContainerEmpty(element.dom); |
15888 | }; |
15180 | }; |
15889 | 15181 | ||
15890 | var postProcessHooks = {}; |
15182 | var postProcessHooks = {}; |
15891 | var filter = filter$2; |
15183 | var filter = filter$2; |
15892 | var each$b = each$i; |
15184 | var each$c = each$i; |
15893 | var addPostProcessHook = function (name, hook) { |
15185 | var addPostProcessHook = function (name, hook) { |
15894 | var hooks = postProcessHooks[name]; |
15186 | var hooks = postProcessHooks[name]; |
15895 | if (!hooks) { |
15187 | if (!hooks) { |
15896 | postProcessHooks[name] = []; |
15188 | postProcessHooks[name] = []; |
15897 | } |
15189 | } |
15898 | postProcessHooks[name].push(hook); |
15190 | postProcessHooks[name].push(hook); |
15899 | }; |
15191 | }; |
15900 | var postProcess$1 = function (name, editor) { |
15192 | var postProcess$1 = function (name, editor) { |
15901 | each$b(postProcessHooks[name], function (hook) { |
15193 | each$c(postProcessHooks[name], function (hook) { |
15902 | hook(editor); |
15194 | hook(editor); |
15903 | }); |
15195 | }); |
15904 | }; |
15196 | }; |
15905 | addPostProcessHook('pre', function (editor) { |
15197 | addPostProcessHook('pre', function (editor) { |
15906 | var rng = editor.selection.getRng(); |
15198 | var rng = editor.selection.getRng(); |
Line 15913... | Line 15205... | ||
15913 | DomQuery(pre1).append('<br><br>').append(pre2.childNodes); |
15205 | DomQuery(pre1).append('<br><br>').append(pre2.childNodes); |
15914 | }; |
15206 | }; |
15915 | var isPre = matchNodeNames(['pre']); |
15207 | var isPre = matchNodeNames(['pre']); |
15916 | if (!rng.collapsed) { |
15208 | if (!rng.collapsed) { |
15917 | blocks = editor.selection.getSelectedBlocks(); |
15209 | blocks = editor.selection.getSelectedBlocks(); |
15918 | each$b(filter(filter(blocks, isPre), hasPreSibling), function (pre) { |
15210 | each$c(filter(filter(blocks, isPre), hasPreSibling), function (pre) { |
15919 | joinPre(pre.previousSibling, pre); |
15211 | joinPre(pre.previousSibling, pre); |
15920 | }); |
15212 | }); |
15921 | } |
15213 | } |
15922 | }); |
15214 | }); |
15923 | 15215 | ||
15924 | var each$a = Tools.each; |
15216 | var each$b = Tools.each; |
15925 | var isElementNode$1 = function (node) { |
15217 | var isElementNode$1 = function (node) { |
15926 | return isElement$5(node) && !isBookmarkNode$1(node) && !isCaretNode(node) && !isBogus$2(node); |
15218 | return isElement$5(node) && !isBookmarkNode$1(node) && !isCaretNode(node) && !isBogus$2(node); |
15927 | }; |
15219 | }; |
15928 | var findElementSibling = function (node, siblingName) { |
15220 | var findElementSibling = function (node, siblingName) { |
15929 | for (var sibling = node; sibling; sibling = sibling[siblingName]) { |
15221 | for (var sibling = node; sibling; sibling = sibling[siblingName]) { |
Line 15963... | Line 15255... | ||
15963 | } |
15255 | } |
15964 | }; |
15256 | }; |
15965 | var clearChildStyles = function (dom, format, node) { |
15257 | var clearChildStyles = function (dom, format, node) { |
15966 | if (format.clear_child_styles) { |
15258 | if (format.clear_child_styles) { |
15967 | var selector = format.links ? '*:not(a)' : '*'; |
15259 | var selector = format.links ? '*:not(a)' : '*'; |
15968 | each$a(dom.select(selector, node), function (node) { |
15260 | each$b(dom.select(selector, node), function (node) { |
15969 | if (isElementNode$1(node)) { |
15261 | if (isElementNode$1(node)) { |
15970 | each$a(format.styles, function (value, name) { |
15262 | each$b(format.styles, function (value, name) { |
15971 | dom.setStyle(node, name, ''); |
15263 | dom.setStyle(node, name, ''); |
15972 | }); |
15264 | }); |
15973 | } |
15265 | } |
15974 | }); |
15266 | }); |
15975 | } |
15267 | } |
15976 | }; |
15268 | }; |
15977 | var processChildElements = function (node, filter, process) { |
15269 | var processChildElements = function (node, filter, process) { |
15978 | each$a(node.childNodes, function (node) { |
15270 | each$b(node.childNodes, function (node) { |
15979 | if (isElementNode$1(node)) { |
15271 | if (isElementNode$1(node)) { |
15980 | if (filter(node)) { |
15272 | if (filter(node)) { |
15981 | process(node); |
15273 | process(node); |
15982 | } |
15274 | } |
15983 | if (node.hasChildNodes()) { |
15275 | if (node.hasChildNodes()) { |
Line 16010... | Line 15302... | ||
16010 | { keep: [] }, |
15302 | { keep: [] }, |
16011 | { rename: ['name'] }, |
15303 | { rename: ['name'] }, |
16012 | { removed: [] } |
15304 | { removed: [] } |
16013 | ]); |
15305 | ]); |
16014 | var MCE_ATTR_RE = /^(src|href|style)$/; |
15306 | var MCE_ATTR_RE = /^(src|href|style)$/; |
16015 | var each$9 = Tools.each; |
15307 | var each$a = Tools.each; |
16016 | var isEq$2 = isEq$5; |
15308 | var isEq$2 = isEq$5; |
16017 | var isTableCellOrRow = function (node) { |
15309 | var isTableCellOrRow = function (node) { |
16018 | return /^(TR|TH|TD)$/.test(node.nodeName); |
15310 | return /^(TR|TH|TD)$/.test(node.nodeName); |
16019 | }; |
15311 | }; |
16020 | var isChildOfInlineParent = function (dom, node, parent) { |
15312 | var isChildOfInlineParent = function (dom, node, parent) { |
Line 16144... | Line 15436... | ||
16144 | if (attrsToPreserve.length > 0) { |
15436 | if (attrsToPreserve.length > 0) { |
16145 | return removeResult.rename('span'); |
15437 | return removeResult.rename('span'); |
16146 | } |
15438 | } |
16147 | } |
15439 | } |
16148 | if (format.remove !== 'all') { |
15440 | if (format.remove !== 'all') { |
16149 | each$9(format.styles, function (value, name) { |
15441 | each$a(format.styles, function (value, name) { |
16150 | value = normalizeStyleValue(dom, replaceVars(value, vars), name + ''); |
15442 | value = normalizeStyleValue(dom, replaceVars(value, vars), name + ''); |
16151 | if (isNumber(name)) { |
15443 | if (isNumber(name)) { |
16152 | name = value; |
15444 | name = value; |
16153 | compareNode = null; |
15445 | compareNode = null; |
16154 | } |
15446 | } |
Line 16159... | Line 15451... | ||
16159 | }); |
15451 | }); |
16160 | if (stylesModified && dom.getAttrib(elm, 'style') === '') { |
15452 | if (stylesModified && dom.getAttrib(elm, 'style') === '') { |
16161 | elm.removeAttribute('style'); |
15453 | elm.removeAttribute('style'); |
16162 | elm.removeAttribute('data-mce-style'); |
15454 | elm.removeAttribute('data-mce-style'); |
16163 | } |
15455 | } |
16164 | each$9(format.attributes, function (value, name) { |
15456 | each$a(format.attributes, function (value, name) { |
16165 | var valueOut; |
15457 | var valueOut; |
16166 | value = replaceVars(value, vars); |
15458 | value = replaceVars(value, vars); |
16167 | if (isNumber(name)) { |
15459 | if (isNumber(name)) { |
16168 | name = value; |
15460 | name = value; |
16169 | compareNode = null; |
15461 | compareNode = null; |
Line 16196... | Line 15488... | ||
16196 | elm.removeAttribute('className'); |
15488 | elm.removeAttribute('className'); |
16197 | } |
15489 | } |
16198 | elm.removeAttribute(name); |
15490 | elm.removeAttribute(name); |
16199 | } |
15491 | } |
16200 | }); |
15492 | }); |
16201 | each$9(format.classes, function (value) { |
15493 | each$a(format.classes, function (value) { |
16202 | value = replaceVars(value, vars); |
15494 | value = replaceVars(value, vars); |
16203 | if (!compareNode || dom.hasClass(compareNode, value)) { |
15495 | if (!compareNode || dom.hasClass(compareNode, value)) { |
16204 | dom.removeClass(elm, value); |
15496 | dom.removeClass(elm, value); |
16205 | } |
15497 | } |
16206 | }); |
15498 | }); |
Line 16452... | Line 15744... | ||
16452 | removeCaretFormat(ed, name, vars, similar); |
15744 | removeCaretFormat(ed, name, vars, similar); |
16453 | } |
15745 | } |
16454 | fireFormatRemove(ed, name, node, vars); |
15746 | fireFormatRemove(ed, name, node, vars); |
16455 | }; |
15747 | }; |
16456 | 15748 | ||
16457 | var each$8 = Tools.each; |
15749 | var each$9 = Tools.each; |
16458 | var mergeTextDecorationsAndColor = function (dom, format, vars, node) { |
15750 | var mergeTextDecorationsAndColor = function (dom, format, vars, node) { |
16459 | var processTextDecorationsAndColor = function (n) { |
15751 | var processTextDecorationsAndColor = function (n) { |
16460 | if (n.nodeType === 1 && n.parentNode && n.parentNode.nodeType === 1) { |
15752 | if (n.nodeType === 1 && n.parentNode && n.parentNode.nodeType === 1) { |
16461 | var textDecoration = getTextDecoration(dom, n.parentNode); |
15753 | var textDecoration = getTextDecoration(dom, n.parentNode); |
16462 | if (dom.getStyle(n, 'color') && textDecoration) { |
15754 | if (dom.getStyle(n, 'color') && textDecoration) { |
Line 16481... | Line 15773... | ||
16481 | processChildElements(node, hasStyle(dom, 'fontSize'), applyStyle(dom, 'fontSize', '')); |
15773 | processChildElements(node, hasStyle(dom, 'fontSize'), applyStyle(dom, 'fontSize', '')); |
16482 | dom.remove(dom.select(format.inline === 'sup' ? 'sub' : 'sup', node), true); |
15774 | dom.remove(dom.select(format.inline === 'sup' ? 'sub' : 'sup', node), true); |
16483 | } |
15775 | } |
16484 | }; |
15776 | }; |
16485 | var mergeWithChildren = function (editor, formatList, vars, node) { |
15777 | var mergeWithChildren = function (editor, formatList, vars, node) { |
16486 | each$8(formatList, function (format) { |
15778 | each$9(formatList, function (format) { |
16487 | if (isInlineFormat(format)) { |
15779 | if (isInlineFormat(format)) { |
16488 | each$8(editor.dom.select(format.inline, node), function (child) { |
15780 | each$9(editor.dom.select(format.inline, node), function (child) { |
16489 | if (!isElementNode$1(child)) { |
15781 | if (!isElementNode$1(child)) { |
16490 | return; |
15782 | return; |
16491 | } |
15783 | } |
16492 | removeFormat$1(editor, format, vars, child, format.exact ? child : null); |
15784 | removeFormat$1(editor, format, vars, child, format.exact ? child : null); |
16493 | }); |
15785 | }); |
Line 16509... | Line 15801... | ||
16509 | } |
15801 | } |
16510 | }); |
15802 | }); |
16511 | } |
15803 | } |
16512 | }; |
15804 | }; |
16513 | 15805 | ||
16514 | var each$7 = Tools.each; |
15806 | var each$8 = Tools.each; |
16515 | var isElementNode = function (node) { |
15807 | var isElementNode = function (node) { |
16516 | return isElement$5(node) && !isBookmarkNode$1(node) && !isCaretNode(node) && !isBogus$2(node); |
15808 | return isElement$5(node) && !isBookmarkNode$1(node) && !isCaretNode(node) && !isBogus$2(node); |
16517 | }; |
15809 | }; |
16518 | var canFormatBR = function (editor, format, node, parentName) { |
15810 | var canFormatBR = function (editor, format, node, parentName) { |
16519 | if (canFormatEmptyLines(editor) && isInlineFormat(format)) { |
15811 | if (canFormatEmptyLines(editor) && isInlineFormat(format)) { |
Line 16537... | Line 15829... | ||
16537 | fmt = format; |
15829 | fmt = format; |
16538 | } |
15830 | } |
16539 | if (isFunction(fmt.onformat)) { |
15831 | if (isFunction(fmt.onformat)) { |
16540 | fmt.onformat(elm, fmt, vars, node); |
15832 | fmt.onformat(elm, fmt, vars, node); |
16541 | } |
15833 | } |
16542 | each$7(fmt.styles, function (value, name) { |
15834 | each$8(fmt.styles, function (value, name) { |
16543 | dom.setStyle(elm, name, replaceVars(value, vars)); |
15835 | dom.setStyle(elm, name, replaceVars(value, vars)); |
16544 | }); |
15836 | }); |
16545 | if (fmt.styles) { |
15837 | if (fmt.styles) { |
16546 | var styleVal = dom.getAttrib(elm, 'style'); |
15838 | var styleVal = dom.getAttrib(elm, 'style'); |
16547 | if (styleVal) { |
15839 | if (styleVal) { |
16548 | dom.setAttrib(elm, 'data-mce-style', styleVal); |
15840 | dom.setAttrib(elm, 'data-mce-style', styleVal); |
16549 | } |
15841 | } |
16550 | } |
15842 | } |
16551 | each$7(fmt.attributes, function (value, name) { |
15843 | each$8(fmt.attributes, function (value, name) { |
16552 | dom.setAttrib(elm, name, replaceVars(value, vars)); |
15844 | dom.setAttrib(elm, name, replaceVars(value, vars)); |
16553 | }); |
15845 | }); |
16554 | each$7(fmt.classes, function (value) { |
15846 | each$8(fmt.classes, function (value) { |
16555 | value = replaceVars(value, vars); |
15847 | value = replaceVars(value, vars); |
16556 | if (!dom.hasClass(elm, value)) { |
15848 | if (!dom.hasClass(elm, value)) { |
16557 | dom.addClass(elm, value); |
15849 | dom.addClass(elm, value); |
16558 | } |
15850 | } |
16559 | }); |
15851 | }); |
16560 | }; |
15852 | }; |
16561 | var applyNodeStyle = function (formatList, node) { |
15853 | var applyNodeStyle = function (formatList, node) { |
16562 | var found = false; |
15854 | var found = false; |
16563 | each$7(formatList, function (format) { |
15855 | each$8(formatList, function (format) { |
16564 | if (!isSelectorFormat(format)) { |
15856 | if (!isSelectorFormat(format)) { |
16565 | return false; |
15857 | return false; |
16566 | } |
15858 | } |
16567 | if (isNonNullable(format.collapsed) && format.collapsed !== isCollapsed) { |
15859 | if (isNonNullable(format.collapsed) && format.collapsed !== isCollapsed) { |
16568 | return; |
15860 | return; |
Line 17125... | Line 16417... | ||
17125 | }; |
16417 | }; |
17126 | var isCollapsibleWhitespace = function (text, index) { |
16418 | var isCollapsibleWhitespace = function (text, index) { |
17127 | return index >= 0 && index < text.length && isWhiteSpace(text.charAt(index)); |
16419 | return index >= 0 && index < text.length && isWhiteSpace(text.charAt(index)); |
17128 | }; |
16420 | }; |
17129 | var getInnerText = function (bin, shouldTrim) { |
16421 | var getInnerText = function (bin, shouldTrim) { |
17130 | var text = trim$2(bin.innerText); |
16422 | var text = trim$3(bin.innerText); |
17131 | return shouldTrim ? trimLeadingCollapsibleText(text) : text; |
16423 | return shouldTrim ? trimLeadingCollapsibleText(text) : text; |
17132 | }; |
16424 | }; |
17133 | var getContextNodeName = function (parentBlockOpt) { |
16425 | var getContextNodeName = function (parentBlockOpt) { |
17134 | return parentBlockOpt.map(function (block) { |
16426 | return parentBlockOpt.map(function (block) { |
17135 | return block.nodeName; |
16427 | return block.nodeName; |
Line 17144... | Line 16436... | ||
17144 | var bin = editor.dom.add(body, contextNodeName, { |
16436 | var bin = editor.dom.add(body, contextNodeName, { |
17145 | 'data-mce-bogus': 'all', |
16437 | 'data-mce-bogus': 'all', |
17146 | 'style': 'overflow: hidden; opacity: 0;' |
16438 | 'style': 'overflow: hidden; opacity: 0;' |
17147 | }, rng.cloneContents()); |
16439 | }, rng.cloneContents()); |
17148 | var text = getInnerText(bin, shouldTrimSpaces); |
16440 | var text = getInnerText(bin, shouldTrimSpaces); |
17149 | var nonRenderedText = trim$2(bin.textContent); |
16441 | var nonRenderedText = trim$3(bin.textContent); |
17150 | editor.dom.remove(bin); |
16442 | editor.dom.remove(bin); |
17151 | if (isCollapsibleWhitespace(nonRenderedText, 0) || isCollapsibleWhitespace(nonRenderedText, nonRenderedText.length - 1)) { |
16443 | if (isCollapsibleWhitespace(nonRenderedText, 0) || isCollapsibleWhitespace(nonRenderedText, nonRenderedText.length - 1)) { |
17152 | var parentBlock = parentBlockOpt.getOr(body); |
16444 | var parentBlock = parentBlockOpt.getOr(body); |
17153 | var parentBlockText = getInnerText(parentBlock, shouldTrimSpaces); |
16445 | var parentBlockText = getInnerText(parentBlock, shouldTrimSpaces); |
17154 | var textIndex = parentBlockText.indexOf(text); |
16446 | var textIndex = parentBlockText.indexOf(text); |
Line 17371... | Line 16663... | ||
17371 | } else if (action[0] === DELETE) { |
16663 | } else if (action[0] === DELETE) { |
17372 | removeAt(elm, index); |
16664 | removeAt(elm, index); |
17373 | } |
16665 | } |
17374 | }); |
16666 | }); |
17375 | }; |
16667 | }; |
17376 | var read$2 = function (elm) { |
16668 | var read$2 = function (elm, trimZwsp) { |
17377 | return filter$4(map$3(from(elm.childNodes), getOuterHtml), function (item) { |
16669 | return filter$4(map$3(from(elm.childNodes), trimZwsp ? compose(trim$3, getOuterHtml) : getOuterHtml), function (item) { |
17378 | return item.length > 0; |
16670 | return item.length > 0; |
17379 | }); |
16671 | }); |
17380 | }; |
16672 | }; |
17381 | var write = function (fragments, elm) { |
16673 | var write = function (fragments, elm) { |
17382 | var currentFragments = map$3(from(elm.childNodes), getOuterHtml); |
16674 | var currentFragments = map$3(from(elm.childNodes), getOuterHtml); |
17383 | applyDiff(diff(currentFragments, fragments), elm); |
16675 | applyDiff(diff(currentFragments, fragments), elm); |
17384 | return elm; |
16676 | return elm; |
17385 | }; |
16677 | }; |
17386 | 16678 | ||
17387 | var lazyTempDocument = cached(function () { |
16679 | var lazyTempDocument$1 = cached(function () { |
17388 | return document.implementation.createHTMLDocument('undo'); |
16680 | return document.implementation.createHTMLDocument('undo'); |
17389 | }); |
16681 | }); |
17390 | var hasIframes = function (html) { |
16682 | var hasIframes = function (body) { |
17391 | return html.indexOf('</iframe>') !== -1; |
16683 | return body.querySelector('iframe') !== null; |
17392 | }; |
16684 | }; |
17393 | var createFragmentedLevel = function (fragments) { |
16685 | var createFragmentedLevel = function (fragments) { |
17394 | return { |
16686 | return { |
17395 | type: 'fragmented', |
16687 | type: 'fragmented', |
17396 | fragments: fragments, |
16688 | fragments: fragments, |
Line 17407... | Line 16699... | ||
17407 | bookmark: null, |
16699 | bookmark: null, |
17408 | beforeBookmark: null |
16700 | beforeBookmark: null |
17409 | }; |
16701 | }; |
17410 | }; |
16702 | }; |
17411 | var createFromEditor = function (editor) { |
16703 | var createFromEditor = function (editor) { |
17412 | var fragments = read$2(editor.getBody()); |
- | |
17413 | var trimmedFragments = bind(fragments, function (html) { |
- | |
17414 | var trimmed = trimInternal(editor.serializer, html); |
16704 | var tempAttrs = editor.serializer.getTempAttrs(); |
17415 | return trimmed.length > 0 ? [trimmed] : []; |
- | |
17416 | }); |
- | |
17417 | var content = trimmedFragments.join(''); |
16705 | var body = trim$1(editor.getBody(), tempAttrs); |
17418 | return hasIframes(content) ? createFragmentedLevel(trimmedFragments) : createCompleteLevel(content); |
16706 | return hasIframes(body) ? createFragmentedLevel(read$2(body, true)) : createCompleteLevel(trim$3(body.innerHTML)); |
17419 | }; |
16707 | }; |
17420 | var applyToEditor = function (editor, level, before) { |
16708 | var applyToEditor = function (editor, level, before) { |
17421 | var bookmark = before ? level.beforeBookmark : level.bookmark; |
16709 | var bookmark = before ? level.beforeBookmark : level.bookmark; |
17422 | if (level.type === 'fragmented') { |
16710 | if (level.type === 'fragmented') { |
17423 | write(level.fragments, editor.getBody()); |
16711 | write(level.fragments, editor.getBody()); |
Line 17431... | Line 16719... | ||
17431 | }; |
16719 | }; |
17432 | var getLevelContent = function (level) { |
16720 | var getLevelContent = function (level) { |
17433 | return level.type === 'fragmented' ? level.fragments.join('') : level.content; |
16721 | return level.type === 'fragmented' ? level.fragments.join('') : level.content; |
17434 | }; |
16722 | }; |
17435 | var getCleanLevelContent = function (level) { |
16723 | var getCleanLevelContent = function (level) { |
17436 | var elm = SugarElement.fromTag('body', lazyTempDocument()); |
16724 | var elm = SugarElement.fromTag('body', lazyTempDocument$1()); |
17437 | set(elm, getLevelContent(level)); |
16725 | set(elm, getLevelContent(level)); |
17438 | each$k(descendants(elm, '*[data-mce-bogus]'), unwrap); |
16726 | each$k(descendants(elm, '*[data-mce-bogus]'), unwrap); |
17439 | return get$3(elm); |
16727 | return get$3(elm); |
17440 | }; |
16728 | }; |
17441 | var hasEqualContent = function (level1, level2) { |
16729 | var hasEqualContent = function (level1, level2) { |
Line 18499... | Line 17787... | ||
18499 | } catch (ex) { |
17787 | } catch (ex) { |
18500 | rejectWithError(); |
17788 | rejectWithError(); |
18501 | } |
17789 | } |
18502 | }); |
17790 | }); |
18503 | }; |
17791 | }; |
18504 | var parseDataUri = function (uri) { |
17792 | var parseDataUri$1 = function (uri) { |
18505 | var type; |
17793 | var type; |
18506 | var uriParts = decodeURIComponent(uri).split(','); |
17794 | var uriParts = decodeURIComponent(uri).split(','); |
18507 | var matches = /data:([^;]+)/.exec(uriParts[0]); |
17795 | var matches = /data:([^;]+)/.exec(uriParts[0]); |
18508 | if (matches) { |
17796 | if (matches) { |
18509 | type = matches[1]; |
17797 | type = matches[1]; |
Line 18526... | Line 17814... | ||
18526 | } |
17814 | } |
18527 | return Optional.some(new Blob([arr], { type: type })); |
17815 | return Optional.some(new Blob([arr], { type: type })); |
18528 | }; |
17816 | }; |
18529 | var dataUriToBlob = function (uri) { |
17817 | var dataUriToBlob = function (uri) { |
18530 | return new promiseObj(function (resolve) { |
17818 | return new promiseObj(function (resolve) { |
18531 | var _a = parseDataUri(uri), type = _a.type, data = _a.data; |
17819 | var _a = parseDataUri$1(uri), type = _a.type, data = _a.data; |
18532 | buildBlob(type, data).fold(function () { |
17820 | buildBlob(type, data).fold(function () { |
18533 | return resolve(new Blob([])); |
17821 | return resolve(new Blob([])); |
18534 | }, resolve); |
17822 | }, resolve); |
18535 | }); |
17823 | }); |
18536 | }; |
17824 | }; |
Line 18567... | Line 17855... | ||
18567 | blobInfo: blobInfo |
17855 | blobInfo: blobInfo |
18568 | }); |
17856 | }); |
18569 | } else { |
17857 | } else { |
18570 | uriToBlob(img.src).then(function (blob) { |
17858 | uriToBlob(img.src).then(function (blob) { |
18571 | blobToDataUri(blob).then(function (dataUri) { |
17859 | blobToDataUri(blob).then(function (dataUri) { |
18572 | base64 = parseDataUri(dataUri).data; |
17860 | base64 = parseDataUri$1(dataUri).data; |
18573 | blobInfo = blobCache.create(uniqueId(), blob, base64); |
17861 | blobInfo = blobCache.create(uniqueId(), blob, base64); |
18574 | blobCache.add(blobInfo); |
17862 | blobCache.add(blobInfo); |
18575 | resolve({ |
17863 | resolve({ |
18576 | image: img, |
17864 | image: img, |
18577 | blobInfo: blobInfo |
17865 | blobInfo: blobInfo |
Line 18581... | Line 17869... | ||
18581 | reject(err); |
17869 | reject(err); |
18582 | }); |
17870 | }); |
18583 | } |
17871 | } |
18584 | return; |
17872 | return; |
18585 | } |
17873 | } |
18586 | var _a = parseDataUri(img.src), data = _a.data, type = _a.type; |
17874 | var _a = parseDataUri$1(img.src), data = _a.data, type = _a.type; |
18587 | base64 = data; |
17875 | base64 = data; |
18588 | blobInfo = blobCache.getByData(base64, type); |
17876 | blobInfo = blobCache.getByData(base64, type); |
18589 | if (blobInfo) { |
17877 | if (blobInfo) { |
18590 | resolve({ |
17878 | resolve({ |
18591 | image: img, |
17879 | image: img, |
Line 18664... | Line 17952... | ||
18664 | return promiseObj.all(promises); |
17952 | return promiseObj.all(promises); |
18665 | }; |
17953 | }; |
18666 | return { findAll: findAll }; |
17954 | return { findAll: findAll }; |
18667 | }; |
17955 | }; |
18668 | 17956 | ||
- | 17957 | var extractBase64DataUris = function (html) { |
|
- | 17958 | var dataImageUri = /data:[^;<"'\s]+;base64,([a-z0-9\+\/=\s]+)/gi; |
|
- | 17959 | var chunks = []; |
|
- | 17960 | var uris = {}; |
|
- | 17961 | var prefix = generate('img'); |
|
- | 17962 | var matches; |
|
- | 17963 | var index = 0; |
|
- | 17964 | var count = 0; |
|
- | 17965 | while (matches = dataImageUri.exec(html)) { |
|
- | 17966 | var uri = matches[0]; |
|
- | 17967 | var imageId = prefix + '_' + count++; |
|
- | 17968 | uris[imageId] = uri; |
|
- | 17969 | if (index < matches.index) { |
|
- | 17970 | chunks.push(html.substr(index, matches.index - index)); |
|
- | 17971 | } |
|
- | 17972 | chunks.push(imageId); |
|
- | 17973 | index = matches.index + uri.length; |
|
- | 17974 | } |
|
- | 17975 | var re = new RegExp(prefix + '_[0-9]+', 'g'); |
|
- | 17976 | if (index === 0) { |
|
- | 17977 | return { |
|
- | 17978 | prefix: prefix, |
|
- | 17979 | uris: uris, |
|
- | 17980 | html: html, |
|
- | 17981 | re: re |
|
- | 17982 | }; |
|
- | 17983 | } else { |
|
- | 17984 | if (index < html.length) { |
|
- | 17985 | chunks.push(html.substr(index)); |
|
- | 17986 | } |
|
- | 17987 | return { |
|
- | 17988 | prefix: prefix, |
|
- | 17989 | uris: uris, |
|
- | 17990 | html: chunks.join(''), |
|
- | 17991 | re: re |
|
- | 17992 | }; |
|
- | 17993 | } |
|
- | 17994 | }; |
|
- | 17995 | var restoreDataUris = function (html, result) { |
|
- | 17996 | return html.replace(result.re, function (imageId) { |
|
- | 17997 | return get$9(result.uris, imageId).getOr(imageId); |
|
- | 17998 | }); |
|
- | 17999 | }; |
|
- | 18000 | var parseDataUri = function (uri) { |
|
- | 18001 | var matches = /data:([^;]+);base64,([a-z0-9\+\/=\s]+)/i.exec(uri); |
|
- | 18002 | if (matches) { |
|
- | 18003 | return Optional.some({ |
|
- | 18004 | type: matches[1], |
|
- | 18005 | data: decodeURIComponent(matches[2]) |
|
- | 18006 | }); |
|
- | 18007 | } else { |
|
- | 18008 | return Optional.none(); |
|
- | 18009 | } |
|
- | 18010 | }; |
|
- | 18011 | ||
18669 | var paddEmptyNode = function (settings, args, blockElements, node) { |
18012 | var paddEmptyNode = function (settings, args, blockElements, node) { |
18670 | var brPreferred = settings.padd_empty_with_br || args.insert; |
18013 | var brPreferred = settings.padd_empty_with_br || args.insert; |
18671 | if (brPreferred && blockElements[node.name]) { |
18014 | if (brPreferred && blockElements[node.name]) { |
18672 | node.empty().append(new AstNode('br', 1)).shortEnded = true; |
18015 | node.empty().append(new AstNode('br', 1)).shortEnded = true; |
18673 | } else { |
18016 | } else { |
Line 18716... | Line 18059... | ||
18716 | var processImage = function (img) { |
18059 | var processImage = function (img) { |
18717 | var inputSrc = img.attr('src'); |
18060 | var inputSrc = img.attr('src'); |
18718 | if (isInternalImageSource(img) || isBogusImage(img)) { |
18061 | if (isInternalImageSource(img) || isBogusImage(img)) { |
18719 | return; |
18062 | return; |
18720 | } |
18063 | } |
18721 | parseDataUri$1(inputSrc).filter(function () { |
18064 | parseDataUri(inputSrc).filter(function () { |
18722 | return isValidDataImg(img, settings); |
18065 | return isValidDataImg(img, settings); |
18723 | }).bind(function (_a) { |
18066 | }).bind(function (_a) { |
18724 | var type = _a.type, data = _a.data; |
18067 | var type = _a.type, data = _a.data; |
18725 | return Optional.from(blobCache.getByData(data, type)).orThunk(function () { |
18068 | return Optional.from(blobCache.getByData(data, type)).orThunk(function () { |
18726 | return buildBlob(type, data).map(function (blob) { |
18069 | return buildBlob(type, data).map(function (blob) { |
Line 18892... | Line 18235... | ||
18892 | }); |
18235 | }); |
18893 | } |
18236 | } |
18894 | registerBase64ImageFilter(parser, settings); |
18237 | registerBase64ImageFilter(parser, settings); |
18895 | }; |
18238 | }; |
18896 | 18239 | ||
- | 18240 | var each$7 = Tools.each, trim = Tools.trim; |
|
- | 18241 | var queryParts = 'source protocol authority userInfo user password host port relative path directory file query anchor'.split(' '); |
|
- | 18242 | var DEFAULT_PORTS = { |
|
- | 18243 | ftp: 21, |
|
- | 18244 | http: 80, |
|
- | 18245 | https: 443, |
|
- | 18246 | mailto: 25 |
|
- | 18247 | }; |
|
- | 18248 | var safeSvgDataUrlElements = [ |
|
- | 18249 | 'img', |
|
- | 18250 | 'video' |
|
- | 18251 | ]; |
|
- | 18252 | var blockSvgDataUris = function (allowSvgDataUrls, tagName) { |
|
- | 18253 | if (isNonNullable(allowSvgDataUrls)) { |
|
- | 18254 | return !allowSvgDataUrls; |
|
- | 18255 | } else { |
|
- | 18256 | return isNonNullable(tagName) ? !contains$3(safeSvgDataUrlElements, tagName) : true; |
|
- | 18257 | } |
|
- | 18258 | }; |
|
- | 18259 | var isInvalidUri = function (settings, uri, tagName) { |
|
- | 18260 | if (settings.allow_html_data_urls) { |
|
- | 18261 | return false; |
|
- | 18262 | } else if (/^data:image\//i.test(uri)) { |
|
- | 18263 | return blockSvgDataUris(settings.allow_svg_data_urls, tagName) && /^data:image\/svg\+xml/i.test(uri); |
|
- | 18264 | } else { |
|
- | 18265 | return /^data:/i.test(uri); |
|
- | 18266 | } |
|
- | 18267 | }; |
|
- | 18268 | var URI = function () { |
|
- | 18269 | function URI(url, settings) { |
|
- | 18270 | url = trim(url); |
|
- | 18271 | this.settings = settings || {}; |
|
- | 18272 | var baseUri = this.settings.base_uri; |
|
- | 18273 | var self = this; |
|
- | 18274 | if (/^([\w\-]+):([^\/]{2})/i.test(url) || /^\s*#/.test(url)) { |
|
- | 18275 | self.source = url; |
|
- | 18276 | return; |
|
- | 18277 | } |
|
- | 18278 | var isProtocolRelative = url.indexOf('//') === 0; |
|
- | 18279 | if (url.indexOf('/') === 0 && !isProtocolRelative) { |
|
- | 18280 | url = (baseUri ? baseUri.protocol || 'http' : 'http') + '://mce_host' + url; |
|
- | 18281 | } |
|
- | 18282 | if (!/^[\w\-]*:?\/\//.test(url)) { |
|
- | 18283 | var baseUrl = this.settings.base_uri ? this.settings.base_uri.path : new URI(document.location.href).directory; |
|
- | 18284 | if (this.settings.base_uri && this.settings.base_uri.protocol == '') { |
|
- | 18285 | url = '//mce_host' + self.toAbsPath(baseUrl, url); |
|
- | 18286 | } else { |
|
- | 18287 | var match = /([^#?]*)([#?]?.*)/.exec(url); |
|
- | 18288 | url = (baseUri && baseUri.protocol || 'http') + '://mce_host' + self.toAbsPath(baseUrl, match[1]) + match[2]; |
|
- | 18289 | } |
|
- | 18290 | } |
|
- | 18291 | url = url.replace(/@@/g, '(mce_at)'); |
|
- | 18292 | var urlMatch = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?(\[[a-zA-Z0-9:.%]+\]|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(url); |
|
- | 18293 | each$7(queryParts, function (v, i) { |
|
- | 18294 | var part = urlMatch[i]; |
|
- | 18295 | if (part) { |
|
- | 18296 | part = part.replace(/\(mce_at\)/g, '@@'); |
|
- | 18297 | } |
|
- | 18298 | self[v] = part; |
|
- | 18299 | }); |
|
- | 18300 | if (baseUri) { |
|
- | 18301 | if (!self.protocol) { |
|
- | 18302 | self.protocol = baseUri.protocol; |
|
- | 18303 | } |
|
- | 18304 | if (!self.userInfo) { |
|
- | 18305 | self.userInfo = baseUri.userInfo; |
|
- | 18306 | } |
|
- | 18307 | if (!self.port && self.host === 'mce_host') { |
|
- | 18308 | self.port = baseUri.port; |
|
- | 18309 | } |
|
- | 18310 | if (!self.host || self.host === 'mce_host') { |
|
- | 18311 | self.host = baseUri.host; |
|
- | 18312 | } |
|
- | 18313 | self.source = ''; |
|
- | 18314 | } |
|
- | 18315 | if (isProtocolRelative) { |
|
- | 18316 | self.protocol = ''; |
|
- | 18317 | } |
|
- | 18318 | } |
|
- | 18319 | URI.parseDataUri = function (uri) { |
|
- | 18320 | var type; |
|
- | 18321 | var uriComponents = decodeURIComponent(uri).split(','); |
|
- | 18322 | var matches = /data:([^;]+)/.exec(uriComponents[0]); |
|
- | 18323 | if (matches) { |
|
- | 18324 | type = matches[1]; |
|
- | 18325 | } |
|
- | 18326 | return { |
|
- | 18327 | type: type, |
|
- | 18328 | data: uriComponents[1] |
|
- | 18329 | }; |
|
- | 18330 | }; |
|
- | 18331 | URI.isDomSafe = function (uri, context, options) { |
|
- | 18332 | if (options === void 0) { |
|
- | 18333 | options = {}; |
|
- | 18334 | } |
|
- | 18335 | if (options.allow_script_urls) { |
|
- | 18336 | return true; |
|
- | 18337 | } else { |
|
- | 18338 | var decodedUri = Entities.decode(uri).replace(/[\s\u0000-\u001F]+/g, ''); |
|
- | 18339 | try { |
|
- | 18340 | decodedUri = decodeURIComponent(decodedUri); |
|
- | 18341 | } catch (ex) { |
|
- | 18342 | decodedUri = unescape(decodedUri); |
|
- | 18343 | } |
|
- | 18344 | if (/((java|vb)script|mhtml):/i.test(decodedUri)) { |
|
- | 18345 | return false; |
|
- | 18346 | } |
|
- | 18347 | return !isInvalidUri(options, decodedUri, context); |
|
- | 18348 | } |
|
- | 18349 | }; |
|
- | 18350 | URI.getDocumentBaseUrl = function (loc) { |
|
- | 18351 | var baseUrl; |
|
- | 18352 | if (loc.protocol.indexOf('http') !== 0 && loc.protocol !== 'file:') { |
|
- | 18353 | baseUrl = loc.href; |
|
- | 18354 | } else { |
|
- | 18355 | baseUrl = loc.protocol + '//' + loc.host + loc.pathname; |
|
- | 18356 | } |
|
- | 18357 | if (/^[^:]+:\/\/\/?[^\/]+\//.test(baseUrl)) { |
|
- | 18358 | baseUrl = baseUrl.replace(/[\?#].*$/, '').replace(/[\/\\][^\/]+$/, ''); |
|
- | 18359 | if (!/[\/\\]$/.test(baseUrl)) { |
|
- | 18360 | baseUrl += '/'; |
|
- | 18361 | } |
|
- | 18362 | } |
|
- | 18363 | return baseUrl; |
|
- | 18364 | }; |
|
- | 18365 | URI.prototype.setPath = function (path) { |
|
- | 18366 | var pathMatch = /^(.*?)\/?(\w+)?$/.exec(path); |
|
- | 18367 | this.path = pathMatch[0]; |
|
- | 18368 | this.directory = pathMatch[1]; |
|
- | 18369 | this.file = pathMatch[2]; |
|
- | 18370 | this.source = ''; |
|
- | 18371 | this.getURI(); |
|
- | 18372 | }; |
|
- | 18373 | URI.prototype.toRelative = function (uri) { |
|
- | 18374 | var output; |
|
- | 18375 | if (uri === './') { |
|
- | 18376 | return uri; |
|
- | 18377 | } |
|
- | 18378 | var relativeUri = new URI(uri, { base_uri: this }); |
|
- | 18379 | if (relativeUri.host !== 'mce_host' && this.host !== relativeUri.host && relativeUri.host || this.port !== relativeUri.port || this.protocol !== relativeUri.protocol && relativeUri.protocol !== '') { |
|
- | 18380 | return relativeUri.getURI(); |
|
- | 18381 | } |
|
- | 18382 | var tu = this.getURI(), uu = relativeUri.getURI(); |
|
- | 18383 | if (tu === uu || tu.charAt(tu.length - 1) === '/' && tu.substr(0, tu.length - 1) === uu) { |
|
- | 18384 | return tu; |
|
- | 18385 | } |
|
- | 18386 | output = this.toRelPath(this.path, relativeUri.path); |
|
- | 18387 | if (relativeUri.query) { |
|
- | 18388 | output += '?' + relativeUri.query; |
|
- | 18389 | } |
|
- | 18390 | if (relativeUri.anchor) { |
|
- | 18391 | output += '#' + relativeUri.anchor; |
|
- | 18392 | } |
|
- | 18393 | return output; |
|
- | 18394 | }; |
|
- | 18395 | URI.prototype.toAbsolute = function (uri, noHost) { |
|
- | 18396 | var absoluteUri = new URI(uri, { base_uri: this }); |
|
- | 18397 | return absoluteUri.getURI(noHost && this.isSameOrigin(absoluteUri)); |
|
- | 18398 | }; |
|
- | 18399 | URI.prototype.isSameOrigin = function (uri) { |
|
- | 18400 | if (this.host == uri.host && this.protocol == uri.protocol) { |
|
- | 18401 | if (this.port == uri.port) { |
|
- | 18402 | return true; |
|
- | 18403 | } |
|
- | 18404 | var defaultPort = DEFAULT_PORTS[this.protocol]; |
|
- | 18405 | if (defaultPort && (this.port || defaultPort) == (uri.port || defaultPort)) { |
|
- | 18406 | return true; |
|
- | 18407 | } |
|
- | 18408 | } |
|
- | 18409 | return false; |
|
- | 18410 | }; |
|
- | 18411 | URI.prototype.toRelPath = function (base, path) { |
|
- | 18412 | var breakPoint = 0, out = '', i, l; |
|
- | 18413 | var normalizedBase = base.substring(0, base.lastIndexOf('/')).split('/'); |
|
- | 18414 | var items = path.split('/'); |
|
- | 18415 | if (normalizedBase.length >= items.length) { |
|
- | 18416 | for (i = 0, l = normalizedBase.length; i < l; i++) { |
|
- | 18417 | if (i >= items.length || normalizedBase[i] !== items[i]) { |
|
- | 18418 | breakPoint = i + 1; |
|
- | 18419 | break; |
|
- | 18420 | } |
|
- | 18421 | } |
|
- | 18422 | } |
|
- | 18423 | if (normalizedBase.length < items.length) { |
|
- | 18424 | for (i = 0, l = items.length; i < l; i++) { |
|
- | 18425 | if (i >= normalizedBase.length || normalizedBase[i] !== items[i]) { |
|
- | 18426 | breakPoint = i + 1; |
|
- | 18427 | break; |
|
- | 18428 | } |
|
- | 18429 | } |
|
- | 18430 | } |
|
- | 18431 | if (breakPoint === 1) { |
|
- | 18432 | return path; |
|
- | 18433 | } |
|
- | 18434 | for (i = 0, l = normalizedBase.length - (breakPoint - 1); i < l; i++) { |
|
- | 18435 | out += '../'; |
|
- | 18436 | } |
|
- | 18437 | for (i = breakPoint - 1, l = items.length; i < l; i++) { |
|
- | 18438 | if (i !== breakPoint - 1) { |
|
- | 18439 | out += '/' + items[i]; |
|
- | 18440 | } else { |
|
- | 18441 | out += items[i]; |
|
- | 18442 | } |
|
- | 18443 | } |
|
- | 18444 | return out; |
|
- | 18445 | }; |
|
- | 18446 | URI.prototype.toAbsPath = function (base, path) { |
|
- | 18447 | var i, nb = 0, o = [], outPath; |
|
- | 18448 | var tr = /\/$/.test(path) ? '/' : ''; |
|
- | 18449 | var normalizedBase = base.split('/'); |
|
- | 18450 | var normalizedPath = path.split('/'); |
|
- | 18451 | each$7(normalizedBase, function (k) { |
|
- | 18452 | if (k) { |
|
- | 18453 | o.push(k); |
|
- | 18454 | } |
|
- | 18455 | }); |
|
- | 18456 | normalizedBase = o; |
|
- | 18457 | for (i = normalizedPath.length - 1, o = []; i >= 0; i--) { |
|
- | 18458 | if (normalizedPath[i].length === 0 || normalizedPath[i] === '.') { |
|
- | 18459 | continue; |
|
- | 18460 | } |
|
- | 18461 | if (normalizedPath[i] === '..') { |
|
- | 18462 | nb++; |
|
- | 18463 | continue; |
|
- | 18464 | } |
|
- | 18465 | if (nb > 0) { |
|
- | 18466 | nb--; |
|
- | 18467 | continue; |
|
- | 18468 | } |
|
- | 18469 | o.push(normalizedPath[i]); |
|
- | 18470 | } |
|
- | 18471 | i = normalizedBase.length - nb; |
|
- | 18472 | if (i <= 0) { |
|
- | 18473 | outPath = reverse(o).join('/'); |
|
- | 18474 | } else { |
|
- | 18475 | outPath = normalizedBase.slice(0, i).join('/') + '/' + reverse(o).join('/'); |
|
- | 18476 | } |
|
- | 18477 | if (outPath.indexOf('/') !== 0) { |
|
- | 18478 | outPath = '/' + outPath; |
|
- | 18479 | } |
|
- | 18480 | if (tr && outPath.lastIndexOf('/') !== outPath.length - 1) { |
|
- | 18481 | outPath += tr; |
|
- | 18482 | } |
|
- | 18483 | return outPath; |
|
- | 18484 | }; |
|
- | 18485 | URI.prototype.getURI = function (noProtoHost) { |
|
- | 18486 | if (noProtoHost === void 0) { |
|
- | 18487 | noProtoHost = false; |
|
- | 18488 | } |
|
- | 18489 | var s; |
|
- | 18490 | if (!this.source || noProtoHost) { |
|
- | 18491 | s = ''; |
|
- | 18492 | if (!noProtoHost) { |
|
- | 18493 | if (this.protocol) { |
|
- | 18494 | s += this.protocol + '://'; |
|
- | 18495 | } else { |
|
- | 18496 | s += '//'; |
|
- | 18497 | } |
|
- | 18498 | if (this.userInfo) { |
|
- | 18499 | s += this.userInfo + '@'; |
|
- | 18500 | } |
|
- | 18501 | if (this.host) { |
|
- | 18502 | s += this.host; |
|
- | 18503 | } |
|
- | 18504 | if (this.port) { |
|
- | 18505 | s += ':' + this.port; |
|
- | 18506 | } |
|
- | 18507 | } |
|
- | 18508 | if (this.path) { |
|
- | 18509 | s += this.path; |
|
- | 18510 | } |
|
- | 18511 | if (this.query) { |
|
- | 18512 | s += '?' + this.query; |
|
- | 18513 | } |
|
- | 18514 | if (this.anchor) { |
|
- | 18515 | s += '#' + this.anchor; |
|
- | 18516 | } |
|
- | 18517 | this.source = s; |
|
- | 18518 | } |
|
- | 18519 | return this.source; |
|
- | 18520 | }; |
|
- | 18521 | return URI; |
|
- | 18522 | }(); |
|
- | 18523 | ||
- | 18524 | var filteredClobberElements = Tools.makeMap('button,fieldset,form,iframe,img,image,input,object,output,select,textarea'); |
|
- | 18525 | var isValidPrefixAttrName = function (name) { |
|
- | 18526 | return name.indexOf('data-') === 0 || name.indexOf('aria-') === 0; |
|
- | 18527 | }; |
|
- | 18528 | var lazyTempDocument = cached(function () { |
|
- | 18529 | return document.implementation.createHTMLDocument('parser'); |
|
- | 18530 | }); |
|
- | 18531 | var findMatchingEndTagIndex = function (schema, html, startIndex) { |
|
- | 18532 | var startTagRegExp = /<([!?\/])?([A-Za-z0-9\-_:.]+)/g; |
|
- | 18533 | var endTagRegExp = /(?:\s(?:[^'">]+(?:"[^"]*"|'[^']*'))*[^"'>]*(?:"[^">]*|'[^'>]*)?|\s*|\/)>/g; |
|
- | 18534 | var shortEndedElements = schema.getShortEndedElements(); |
|
- | 18535 | var count = 1, index = startIndex; |
|
- | 18536 | while (count !== 0) { |
|
- | 18537 | startTagRegExp.lastIndex = index; |
|
- | 18538 | while (true) { |
|
- | 18539 | var startMatch = startTagRegExp.exec(html); |
|
- | 18540 | if (startMatch === null) { |
|
- | 18541 | return index; |
|
- | 18542 | } else if (startMatch[1] === '!') { |
|
- | 18543 | if (startsWith(startMatch[2], '--')) { |
|
- | 18544 | index = findCommentEndIndex(html, false, startMatch.index + '!--'.length); |
|
- | 18545 | } else { |
|
- | 18546 | index = findCommentEndIndex(html, true, startMatch.index + 1); |
|
- | 18547 | } |
|
- | 18548 | break; |
|
- | 18549 | } else { |
|
- | 18550 | endTagRegExp.lastIndex = startTagRegExp.lastIndex; |
|
- | 18551 | var endMatch = endTagRegExp.exec(html); |
|
- | 18552 | if (isNull(endMatch) || endMatch.index !== startTagRegExp.lastIndex) { |
|
- | 18553 | continue; |
|
- | 18554 | } |
|
- | 18555 | if (startMatch[1] === '/') { |
|
- | 18556 | count -= 1; |
|
- | 18557 | } else if (!has$2(shortEndedElements, startMatch[2])) { |
|
- | 18558 | count += 1; |
|
- | 18559 | } |
|
- | 18560 | index = startTagRegExp.lastIndex + endMatch[0].length; |
|
- | 18561 | break; |
|
- | 18562 | } |
|
- | 18563 | } |
|
- | 18564 | } |
|
- | 18565 | return index; |
|
- | 18566 | }; |
|
- | 18567 | var isConditionalComment = function (html, startIndex) { |
|
- | 18568 | return /^\s*\[if [\w\W]+\]>.*<!\[endif\](--!?)?>/.test(html.substr(startIndex)); |
|
- | 18569 | }; |
|
- | 18570 | var findCommentEndIndex = function (html, isBogus, startIndex) { |
|
- | 18571 | if (startIndex === void 0) { |
|
- | 18572 | startIndex = 0; |
|
- | 18573 | } |
|
- | 18574 | var lcHtml = html.toLowerCase(); |
|
- | 18575 | if (lcHtml.indexOf('[if ', startIndex) !== -1 && isConditionalComment(lcHtml, startIndex)) { |
|
- | 18576 | var endIfIndex = lcHtml.indexOf('[endif]', startIndex); |
|
- | 18577 | return lcHtml.indexOf('>', endIfIndex); |
|
- | 18578 | } else { |
|
- | 18579 | if (isBogus) { |
|
- | 18580 | var endIndex = lcHtml.indexOf('>', startIndex); |
|
- | 18581 | return endIndex !== -1 ? endIndex : lcHtml.length; |
|
- | 18582 | } else { |
|
- | 18583 | var endCommentRegexp = /--!?>/g; |
|
- | 18584 | endCommentRegexp.lastIndex = startIndex; |
|
- | 18585 | var match = endCommentRegexp.exec(html); |
|
- | 18586 | return match ? match.index + match[0].length : lcHtml.length; |
|
- | 18587 | } |
|
- | 18588 | } |
|
- | 18589 | }; |
|
- | 18590 | var checkBogusAttribute = function (regExp, attrString) { |
|
- | 18591 | var matches = regExp.exec(attrString); |
|
- | 18592 | if (matches) { |
|
- | 18593 | var name_1 = matches[1]; |
|
- | 18594 | var value = matches[2]; |
|
- | 18595 | return typeof name_1 === 'string' && name_1.toLowerCase() === 'data-mce-bogus' ? value : null; |
|
- | 18596 | } else { |
|
- | 18597 | return null; |
|
- | 18598 | } |
|
- | 18599 | }; |
|
- | 18600 | var SaxParser = function (settings, schema) { |
|
- | 18601 | if (schema === void 0) { |
|
- | 18602 | schema = Schema(); |
|
- | 18603 | } |
|
- | 18604 | settings = settings || {}; |
|
- | 18605 | var doc = lazyTempDocument(); |
|
- | 18606 | var form = doc.createElement('form'); |
|
- | 18607 | if (settings.fix_self_closing !== false) { |
|
- | 18608 | settings.fix_self_closing = true; |
|
- | 18609 | } |
|
- | 18610 | var comment = settings.comment ? settings.comment : noop; |
|
- | 18611 | var cdata = settings.cdata ? settings.cdata : noop; |
|
- | 18612 | var text = settings.text ? settings.text : noop; |
|
- | 18613 | var start = settings.start ? settings.start : noop; |
|
- | 18614 | var end = settings.end ? settings.end : noop; |
|
- | 18615 | var pi = settings.pi ? settings.pi : noop; |
|
- | 18616 | var doctype = settings.doctype ? settings.doctype : noop; |
|
- | 18617 | var parseInternal = function (base64Extract, format) { |
|
- | 18618 | if (format === void 0) { |
|
- | 18619 | format = 'html'; |
|
- | 18620 | } |
|
- | 18621 | var html = base64Extract.html; |
|
- | 18622 | var matches, index = 0, value, endRegExp; |
|
- | 18623 | var stack = []; |
|
- | 18624 | var attrList, i, textData, name; |
|
- | 18625 | var isInternalElement, isShortEnded; |
|
- | 18626 | var elementRule, isValidElement, attr, attribsValue, validAttributesMap, validAttributePatterns; |
|
- | 18627 | var attributesRequired, attributesDefault, attributesForced; |
|
- | 18628 | var anyAttributesRequired, attrValue, idCount = 0; |
|
- | 18629 | var decode = Entities.decode; |
|
- | 18630 | var filteredUrlAttrs = Tools.makeMap('src,href,data,background,action,formaction,poster,xlink:href'); |
|
- | 18631 | var parsingMode = format === 'html' ? 0 : 1; |
|
- | 18632 | var processEndTag = function (name) { |
|
- | 18633 | var pos, i; |
|
- | 18634 | pos = stack.length; |
|
- | 18635 | while (pos--) { |
|
- | 18636 | if (stack[pos].name === name) { |
|
- | 18637 | break; |
|
- | 18638 | } |
|
- | 18639 | } |
|
- | 18640 | if (pos >= 0) { |
|
- | 18641 | for (i = stack.length - 1; i >= pos; i--) { |
|
- | 18642 | name = stack[i]; |
|
- | 18643 | if (name.valid) { |
|
- | 18644 | end(name.name); |
|
- | 18645 | } |
|
- | 18646 | } |
|
- | 18647 | stack.length = pos; |
|
- | 18648 | } |
|
- | 18649 | }; |
|
- | 18650 | var processText = function (value, raw) { |
|
- | 18651 | return text(restoreDataUris(value, base64Extract), raw); |
|
- | 18652 | }; |
|
- | 18653 | var processComment = function (value) { |
|
- | 18654 | if (value === '') { |
|
- | 18655 | return; |
|
- | 18656 | } |
|
- | 18657 | if (value.charAt(0) === '>') { |
|
- | 18658 | value = ' ' + value; |
|
- | 18659 | } |
|
- | 18660 | if (!settings.allow_conditional_comments && value.substr(0, 3).toLowerCase() === '[if') { |
|
- | 18661 | value = ' ' + value; |
|
- | 18662 | } |
|
- | 18663 | comment(restoreDataUris(value, base64Extract)); |
|
- | 18664 | }; |
|
- | 18665 | var processAttr = function (value) { |
|
- | 18666 | return restoreDataUris(value, base64Extract); |
|
- | 18667 | }; |
|
- | 18668 | var processMalformedComment = function (value, startIndex) { |
|
- | 18669 | var startTag = value || ''; |
|
- | 18670 | var isBogus = !startsWith(startTag, '--'); |
|
- | 18671 | var endIndex = findCommentEndIndex(html, isBogus, startIndex); |
|
- | 18672 | value = html.substr(startIndex, endIndex - startIndex); |
|
- | 18673 | processComment(isBogus ? startTag + value : value); |
|
- | 18674 | return endIndex + 1; |
|
- | 18675 | }; |
|
- | 18676 | var parseAttribute = function (tagName, name, value, val2, val3) { |
|
- | 18677 | name = name.toLowerCase(); |
|
- | 18678 | value = processAttr(name in fillAttrsMap ? name : decode(value || val2 || val3 || '')); |
|
- | 18679 | if (validate && !isInternalElement && isValidPrefixAttrName(name) === false) { |
|
- | 18680 | var attrRule = validAttributesMap[name]; |
|
- | 18681 | if (!attrRule && validAttributePatterns) { |
|
- | 18682 | var i_1 = validAttributePatterns.length; |
|
- | 18683 | while (i_1--) { |
|
- | 18684 | attrRule = validAttributePatterns[i_1]; |
|
- | 18685 | if (attrRule.pattern.test(name)) { |
|
- | 18686 | break; |
|
- | 18687 | } |
|
- | 18688 | } |
|
- | 18689 | if (i_1 === -1) { |
|
- | 18690 | attrRule = null; |
|
- | 18691 | } |
|
- | 18692 | } |
|
- | 18693 | if (!attrRule) { |
|
- | 18694 | return; |
|
- | 18695 | } |
|
- | 18696 | if (attrRule.validValues && !(value in attrRule.validValues)) { |
|
- | 18697 | return; |
|
- | 18698 | } |
|
- | 18699 | } |
|
- | 18700 | var isNameOrId = name === 'name' || name === 'id'; |
|
- | 18701 | if (isNameOrId && tagName in filteredClobberElements && (value in doc || value in form)) { |
|
- | 18702 | return; |
|
- | 18703 | } |
|
- | 18704 | if (filteredUrlAttrs[name] && !URI.isDomSafe(value, tagName, settings)) { |
|
- | 18705 | return; |
|
- | 18706 | } |
|
- | 18707 | if (isInternalElement && (name in filteredUrlAttrs || name.indexOf('on') === 0)) { |
|
- | 18708 | return; |
|
- | 18709 | } |
|
- | 18710 | attrList.map[name] = value; |
|
- | 18711 | attrList.push({ |
|
- | 18712 | name: name, |
|
- | 18713 | value: value |
|
- | 18714 | }); |
|
- | 18715 | }; |
|
- | 18716 | var tokenRegExp = new RegExp('<(?:' + '(?:!--([\\w\\W]*?)--!?>)|' + '(?:!\\[CDATA\\[([\\w\\W]*?)\\]\\]>)|' + '(?:![Dd][Oo][Cc][Tt][Yy][Pp][Ee]([\\w\\W]*?)>)|' + '(?:!(--)?)|' + '(?:\\?([^\\s\\/<>]+) ?([\\w\\W]*?)[?/]>)|' + '(?:\\/([A-Za-z][A-Za-z0-9\\-_\\:\\.]*)>)|' + '(?:([A-Za-z][A-Za-z0-9\\-_:.]*)(\\s(?:[^\'">]+(?:"[^"]*"|\'[^\']*\'))*[^"\'>]*(?:"[^">]*|\'[^\'>]*)?|\\s*|\\/)>)' + ')', 'g'); |
|
- | 18717 | var attrRegExp = /([\w:\-]+)(?:\s*=\s*(?:(?:\"((?:[^\"])*)\")|(?:\'((?:[^\'])*)\')|([^>\s]+)))?/g; |
|
- | 18718 | var shortEndedElements = schema.getShortEndedElements(); |
|
- | 18719 | var selfClosing = settings.self_closing_elements || schema.getSelfClosingElements(); |
|
- | 18720 | var fillAttrsMap = schema.getBoolAttrs(); |
|
- | 18721 | var validate = settings.validate; |
|
- | 18722 | var removeInternalElements = settings.remove_internals; |
|
- | 18723 | var fixSelfClosing = settings.fix_self_closing; |
|
- | 18724 | var specialElements = schema.getSpecialElements(); |
|
- | 18725 | var processHtml = html + '>'; |
|
- | 18726 | while (matches = tokenRegExp.exec(processHtml)) { |
|
- | 18727 | var matchText = matches[0]; |
|
- | 18728 | if (index < matches.index) { |
|
- | 18729 | processText(decode(html.substr(index, matches.index - index))); |
|
- | 18730 | } |
|
- | 18731 | if (value = matches[7]) { |
|
- | 18732 | value = value.toLowerCase(); |
|
- | 18733 | if (value.charAt(0) === ':') { |
|
- | 18734 | value = value.substr(1); |
|
- | 18735 | } |
|
- | 18736 | processEndTag(value); |
|
- | 18737 | } else if (value = matches[8]) { |
|
- | 18738 | if (matches.index + matchText.length > html.length) { |
|
- | 18739 | processText(decode(html.substr(matches.index))); |
|
- | 18740 | index = matches.index + matchText.length; |
|
- | 18741 | continue; |
|
- | 18742 | } |
|
- | 18743 | value = value.toLowerCase(); |
|
- | 18744 | if (value.charAt(0) === ':') { |
|
- | 18745 | value = value.substr(1); |
|
- | 18746 | } |
|
- | 18747 | isShortEnded = value in shortEndedElements; |
|
- | 18748 | if (fixSelfClosing && selfClosing[value] && stack.length > 0 && stack[stack.length - 1].name === value) { |
|
- | 18749 | processEndTag(value); |
|
- | 18750 | } |
|
- | 18751 | var bogusValue = checkBogusAttribute(attrRegExp, matches[9]); |
|
- | 18752 | if (bogusValue !== null) { |
|
- | 18753 | if (bogusValue === 'all') { |
|
- | 18754 | index = findMatchingEndTagIndex(schema, html, tokenRegExp.lastIndex); |
|
- | 18755 | tokenRegExp.lastIndex = index; |
|
- | 18756 | continue; |
|
- | 18757 | } |
|
- | 18758 | isValidElement = false; |
|
- | 18759 | } |
|
- | 18760 | if (!validate || (elementRule = schema.getElementRule(value))) { |
|
- | 18761 | isValidElement = true; |
|
- | 18762 | if (validate) { |
|
- | 18763 | validAttributesMap = elementRule.attributes; |
|
- | 18764 | validAttributePatterns = elementRule.attributePatterns; |
|
- | 18765 | } |
|
- | 18766 | if (attribsValue = matches[9]) { |
|
- | 18767 | isInternalElement = attribsValue.indexOf('data-mce-type') !== -1; |
|
- | 18768 | if (isInternalElement && removeInternalElements) { |
|
- | 18769 | isValidElement = false; |
|
- | 18770 | } |
|
- | 18771 | attrList = []; |
|
- | 18772 | attrList.map = {}; |
|
- | 18773 | attribsValue.replace(attrRegExp, function (match, name, val, val2, val3) { |
|
- | 18774 | parseAttribute(value, name, val, val2, val3); |
|
- | 18775 | return ''; |
|
- | 18776 | }); |
|
- | 18777 | } else { |
|
- | 18778 | attrList = []; |
|
- | 18779 | attrList.map = {}; |
|
- | 18780 | } |
|
- | 18781 | if (validate && !isInternalElement) { |
|
- | 18782 | attributesRequired = elementRule.attributesRequired; |
|
- | 18783 | attributesDefault = elementRule.attributesDefault; |
|
- | 18784 | attributesForced = elementRule.attributesForced; |
|
- | 18785 | anyAttributesRequired = elementRule.removeEmptyAttrs; |
|
- | 18786 | if (anyAttributesRequired && !attrList.length) { |
|
- | 18787 | isValidElement = false; |
|
- | 18788 | } |
|
- | 18789 | if (attributesForced) { |
|
- | 18790 | i = attributesForced.length; |
|
- | 18791 | while (i--) { |
|
- | 18792 | attr = attributesForced[i]; |
|
- | 18793 | name = attr.name; |
|
- | 18794 | attrValue = attr.value; |
|
- | 18795 | if (attrValue === '{$uid}') { |
|
- | 18796 | attrValue = 'mce_' + idCount++; |
|
- | 18797 | } |
|
- | 18798 | attrList.map[name] = attrValue; |
|
- | 18799 | attrList.push({ |
|
- | 18800 | name: name, |
|
- | 18801 | value: attrValue |
|
- | 18802 | }); |
|
- | 18803 | } |
|
- | 18804 | } |
|
- | 18805 | if (attributesDefault) { |
|
- | 18806 | i = attributesDefault.length; |
|
- | 18807 | while (i--) { |
|
- | 18808 | attr = attributesDefault[i]; |
|
- | 18809 | name = attr.name; |
|
- | 18810 | if (!(name in attrList.map)) { |
|
- | 18811 | attrValue = attr.value; |
|
- | 18812 | if (attrValue === '{$uid}') { |
|
- | 18813 | attrValue = 'mce_' + idCount++; |
|
- | 18814 | } |
|
- | 18815 | attrList.map[name] = attrValue; |
|
- | 18816 | attrList.push({ |
|
- | 18817 | name: name, |
|
- | 18818 | value: attrValue |
|
- | 18819 | }); |
|
- | 18820 | } |
|
- | 18821 | } |
|
- | 18822 | } |
|
- | 18823 | if (attributesRequired) { |
|
- | 18824 | i = attributesRequired.length; |
|
- | 18825 | while (i--) { |
|
- | 18826 | if (attributesRequired[i] in attrList.map) { |
|
- | 18827 | break; |
|
- | 18828 | } |
|
- | 18829 | } |
|
- | 18830 | if (i === -1) { |
|
- | 18831 | isValidElement = false; |
|
- | 18832 | } |
|
- | 18833 | } |
|
- | 18834 | if (attr = attrList.map['data-mce-bogus']) { |
|
- | 18835 | if (attr === 'all') { |
|
- | 18836 | index = findMatchingEndTagIndex(schema, html, tokenRegExp.lastIndex); |
|
- | 18837 | tokenRegExp.lastIndex = index; |
|
- | 18838 | continue; |
|
- | 18839 | } |
|
- | 18840 | isValidElement = false; |
|
- | 18841 | } |
|
- | 18842 | } |
|
- | 18843 | if (isValidElement) { |
|
- | 18844 | start(value, attrList, isShortEnded); |
|
- | 18845 | } |
|
- | 18846 | } else { |
|
- | 18847 | isValidElement = false; |
|
- | 18848 | } |
|
- | 18849 | if (endRegExp = specialElements[value]) { |
|
- | 18850 | endRegExp.lastIndex = index = matches.index + matchText.length; |
|
- | 18851 | if (matches = endRegExp.exec(html)) { |
|
- | 18852 | if (isValidElement) { |
|
- | 18853 | textData = html.substr(index, matches.index - index); |
|
- | 18854 | } |
|
- | 18855 | index = matches.index + matches[0].length; |
|
- | 18856 | } else { |
|
- | 18857 | textData = html.substr(index); |
|
- | 18858 | index = html.length; |
|
- | 18859 | } |
|
- | 18860 | if (isValidElement) { |
|
- | 18861 | if (textData.length > 0) { |
|
- | 18862 | processText(textData, true); |
|
- | 18863 | } |
|
- | 18864 | end(value); |
|
- | 18865 | } |
|
- | 18866 | tokenRegExp.lastIndex = index; |
|
- | 18867 | continue; |
|
- | 18868 | } |
|
- | 18869 | if (!isShortEnded) { |
|
- | 18870 | if (!attribsValue || attribsValue.indexOf('/') !== attribsValue.length - 1) { |
|
- | 18871 | stack.push({ |
|
- | 18872 | name: value, |
|
- | 18873 | valid: isValidElement |
|
- | 18874 | }); |
|
- | 18875 | } else if (isValidElement) { |
|
- | 18876 | end(value); |
|
- | 18877 | } |
|
- | 18878 | } |
|
- | 18879 | } else if (value = matches[1]) { |
|
- | 18880 | processComment(value); |
|
- | 18881 | } else if (value = matches[2]) { |
|
- | 18882 | var isValidCdataSection = parsingMode === 1 || settings.preserve_cdata || stack.length > 0 && schema.isValidChild(stack[stack.length - 1].name, '#cdata'); |
|
- | 18883 | if (isValidCdataSection) { |
|
- | 18884 | cdata(value); |
|
- | 18885 | } else { |
|
- | 18886 | index = processMalformedComment('', matches.index + 2); |
|
- | 18887 | tokenRegExp.lastIndex = index; |
|
- | 18888 | continue; |
|
- | 18889 | } |
|
- | 18890 | } else if (value = matches[3]) { |
|
- | 18891 | doctype(value); |
|
- | 18892 | } else if ((value = matches[4]) || matchText === '<!') { |
|
- | 18893 | index = processMalformedComment(value, matches.index + matchText.length); |
|
- | 18894 | tokenRegExp.lastIndex = index; |
|
- | 18895 | continue; |
|
- | 18896 | } else if (value = matches[5]) { |
|
- | 18897 | if (parsingMode === 1) { |
|
- | 18898 | pi(value, matches[6]); |
|
- | 18899 | } else { |
|
- | 18900 | index = processMalformedComment('?', matches.index + 2); |
|
- | 18901 | tokenRegExp.lastIndex = index; |
|
- | 18902 | continue; |
|
- | 18903 | } |
|
- | 18904 | } |
|
- | 18905 | index = matches.index + matchText.length; |
|
- | 18906 | } |
|
- | 18907 | if (index < html.length) { |
|
- | 18908 | processText(decode(html.substr(index))); |
|
- | 18909 | } |
|
- | 18910 | for (i = stack.length - 1; i >= 0; i--) { |
|
- | 18911 | value = stack[i]; |
|
- | 18912 | if (value.valid) { |
|
- | 18913 | end(value.name); |
|
- | 18914 | } |
|
- | 18915 | } |
|
- | 18916 | }; |
|
- | 18917 | var parse = function (html, format) { |
|
- | 18918 | if (format === void 0) { |
|
- | 18919 | format = 'html'; |
|
- | 18920 | } |
|
- | 18921 | parseInternal(extractBase64DataUris(html), format); |
|
- | 18922 | }; |
|
- | 18923 | return { parse: parse }; |
|
- | 18924 | }; |
|
- | 18925 | SaxParser.findEndTag = findMatchingEndTagIndex; |
|
- | 18926 | ||
18897 | var makeMap = Tools.makeMap, each$6 = Tools.each, explode$2 = Tools.explode, extend$4 = Tools.extend; |
18927 | var makeMap = Tools.makeMap, each$6 = Tools.each, explode$2 = Tools.explode, extend$4 = Tools.extend; |
18898 | var DomParser = function (settings, schema) { |
18928 | var DomParser = function (settings, schema) { |
18899 | if (schema === void 0) { |
18929 | if (schema === void 0) { |
18900 | schema = Schema(); |
18930 | schema = Schema(); |
18901 | } |
18931 | } |
Line 19597... | Line 19627... | ||
19597 | } else { |
19627 | } else { |
19598 | return content; |
19628 | return content; |
19599 | } |
19629 | } |
19600 | }; |
19630 | }; |
19601 | var getHtmlFromNode = function (dom, node, args) { |
19631 | var getHtmlFromNode = function (dom, node, args) { |
19602 | var html = trim$2(args.getInner ? node.innerHTML : dom.getOuterHTML(node)); |
19632 | var html = trim$3(args.getInner ? node.innerHTML : dom.getOuterHTML(node)); |
19603 | return args.selection || isWsPreserveElement(SugarElement.fromDom(node)) ? html : Tools.trim(html); |
19633 | return args.selection || isWsPreserveElement(SugarElement.fromDom(node)) ? html : Tools.trim(html); |
19604 | }; |
19634 | }; |
19605 | var parseHtml = function (htmlParser, html, args) { |
19635 | var parseHtml = function (htmlParser, html, args) { |
19606 | var parserArgs = args.selection ? __assign({ forced_root_block: false }, args) : args; |
19636 | var parserArgs = args.selection ? __assign({ forced_root_block: false }, args) : args; |
19607 | var rootNode = htmlParser.parse(html, parserArgs); |
19637 | var rootNode = htmlParser.parse(html, parserArgs); |
Line 19839... | Line 19869... | ||
19839 | object_resizing: false, |
19869 | object_resizing: false, |
19840 | resize: false |
19870 | resize: false |
19841 | }; |
19871 | }; |
19842 | var normalizePlugins = function (plugins) { |
19872 | var normalizePlugins = function (plugins) { |
19843 | var pluginNames = isArray$1(plugins) ? plugins.join(' ') : plugins; |
19873 | var pluginNames = isArray$1(plugins) ? plugins.join(' ') : plugins; |
19844 | var trimmedPlugins = map$3(isString$1(pluginNames) ? pluginNames.split(' ') : [], trim$4); |
19874 | var trimmedPlugins = map$3(isString$1(pluginNames) ? pluginNames.split(' ') : [], trim$5); |
19845 | return filter$4(trimmedPlugins, function (item) { |
19875 | return filter$4(trimmedPlugins, function (item) { |
19846 | return item.length > 0; |
19876 | return item.length > 0; |
19847 | }); |
19877 | }); |
19848 | }; |
19878 | }; |
19849 | var filterLegacyMobilePlugins = function (plugins) { |
19879 | var filterLegacyMobilePlugins = function (plugins) { |
Line 24414... | Line 24444... | ||
24414 | }; |
24444 | }; |
24415 | 24445 | ||
24416 | var trimZwsp = function (fragment) { |
24446 | var trimZwsp = function (fragment) { |
24417 | each$k(descendants$1(SugarElement.fromDom(fragment), isText$8), function (text) { |
24447 | each$k(descendants$1(SugarElement.fromDom(fragment), isText$8), function (text) { |
24418 | var rawNode = text.dom; |
24448 | var rawNode = text.dom; |
24419 | rawNode.nodeValue = trim$2(rawNode.nodeValue); |
24449 | rawNode.nodeValue = trim$3(rawNode.nodeValue); |
24420 | }); |
24450 | }); |
24421 | }; |
24451 | }; |
24422 | var isEmptyAnchor = function (dom, elm) { |
24452 | var isEmptyAnchor = function (dom, elm) { |
24423 | return elm && elm.nodeName === 'A' && dom.isEmpty(elm); |
24453 | return elm && elm.nodeName === 'A' && dom.isEmpty(elm); |
24424 | }; |
24454 | }; |
Line 29026... | Line 29056... | ||
29026 | defaultSettings: {}, |
29056 | defaultSettings: {}, |
29027 | documentBaseURL: null, |
29057 | documentBaseURL: null, |
29028 | suffix: null, |
29058 | suffix: null, |
29029 | $: DomQuery, |
29059 | $: DomQuery, |
29030 | majorVersion: '5', |
29060 | majorVersion: '5', |
29031 | minorVersion: '10.7', |
29061 | minorVersion: '10.8', |
29032 | releaseDate: '2022-12-06', |
29062 | releaseDate: '2023-10-19', |
29033 | editors: legacyEditors, |
29063 | editors: legacyEditors, |
29034 | i18n: I18n, |
29064 | i18n: I18n, |
29035 | activeEditor: null, |
29065 | activeEditor: null, |
29036 | focusedEditor: null, |
29066 | focusedEditor: null, |
29037 | settings: {}, |
29067 | settings: {}, |