feat: 更新资源
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* TinyMCE version 6.0.3 (2022-05-25)
|
||||
* TinyMCE version 6.2.0 (2022-09-08)
|
||||
*/
|
||||
|
||||
(function () {
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
var global$5 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
var global$4 = tinymce.util.Tools.resolve('tinymce.util.VK');
|
||||
|
||||
const hasProto = (v, constructor, predicate) => {
|
||||
var _a;
|
||||
if (predicate(v, constructor.prototype)) {
|
||||
@@ -54,6 +52,11 @@
|
||||
|
||||
const noop = () => {
|
||||
};
|
||||
const constant = value => {
|
||||
return () => {
|
||||
return value;
|
||||
};
|
||||
};
|
||||
const tripleEquals = (a, b) => {
|
||||
return a === b;
|
||||
};
|
||||
@@ -289,7 +292,7 @@
|
||||
const allowUnsafeLinkTarget = option('allow_unsafe_link_target');
|
||||
const useQuickLink = option('link_quicklink');
|
||||
|
||||
var global$3 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
const getValue = item => isString(item.value) ? item.value : '';
|
||||
const getText = item => {
|
||||
@@ -303,7 +306,7 @@
|
||||
};
|
||||
const sanitizeList = (list, extractValue) => {
|
||||
const out = [];
|
||||
global$3.each(list, item => {
|
||||
global$4.each(list, item => {
|
||||
const text = getText(item);
|
||||
if (item.menu !== undefined) {
|
||||
const items = sanitizeList(item.menu, extractValue);
|
||||
@@ -350,11 +353,9 @@
|
||||
r[i] = x;
|
||||
};
|
||||
const internalFilter = (obj, pred, onTrue, onFalse) => {
|
||||
const r = {};
|
||||
each(obj, (x, i) => {
|
||||
(pred(x, i) ? onTrue : onFalse)(x, i);
|
||||
});
|
||||
return r;
|
||||
};
|
||||
const filter = (obj, pred) => {
|
||||
const t = {};
|
||||
@@ -364,20 +365,21 @@
|
||||
const has = (obj, key) => hasOwnProperty.call(obj, key);
|
||||
const hasNonNullableKey = (obj, key) => has(obj, key) && obj[key] !== undefined && obj[key] !== null;
|
||||
|
||||
var global$2 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
|
||||
var global$3 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
|
||||
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.URI');
|
||||
var global$2 = tinymce.util.Tools.resolve('tinymce.util.URI');
|
||||
|
||||
const isAnchor = elm => elm && elm.nodeName.toLowerCase() === 'a';
|
||||
const isAnchor = elm => isNonNullable(elm) && elm.nodeName.toLowerCase() === 'a';
|
||||
const isLink = elm => isAnchor(elm) && !!getHref(elm);
|
||||
const collectNodesInRange = (rng, predicate) => {
|
||||
if (rng.collapsed) {
|
||||
return [];
|
||||
} else {
|
||||
const contents = rng.cloneContents();
|
||||
const walker = new global$2(contents.firstChild, contents);
|
||||
const firstChild = contents.firstChild;
|
||||
const walker = new global$3(firstChild, contents);
|
||||
const elements = [];
|
||||
let current = contents.firstChild;
|
||||
let current = firstChild;
|
||||
do {
|
||||
if (predicate(current)) {
|
||||
elements.push(current);
|
||||
@@ -388,18 +390,18 @@
|
||||
};
|
||||
const hasProtocol = url => /^\w+:/i.test(url);
|
||||
const getHref = elm => {
|
||||
const href = elm.getAttribute('data-mce-href');
|
||||
return href ? href : elm.getAttribute('href');
|
||||
var _a, _b;
|
||||
return (_b = (_a = elm.getAttribute('data-mce-href')) !== null && _a !== void 0 ? _a : elm.getAttribute('href')) !== null && _b !== void 0 ? _b : '';
|
||||
};
|
||||
const applyRelTargetRules = (rel, isUnsafe) => {
|
||||
const rules = ['noopener'];
|
||||
const rels = rel ? rel.split(/\s+/) : [];
|
||||
const toString = rels => global$3.trim(rels.sort().join(' '));
|
||||
const toString = rels => global$4.trim(rels.sort().join(' '));
|
||||
const addTargetRules = rels => {
|
||||
rels = removeTargetRules(rels);
|
||||
return rels.length > 0 ? rels.concat(rules) : rules;
|
||||
};
|
||||
const removeTargetRules = rels => rels.filter(val => global$3.inArray(rules, val) === -1);
|
||||
const removeTargetRules = rels => rels.filter(val => global$4.inArray(rules, val) === -1);
|
||||
const newRels = isUnsafe ? addTargetRules(rels) : removeTargetRules(rels);
|
||||
return newRels.length > 0 ? toString(newRels) : '';
|
||||
};
|
||||
@@ -407,16 +409,17 @@
|
||||
const getAnchorElement = (editor, selectedElm) => {
|
||||
selectedElm = selectedElm || editor.selection.getNode();
|
||||
if (isImageFigure(selectedElm)) {
|
||||
return editor.dom.select('a[href]', selectedElm)[0];
|
||||
return Optional.from(editor.dom.select('a[href]', selectedElm)[0]);
|
||||
} else {
|
||||
return editor.dom.getParent(selectedElm, 'a[href]');
|
||||
return Optional.from(editor.dom.getParent(selectedElm, 'a[href]'));
|
||||
}
|
||||
};
|
||||
const isInAnchor = (editor, selectedElm) => getAnchorElement(editor, selectedElm).isSome();
|
||||
const getAnchorText = (selection, anchorElm) => {
|
||||
const text = anchorElm ? anchorElm.innerText || anchorElm.textContent : selection.getContent({ format: 'text' });
|
||||
const text = anchorElm.fold(() => selection.getContent({ format: 'text' }), anchorElm => anchorElm.innerText || anchorElm.textContent || '');
|
||||
return trimCaretContainers(text);
|
||||
};
|
||||
const hasLinks = elements => global$3.grep(elements, isLink).length > 0;
|
||||
const hasLinks = elements => global$4.grep(elements, isLink).length > 0;
|
||||
const hasLinksInSelection = rng => collectNodesInRange(rng, isLink).length > 0;
|
||||
const isOnlyTextSelected = editor => {
|
||||
const inlineTextElements = editor.schema.getTextInlineElements();
|
||||
@@ -424,7 +427,7 @@
|
||||
const elements = collectNodesInRange(editor.selection.getRng(), isElement);
|
||||
return elements.length === 0;
|
||||
};
|
||||
const isImageFigure = elm => elm && elm.nodeName === 'FIGURE' && /\bimage\b/i.test(elm.className);
|
||||
const isImageFigure = elm => isNonNullable(elm) && elm.nodeName === 'FIGURE' && /\bimage\b/i.test(elm.className);
|
||||
const getLinkAttrs = data => {
|
||||
const attrs = [
|
||||
'title',
|
||||
@@ -469,13 +472,14 @@
|
||||
editor.selection.select(anchorElm);
|
||||
};
|
||||
const createLink = (editor, selectedElm, text, linkAttrs) => {
|
||||
const dom = editor.dom;
|
||||
if (isImageFigure(selectedElm)) {
|
||||
linkImageFigure(editor, selectedElm, linkAttrs);
|
||||
linkImageFigure(dom, selectedElm, linkAttrs);
|
||||
} else {
|
||||
text.fold(() => {
|
||||
editor.execCommand('mceInsertLink', false, linkAttrs);
|
||||
}, text => {
|
||||
editor.insertContent(editor.dom.createHTML('a', linkAttrs, editor.dom.encode(text)));
|
||||
editor.insertContent(dom.createHTML('a', linkAttrs, dom.encode(text)));
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -487,12 +491,12 @@
|
||||
if (data.href === attachState.href) {
|
||||
attachState.attach();
|
||||
}
|
||||
if (anchorElm) {
|
||||
editor.focus();
|
||||
updateLink(editor, anchorElm, data.text, linkAttrs);
|
||||
} else {
|
||||
anchorElm.fold(() => {
|
||||
createLink(editor, selectedElm, data.text, linkAttrs);
|
||||
}
|
||||
}, elm => {
|
||||
editor.focus();
|
||||
updateLink(editor, elm, data.text, linkAttrs);
|
||||
});
|
||||
});
|
||||
};
|
||||
const unlinkSelection = editor => {
|
||||
@@ -550,7 +554,7 @@
|
||||
const href = data.href;
|
||||
return {
|
||||
...data,
|
||||
href: global$1.isDomSafe(href, 'a', uriOptions) ? href : ''
|
||||
href: global$2.isDomSafe(href, 'a', uriOptions) ? href : ''
|
||||
};
|
||||
};
|
||||
const link = (editor, attachState, data) => {
|
||||
@@ -561,20 +565,22 @@
|
||||
editor.hasPlugin('rtc', true) ? editor.execCommand('unlink') : unlinkDomMutation(editor);
|
||||
};
|
||||
const unlinkImageFigure = (editor, fig) => {
|
||||
var _a;
|
||||
const img = editor.dom.select('img', fig)[0];
|
||||
if (img) {
|
||||
const a = editor.dom.getParents(img, 'a[href]', fig)[0];
|
||||
if (a) {
|
||||
a.parentNode.insertBefore(img, a);
|
||||
(_a = a.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(img, a);
|
||||
editor.dom.remove(a);
|
||||
}
|
||||
}
|
||||
};
|
||||
const linkImageFigure = (editor, fig, attrs) => {
|
||||
const img = editor.dom.select('img', fig)[0];
|
||||
const linkImageFigure = (dom, fig, attrs) => {
|
||||
var _a;
|
||||
const img = dom.select('img', fig)[0];
|
||||
if (img) {
|
||||
const a = editor.dom.create('a', attrs);
|
||||
img.parentNode.insertBefore(a, img);
|
||||
const a = dom.create('a', attrs);
|
||||
(_a = img.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(a, img);
|
||||
a.appendChild(img);
|
||||
}
|
||||
};
|
||||
@@ -615,8 +621,14 @@
|
||||
text: initialData.text,
|
||||
title: initialData.title
|
||||
};
|
||||
const getTitleFromUrlChange = url => someIf(persistentData.title.length <= 0, Optional.from(url.meta.title).getOr(''));
|
||||
const getTextFromUrlChange = url => someIf(persistentData.text.length <= 0, Optional.from(url.meta.text).getOr(url.value));
|
||||
const getTitleFromUrlChange = url => {
|
||||
var _a;
|
||||
return someIf(persistentData.title.length <= 0, Optional.from((_a = url.meta) === null || _a === void 0 ? void 0 : _a.title).getOr(''));
|
||||
};
|
||||
const getTextFromUrlChange = url => {
|
||||
var _a;
|
||||
return someIf(persistentData.text.length <= 0, Optional.from((_a = url.meta) === null || _a === void 0 ? void 0 : _a.text).getOr(url.value));
|
||||
};
|
||||
const onUrlChange = data => {
|
||||
const text = getTextFromUrlChange(data.url);
|
||||
const title = getTitleFromUrlChange(data.url);
|
||||
@@ -630,8 +642,8 @@
|
||||
}
|
||||
};
|
||||
const onCatalogChange = (data, change) => {
|
||||
const catalog = findCatalog(linkCatalog, change.name).getOr([]);
|
||||
return getDelta(persistentData.text, change.name, catalog, data);
|
||||
const catalog = findCatalog(linkCatalog, change).getOr([]);
|
||||
return getDelta(persistentData.text, change, catalog, data);
|
||||
};
|
||||
const onChange = (getData, change) => {
|
||||
const name = change.name;
|
||||
@@ -641,7 +653,7 @@
|
||||
'anchor',
|
||||
'link'
|
||||
], name)) {
|
||||
return onCatalogChange(getData(), change);
|
||||
return onCatalogChange(getData(), name);
|
||||
} else if (name === 'text' || name === 'title') {
|
||||
persistentData[name] = getData()[name];
|
||||
return Optional.none();
|
||||
@@ -656,11 +668,11 @@
|
||||
getDelta
|
||||
};
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
||||
|
||||
const delayedConfirm = (editor, message, callback) => {
|
||||
const rng = editor.selection.getRng();
|
||||
global.setEditorTimeout(editor, () => {
|
||||
global$1.setEditorTimeout(editor, () => {
|
||||
editor.windowManager.confirm(message, state => {
|
||||
editor.selection.setRng(rng);
|
||||
callback(state);
|
||||
@@ -732,7 +744,7 @@
|
||||
}
|
||||
};
|
||||
const getLinks = editor => {
|
||||
const extractor = item => editor.convertURL(item.value || item.url, 'href');
|
||||
const extractor = item => editor.convertURL(item.value || item.url || '', 'href');
|
||||
const linkList = getLinkList(editor);
|
||||
return new Promise(resolve => {
|
||||
if (isString(linkList)) {
|
||||
@@ -798,11 +810,11 @@
|
||||
const dom = editor.dom;
|
||||
const onlyText = isOnlyTextSelected(editor);
|
||||
const text = onlyText ? Optional.some(getAnchorText(editor.selection, anchor)) : Optional.none();
|
||||
const url = anchor ? Optional.some(dom.getAttrib(anchor, 'href')) : Optional.none();
|
||||
const target = anchor ? Optional.from(dom.getAttrib(anchor, 'target')) : Optional.none();
|
||||
const rel = nonEmptyAttr(dom, anchor, 'rel');
|
||||
const linkClass = nonEmptyAttr(dom, anchor, 'class');
|
||||
const title = nonEmptyAttr(dom, anchor, 'title');
|
||||
const url = anchor.bind(anchorElm => Optional.from(dom.getAttrib(anchorElm, 'href')));
|
||||
const target = anchor.bind(anchorElm => Optional.from(dom.getAttrib(anchorElm, 'target')));
|
||||
const rel = anchor.bind(anchorElm => nonEmptyAttr(dom, anchorElm, 'rel'));
|
||||
const linkClass = anchor.bind(anchorElm => nonEmptyAttr(dom, anchorElm, 'class'));
|
||||
const title = anchor.bind(anchorElm => nonEmptyAttr(dom, anchorElm, 'title'));
|
||||
return {
|
||||
url,
|
||||
text,
|
||||
@@ -823,7 +835,7 @@
|
||||
anchor: AnchorListOptions.getAnchors(editor),
|
||||
link: links
|
||||
},
|
||||
optNode: Optional.from(linkNode),
|
||||
optNode: linkNode,
|
||||
flags: { titleEnabled: shouldShowLinkTitle(editor) }
|
||||
};
|
||||
});
|
||||
@@ -947,6 +959,18 @@
|
||||
});
|
||||
};
|
||||
|
||||
const register = editor => {
|
||||
editor.addCommand('mceLink', (_ui, value) => {
|
||||
if ((value === null || value === void 0 ? void 0 : value.dialog) === true || !useQuickLink(editor)) {
|
||||
open$1(editor);
|
||||
} else {
|
||||
editor.dispatch('contexttoolbar-show', { toolbarKey: 'quicklink' });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.util.VK');
|
||||
|
||||
const appendClickRemove = (link, evt) => {
|
||||
document.body.appendChild(link);
|
||||
link.dispatchEvent(evt);
|
||||
@@ -981,7 +1005,7 @@
|
||||
}
|
||||
};
|
||||
const openDialog = editor => () => {
|
||||
open$1(editor);
|
||||
editor.execCommand('mceLink', false, { dialog: true });
|
||||
};
|
||||
const gotoSelectedLink = editor => () => {
|
||||
gotoLink(editor, getSelectedLink(editor));
|
||||
@@ -989,16 +1013,18 @@
|
||||
const setupGotoLinks = editor => {
|
||||
editor.on('click', e => {
|
||||
const link = getLink(editor, e.target);
|
||||
if (link && global$4.metaKeyPressed(e)) {
|
||||
if (link && global.metaKeyPressed(e)) {
|
||||
e.preventDefault();
|
||||
gotoLink(editor, link);
|
||||
}
|
||||
});
|
||||
editor.on('keydown', e => {
|
||||
const link = getSelectedLink(editor);
|
||||
if (link && e.keyCode === 13 && hasOnlyAltModifier(e)) {
|
||||
e.preventDefault();
|
||||
gotoLink(editor, link);
|
||||
if (!e.isDefaultPrevented() && e.keyCode === 13 && hasOnlyAltModifier(e)) {
|
||||
const link = getSelectedLink(editor);
|
||||
if (link) {
|
||||
e.preventDefault();
|
||||
gotoLink(editor, link);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -1007,12 +1033,12 @@
|
||||
return () => editor.off('NodeChange', toggler);
|
||||
};
|
||||
const toggleActiveState = editor => api => {
|
||||
const updateState = () => api.setActive(!editor.mode.isReadOnly() && getAnchorElement(editor, editor.selection.getNode()) !== null);
|
||||
const updateState = () => api.setActive(!editor.mode.isReadOnly() && isInAnchor(editor, editor.selection.getNode()));
|
||||
updateState();
|
||||
return toggleState(editor, updateState);
|
||||
};
|
||||
const toggleEnabledState = editor => api => {
|
||||
const updateState = () => api.setEnabled(getAnchorElement(editor, editor.selection.getNode()) !== null);
|
||||
const updateState = () => api.setEnabled(isInAnchor(editor, editor.selection.getNode()));
|
||||
updateState();
|
||||
return toggleState(editor, updateState);
|
||||
};
|
||||
@@ -1023,16 +1049,6 @@
|
||||
return toggleState(editor, e => api.setEnabled(hasLinks$1(e.parents)));
|
||||
};
|
||||
|
||||
const register = editor => {
|
||||
editor.addCommand('mceLink', () => {
|
||||
if (useQuickLink(editor)) {
|
||||
editor.dispatch('contexttoolbar-show', { toolbarKey: 'quicklink' });
|
||||
} else {
|
||||
openDialog(editor)();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const setup = editor => {
|
||||
editor.addShortcut('Meta+K', '', () => {
|
||||
editor.execCommand('mceLink');
|
||||
@@ -1090,13 +1106,13 @@
|
||||
};
|
||||
const onSetupLink = buttonApi => {
|
||||
const node = editor.selection.getNode();
|
||||
buttonApi.setEnabled(getAnchorElement(editor, node) !== null);
|
||||
buttonApi.setEnabled(isInAnchor(editor, node));
|
||||
return noop;
|
||||
};
|
||||
const getLinkText = value => {
|
||||
const anchor = getAnchorElement(editor);
|
||||
const onlyText = isOnlyTextSelected(editor);
|
||||
if (!anchor && onlyText) {
|
||||
if (anchor.isNone() && onlyText) {
|
||||
const text = getAnchorText(editor.selection, anchor);
|
||||
return Optional.some(text.length > 0 ? text : value);
|
||||
} else {
|
||||
@@ -1111,10 +1127,10 @@
|
||||
onSetup: toggleActiveState(editor)
|
||||
},
|
||||
label: 'Link',
|
||||
predicate: node => !!getAnchorElement(editor, node) && hasContextToolbar(editor),
|
||||
predicate: node => hasContextToolbar(editor) && isInAnchor(editor, node),
|
||||
initValue: () => {
|
||||
const elm = getAnchorElement(editor);
|
||||
return !!elm ? getHref(elm) : '';
|
||||
return elm.fold(constant(''), getHref);
|
||||
},
|
||||
commands: [
|
||||
{
|
||||
@@ -1124,7 +1140,7 @@
|
||||
primary: true,
|
||||
onSetup: buttonApi => {
|
||||
const node = editor.selection.getNode();
|
||||
buttonApi.setActive(!!getAnchorElement(editor, node));
|
||||
buttonApi.setActive(isInAnchor(editor, node));
|
||||
return toggleActiveState(editor)(buttonApi);
|
||||
},
|
||||
onAction: formApi => {
|
||||
|
||||
+2
-2
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user