mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-04 18:29:39 +02:00
Improving the get restream credentials
This commit is contained in:
parent
654dda115a
commit
56cb1fd5cb
6058 changed files with 1166166 additions and 1430809 deletions
12
node_modules/tinymce/plugins/autolink/index.js
generated
vendored
12
node_modules/tinymce/plugins/autolink/index.js
generated
vendored
|
@ -1,7 +1,7 @@
|
|||
// Exports the "autolink" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/autolink')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/autolink'
|
||||
// Exports the "autolink" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/autolink')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/autolink'
|
||||
require('./plugin.js');
|
411
node_modules/tinymce/plugins/autolink/plugin.js
generated
vendored
411
node_modules/tinymce/plugins/autolink/plugin.js
generated
vendored
|
@ -1,207 +1,204 @@
|
|||
/**
|
||||
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
||||
* Licensed under the LGPL or a commercial license.
|
||||
* For LGPL see License.txt in the project root for license information.
|
||||
* For commercial licenses see https://www.tiny.cloud/
|
||||
*
|
||||
* Version: 5.10.0 (2021-10-11)
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
var checkRange = function (str, substr, start) {
|
||||
return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
|
||||
};
|
||||
var contains = function (str, substr) {
|
||||
return str.indexOf(substr) !== -1;
|
||||
};
|
||||
var startsWith = function (str, prefix) {
|
||||
return checkRange(str, prefix, 0);
|
||||
};
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.Env');
|
||||
|
||||
var link = function () {
|
||||
return /(?:[A-Za-z][A-Za-z\d.+-]{0,14}:\/\/(?:[-.~*+=!&;:'%@?^${}(),\w]+@)?|www\.|[-;:&=+$,.\w]+@)[A-Za-z\d-]+(?:\.[A-Za-z\d-]+)*(?::\d+)?(?:\/(?:[-+~=.,%()\/\w]*[-+~=%()\/\w])?)?(?:\?(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?(?:#(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?/g;
|
||||
};
|
||||
|
||||
var defaultLinkPattern = new RegExp('^' + link().source + '$', 'i');
|
||||
var getAutoLinkPattern = function (editor) {
|
||||
return editor.getParam('autolink_pattern', defaultLinkPattern);
|
||||
};
|
||||
var getDefaultLinkTarget = function (editor) {
|
||||
return editor.getParam('default_link_target', false);
|
||||
};
|
||||
var getDefaultLinkProtocol = function (editor) {
|
||||
return editor.getParam('link_default_protocol', 'http', 'string');
|
||||
};
|
||||
|
||||
var rangeEqualsDelimiterOrSpace = function (rangeString, delimiter) {
|
||||
return rangeString === delimiter || rangeString === ' ' || rangeString.charCodeAt(0) === 160;
|
||||
};
|
||||
var handleEclipse = function (editor) {
|
||||
parseCurrentLine(editor, -1, '(');
|
||||
};
|
||||
var handleSpacebar = function (editor) {
|
||||
parseCurrentLine(editor, 0, '');
|
||||
};
|
||||
var handleEnter = function (editor) {
|
||||
parseCurrentLine(editor, -1, '');
|
||||
};
|
||||
var scopeIndex = function (container, index) {
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
if (container.nodeType === 3) {
|
||||
var len = container.data.length;
|
||||
if (index > len) {
|
||||
index = len;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
};
|
||||
var setStart = function (rng, container, offset) {
|
||||
if (container.nodeType !== 1 || container.hasChildNodes()) {
|
||||
rng.setStart(container, scopeIndex(container, offset));
|
||||
} else {
|
||||
rng.setStartBefore(container);
|
||||
}
|
||||
};
|
||||
var setEnd = function (rng, container, offset) {
|
||||
if (container.nodeType !== 1 || container.hasChildNodes()) {
|
||||
rng.setEnd(container, scopeIndex(container, offset));
|
||||
} else {
|
||||
rng.setEndAfter(container);
|
||||
}
|
||||
};
|
||||
var hasProtocol = function (url) {
|
||||
return /^([A-Za-z][A-Za-z\d.+-]*:\/\/)|mailto:/.test(url);
|
||||
};
|
||||
var isPunctuation = function (char) {
|
||||
return /[?!,.;:]/.test(char);
|
||||
};
|
||||
var parseCurrentLine = function (editor, endOffset, delimiter) {
|
||||
var end, endContainer, bookmark, text, prev, len, rngText;
|
||||
var autoLinkPattern = getAutoLinkPattern(editor);
|
||||
var defaultLinkTarget = getDefaultLinkTarget(editor);
|
||||
if (editor.selection.getNode().tagName === 'A') {
|
||||
return;
|
||||
}
|
||||
var rng = editor.selection.getRng().cloneRange();
|
||||
if (rng.startOffset < 5) {
|
||||
prev = rng.endContainer.previousSibling;
|
||||
if (!prev) {
|
||||
if (!rng.endContainer.firstChild || !rng.endContainer.firstChild.nextSibling) {
|
||||
return;
|
||||
}
|
||||
prev = rng.endContainer.firstChild.nextSibling;
|
||||
}
|
||||
len = prev.length;
|
||||
setStart(rng, prev, len);
|
||||
setEnd(rng, prev, len);
|
||||
if (rng.endOffset < 5) {
|
||||
return;
|
||||
}
|
||||
end = rng.endOffset;
|
||||
endContainer = prev;
|
||||
} else {
|
||||
endContainer = rng.endContainer;
|
||||
if (endContainer.nodeType !== 3 && endContainer.firstChild) {
|
||||
while (endContainer.nodeType !== 3 && endContainer.firstChild) {
|
||||
endContainer = endContainer.firstChild;
|
||||
}
|
||||
if (endContainer.nodeType === 3) {
|
||||
setStart(rng, endContainer, 0);
|
||||
setEnd(rng, endContainer, endContainer.nodeValue.length);
|
||||
}
|
||||
}
|
||||
if (rng.endOffset === 1) {
|
||||
end = 2;
|
||||
} else {
|
||||
end = rng.endOffset - 1 - endOffset;
|
||||
}
|
||||
}
|
||||
var start = end;
|
||||
do {
|
||||
setStart(rng, endContainer, end >= 2 ? end - 2 : 0);
|
||||
setEnd(rng, endContainer, end >= 1 ? end - 1 : 0);
|
||||
end -= 1;
|
||||
rngText = rng.toString();
|
||||
} while (rngText !== ' ' && rngText !== '' && rngText.charCodeAt(0) !== 160 && end - 2 >= 0 && rngText !== delimiter);
|
||||
if (rangeEqualsDelimiterOrSpace(rng.toString(), delimiter)) {
|
||||
setStart(rng, endContainer, end);
|
||||
setEnd(rng, endContainer, start);
|
||||
end += 1;
|
||||
} else if (rng.startOffset === 0) {
|
||||
setStart(rng, endContainer, 0);
|
||||
setEnd(rng, endContainer, start);
|
||||
} else {
|
||||
setStart(rng, endContainer, end);
|
||||
setEnd(rng, endContainer, start);
|
||||
}
|
||||
text = rng.toString();
|
||||
if (isPunctuation(text.charAt(text.length - 1))) {
|
||||
setEnd(rng, endContainer, start - 1);
|
||||
}
|
||||
text = rng.toString().trim();
|
||||
var matches = text.match(autoLinkPattern);
|
||||
var protocol = getDefaultLinkProtocol(editor);
|
||||
if (matches) {
|
||||
var url = matches[0];
|
||||
if (startsWith(url, 'www.')) {
|
||||
url = protocol + '://' + url;
|
||||
} else if (contains(url, '@') && !hasProtocol(url)) {
|
||||
url = 'mailto:' + url;
|
||||
}
|
||||
bookmark = editor.selection.getBookmark();
|
||||
editor.selection.setRng(rng);
|
||||
editor.execCommand('createlink', false, url);
|
||||
if (defaultLinkTarget !== false) {
|
||||
editor.dom.setAttrib(editor.selection.getNode(), 'target', defaultLinkTarget);
|
||||
}
|
||||
editor.selection.moveToBookmark(bookmark);
|
||||
editor.nodeChanged();
|
||||
}
|
||||
};
|
||||
var setup = function (editor) {
|
||||
var autoUrlDetectState;
|
||||
editor.on('keydown', function (e) {
|
||||
if (e.keyCode === 13) {
|
||||
return handleEnter(editor);
|
||||
}
|
||||
});
|
||||
if (global.browser.isIE()) {
|
||||
editor.on('focus', function () {
|
||||
if (!autoUrlDetectState) {
|
||||
autoUrlDetectState = true;
|
||||
try {
|
||||
editor.execCommand('AutoUrlDetect', false, true);
|
||||
} catch (ex) {
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
editor.on('keypress', function (e) {
|
||||
if (e.keyCode === 41) {
|
||||
return handleEclipse(editor);
|
||||
}
|
||||
});
|
||||
editor.on('keyup', function (e) {
|
||||
if (e.keyCode === 32) {
|
||||
return handleSpacebar(editor);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function Plugin () {
|
||||
global$1.add('autolink', function (editor) {
|
||||
setup(editor);
|
||||
});
|
||||
}
|
||||
|
||||
Plugin();
|
||||
|
||||
}());
|
||||
/**
|
||||
* TinyMCE version 6.0.2 (2022-04-27)
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
const link = () => /(?:[A-Za-z][A-Za-z\d.+-]{0,14}:\/\/(?:[-.~*+=!&;:'%@?^${}(),\w]+@)?|www\.|[-;:&=+$,.\w]+@)[A-Za-z\d-]+(?:\.[A-Za-z\d-]+)*(?::\d+)?(?:\/(?:[-+~=.,%()\/\w]*[-+~=%()\/\w])?)?(?:\?(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?(?:#(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?/g;
|
||||
|
||||
const option = name => editor => editor.options.get(name);
|
||||
const register = editor => {
|
||||
const registerOption = editor.options.register;
|
||||
registerOption('autolink_pattern', {
|
||||
processor: 'regexp',
|
||||
default: new RegExp('^' + link().source + '$', 'i')
|
||||
});
|
||||
registerOption('link_default_target', { processor: 'string' });
|
||||
registerOption('link_default_protocol', {
|
||||
processor: 'string',
|
||||
default: 'https'
|
||||
});
|
||||
};
|
||||
const getAutoLinkPattern = option('autolink_pattern');
|
||||
const getDefaultLinkTarget = option('link_default_target');
|
||||
const getDefaultLinkProtocol = option('link_default_protocol');
|
||||
|
||||
const hasProto = (v, constructor, predicate) => {
|
||||
var _a;
|
||||
if (predicate(v, constructor.prototype)) {
|
||||
return true;
|
||||
} else {
|
||||
return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
|
||||
}
|
||||
};
|
||||
const typeOf = x => {
|
||||
const t = typeof x;
|
||||
if (x === null) {
|
||||
return 'null';
|
||||
} else if (t === 'object' && Array.isArray(x)) {
|
||||
return 'array';
|
||||
} else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
|
||||
return 'string';
|
||||
} else {
|
||||
return t;
|
||||
}
|
||||
};
|
||||
const isType = type => value => typeOf(value) === type;
|
||||
const isString = isType('string');
|
||||
|
||||
const checkRange = (str, substr, start) => substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
|
||||
const contains = (str, substr) => {
|
||||
return str.indexOf(substr) !== -1;
|
||||
};
|
||||
const startsWith = (str, prefix) => {
|
||||
return checkRange(str, prefix, 0);
|
||||
};
|
||||
|
||||
const rangeEqualsBracketOrSpace = rangeString => /^[(\[{ \u00a0]$/.test(rangeString);
|
||||
const isTextNode = node => node.nodeType === 3;
|
||||
const isElement = node => node.nodeType === 1;
|
||||
const handleBracket = editor => parseCurrentLine(editor, -1);
|
||||
const handleSpacebar = editor => parseCurrentLine(editor, 0);
|
||||
const handleEnter = editor => parseCurrentLine(editor, -1);
|
||||
const scopeIndex = (container, index) => {
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
if (isTextNode(container)) {
|
||||
const len = container.data.length;
|
||||
if (index > len) {
|
||||
index = len;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
};
|
||||
const setStart = (rng, container, offset) => {
|
||||
if (!isElement(container) || container.hasChildNodes()) {
|
||||
rng.setStart(container, scopeIndex(container, offset));
|
||||
} else {
|
||||
rng.setStartBefore(container);
|
||||
}
|
||||
};
|
||||
const setEnd = (rng, container, offset) => {
|
||||
if (!isElement(container) || container.hasChildNodes()) {
|
||||
rng.setEnd(container, scopeIndex(container, offset));
|
||||
} else {
|
||||
rng.setEndAfter(container);
|
||||
}
|
||||
};
|
||||
const hasProtocol = url => /^([A-Za-z][A-Za-z\d.+-]*:\/\/)|mailto:/.test(url);
|
||||
const isPunctuation = char => /[?!,.;:]/.test(char);
|
||||
const parseCurrentLine = (editor, endOffset) => {
|
||||
let end, endContainer, bookmark, text, prev, len, rngText;
|
||||
const autoLinkPattern = getAutoLinkPattern(editor);
|
||||
const defaultLinkTarget = getDefaultLinkTarget(editor);
|
||||
if (editor.dom.getParent(editor.selection.getNode(), 'a[href]') !== null) {
|
||||
return;
|
||||
}
|
||||
const rng = editor.selection.getRng().cloneRange();
|
||||
if (rng.startOffset < 5) {
|
||||
prev = rng.endContainer.previousSibling;
|
||||
if (!prev) {
|
||||
if (!rng.endContainer.firstChild || !rng.endContainer.firstChild.nextSibling) {
|
||||
return;
|
||||
}
|
||||
prev = rng.endContainer.firstChild.nextSibling;
|
||||
}
|
||||
len = prev.length;
|
||||
setStart(rng, prev, len);
|
||||
setEnd(rng, prev, len);
|
||||
if (rng.endOffset < 5) {
|
||||
return;
|
||||
}
|
||||
end = rng.endOffset;
|
||||
endContainer = prev;
|
||||
} else {
|
||||
endContainer = rng.endContainer;
|
||||
if (!isTextNode(endContainer) && endContainer.firstChild) {
|
||||
while (!isTextNode(endContainer) && endContainer.firstChild) {
|
||||
endContainer = endContainer.firstChild;
|
||||
}
|
||||
if (isTextNode(endContainer)) {
|
||||
setStart(rng, endContainer, 0);
|
||||
setEnd(rng, endContainer, endContainer.nodeValue.length);
|
||||
}
|
||||
}
|
||||
if (rng.endOffset === 1) {
|
||||
end = 2;
|
||||
} else {
|
||||
end = rng.endOffset - 1 - endOffset;
|
||||
}
|
||||
}
|
||||
const start = end;
|
||||
do {
|
||||
setStart(rng, endContainer, end >= 2 ? end - 2 : 0);
|
||||
setEnd(rng, endContainer, end >= 1 ? end - 1 : 0);
|
||||
end -= 1;
|
||||
rngText = rng.toString();
|
||||
} while (!rangeEqualsBracketOrSpace(rngText) && end - 2 >= 0);
|
||||
if (rangeEqualsBracketOrSpace(rng.toString())) {
|
||||
setStart(rng, endContainer, end);
|
||||
setEnd(rng, endContainer, start);
|
||||
end += 1;
|
||||
} else if (rng.startOffset === 0) {
|
||||
setStart(rng, endContainer, 0);
|
||||
setEnd(rng, endContainer, start);
|
||||
} else {
|
||||
setStart(rng, endContainer, end);
|
||||
setEnd(rng, endContainer, start);
|
||||
}
|
||||
text = rng.toString();
|
||||
if (isPunctuation(text.charAt(text.length - 1))) {
|
||||
setEnd(rng, endContainer, start - 1);
|
||||
}
|
||||
text = rng.toString().trim();
|
||||
const matches = text.match(autoLinkPattern);
|
||||
const protocol = getDefaultLinkProtocol(editor);
|
||||
if (matches) {
|
||||
let url = matches[0];
|
||||
if (startsWith(url, 'www.')) {
|
||||
url = protocol + '://' + url;
|
||||
} else if (contains(url, '@') && !hasProtocol(url)) {
|
||||
url = 'mailto:' + url;
|
||||
}
|
||||
bookmark = editor.selection.getBookmark();
|
||||
editor.selection.setRng(rng);
|
||||
editor.getDoc().execCommand('createlink', false, url);
|
||||
if (isString(defaultLinkTarget)) {
|
||||
editor.dom.setAttrib(editor.selection.getNode(), 'target', defaultLinkTarget);
|
||||
}
|
||||
editor.selection.moveToBookmark(bookmark);
|
||||
editor.nodeChanged();
|
||||
}
|
||||
};
|
||||
const setup = editor => {
|
||||
editor.on('keydown', e => {
|
||||
if (e.keyCode === 13) {
|
||||
return handleEnter(editor);
|
||||
}
|
||||
});
|
||||
editor.on('keypress', e => {
|
||||
if (e.keyCode === 41 || e.keyCode === 93 || e.keyCode === 125) {
|
||||
return handleBracket(editor);
|
||||
}
|
||||
});
|
||||
editor.on('keyup', e => {
|
||||
if (e.keyCode === 32) {
|
||||
return handleSpacebar(editor);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var Plugin = () => {
|
||||
global.add('autolink', editor => {
|
||||
register(editor);
|
||||
setup(editor);
|
||||
});
|
||||
};
|
||||
|
||||
Plugin();
|
||||
|
||||
})();
|
||||
|
|
13
node_modules/tinymce/plugins/autolink/plugin.min.js
generated
vendored
13
node_modules/tinymce/plugins/autolink/plugin.min.js
generated
vendored
|
@ -1,9 +1,4 @@
|
|||
/**
|
||||
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
||||
* Licensed under the LGPL or a commercial license.
|
||||
* For LGPL see License.txt in the project root for license information.
|
||||
* For commercial licenses see https://www.tiny.cloud/
|
||||
*
|
||||
* Version: 5.10.0 (2021-10-11)
|
||||
*/
|
||||
!function(){"use strict";function o(e,t){var n;return t<0&&(t=0),3!==e.nodeType||(n=e.data.length)<t&&(t=n),t}function p(e,t,n){1!==t.nodeType||t.hasChildNodes()?e.setStart(t,o(t,n)):e.setStartBefore(t)}function A(e,t,n){1!==t.nodeType||t.hasChildNodes()?e.setEnd(t,o(t,n)):e.setEndAfter(t)}function i(e,t,n){var o,i,r,a,d,s,l=e.getParam("autolink_pattern",v),f=e.getParam("default_link_target",!1);if("A"!==e.selection.getNode().tagName){var c=e.selection.getRng().cloneRange();if(c.startOffset<5){if(!(a=c.endContainer.previousSibling)){if(!c.endContainer.firstChild||!c.endContainer.firstChild.nextSibling)return;a=c.endContainer.firstChild.nextSibling}if(p(c,a,d=a.length),A(c,a,d),c.endOffset<5)return;o=c.endOffset,i=a}else{if(3!==(i=c.endContainer).nodeType&&i.firstChild){for(;3!==i.nodeType&&i.firstChild;)i=i.firstChild;3===i.nodeType&&(p(c,i,0),A(c,i,i.nodeValue.length))}o=1===c.endOffset?2:c.endOffset-1-t}for(var g,u=o;p(c,i,2<=o?o-2:0),A(c,i,1<=o?o-1:0),--o," "!==(s=c.toString())&&""!==s&&160!==s.charCodeAt(0)&&0<=o-2&&s!==n;);(g=c.toString())===n||" "===g||160===g.charCodeAt(0)?(p(c,i,o),A(c,i,u),o+=1):(0===c.startOffset?p(c,i,0):p(c,i,o),A(c,i,u)),h=c.toString(),/[?!,.;:]/.test(h.charAt(h.length-1))&&A(c,i,u-1);var h,C,m,y,k=(h=c.toString().trim()).match(l),w=e.getParam("link_default_protocol","http","string");k&&((m=C=k[0]).length>=(y="www.").length&&m.substr(0,0+y.length)===y?C=w+"://"+C:-1===C.indexOf("@")||/^([A-Za-z][A-Za-z\d.+-]*:\/\/)|mailto:/.test(C)||(C="mailto:"+C),r=e.selection.getBookmark(),e.selection.setRng(c),e.execCommand("createlink",!1,C),!1!==f&&e.dom.setAttrib(e.selection.getNode(),"target",f),e.selection.moveToBookmark(r),e.nodeChanged())}}var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),r=tinymce.util.Tools.resolve("tinymce.Env"),v=new RegExp("^"+/(?:[A-Za-z][A-Za-z\d.+-]{0,14}:\/\/(?:[-.~*+=!&;:'%@?^${}(),\w]+@)?|www\.|[-;:&=+$,.\w]+@)[A-Za-z\d-]+(?:\.[A-Za-z\d-]+)*(?::\d+)?(?:\/(?:[-+~=.,%()\/\w]*[-+~=%()\/\w])?)?(?:\?(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?(?:#(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?/g.source+"$","i");e.add("autolink",function(e){var t,n;(t=e).on("keydown",function(e){13===e.keyCode&&i(t,-1,"")}),r.browser.isIE()?t.on("focus",function(){if(!n){n=!0;try{t.execCommand("AutoUrlDetect",!1,!0)}catch(e){}}}):(t.on("keypress",function(e){41===e.keyCode&&i(t,-1,"(")}),t.on("keyup",function(e){32===e.keyCode&&i(t,0,"")}))})}();
|
||||
/**
|
||||
* TinyMCE version 6.0.2 (2022-04-27)
|
||||
*/
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager");const e=t=>e=>e.options.get(t),n=e("autolink_pattern"),o=e("link_default_target"),r=e("link_default_protocol"),i=("string",t=>"string"===(t=>{const e=typeof t;return null===t?"null":"object"===e&&Array.isArray(t)?"array":"object"===e&&(n=o=t,(r=String).prototype.isPrototypeOf(n)||(null===(i=o.constructor)||void 0===i?void 0:i.name)===r.name)?"string":e;var n,o,r,i})(t));const s=t=>/^[(\[{ \u00a0]$/.test(t),a=t=>3===t.nodeType,l=t=>1===t.nodeType,d=(t,e)=>{if(e<0&&(e=0),a(t)){const n=t.data.length;e>n&&(e=n)}return e},f=(t,e,n)=>{!l(e)||e.hasChildNodes()?t.setStart(e,d(e,n)):t.setStartBefore(e)},g=(t,e,n)=>{!l(e)||e.hasChildNodes()?t.setEnd(e,d(e,n)):t.setEndAfter(e)},c=(t,e)=>{let l,d,c,u,h,p,k;const C=n(t),y=o(t);if(null!==t.dom.getParent(t.selection.getNode(),"a[href]"))return;const m=t.selection.getRng().cloneRange();if(m.startOffset<5){if(h=m.endContainer.previousSibling,!h){if(!m.endContainer.firstChild||!m.endContainer.firstChild.nextSibling)return;h=m.endContainer.firstChild.nextSibling}if(p=h.length,f(m,h,p),g(m,h,p),m.endOffset<5)return;l=m.endOffset,d=h}else{if(d=m.endContainer,!a(d)&&d.firstChild){for(;!a(d)&&d.firstChild;)d=d.firstChild;a(d)&&(f(m,d,0),g(m,d,d.nodeValue.length))}l=1===m.endOffset?2:m.endOffset-1-e}const w=l;do{f(m,d,l>=2?l-2:0),g(m,d,l>=1?l-1:0),l-=1,k=m.toString()}while(!s(k)&&l-2>=0);var A;s(m.toString())?(f(m,d,l),g(m,d,w),l+=1):0===m.startOffset?(f(m,d,0),g(m,d,w)):(f(m,d,l),g(m,d,w)),u=m.toString(),A=u.charAt(u.length-1),/[?!,.;:]/.test(A)&&g(m,d,w-1),u=m.toString().trim();const S=u.match(C),_=r(t);if(S){let e=S[0];O="www.",(v=e).length>=O.length&&v.substr(0,0+O.length)===O?e=_+"://"+e:((t,e)=>-1!==t.indexOf("@"))(e)&&!(t=>/^([A-Za-z][A-Za-z\d.+-]*:\/\/)|mailto:/.test(t))(e)&&(e="mailto:"+e),c=t.selection.getBookmark(),t.selection.setRng(m),t.getDoc().execCommand("createlink",!1,e),i(y)&&t.dom.setAttrib(t.selection.getNode(),"target",y),t.selection.moveToBookmark(c),t.nodeChanged()}var v,O};t.add("autolink",(t=>{(t=>{const e=t.options.register;e("autolink_pattern",{processor:"regexp",default:new RegExp("^"+/(?:[A-Za-z][A-Za-z\d.+-]{0,14}:\/\/(?:[-.~*+=!&;:'%@?^${}(),\w]+@)?|www\.|[-;:&=+$,.\w]+@)[A-Za-z\d-]+(?:\.[A-Za-z\d-]+)*(?::\d+)?(?:\/(?:[-+~=.,%()\/\w]*[-+~=%()\/\w])?)?(?:\?(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?(?:#(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?/g.source+"$","i")}),e("link_default_target",{processor:"string"}),e("link_default_protocol",{processor:"string",default:"https"})})(t),(t=>{t.on("keydown",(e=>{if(13===e.keyCode)return(t=>c(t,-1))(t)})),t.on("keypress",(e=>{if(41===e.keyCode||93===e.keyCode||125===e.keyCode)return(t=>c(t,-1))(t)})),t.on("keyup",(e=>{if(32===e.keyCode)return(t=>c(t,0))(t)}))})(t)}))}();
|
Loading…
Add table
Add a link
Reference in a new issue