initial commit
This commit is contained in:
1275
hamrokhaanpaan/wp-includes/js/tinymce/plugins/charmap/plugin.js
Normal file
1275
hamrokhaanpaan/wp-includes/js/tinymce/plugins/charmap/plugin.js
Normal file
File diff suppressed because it is too large
Load Diff
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/charmap/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/charmap/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,126 @@
|
||||
(function () {
|
||||
var colorpicker = (function () {
|
||||
'use strict';
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Color');
|
||||
|
||||
var showPreview = function (win, hexColor) {
|
||||
win.find('#preview')[0].getEl().style.background = hexColor;
|
||||
};
|
||||
var setColor = function (win, value) {
|
||||
var color = global$1(value), rgb = color.toRgb();
|
||||
win.fromJSON({
|
||||
r: rgb.r,
|
||||
g: rgb.g,
|
||||
b: rgb.b,
|
||||
hex: color.toHex().substr(1)
|
||||
});
|
||||
showPreview(win, color.toHex());
|
||||
};
|
||||
var open = function (editor, callback, value) {
|
||||
var win = editor.windowManager.open({
|
||||
title: 'Color',
|
||||
items: {
|
||||
type: 'container',
|
||||
layout: 'flex',
|
||||
direction: 'row',
|
||||
align: 'stretch',
|
||||
padding: 5,
|
||||
spacing: 10,
|
||||
items: [
|
||||
{
|
||||
type: 'colorpicker',
|
||||
value: value,
|
||||
onchange: function () {
|
||||
var rgb = this.rgb();
|
||||
if (win) {
|
||||
win.find('#r').value(rgb.r);
|
||||
win.find('#g').value(rgb.g);
|
||||
win.find('#b').value(rgb.b);
|
||||
win.find('#hex').value(this.value().substr(1));
|
||||
showPreview(win, this.value());
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'form',
|
||||
padding: 0,
|
||||
labelGap: 5,
|
||||
defaults: {
|
||||
type: 'textbox',
|
||||
size: 7,
|
||||
value: '0',
|
||||
flex: 1,
|
||||
spellcheck: false,
|
||||
onchange: function () {
|
||||
var colorPickerCtrl = win.find('colorpicker')[0];
|
||||
var name, value;
|
||||
name = this.name();
|
||||
value = this.value();
|
||||
if (name === 'hex') {
|
||||
value = '#' + value;
|
||||
setColor(win, value);
|
||||
colorPickerCtrl.value(value);
|
||||
return;
|
||||
}
|
||||
value = {
|
||||
r: win.find('#r').value(),
|
||||
g: win.find('#g').value(),
|
||||
b: win.find('#b').value()
|
||||
};
|
||||
colorPickerCtrl.value(value);
|
||||
setColor(win, value);
|
||||
}
|
||||
},
|
||||
items: [
|
||||
{
|
||||
name: 'r',
|
||||
label: 'R',
|
||||
autofocus: 1
|
||||
},
|
||||
{
|
||||
name: 'g',
|
||||
label: 'G'
|
||||
},
|
||||
{
|
||||
name: 'b',
|
||||
label: 'B'
|
||||
},
|
||||
{
|
||||
name: 'hex',
|
||||
label: '#',
|
||||
value: '000000'
|
||||
},
|
||||
{
|
||||
name: 'preview',
|
||||
type: 'container',
|
||||
border: 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
onSubmit: function () {
|
||||
callback('#' + win.toJSON().hex);
|
||||
}
|
||||
});
|
||||
setColor(win, value);
|
||||
};
|
||||
var Dialog = { open: open };
|
||||
|
||||
global.add('colorpicker', function (editor) {
|
||||
if (!editor.settings.color_picker_callback) {
|
||||
editor.settings.color_picker_callback = function (callback, value) {
|
||||
Dialog.open(editor, callback, value);
|
||||
};
|
||||
}
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
return Plugin;
|
||||
|
||||
}());
|
||||
})();
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/colorpicker/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/colorpicker/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),l=tinymce.util.Tools.resolve("tinymce.util.Color"),a=function(e,n){e.find("#preview")[0].getEl().style.background=n},o=function(e,n){var i=l(n),t=i.toRgb();e.fromJSON({r:t.r,g:t.g,b:t.b,hex:i.toHex().substr(1)}),a(e,i.toHex())},t=function(e,n,i){var t=e.windowManager.open({title:"Color",items:{type:"container",layout:"flex",direction:"row",align:"stretch",padding:5,spacing:10,items:[{type:"colorpicker",value:i,onchange:function(){var e=this.rgb();t&&(t.find("#r").value(e.r),t.find("#g").value(e.g),t.find("#b").value(e.b),t.find("#hex").value(this.value().substr(1)),a(t,this.value()))}},{type:"form",padding:0,labelGap:5,defaults:{type:"textbox",size:7,value:"0",flex:1,spellcheck:!1,onchange:function(){var e,n,i=t.find("colorpicker")[0];if(e=this.name(),n=this.value(),"hex"===e)return o(t,n="#"+n),void i.value(n);n={r:t.find("#r").value(),g:t.find("#g").value(),b:t.find("#b").value()},i.value(n),o(t,n)}},items:[{name:"r",label:"R",autofocus:1},{name:"g",label:"G"},{name:"b",label:"B"},{name:"hex",label:"#",value:"000000"},{name:"preview",type:"container",border:1}]}]},onSubmit:function(){n("#"+t.toJSON().hex)}});o(t,i)};e.add("colorpicker",function(i){i.settings.color_picker_callback||(i.settings.color_picker_callback=function(e,n){t(i,e,n)})})}();
|
@ -0,0 +1,215 @@
|
||||
/*
|
||||
* Edited for compatibility with old TinyMCE 3.x plugins in WordPress.
|
||||
* More info: https://core.trac.wordpress.org/ticket/31596#comment:10
|
||||
*/
|
||||
|
||||
/* Generic */
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||
font-size:13px;
|
||||
background:#fcfcfc;
|
||||
padding:0;
|
||||
margin:8px 8px 0 8px;
|
||||
}
|
||||
|
||||
textarea {resize:none;outline:none;}
|
||||
|
||||
a:link, a:hover {
|
||||
color: #2B6FB6;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #3C2BB6;
|
||||
}
|
||||
|
||||
.nowrap {white-space: nowrap}
|
||||
|
||||
/* Forms */
|
||||
form {margin: 0;}
|
||||
fieldset {margin:0; padding:4px; border:1px solid #dfdfdf; font-family:Verdana, Arial; font-size:10px;}
|
||||
legend {color:#2B6FB6; font-weight:bold;}
|
||||
label.msg {display:none;}
|
||||
label.invalid {color:#EE0000; display:inline;}
|
||||
input.invalid {border:1px solid #EE0000;}
|
||||
input {background:#FFF; border:1px solid #dfdfdf;}
|
||||
input, select, textarea {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;}
|
||||
input, select, textarea {border:1px solid #dfdfdf;}
|
||||
input.radio {border:1px none #000000; background:transparent; vertical-align:middle;}
|
||||
input.checkbox {border:1px none #000000; background:transparent; vertical-align:middle;}
|
||||
.input_noborder {border:0;}
|
||||
|
||||
/* Buttons */
|
||||
#insert,
|
||||
#cancel,
|
||||
#apply,
|
||||
.mceActionPanel .button,
|
||||
input.mceButton,
|
||||
.updateButton {
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
border: 1px solid #adadad;
|
||||
margin: 0;
|
||||
padding: 0 10px 1px;
|
||||
font-size: 13px;
|
||||
height: 24px;
|
||||
line-height: 22px;
|
||||
color: #333;
|
||||
cursor: pointer;
|
||||
-webkit-border-radius: 3px;
|
||||
-webkit-appearance: none;
|
||||
border-radius: 3px;
|
||||
white-space: nowrap;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
background: #fafafa;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#fafafa), to(#e9e9e9));
|
||||
background-image: -webkit-linear-gradient(top, #fafafa, #e9e9e9);
|
||||
background-image: -moz-linear-gradient(top, #fafafa, #e9e9e9);
|
||||
background-image: -o-linear-gradient(top, #fafafa, #e9e9e9);
|
||||
background-image: linear-gradient(to bottom, #fafafa, #e9e9e9);
|
||||
|
||||
text-shadow: 0 1px 0 #fff;
|
||||
-webkit-box-shadow: inset 0 1px 0 #fff;
|
||||
-moz-box-shadow: inset 0 1px 0 #fff;
|
||||
box-shadow: inset 0 1px 0 #fff;
|
||||
}
|
||||
|
||||
#insert {
|
||||
background: #2ea2cc;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#2ea2cc), to(#1e8cbe));
|
||||
background: -webkit-linear-gradient(top, #2ea2cc 0%,#1e8cbe 100%);
|
||||
background: linear-gradient(top, #2ea2cc 0%,#1e8cbe 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2ea2cc', endColorstr='#1e8cbe',GradientType=0 );
|
||||
border-color: #0074a2;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
|
||||
box-shadow: inset 0 1px 0 rgba(120,200,230,0.5);
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
text-shadow: 0 1px 0 rgba(0,86,132,0.7);
|
||||
}
|
||||
|
||||
#cancel:hover,
|
||||
input.mceButton:hover,
|
||||
.updateButton:hover,
|
||||
#cancel:focus,
|
||||
input.mceButton:focus,
|
||||
.updateButton:focus {
|
||||
background: #f3f3f3;
|
||||
background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#f3f3f3));
|
||||
background-image: -webkit-linear-gradient(top, #fff, #f3f3f3);
|
||||
background-image: -moz-linear-gradient(top, #fff, #f3f3f3);
|
||||
background-image: -ms-linear-gradient(top, #fff, #f3f3f3);
|
||||
background-image: -o-linear-gradient(top, #fff, #f3f3f3);
|
||||
background-image: linear-gradient(to bottom, #fff, #f3f3f3);
|
||||
border-color: #999;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
#insert:hover,
|
||||
#insert:focus {
|
||||
background: #1e8cbe;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#1e8cbe), to(#0074a2));
|
||||
background: -webkit-linear-gradient(top, #1e8cbe 0%,#0074a2 100%);
|
||||
background: linear-gradient(top, #1e8cbe 0%,#0074a2 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e8cbe', endColorstr='#0074a2',GradientType=0 );
|
||||
border-color: #0074a2;
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(120,200,230,0.6);
|
||||
box-shadow: inset 0 1px 0 rgba(120,200,230,0.6);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.mceActionPanel #insert {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* Browse */
|
||||
a.pickcolor, a.browse {text-decoration:none}
|
||||
a.browse span {display:block; width:20px; height:18px; border:1px solid #FFF; margin-left:1px;}
|
||||
.mceOldBoxModel a.browse span {width:22px; height:20px;}
|
||||
a.browse:hover span {border:1px solid #0A246A; background-color:#B2BBD0;}
|
||||
a.browse span.disabled {border:1px solid white; opacity:0.3; -ms-filter:'alpha(opacity=30)'; filter:alpha(opacity=30);}
|
||||
a.browse:hover span.disabled {border:1px solid white; background-color:transparent;}
|
||||
a.pickcolor span {display:block; width:20px; height:16px; margin-left:2px;}
|
||||
.mceOldBoxModel a.pickcolor span {width:21px; height:17px;}
|
||||
a.pickcolor:hover span {background-color:#B2BBD0;}
|
||||
div.iframecontainer {background: #fff;}
|
||||
|
||||
/* Charmap */
|
||||
table.charmap {border:1px solid #AAA; text-align:center}
|
||||
td.charmap, #charmap a {width:18px; height:18px; color:#000; border:1px solid #AAA; text-align:center; font-size:12px; vertical-align:middle; line-height: 18px;}
|
||||
#charmap a {display:block; color:#000; text-decoration:none; border:0}
|
||||
#charmap a:hover {background:#CCC;color:#2B6FB6}
|
||||
#charmap #codeN {font-size:10px; font-family:Arial,Helvetica,sans-serif; text-align:center}
|
||||
#charmap #codeV {font-size:40px; height:80px; border:1px solid #AAA; text-align:center}
|
||||
#charmap #charmapView {background-color:#fff;}
|
||||
|
||||
/* Source */
|
||||
.wordWrapCode {vertical-align:middle; border:1px none #000000; background:transparent;}
|
||||
.mceActionPanel {margin-top:5px;}
|
||||
|
||||
/* Tabs classes */
|
||||
.tabs {width:100%; height:19px; line-height:normal; border-bottom: 1px solid #aaa;}
|
||||
.tabs ul {margin:0; padding:0; list-style:none;}
|
||||
.tabs li {float:left; border: 1px solid #aaa; margin:0 2px 0 0; padding:0 0 0 10px; line-height:17px; height:18px; display:block;}
|
||||
.tabs li.current {border-bottom: 1px solid #fff; margin-right:2px;}
|
||||
.tabs span {float:left; display:block; padding:0px 10px 0 0;}
|
||||
.tabs a {text-decoration:none; font-family:Verdana, Arial; font-size:10px;}
|
||||
.tabs a:link, .tabs a:visited, .tabs a:hover {color:black;}
|
||||
|
||||
.wp-core-ui #tabs {
|
||||
padding-bottom: 5px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.wp-core-ui #tabs a {
|
||||
padding: 6px 10px;
|
||||
margin: 0 2px;
|
||||
}
|
||||
|
||||
/* Panels */
|
||||
.panel_wrapper div.panel {display:none;}
|
||||
.panel_wrapper div.current {display:block; width:100%; height:300px; overflow:visible;}
|
||||
.panel_wrapper {border:1px solid #919B9C; border-top:0px; padding:10px; padding-top:5px; clear:both; background:white;}
|
||||
|
||||
/* Columns */
|
||||
.column {float:left;}
|
||||
.properties {width:100%;}
|
||||
.properties .column1 {}
|
||||
.properties .column2 {text-align:left;}
|
||||
|
||||
/* Titles */
|
||||
h1, h2, h3, h4 {color:#2B6FB6; margin:0; padding:0; padding-top:5px;}
|
||||
h3 {font-size:14px;}
|
||||
.title {font-size:12px; font-weight:bold; color:#2B6FB6;}
|
||||
|
||||
/* Dialog specific */
|
||||
#link .panel_wrapper, #link div.current {height:125px;}
|
||||
#image .panel_wrapper, #image div.current {height:200px;}
|
||||
#plugintable thead {font-weight:bold; background:#DDD;}
|
||||
#plugintable, #about #plugintable td {border:1px solid #919B9C;}
|
||||
#plugintable {width:96%; margin-top:10px;}
|
||||
#pluginscontainer {height:290px; overflow:auto;}
|
||||
#colorpicker #preview {display:inline-block; padding-left:40px; height:14px; border:1px solid black; margin-left:5px; margin-right: 5px}
|
||||
#colorpicker #previewblock {position: relative; top: -3px; padding-left:5px; padding-top: 0px; display:inline}
|
||||
#colorpicker #preview_wrapper {text-align:center; padding-top:4px; white-space: nowrap; float: right;}
|
||||
#colorpicker #insert, #colorpicker #cancel {width: 90px}
|
||||
#colorpicker #colors {float:left; border:1px solid gray; cursor:crosshair;}
|
||||
#colorpicker #light {border:1px solid gray; margin-left:5px; float:left;width:15px; height:150px; cursor:crosshair;}
|
||||
#colorpicker #light div {overflow:hidden;}
|
||||
#colorpicker .panel_wrapper div.current {height:175px;}
|
||||
#colorpicker #namedcolors {width:150px;}
|
||||
#colorpicker #namedcolors a {display:block; float:left; width:10px; height:10px; margin:1px 1px 0 0; overflow:hidden;}
|
||||
#colorpicker #colornamecontainer {margin-top:5px;}
|
||||
#colorpicker #picker_panel fieldset {margin:auto;width:325px;}
|
||||
|
||||
|
||||
/* Localization */
|
||||
|
||||
body[dir="rtl"],
|
||||
body[dir="rtl"] fieldset,
|
||||
body[dir="rtl"] input, body[dir="rtl"] select, body[dir="rtl"] textarea,
|
||||
body[dir="rtl"] #charmap #codeN,
|
||||
body[dir="rtl"] .tabs a {
|
||||
font-family: Tahoma, sans-serif;
|
||||
}
|
322
hamrokhaanpaan/wp-includes/js/tinymce/plugins/compat3x/plugin.js
Normal file
322
hamrokhaanpaan/wp-includes/js/tinymce/plugins/compat3x/plugin.js
Normal file
@ -0,0 +1,322 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Released under LGPL License.
|
||||
* Copyright (c) 1999-2017 Ephox Corp. All rights reserved
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/*global tinymce:true, console:true */
|
||||
/*eslint no-console:0, new-cap:0 */
|
||||
|
||||
/**
|
||||
* This plugin adds missing events form the 4.x API back. Not every event is
|
||||
* properly supported but most things should work.
|
||||
*
|
||||
* Unsupported things:
|
||||
* - No editor.onEvent
|
||||
* - Can't cancel execCommands with beforeExecCommand
|
||||
*/
|
||||
(function (tinymce) {
|
||||
var reported;
|
||||
|
||||
function noop() {
|
||||
}
|
||||
|
||||
function log(apiCall) {
|
||||
if (!reported && window && window.console) {
|
||||
reported = true;
|
||||
console.log("Deprecated TinyMCE API call: " + apiCall);
|
||||
}
|
||||
}
|
||||
|
||||
function Dispatcher(target, newEventName, argsMap, defaultScope) {
|
||||
target = target || this;
|
||||
var cbs = [];
|
||||
|
||||
if (!newEventName) {
|
||||
this.add = this.addToTop = this.remove = this.dispatch = noop;
|
||||
return;
|
||||
}
|
||||
|
||||
this.add = function (callback, scope, prepend) {
|
||||
log('<target>.on' + newEventName + ".add(..)");
|
||||
|
||||
// Convert callback({arg1:x, arg2:x}) -> callback(arg1, arg2)
|
||||
function patchedEventCallback(e) {
|
||||
var callbackArgs = [];
|
||||
|
||||
if (typeof argsMap == "string") {
|
||||
argsMap = argsMap.split(" ");
|
||||
}
|
||||
|
||||
if (argsMap && typeof argsMap !== "function") {
|
||||
for (var i = 0; i < argsMap.length; i++) {
|
||||
callbackArgs.push(e[argsMap[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof argsMap == "function") {
|
||||
callbackArgs = argsMap(newEventName, e, target);
|
||||
if (!callbackArgs) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!argsMap) {
|
||||
callbackArgs = [e];
|
||||
}
|
||||
|
||||
callbackArgs.unshift(defaultScope || target);
|
||||
|
||||
if (callback.apply(scope || defaultScope || target, callbackArgs) === false) {
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
|
||||
target.on(newEventName, patchedEventCallback, prepend);
|
||||
|
||||
var handlers = {
|
||||
original: callback,
|
||||
patched: patchedEventCallback
|
||||
};
|
||||
|
||||
cbs.push(handlers);
|
||||
return patchedEventCallback;
|
||||
};
|
||||
|
||||
this.addToTop = function (callback, scope) {
|
||||
this.add(callback, scope, true);
|
||||
};
|
||||
|
||||
this.remove = function (callback) {
|
||||
cbs.forEach(function (item, i) {
|
||||
if (item.original === callback) {
|
||||
cbs.splice(i, 1);
|
||||
return target.off(newEventName, item.patched);
|
||||
}
|
||||
});
|
||||
|
||||
return target.off(newEventName, callback);
|
||||
};
|
||||
|
||||
this.dispatch = function () {
|
||||
target.fire(newEventName);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
tinymce.util.Dispatcher = Dispatcher;
|
||||
tinymce.onBeforeUnload = new Dispatcher(tinymce, "BeforeUnload");
|
||||
tinymce.onAddEditor = new Dispatcher(tinymce, "AddEditor", "editor");
|
||||
tinymce.onRemoveEditor = new Dispatcher(tinymce, "RemoveEditor", "editor");
|
||||
|
||||
tinymce.util.Cookie = {
|
||||
get: noop, getHash: noop, remove: noop, set: noop, setHash: noop
|
||||
};
|
||||
|
||||
function patchEditor(editor) {
|
||||
|
||||
function translate(str) {
|
||||
var prefix = editor.settings.language || "en";
|
||||
var prefixedStr = [prefix, str].join('.');
|
||||
var translatedStr = tinymce.i18n.translate(prefixedStr);
|
||||
|
||||
return prefixedStr !== translatedStr ? translatedStr : tinymce.i18n.translate(str);
|
||||
}
|
||||
|
||||
function patchEditorEvents(oldEventNames, argsMap) {
|
||||
tinymce.each(oldEventNames.split(" "), function (oldName) {
|
||||
editor["on" + oldName] = new Dispatcher(editor, oldName, argsMap);
|
||||
});
|
||||
}
|
||||
|
||||
function convertUndoEventArgs(type, event, target) {
|
||||
return [
|
||||
event.level,
|
||||
target
|
||||
];
|
||||
}
|
||||
|
||||
function filterSelectionEvents(needsSelection) {
|
||||
return function (type, e) {
|
||||
if ((!e.selection && !needsSelection) || e.selection == needsSelection) {
|
||||
return [e];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (editor.controlManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
function cmNoop() {
|
||||
var obj = {}, methods = 'add addMenu addSeparator collapse createMenu destroy displayColor expand focus ' +
|
||||
'getLength hasMenus hideMenu isActive isCollapsed isDisabled isRendered isSelected mark ' +
|
||||
'postRender remove removeAll renderHTML renderMenu renderNode renderTo select selectByIndex ' +
|
||||
'setActive setAriaProperty setColor setDisabled setSelected setState showMenu update';
|
||||
|
||||
log('editor.controlManager.*');
|
||||
|
||||
function _noop() {
|
||||
return cmNoop();
|
||||
}
|
||||
|
||||
tinymce.each(methods.split(' '), function (method) {
|
||||
obj[method] = _noop;
|
||||
});
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
editor.controlManager = {
|
||||
buttons: {},
|
||||
|
||||
setDisabled: function (name, state) {
|
||||
log("controlManager.setDisabled(..)");
|
||||
|
||||
if (this.buttons[name]) {
|
||||
this.buttons[name].disabled(state);
|
||||
}
|
||||
},
|
||||
|
||||
setActive: function (name, state) {
|
||||
log("controlManager.setActive(..)");
|
||||
|
||||
if (this.buttons[name]) {
|
||||
this.buttons[name].active(state);
|
||||
}
|
||||
},
|
||||
|
||||
onAdd: new Dispatcher(),
|
||||
onPostRender: new Dispatcher(),
|
||||
|
||||
add: function (obj) {
|
||||
return obj;
|
||||
},
|
||||
createButton: cmNoop,
|
||||
createColorSplitButton: cmNoop,
|
||||
createControl: cmNoop,
|
||||
createDropMenu: cmNoop,
|
||||
createListBox: cmNoop,
|
||||
createMenuButton: cmNoop,
|
||||
createSeparator: cmNoop,
|
||||
createSplitButton: cmNoop,
|
||||
createToolbar: cmNoop,
|
||||
createToolbarGroup: cmNoop,
|
||||
destroy: noop,
|
||||
get: noop,
|
||||
setControlType: cmNoop
|
||||
};
|
||||
|
||||
patchEditorEvents("PreInit BeforeRenderUI PostRender Load Init Remove Activate Deactivate", "editor");
|
||||
patchEditorEvents("Click MouseUp MouseDown DblClick KeyDown KeyUp KeyPress ContextMenu Paste Submit Reset");
|
||||
patchEditorEvents("BeforeExecCommand ExecCommand", "command ui value args"); // args.terminate not supported
|
||||
patchEditorEvents("PreProcess PostProcess LoadContent SaveContent Change");
|
||||
patchEditorEvents("BeforeSetContent BeforeGetContent SetContent GetContent", filterSelectionEvents(false));
|
||||
patchEditorEvents("SetProgressState", "state time");
|
||||
patchEditorEvents("VisualAid", "element hasVisual");
|
||||
patchEditorEvents("Undo Redo", convertUndoEventArgs);
|
||||
|
||||
patchEditorEvents("NodeChange", function (type, e) {
|
||||
return [
|
||||
editor.controlManager,
|
||||
e.element,
|
||||
editor.selection.isCollapsed(),
|
||||
e
|
||||
];
|
||||
});
|
||||
|
||||
var originalAddButton = editor.addButton;
|
||||
editor.addButton = function (name, settings) {
|
||||
var originalOnPostRender;
|
||||
|
||||
function patchedPostRender() {
|
||||
editor.controlManager.buttons[name] = this;
|
||||
|
||||
if (originalOnPostRender) {
|
||||
return originalOnPostRender.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
for (var key in settings) {
|
||||
if (key.toLowerCase() === "onpostrender") {
|
||||
originalOnPostRender = settings[key];
|
||||
settings.onPostRender = patchedPostRender;
|
||||
}
|
||||
}
|
||||
|
||||
if (!originalOnPostRender) {
|
||||
settings.onPostRender = patchedPostRender;
|
||||
}
|
||||
|
||||
if (settings.title) {
|
||||
settings.title = translate(settings.title);
|
||||
}
|
||||
|
||||
return originalAddButton.call(this, name, settings);
|
||||
};
|
||||
|
||||
editor.on('init', function () {
|
||||
var undoManager = editor.undoManager, selection = editor.selection;
|
||||
|
||||
undoManager.onUndo = new Dispatcher(editor, "Undo", convertUndoEventArgs, null, undoManager);
|
||||
undoManager.onRedo = new Dispatcher(editor, "Redo", convertUndoEventArgs, null, undoManager);
|
||||
undoManager.onBeforeAdd = new Dispatcher(editor, "BeforeAddUndo", null, undoManager);
|
||||
undoManager.onAdd = new Dispatcher(editor, "AddUndo", null, undoManager);
|
||||
|
||||
selection.onBeforeGetContent = new Dispatcher(editor, "BeforeGetContent", filterSelectionEvents(true), selection);
|
||||
selection.onGetContent = new Dispatcher(editor, "GetContent", filterSelectionEvents(true), selection);
|
||||
selection.onBeforeSetContent = new Dispatcher(editor, "BeforeSetContent", filterSelectionEvents(true), selection);
|
||||
selection.onSetContent = new Dispatcher(editor, "SetContent", filterSelectionEvents(true), selection);
|
||||
});
|
||||
|
||||
editor.on('BeforeRenderUI', function () {
|
||||
var windowManager = editor.windowManager;
|
||||
|
||||
windowManager.onOpen = new Dispatcher();
|
||||
windowManager.onClose = new Dispatcher();
|
||||
windowManager.createInstance = function (className, a, b, c, d, e) {
|
||||
log("windowManager.createInstance(..)");
|
||||
|
||||
var constr = tinymce.resolve(className);
|
||||
return new constr(a, b, c, d, e);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
tinymce.on('SetupEditor', function (e) {
|
||||
patchEditor(e.editor);
|
||||
});
|
||||
|
||||
tinymce.PluginManager.add("compat3x", patchEditor);
|
||||
|
||||
tinymce.addI18n = function (prefix, o) {
|
||||
var I18n = tinymce.util.I18n, each = tinymce.each;
|
||||
|
||||
if (typeof prefix == "string" && prefix.indexOf('.') === -1) {
|
||||
I18n.add(prefix, o);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tinymce.is(prefix, 'string')) {
|
||||
each(prefix, function (o, lc) {
|
||||
each(o, function (o, g) {
|
||||
each(o, function (o, k) {
|
||||
if (g === 'common') {
|
||||
I18n.data[lc + '.' + k] = o;
|
||||
} else {
|
||||
I18n.data[lc + '.' + g + '.' + k] = o;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
each(o, function (o, k) {
|
||||
I18n.data[prefix + '.' + k] = o;
|
||||
});
|
||||
}
|
||||
};
|
||||
})(tinymce);
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/compat3x/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/compat3x/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(u){var t;function l(){}function f(e){!t&&window&&window.console&&(t=!0,console.log("Deprecated TinyMCE API call: "+e))}function i(i,a,d,s){i=i||this;var c=[];a?(this.add=function(o,r,e){function t(e){var t=[];if("string"==typeof d&&(d=d.split(" ")),d&&"function"!=typeof d)for(var n=0;n<d.length;n++)t.push(e[d[n]]);("function"!=typeof d||(t=d(a,e,i)))&&(d||(t=[e]),t.unshift(s||i),!1===o.apply(r||s||i,t)&&e.stopImmediatePropagation())}f("<target>.on"+a+".add(..)"),i.on(a,t,e);var n={original:o,patched:t};return c.push(n),t},this.addToTop=function(e,t){this.add(e,t,!0)},this.remove=function(n){return c.forEach(function(e,t){if(e.original===n)return c.splice(t,1),i.off(a,e.patched)}),i.off(a,n)},this.dispatch=function(){return i.fire(a),!0}):this.add=this.addToTop=this.remove=this.dispatch=l}function n(s){function e(e,t){u.each(e.split(" "),function(e){s["on"+e]=new i(s,e,t)})}function n(e,t,n){return[t.level,n]}function o(n){return function(e,t){if(!t.selection&&!n||t.selection==n)return[t]}}if(!s.controlManager){s.controlManager={buttons:{},setDisabled:function(e,t){f("controlManager.setDisabled(..)"),this.buttons[e]&&this.buttons[e].disabled(t)},setActive:function(e,t){f("controlManager.setActive(..)"),this.buttons[e]&&this.buttons[e].active(t)},onAdd:new i,onPostRender:new i,add:function(e){return e},createButton:r,createColorSplitButton:r,createControl:r,createDropMenu:r,createListBox:r,createMenuButton:r,createSeparator:r,createSplitButton:r,createToolbar:r,createToolbarGroup:r,destroy:l,get:l,setControlType:r},e("PreInit BeforeRenderUI PostRender Load Init Remove Activate Deactivate","editor"),e("Click MouseUp MouseDown DblClick KeyDown KeyUp KeyPress ContextMenu Paste Submit Reset"),e("BeforeExecCommand ExecCommand","command ui value args"),e("PreProcess PostProcess LoadContent SaveContent Change"),e("BeforeSetContent BeforeGetContent SetContent GetContent",o(!1)),e("SetProgressState","state time"),e("VisualAid","element hasVisual"),e("Undo Redo",n),e("NodeChange",function(e,t){return[s.controlManager,t.element,s.selection.isCollapsed(),t]});var c=s.addButton;s.addButton=function(e,t){var n,o,r,i;function a(){if(s.controlManager.buttons[e]=this,n)return n.apply(this,arguments)}for(var d in t)"onpostrender"===d.toLowerCase()&&(n=t[d],t.onPostRender=a);return n||(t.onPostRender=a),t.title&&(t.title=(o=t.title,r=[s.settings.language||"en",o].join("."),i=u.i18n.translate(r),r!==i?i:u.i18n.translate(o))),c.call(this,e,t)},s.on("init",function(){var e=s.undoManager,t=s.selection;e.onUndo=new i(s,"Undo",n,null,e),e.onRedo=new i(s,"Redo",n,null,e),e.onBeforeAdd=new i(s,"BeforeAddUndo",null,e),e.onAdd=new i(s,"AddUndo",null,e),t.onBeforeGetContent=new i(s,"BeforeGetContent",o(!0),t),t.onGetContent=new i(s,"GetContent",o(!0),t),t.onBeforeSetContent=new i(s,"BeforeSetContent",o(!0),t),t.onSetContent=new i(s,"SetContent",o(!0),t)}),s.on("BeforeRenderUI",function(){var e=s.windowManager;e.onOpen=new i,e.onClose=new i,e.createInstance=function(e,t,n,o,r,i){return f("windowManager.createInstance(..)"),new(u.resolve(e))(t,n,o,r,i)}})}function r(){var t={};function n(){return r()}return f("editor.controlManager.*"),u.each("add addMenu addSeparator collapse createMenu destroy displayColor expand focus getLength hasMenus hideMenu isActive isCollapsed isDisabled isRendered isSelected mark postRender remove removeAll renderHTML renderMenu renderNode renderTo select selectByIndex setActive setAriaProperty setColor setDisabled setSelected setState showMenu update".split(" "),function(e){t[e]=n}),t}}u.util.Dispatcher=i,u.onBeforeUnload=new i(u,"BeforeUnload"),u.onAddEditor=new i(u,"AddEditor","editor"),u.onRemoveEditor=new i(u,"RemoveEditor","editor"),u.util.Cookie={get:l,getHash:l,remove:l,set:l,setHash:l},u.on("SetupEditor",function(e){n(e.editor)}),u.PluginManager.add("compat3x",n),u.addI18n=function(n,e){var r=u.util.I18n,t=u.each;"string"!=typeof n||-1!==n.indexOf(".")?u.is(n,"string")?t(e,function(e,t){r.data[n+"."+t]=e}):t(n,function(e,o){t(e,function(e,n){t(e,function(e,t){"common"===n?r.data[o+"."+t]=e:r.data[o+"."+n+"."+t]=e})})}):r.add(n,e)}}(tinymce);
|
@ -0,0 +1,66 @@
|
||||
(function () {
|
||||
var directionality = (function () {
|
||||
'use strict';
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
var setDir = function (editor, dir) {
|
||||
var dom = editor.dom;
|
||||
var curDir;
|
||||
var blocks = editor.selection.getSelectedBlocks();
|
||||
if (blocks.length) {
|
||||
curDir = dom.getAttrib(blocks[0], 'dir');
|
||||
global$1.each(blocks, function (block) {
|
||||
if (!dom.getParent(block.parentNode, '*[dir="' + dir + '"]', dom.getRoot())) {
|
||||
dom.setAttrib(block, 'dir', curDir !== dir ? dir : null);
|
||||
}
|
||||
});
|
||||
editor.nodeChanged();
|
||||
}
|
||||
};
|
||||
var Direction = { setDir: setDir };
|
||||
|
||||
var register = function (editor) {
|
||||
editor.addCommand('mceDirectionLTR', function () {
|
||||
Direction.setDir(editor, 'ltr');
|
||||
});
|
||||
editor.addCommand('mceDirectionRTL', function () {
|
||||
Direction.setDir(editor, 'rtl');
|
||||
});
|
||||
};
|
||||
var Commands = { register: register };
|
||||
|
||||
var generateSelector = function (dir) {
|
||||
var selector = [];
|
||||
global$1.each('h1 h2 h3 h4 h5 h6 div p'.split(' '), function (name) {
|
||||
selector.push(name + '[dir=' + dir + ']');
|
||||
});
|
||||
return selector.join(',');
|
||||
};
|
||||
var register$1 = function (editor) {
|
||||
editor.addButton('ltr', {
|
||||
title: 'Left to right',
|
||||
cmd: 'mceDirectionLTR',
|
||||
stateSelector: generateSelector('ltr')
|
||||
});
|
||||
editor.addButton('rtl', {
|
||||
title: 'Right to left',
|
||||
cmd: 'mceDirectionRTL',
|
||||
stateSelector: generateSelector('rtl')
|
||||
});
|
||||
};
|
||||
var Buttons = { register: register$1 };
|
||||
|
||||
global.add('directionality', function (editor) {
|
||||
Commands.register(editor);
|
||||
Buttons.register(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
return Plugin;
|
||||
|
||||
}());
|
||||
})();
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/directionality/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/directionality/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),c=tinymce.util.Tools.resolve("tinymce.util.Tools"),e=function(t,e){var i,n=t.dom,o=t.selection.getSelectedBlocks();o.length&&(i=n.getAttrib(o[0],"dir"),c.each(o,function(t){n.getParent(t.parentNode,'*[dir="'+e+'"]',n.getRoot())||n.setAttrib(t,"dir",i!==e?e:null)}),t.nodeChanged())},i=function(t){t.addCommand("mceDirectionLTR",function(){e(t,"ltr")}),t.addCommand("mceDirectionRTL",function(){e(t,"rtl")})},n=function(e){var i=[];return c.each("h1 h2 h3 h4 h5 h6 div p".split(" "),function(t){i.push(t+"[dir="+e+"]")}),i.join(",")},o=function(t){t.addButton("ltr",{title:"Left to right",cmd:"mceDirectionLTR",stateSelector:n("ltr")}),t.addButton("rtl",{title:"Right to left",cmd:"mceDirectionRTL",stateSelector:n("rtl")})};t.add("directionality",function(t){i(t),o(t)})}();
|
@ -0,0 +1,177 @@
|
||||
(function () {
|
||||
var fullscreen = (function (domGlobals) {
|
||||
'use strict';
|
||||
|
||||
var Cell = function (initial) {
|
||||
var value = initial;
|
||||
var get = function () {
|
||||
return value;
|
||||
};
|
||||
var set = function (v) {
|
||||
value = v;
|
||||
};
|
||||
var clone = function () {
|
||||
return Cell(get());
|
||||
};
|
||||
return {
|
||||
get: get,
|
||||
set: set,
|
||||
clone: clone
|
||||
};
|
||||
};
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
var get = function (fullscreenState) {
|
||||
return {
|
||||
isFullscreen: function () {
|
||||
return fullscreenState.get() !== null;
|
||||
}
|
||||
};
|
||||
};
|
||||
var Api = { get: get };
|
||||
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
||||
|
||||
var fireFullscreenStateChanged = function (editor, state) {
|
||||
editor.fire('FullscreenStateChanged', { state: state });
|
||||
};
|
||||
var Events = { fireFullscreenStateChanged: fireFullscreenStateChanged };
|
||||
|
||||
var DOM = global$1.DOM;
|
||||
var getWindowSize = function () {
|
||||
var w;
|
||||
var h;
|
||||
var win = domGlobals.window;
|
||||
var doc = domGlobals.document;
|
||||
var body = doc.body;
|
||||
if (body.offsetWidth) {
|
||||
w = body.offsetWidth;
|
||||
h = body.offsetHeight;
|
||||
}
|
||||
if (win.innerWidth && win.innerHeight) {
|
||||
w = win.innerWidth;
|
||||
h = win.innerHeight;
|
||||
}
|
||||
return {
|
||||
w: w,
|
||||
h: h
|
||||
};
|
||||
};
|
||||
var getScrollPos = function () {
|
||||
var vp = DOM.getViewPort();
|
||||
return {
|
||||
x: vp.x,
|
||||
y: vp.y
|
||||
};
|
||||
};
|
||||
var setScrollPos = function (pos) {
|
||||
domGlobals.window.scrollTo(pos.x, pos.y);
|
||||
};
|
||||
var toggleFullscreen = function (editor, fullscreenState) {
|
||||
var body = domGlobals.document.body;
|
||||
var documentElement = domGlobals.document.documentElement;
|
||||
var editorContainerStyle;
|
||||
var editorContainer, iframe, iframeStyle;
|
||||
var fullscreenInfo = fullscreenState.get();
|
||||
var resize = function () {
|
||||
DOM.setStyle(iframe, 'height', getWindowSize().h - (editorContainer.clientHeight - iframe.clientHeight));
|
||||
};
|
||||
var removeResize = function () {
|
||||
DOM.unbind(domGlobals.window, 'resize', resize);
|
||||
};
|
||||
editorContainer = editor.getContainer();
|
||||
editorContainerStyle = editorContainer.style;
|
||||
iframe = editor.getContentAreaContainer().firstChild;
|
||||
iframeStyle = iframe.style;
|
||||
if (!fullscreenInfo) {
|
||||
var newFullScreenInfo = {
|
||||
scrollPos: getScrollPos(),
|
||||
containerWidth: editorContainerStyle.width,
|
||||
containerHeight: editorContainerStyle.height,
|
||||
iframeWidth: iframeStyle.width,
|
||||
iframeHeight: iframeStyle.height,
|
||||
resizeHandler: resize,
|
||||
removeHandler: removeResize
|
||||
};
|
||||
iframeStyle.width = iframeStyle.height = '100%';
|
||||
editorContainerStyle.width = editorContainerStyle.height = '';
|
||||
DOM.addClass(body, 'mce-fullscreen');
|
||||
DOM.addClass(documentElement, 'mce-fullscreen');
|
||||
DOM.addClass(editorContainer, 'mce-fullscreen');
|
||||
DOM.bind(domGlobals.window, 'resize', resize);
|
||||
editor.on('remove', removeResize);
|
||||
resize();
|
||||
fullscreenState.set(newFullScreenInfo);
|
||||
Events.fireFullscreenStateChanged(editor, true);
|
||||
} else {
|
||||
iframeStyle.width = fullscreenInfo.iframeWidth;
|
||||
iframeStyle.height = fullscreenInfo.iframeHeight;
|
||||
if (fullscreenInfo.containerWidth) {
|
||||
editorContainerStyle.width = fullscreenInfo.containerWidth;
|
||||
}
|
||||
if (fullscreenInfo.containerHeight) {
|
||||
editorContainerStyle.height = fullscreenInfo.containerHeight;
|
||||
}
|
||||
DOM.removeClass(body, 'mce-fullscreen');
|
||||
DOM.removeClass(documentElement, 'mce-fullscreen');
|
||||
DOM.removeClass(editorContainer, 'mce-fullscreen');
|
||||
setScrollPos(fullscreenInfo.scrollPos);
|
||||
DOM.unbind(domGlobals.window, 'resize', fullscreenInfo.resizeHandler);
|
||||
editor.off('remove', fullscreenInfo.removeHandler);
|
||||
fullscreenState.set(null);
|
||||
Events.fireFullscreenStateChanged(editor, false);
|
||||
}
|
||||
};
|
||||
var Actions = { toggleFullscreen: toggleFullscreen };
|
||||
|
||||
var register = function (editor, fullscreenState) {
|
||||
editor.addCommand('mceFullScreen', function () {
|
||||
Actions.toggleFullscreen(editor, fullscreenState);
|
||||
});
|
||||
};
|
||||
var Commands = { register: register };
|
||||
|
||||
var postRender = function (editor) {
|
||||
return function (e) {
|
||||
var ctrl = e.control;
|
||||
editor.on('FullscreenStateChanged', function (e) {
|
||||
ctrl.active(e.state);
|
||||
});
|
||||
};
|
||||
};
|
||||
var register$1 = function (editor) {
|
||||
editor.addMenuItem('fullscreen', {
|
||||
text: 'Fullscreen',
|
||||
shortcut: 'Ctrl+Shift+F',
|
||||
selectable: true,
|
||||
cmd: 'mceFullScreen',
|
||||
onPostRender: postRender(editor),
|
||||
context: 'view'
|
||||
});
|
||||
editor.addButton('fullscreen', {
|
||||
active: false,
|
||||
tooltip: 'Fullscreen',
|
||||
cmd: 'mceFullScreen',
|
||||
onPostRender: postRender(editor)
|
||||
});
|
||||
};
|
||||
var Buttons = { register: register$1 };
|
||||
|
||||
global.add('fullscreen', function (editor) {
|
||||
var fullscreenState = Cell(null);
|
||||
if (editor.settings.inline) {
|
||||
return Api.get(fullscreenState);
|
||||
}
|
||||
Commands.register(editor, fullscreenState);
|
||||
Buttons.register(editor);
|
||||
editor.addShortcut('Ctrl+Shift+F', '', 'mceFullScreen');
|
||||
return Api.get(fullscreenState);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
return Plugin;
|
||||
|
||||
}(window));
|
||||
})();
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/fullscreen/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/fullscreen/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(m){"use strict";var i=function(e){var n=e,t=function(){return n};return{get:t,set:function(e){n=e},clone:function(){return i(t())}}},e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=function(e){return{isFullscreen:function(){return null!==e.get()}}},n=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),g=function(e,n){e.fire("FullscreenStateChanged",{state:n})},w=n.DOM,r=function(e,n){var t,r,l,i,o,c,s=m.document.body,u=m.document.documentElement,d=n.get(),a=function(){var e,n,t,i;w.setStyle(l,"height",(t=m.window,i=m.document.body,i.offsetWidth&&(e=i.offsetWidth,n=i.offsetHeight),t.innerWidth&&t.innerHeight&&(e=t.innerWidth,n=t.innerHeight),{w:e,h:n}).h-(r.clientHeight-l.clientHeight))},h=function(){w.unbind(m.window,"resize",a)};if(t=(r=e.getContainer()).style,i=(l=e.getContentAreaContainer().firstChild).style,d)i.width=d.iframeWidth,i.height=d.iframeHeight,d.containerWidth&&(t.width=d.containerWidth),d.containerHeight&&(t.height=d.containerHeight),w.removeClass(s,"mce-fullscreen"),w.removeClass(u,"mce-fullscreen"),w.removeClass(r,"mce-fullscreen"),o=d.scrollPos,m.window.scrollTo(o.x,o.y),w.unbind(m.window,"resize",d.resizeHandler),e.off("remove",d.removeHandler),n.set(null),g(e,!1);else{var f={scrollPos:(c=w.getViewPort(),{x:c.x,y:c.y}),containerWidth:t.width,containerHeight:t.height,iframeWidth:i.width,iframeHeight:i.height,resizeHandler:a,removeHandler:h};i.width=i.height="100%",t.width=t.height="",w.addClass(s,"mce-fullscreen"),w.addClass(u,"mce-fullscreen"),w.addClass(r,"mce-fullscreen"),w.bind(m.window,"resize",a),e.on("remove",h),a(),n.set(f),g(e,!0)}},l=function(e,n){e.addCommand("mceFullScreen",function(){r(e,n)})},o=function(t){return function(e){var n=e.control;t.on("FullscreenStateChanged",function(e){n.active(e.state)})}},c=function(e){e.addMenuItem("fullscreen",{text:"Fullscreen",shortcut:"Ctrl+Shift+F",selectable:!0,cmd:"mceFullScreen",onPostRender:o(e),context:"view"}),e.addButton("fullscreen",{active:!1,tooltip:"Fullscreen",cmd:"mceFullScreen",onPostRender:o(e)})};e.add("fullscreen",function(e){var n=i(null);return e.settings.inline||(l(e,n),c(e),e.addShortcut("Ctrl+Shift+F","","mceFullScreen")),t(n)})}(window);
|
39
hamrokhaanpaan/wp-includes/js/tinymce/plugins/hr/plugin.js
Normal file
39
hamrokhaanpaan/wp-includes/js/tinymce/plugins/hr/plugin.js
Normal file
@ -0,0 +1,39 @@
|
||||
(function () {
|
||||
var hr = (function () {
|
||||
'use strict';
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
var register = function (editor) {
|
||||
editor.addCommand('InsertHorizontalRule', function () {
|
||||
editor.execCommand('mceInsertContent', false, '<hr />');
|
||||
});
|
||||
};
|
||||
var Commands = { register: register };
|
||||
|
||||
var register$1 = function (editor) {
|
||||
editor.addButton('hr', {
|
||||
icon: 'hr',
|
||||
tooltip: 'Horizontal line',
|
||||
cmd: 'InsertHorizontalRule'
|
||||
});
|
||||
editor.addMenuItem('hr', {
|
||||
icon: 'hr',
|
||||
text: 'Horizontal line',
|
||||
cmd: 'InsertHorizontalRule',
|
||||
context: 'insert'
|
||||
});
|
||||
};
|
||||
var Buttons = { register: register$1 };
|
||||
|
||||
global.add('hr', function (editor) {
|
||||
Commands.register(editor);
|
||||
Buttons.register(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
return Plugin;
|
||||
|
||||
}());
|
||||
})();
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/hr/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/hr/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(){"use strict";var n=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=function(n){n.addCommand("InsertHorizontalRule",function(){n.execCommand("mceInsertContent",!1,"<hr />")})},o=function(n){n.addButton("hr",{icon:"hr",tooltip:"Horizontal line",cmd:"InsertHorizontalRule"}),n.addMenuItem("hr",{icon:"hr",text:"Horizontal line",cmd:"InsertHorizontalRule",context:"insert"})};n.add("hr",function(n){t(n),o(n)})}();
|
1209
hamrokhaanpaan/wp-includes/js/tinymce/plugins/image/plugin.js
Normal file
1209
hamrokhaanpaan/wp-includes/js/tinymce/plugins/image/plugin.js
Normal file
File diff suppressed because it is too large
Load Diff
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/image/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/image/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
713
hamrokhaanpaan/wp-includes/js/tinymce/plugins/link/plugin.js
Normal file
713
hamrokhaanpaan/wp-includes/js/tinymce/plugins/link/plugin.js
Normal file
@ -0,0 +1,713 @@
|
||||
(function () {
|
||||
var link = (function (domGlobals) {
|
||||
'use strict';
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.util.VK');
|
||||
|
||||
var assumeExternalTargets = function (editorSettings) {
|
||||
return typeof editorSettings.link_assume_external_targets === 'boolean' ? editorSettings.link_assume_external_targets : false;
|
||||
};
|
||||
var hasContextToolbar = function (editorSettings) {
|
||||
return typeof editorSettings.link_context_toolbar === 'boolean' ? editorSettings.link_context_toolbar : false;
|
||||
};
|
||||
var getLinkList = function (editorSettings) {
|
||||
return editorSettings.link_list;
|
||||
};
|
||||
var hasDefaultLinkTarget = function (editorSettings) {
|
||||
return typeof editorSettings.default_link_target === 'string';
|
||||
};
|
||||
var getDefaultLinkTarget = function (editorSettings) {
|
||||
return editorSettings.default_link_target;
|
||||
};
|
||||
var getTargetList = function (editorSettings) {
|
||||
return editorSettings.target_list;
|
||||
};
|
||||
var setTargetList = function (editor, list) {
|
||||
editor.settings.target_list = list;
|
||||
};
|
||||
var shouldShowTargetList = function (editorSettings) {
|
||||
return getTargetList(editorSettings) !== false;
|
||||
};
|
||||
var getRelList = function (editorSettings) {
|
||||
return editorSettings.rel_list;
|
||||
};
|
||||
var hasRelList = function (editorSettings) {
|
||||
return getRelList(editorSettings) !== undefined;
|
||||
};
|
||||
var getLinkClassList = function (editorSettings) {
|
||||
return editorSettings.link_class_list;
|
||||
};
|
||||
var hasLinkClassList = function (editorSettings) {
|
||||
return getLinkClassList(editorSettings) !== undefined;
|
||||
};
|
||||
var shouldShowLinkTitle = function (editorSettings) {
|
||||
return editorSettings.link_title !== false;
|
||||
};
|
||||
var allowUnsafeLinkTarget = function (editorSettings) {
|
||||
return typeof editorSettings.allow_unsafe_link_target === 'boolean' ? editorSettings.allow_unsafe_link_target : false;
|
||||
};
|
||||
var Settings = {
|
||||
assumeExternalTargets: assumeExternalTargets,
|
||||
hasContextToolbar: hasContextToolbar,
|
||||
getLinkList: getLinkList,
|
||||
hasDefaultLinkTarget: hasDefaultLinkTarget,
|
||||
getDefaultLinkTarget: getDefaultLinkTarget,
|
||||
getTargetList: getTargetList,
|
||||
setTargetList: setTargetList,
|
||||
shouldShowTargetList: shouldShowTargetList,
|
||||
getRelList: getRelList,
|
||||
hasRelList: hasRelList,
|
||||
getLinkClassList: getLinkClassList,
|
||||
hasLinkClassList: hasLinkClassList,
|
||||
shouldShowLinkTitle: shouldShowLinkTitle,
|
||||
allowUnsafeLinkTarget: allowUnsafeLinkTarget
|
||||
};
|
||||
|
||||
var global$2 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
||||
|
||||
var global$3 = tinymce.util.Tools.resolve('tinymce.Env');
|
||||
|
||||
var appendClickRemove = function (link, evt) {
|
||||
domGlobals.document.body.appendChild(link);
|
||||
link.dispatchEvent(evt);
|
||||
domGlobals.document.body.removeChild(link);
|
||||
};
|
||||
var open = function (url) {
|
||||
if (!global$3.ie || global$3.ie > 10) {
|
||||
var link = domGlobals.document.createElement('a');
|
||||
link.target = '_blank';
|
||||
link.href = url;
|
||||
link.rel = 'noreferrer noopener';
|
||||
var evt = domGlobals.document.createEvent('MouseEvents');
|
||||
evt.initMouseEvent('click', true, true, domGlobals.window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
appendClickRemove(link, evt);
|
||||
} else {
|
||||
var win = domGlobals.window.open('', '_blank');
|
||||
if (win) {
|
||||
win.opener = null;
|
||||
var doc = win.document;
|
||||
doc.open();
|
||||
doc.write('<meta http-equiv="refresh" content="0; url=' + global$2.DOM.encode(url) + '">');
|
||||
doc.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
var OpenUrl = { open: open };
|
||||
|
||||
var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
var toggleTargetRules = function (rel, isUnsafe) {
|
||||
var rules = ['noopener'];
|
||||
var newRel = rel ? rel.split(/\s+/) : [];
|
||||
var toString = function (rel) {
|
||||
return global$4.trim(rel.sort().join(' '));
|
||||
};
|
||||
var addTargetRules = function (rel) {
|
||||
rel = removeTargetRules(rel);
|
||||
return rel.length ? rel.concat(rules) : rules;
|
||||
};
|
||||
var removeTargetRules = function (rel) {
|
||||
return rel.filter(function (val) {
|
||||
return global$4.inArray(rules, val) === -1;
|
||||
});
|
||||
};
|
||||
newRel = isUnsafe ? addTargetRules(newRel) : removeTargetRules(newRel);
|
||||
return newRel.length ? toString(newRel) : null;
|
||||
};
|
||||
var trimCaretContainers = function (text) {
|
||||
return text.replace(/\uFEFF/g, '');
|
||||
};
|
||||
var getAnchorElement = function (editor, selectedElm) {
|
||||
selectedElm = selectedElm || editor.selection.getNode();
|
||||
if (isImageFigure(selectedElm)) {
|
||||
return editor.dom.select('a[href]', selectedElm)[0];
|
||||
} else {
|
||||
return editor.dom.getParent(selectedElm, 'a[href]');
|
||||
}
|
||||
};
|
||||
var getAnchorText = function (selection, anchorElm) {
|
||||
var text = anchorElm ? anchorElm.innerText || anchorElm.textContent : selection.getContent({ format: 'text' });
|
||||
return trimCaretContainers(text);
|
||||
};
|
||||
var isLink = function (elm) {
|
||||
return elm && elm.nodeName === 'A' && elm.href;
|
||||
};
|
||||
var hasLinks = function (elements) {
|
||||
return global$4.grep(elements, isLink).length > 0;
|
||||
};
|
||||
var isOnlyTextSelected = function (html) {
|
||||
if (/</.test(html) && (!/^<a [^>]+>[^<]+<\/a>$/.test(html) || html.indexOf('href=') === -1)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
var isImageFigure = function (node) {
|
||||
return node && node.nodeName === 'FIGURE' && /\bimage\b/i.test(node.className);
|
||||
};
|
||||
var link = function (editor, attachState) {
|
||||
return function (data) {
|
||||
editor.undoManager.transact(function () {
|
||||
var selectedElm = editor.selection.getNode();
|
||||
var anchorElm = getAnchorElement(editor, selectedElm);
|
||||
var linkAttrs = {
|
||||
href: data.href,
|
||||
target: data.target ? data.target : null,
|
||||
rel: data.rel ? data.rel : null,
|
||||
class: data.class ? data.class : null,
|
||||
title: data.title ? data.title : null
|
||||
};
|
||||
if (!Settings.hasRelList(editor.settings) && Settings.allowUnsafeLinkTarget(editor.settings) === false) {
|
||||
linkAttrs.rel = toggleTargetRules(linkAttrs.rel, linkAttrs.target === '_blank');
|
||||
}
|
||||
if (data.href === attachState.href) {
|
||||
attachState.attach();
|
||||
attachState = {};
|
||||
}
|
||||
if (anchorElm) {
|
||||
editor.focus();
|
||||
if (data.hasOwnProperty('text')) {
|
||||
if ('innerText' in anchorElm) {
|
||||
anchorElm.innerText = data.text;
|
||||
} else {
|
||||
anchorElm.textContent = data.text;
|
||||
}
|
||||
}
|
||||
editor.dom.setAttribs(anchorElm, linkAttrs);
|
||||
editor.selection.select(anchorElm);
|
||||
editor.undoManager.add();
|
||||
} else {
|
||||
if (isImageFigure(selectedElm)) {
|
||||
linkImageFigure(editor, selectedElm, linkAttrs);
|
||||
} else if (data.hasOwnProperty('text')) {
|
||||
editor.insertContent(editor.dom.createHTML('a', linkAttrs, editor.dom.encode(data.text)));
|
||||
} else {
|
||||
editor.execCommand('mceInsertLink', false, linkAttrs);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
var unlink = function (editor) {
|
||||
return function () {
|
||||
editor.undoManager.transact(function () {
|
||||
var node = editor.selection.getNode();
|
||||
if (isImageFigure(node)) {
|
||||
unlinkImageFigure(editor, node);
|
||||
} else {
|
||||
editor.execCommand('unlink');
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
var unlinkImageFigure = function (editor, fig) {
|
||||
var a, img;
|
||||
img = editor.dom.select('img', fig)[0];
|
||||
if (img) {
|
||||
a = editor.dom.getParents(img, 'a[href]', fig)[0];
|
||||
if (a) {
|
||||
a.parentNode.insertBefore(img, a);
|
||||
editor.dom.remove(a);
|
||||
}
|
||||
}
|
||||
};
|
||||
var linkImageFigure = function (editor, fig, attrs) {
|
||||
var a, img;
|
||||
img = editor.dom.select('img', fig)[0];
|
||||
if (img) {
|
||||
a = editor.dom.create('a', attrs);
|
||||
img.parentNode.insertBefore(a, img);
|
||||
a.appendChild(img);
|
||||
}
|
||||
};
|
||||
var Utils = {
|
||||
link: link,
|
||||
unlink: unlink,
|
||||
isLink: isLink,
|
||||
hasLinks: hasLinks,
|
||||
isOnlyTextSelected: isOnlyTextSelected,
|
||||
getAnchorElement: getAnchorElement,
|
||||
getAnchorText: getAnchorText,
|
||||
toggleTargetRules: toggleTargetRules
|
||||
};
|
||||
|
||||
var global$5 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
||||
|
||||
var global$6 = tinymce.util.Tools.resolve('tinymce.util.XHR');
|
||||
|
||||
var attachState = {};
|
||||
var createLinkList = function (editor, callback) {
|
||||
var linkList = Settings.getLinkList(editor.settings);
|
||||
if (typeof linkList === 'string') {
|
||||
global$6.send({
|
||||
url: linkList,
|
||||
success: function (text) {
|
||||
callback(editor, JSON.parse(text));
|
||||
}
|
||||
});
|
||||
} else if (typeof linkList === 'function') {
|
||||
linkList(function (list) {
|
||||
callback(editor, list);
|
||||
});
|
||||
} else {
|
||||
callback(editor, linkList);
|
||||
}
|
||||
};
|
||||
var buildListItems = function (inputList, itemCallback, startItems) {
|
||||
var appendItems = function (values, output) {
|
||||
output = output || [];
|
||||
global$4.each(values, function (item) {
|
||||
var menuItem = { text: item.text || item.title };
|
||||
if (item.menu) {
|
||||
menuItem.menu = appendItems(item.menu);
|
||||
} else {
|
||||
menuItem.value = item.value;
|
||||
if (itemCallback) {
|
||||
itemCallback(menuItem);
|
||||
}
|
||||
}
|
||||
output.push(menuItem);
|
||||
});
|
||||
return output;
|
||||
};
|
||||
return appendItems(inputList, startItems || []);
|
||||
};
|
||||
var delayedConfirm = function (editor, message, callback) {
|
||||
var rng = editor.selection.getRng();
|
||||
global$5.setEditorTimeout(editor, function () {
|
||||
editor.windowManager.confirm(message, function (state) {
|
||||
editor.selection.setRng(rng);
|
||||
callback(state);
|
||||
});
|
||||
});
|
||||
};
|
||||
var showDialog = function (editor, linkList) {
|
||||
var data = {};
|
||||
var selection = editor.selection;
|
||||
var dom = editor.dom;
|
||||
var anchorElm, initialText;
|
||||
var win, onlyText, textListCtrl, linkListCtrl, relListCtrl, targetListCtrl, classListCtrl, linkTitleCtrl, value;
|
||||
var linkListChangeHandler = function (e) {
|
||||
var textCtrl = win.find('#text');
|
||||
if (!textCtrl.value() || e.lastControl && textCtrl.value() === e.lastControl.text()) {
|
||||
textCtrl.value(e.control.text());
|
||||
}
|
||||
win.find('#href').value(e.control.value());
|
||||
};
|
||||
var buildAnchorListControl = function (url) {
|
||||
var anchorList = [];
|
||||
global$4.each(editor.dom.select('a:not([href])'), function (anchor) {
|
||||
var id = anchor.name || anchor.id;
|
||||
if (id) {
|
||||
anchorList.push({
|
||||
text: id,
|
||||
value: '#' + id,
|
||||
selected: url.indexOf('#' + id) !== -1
|
||||
});
|
||||
}
|
||||
});
|
||||
if (anchorList.length) {
|
||||
anchorList.unshift({
|
||||
text: 'None',
|
||||
value: ''
|
||||
});
|
||||
return {
|
||||
name: 'anchor',
|
||||
type: 'listbox',
|
||||
label: 'Anchors',
|
||||
values: anchorList,
|
||||
onselect: linkListChangeHandler
|
||||
};
|
||||
}
|
||||
};
|
||||
var updateText = function () {
|
||||
if (!initialText && onlyText && !data.text) {
|
||||
this.parent().parent().find('#text')[0].value(this.value());
|
||||
}
|
||||
};
|
||||
var urlChange = function (e) {
|
||||
var meta = e.meta || {};
|
||||
if (linkListCtrl) {
|
||||
linkListCtrl.value(editor.convertURL(this.value(), 'href'));
|
||||
}
|
||||
global$4.each(e.meta, function (value, key) {
|
||||
var inp = win.find('#' + key);
|
||||
if (key === 'text') {
|
||||
if (initialText.length === 0) {
|
||||
inp.value(value);
|
||||
data.text = value;
|
||||
}
|
||||
} else {
|
||||
inp.value(value);
|
||||
}
|
||||
});
|
||||
if (meta.attach) {
|
||||
attachState = {
|
||||
href: this.value(),
|
||||
attach: meta.attach
|
||||
};
|
||||
}
|
||||
if (!meta.text) {
|
||||
updateText.call(this);
|
||||
}
|
||||
};
|
||||
var onBeforeCall = function (e) {
|
||||
e.meta = win.toJSON();
|
||||
};
|
||||
onlyText = Utils.isOnlyTextSelected(selection.getContent());
|
||||
anchorElm = Utils.getAnchorElement(editor);
|
||||
data.text = initialText = Utils.getAnchorText(editor.selection, anchorElm);
|
||||
data.href = anchorElm ? dom.getAttrib(anchorElm, 'href') : '';
|
||||
if (anchorElm) {
|
||||
data.target = dom.getAttrib(anchorElm, 'target');
|
||||
} else if (Settings.hasDefaultLinkTarget(editor.settings)) {
|
||||
data.target = Settings.getDefaultLinkTarget(editor.settings);
|
||||
}
|
||||
if (value = dom.getAttrib(anchorElm, 'rel')) {
|
||||
data.rel = value;
|
||||
}
|
||||
if (value = dom.getAttrib(anchorElm, 'class')) {
|
||||
data.class = value;
|
||||
}
|
||||
if (value = dom.getAttrib(anchorElm, 'title')) {
|
||||
data.title = value;
|
||||
}
|
||||
if (onlyText) {
|
||||
textListCtrl = {
|
||||
name: 'text',
|
||||
type: 'textbox',
|
||||
size: 40,
|
||||
label: 'Text to display',
|
||||
onchange: function () {
|
||||
data.text = this.value();
|
||||
}
|
||||
};
|
||||
}
|
||||
if (linkList) {
|
||||
linkListCtrl = {
|
||||
type: 'listbox',
|
||||
label: 'Link list',
|
||||
values: buildListItems(linkList, function (item) {
|
||||
item.value = editor.convertURL(item.value || item.url, 'href');
|
||||
}, [{
|
||||
text: 'None',
|
||||
value: ''
|
||||
}]),
|
||||
onselect: linkListChangeHandler,
|
||||
value: editor.convertURL(data.href, 'href'),
|
||||
onPostRender: function () {
|
||||
linkListCtrl = this;
|
||||
}
|
||||
};
|
||||
}
|
||||
if (Settings.shouldShowTargetList(editor.settings)) {
|
||||
if (Settings.getTargetList(editor.settings) === undefined) {
|
||||
Settings.setTargetList(editor, [
|
||||
{
|
||||
text: 'None',
|
||||
value: ''
|
||||
},
|
||||
{
|
||||
text: 'New window',
|
||||
value: '_blank'
|
||||
}
|
||||
]);
|
||||
}
|
||||
targetListCtrl = {
|
||||
name: 'target',
|
||||
type: 'listbox',
|
||||
label: 'Target',
|
||||
values: buildListItems(Settings.getTargetList(editor.settings))
|
||||
};
|
||||
}
|
||||
if (Settings.hasRelList(editor.settings)) {
|
||||
relListCtrl = {
|
||||
name: 'rel',
|
||||
type: 'listbox',
|
||||
label: 'Rel',
|
||||
values: buildListItems(Settings.getRelList(editor.settings), function (item) {
|
||||
if (Settings.allowUnsafeLinkTarget(editor.settings) === false) {
|
||||
item.value = Utils.toggleTargetRules(item.value, data.target === '_blank');
|
||||
}
|
||||
})
|
||||
};
|
||||
}
|
||||
if (Settings.hasLinkClassList(editor.settings)) {
|
||||
classListCtrl = {
|
||||
name: 'class',
|
||||
type: 'listbox',
|
||||
label: 'Class',
|
||||
values: buildListItems(Settings.getLinkClassList(editor.settings), function (item) {
|
||||
if (item.value) {
|
||||
item.textStyle = function () {
|
||||
return editor.formatter.getCssText({
|
||||
inline: 'a',
|
||||
classes: [item.value]
|
||||
});
|
||||
};
|
||||
}
|
||||
})
|
||||
};
|
||||
}
|
||||
if (Settings.shouldShowLinkTitle(editor.settings)) {
|
||||
linkTitleCtrl = {
|
||||
name: 'title',
|
||||
type: 'textbox',
|
||||
label: 'Title',
|
||||
value: data.title
|
||||
};
|
||||
}
|
||||
win = editor.windowManager.open({
|
||||
title: 'Insert link',
|
||||
data: data,
|
||||
body: [
|
||||
{
|
||||
name: 'href',
|
||||
type: 'filepicker',
|
||||
filetype: 'file',
|
||||
size: 40,
|
||||
autofocus: true,
|
||||
label: 'Url',
|
||||
onchange: urlChange,
|
||||
onkeyup: updateText,
|
||||
onpaste: updateText,
|
||||
onbeforecall: onBeforeCall
|
||||
},
|
||||
textListCtrl,
|
||||
linkTitleCtrl,
|
||||
buildAnchorListControl(data.href),
|
||||
linkListCtrl,
|
||||
relListCtrl,
|
||||
targetListCtrl,
|
||||
classListCtrl
|
||||
],
|
||||
onSubmit: function (e) {
|
||||
var assumeExternalTargets = Settings.assumeExternalTargets(editor.settings);
|
||||
var insertLink = Utils.link(editor, attachState);
|
||||
var removeLink = Utils.unlink(editor);
|
||||
var resultData = global$4.extend({}, data, e.data);
|
||||
var href = resultData.href;
|
||||
if (!href) {
|
||||
removeLink();
|
||||
return;
|
||||
}
|
||||
if (!onlyText || resultData.text === initialText) {
|
||||
delete resultData.text;
|
||||
}
|
||||
if (href.indexOf('@') > 0 && href.indexOf('//') === -1 && href.indexOf('mailto:') === -1) {
|
||||
delayedConfirm(editor, 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?', function (state) {
|
||||
if (state) {
|
||||
resultData.href = 'mailto:' + href;
|
||||
}
|
||||
insertLink(resultData);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (assumeExternalTargets === true && !/^\w+:/i.test(href) || assumeExternalTargets === false && /^\s*www[\.|\d\.]/i.test(href)) {
|
||||
delayedConfirm(editor, 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?', function (state) {
|
||||
if (state) {
|
||||
resultData.href = 'http://' + href;
|
||||
}
|
||||
insertLink(resultData);
|
||||
});
|
||||
return;
|
||||
}
|
||||
insertLink(resultData);
|
||||
}
|
||||
});
|
||||
};
|
||||
var open$1 = function (editor) {
|
||||
createLinkList(editor, showDialog);
|
||||
};
|
||||
var Dialog = { open: open$1 };
|
||||
|
||||
var getLink = function (editor, elm) {
|
||||
return editor.dom.getParent(elm, 'a[href]');
|
||||
};
|
||||
var getSelectedLink = function (editor) {
|
||||
return getLink(editor, editor.selection.getStart());
|
||||
};
|
||||
var getHref = function (elm) {
|
||||
var href = elm.getAttribute('data-mce-href');
|
||||
return href ? href : elm.getAttribute('href');
|
||||
};
|
||||
var isContextMenuVisible = function (editor) {
|
||||
var contextmenu = editor.plugins.contextmenu;
|
||||
return contextmenu ? contextmenu.isContextMenuVisible() : false;
|
||||
};
|
||||
var hasOnlyAltModifier = function (e) {
|
||||
return e.altKey === true && e.shiftKey === false && e.ctrlKey === false && e.metaKey === false;
|
||||
};
|
||||
var gotoLink = function (editor, a) {
|
||||
if (a) {
|
||||
var href = getHref(a);
|
||||
if (/^#/.test(href)) {
|
||||
var targetEl = editor.$(href);
|
||||
if (targetEl.length) {
|
||||
editor.selection.scrollIntoView(targetEl[0], true);
|
||||
}
|
||||
} else {
|
||||
OpenUrl.open(a.href);
|
||||
}
|
||||
}
|
||||
};
|
||||
var openDialog = function (editor) {
|
||||
return function () {
|
||||
Dialog.open(editor);
|
||||
};
|
||||
};
|
||||
var gotoSelectedLink = function (editor) {
|
||||
return function () {
|
||||
gotoLink(editor, getSelectedLink(editor));
|
||||
};
|
||||
};
|
||||
var leftClickedOnAHref = function (editor) {
|
||||
return function (elm) {
|
||||
var sel, rng, node;
|
||||
if (Settings.hasContextToolbar(editor.settings) && !isContextMenuVisible(editor) && Utils.isLink(elm)) {
|
||||
sel = editor.selection;
|
||||
rng = sel.getRng();
|
||||
node = rng.startContainer;
|
||||
if (node.nodeType === 3 && sel.isCollapsed() && rng.startOffset > 0 && rng.startOffset < node.data.length) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
};
|
||||
var setupGotoLinks = function (editor) {
|
||||
editor.on('click', function (e) {
|
||||
var link = getLink(editor, e.target);
|
||||
if (link && global$1.metaKeyPressed(e)) {
|
||||
e.preventDefault();
|
||||
gotoLink(editor, link);
|
||||
}
|
||||
});
|
||||
editor.on('keydown', function (e) {
|
||||
var link = getSelectedLink(editor);
|
||||
if (link && e.keyCode === 13 && hasOnlyAltModifier(e)) {
|
||||
e.preventDefault();
|
||||
gotoLink(editor, link);
|
||||
}
|
||||
});
|
||||
};
|
||||
var toggleActiveState = function (editor) {
|
||||
return function () {
|
||||
var self = this;
|
||||
editor.on('nodechange', function (e) {
|
||||
self.active(!editor.readonly && !!Utils.getAnchorElement(editor, e.element));
|
||||
});
|
||||
};
|
||||
};
|
||||
var toggleViewLinkState = function (editor) {
|
||||
return function () {
|
||||
var self = this;
|
||||
var toggleVisibility = function (e) {
|
||||
if (Utils.hasLinks(e.parents)) {
|
||||
self.show();
|
||||
} else {
|
||||
self.hide();
|
||||
}
|
||||
};
|
||||
if (!Utils.hasLinks(editor.dom.getParents(editor.selection.getStart()))) {
|
||||
self.hide();
|
||||
}
|
||||
editor.on('nodechange', toggleVisibility);
|
||||
self.on('remove', function () {
|
||||
editor.off('nodechange', toggleVisibility);
|
||||
});
|
||||
};
|
||||
};
|
||||
var Actions = {
|
||||
openDialog: openDialog,
|
||||
gotoSelectedLink: gotoSelectedLink,
|
||||
leftClickedOnAHref: leftClickedOnAHref,
|
||||
setupGotoLinks: setupGotoLinks,
|
||||
toggleActiveState: toggleActiveState,
|
||||
toggleViewLinkState: toggleViewLinkState
|
||||
};
|
||||
|
||||
var register = function (editor) {
|
||||
editor.addCommand('mceLink', Actions.openDialog(editor));
|
||||
};
|
||||
var Commands = { register: register };
|
||||
|
||||
var setup = function (editor) {
|
||||
editor.addShortcut('Meta+K', '', Actions.openDialog(editor));
|
||||
};
|
||||
var Keyboard = { setup: setup };
|
||||
|
||||
var setupButtons = function (editor) {
|
||||
editor.addButton('link', {
|
||||
active: false,
|
||||
icon: 'link',
|
||||
tooltip: 'Insert/edit link',
|
||||
onclick: Actions.openDialog(editor),
|
||||
onpostrender: Actions.toggleActiveState(editor)
|
||||
});
|
||||
editor.addButton('unlink', {
|
||||
active: false,
|
||||
icon: 'unlink',
|
||||
tooltip: 'Remove link',
|
||||
onclick: Utils.unlink(editor),
|
||||
onpostrender: Actions.toggleActiveState(editor)
|
||||
});
|
||||
if (editor.addContextToolbar) {
|
||||
editor.addButton('openlink', {
|
||||
icon: 'newtab',
|
||||
tooltip: 'Open link',
|
||||
onclick: Actions.gotoSelectedLink(editor)
|
||||
});
|
||||
}
|
||||
};
|
||||
var setupMenuItems = function (editor) {
|
||||
editor.addMenuItem('openlink', {
|
||||
text: 'Open link',
|
||||
icon: 'newtab',
|
||||
onclick: Actions.gotoSelectedLink(editor),
|
||||
onPostRender: Actions.toggleViewLinkState(editor),
|
||||
prependToContext: true
|
||||
});
|
||||
editor.addMenuItem('link', {
|
||||
icon: 'link',
|
||||
text: 'Link',
|
||||
shortcut: 'Meta+K',
|
||||
onclick: Actions.openDialog(editor),
|
||||
stateSelector: 'a[href]',
|
||||
context: 'insert',
|
||||
prependToContext: true
|
||||
});
|
||||
editor.addMenuItem('unlink', {
|
||||
icon: 'unlink',
|
||||
text: 'Remove link',
|
||||
onclick: Utils.unlink(editor),
|
||||
stateSelector: 'a[href]'
|
||||
});
|
||||
};
|
||||
var setupContextToolbars = function (editor) {
|
||||
if (editor.addContextToolbar) {
|
||||
editor.addContextToolbar(Actions.leftClickedOnAHref(editor), 'openlink | link unlink');
|
||||
}
|
||||
};
|
||||
var Controls = {
|
||||
setupButtons: setupButtons,
|
||||
setupMenuItems: setupMenuItems,
|
||||
setupContextToolbars: setupContextToolbars
|
||||
};
|
||||
|
||||
global.add('link', function (editor) {
|
||||
Controls.setupButtons(editor);
|
||||
Controls.setupMenuItems(editor);
|
||||
Controls.setupContextToolbars(editor);
|
||||
Actions.setupGotoLinks(editor);
|
||||
Commands.register(editor);
|
||||
Keyboard.setup(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
return Plugin;
|
||||
|
||||
}(window));
|
||||
})();
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/link/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/link/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2148
hamrokhaanpaan/wp-includes/js/tinymce/plugins/lists/plugin.js
Normal file
2148
hamrokhaanpaan/wp-includes/js/tinymce/plugins/lists/plugin.js
Normal file
File diff suppressed because it is too large
Load Diff
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/lists/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/lists/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1306
hamrokhaanpaan/wp-includes/js/tinymce/plugins/media/plugin.js
Normal file
1306
hamrokhaanpaan/wp-includes/js/tinymce/plugins/media/plugin.js
Normal file
File diff suppressed because it is too large
Load Diff
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/media/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/media/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2367
hamrokhaanpaan/wp-includes/js/tinymce/plugins/paste/plugin.js
Normal file
2367
hamrokhaanpaan/wp-includes/js/tinymce/plugins/paste/plugin.js
Normal file
File diff suppressed because it is too large
Load Diff
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/paste/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/paste/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
124
hamrokhaanpaan/wp-includes/js/tinymce/plugins/tabfocus/plugin.js
Normal file
124
hamrokhaanpaan/wp-includes/js/tinymce/plugins/tabfocus/plugin.js
Normal file
@ -0,0 +1,124 @@
|
||||
(function () {
|
||||
var tabfocus = (function (domGlobals) {
|
||||
'use strict';
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
||||
|
||||
var global$2 = tinymce.util.Tools.resolve('tinymce.EditorManager');
|
||||
|
||||
var global$3 = tinymce.util.Tools.resolve('tinymce.Env');
|
||||
|
||||
var global$4 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
||||
|
||||
var global$5 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
var global$6 = tinymce.util.Tools.resolve('tinymce.util.VK');
|
||||
|
||||
var getTabFocusElements = function (editor) {
|
||||
return editor.getParam('tabfocus_elements', ':prev,:next');
|
||||
};
|
||||
var getTabFocus = function (editor) {
|
||||
return editor.getParam('tab_focus', getTabFocusElements(editor));
|
||||
};
|
||||
var Settings = { getTabFocus: getTabFocus };
|
||||
|
||||
var DOM = global$1.DOM;
|
||||
var tabCancel = function (e) {
|
||||
if (e.keyCode === global$6.TAB && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
var setup = function (editor) {
|
||||
function tabHandler(e) {
|
||||
var x, el, v, i;
|
||||
if (e.keyCode !== global$6.TAB || e.ctrlKey || e.altKey || e.metaKey || e.isDefaultPrevented()) {
|
||||
return;
|
||||
}
|
||||
function find(direction) {
|
||||
el = DOM.select(':input:enabled,*[tabindex]:not(iframe)');
|
||||
function canSelectRecursive(e) {
|
||||
return e.nodeName === 'BODY' || e.type !== 'hidden' && e.style.display !== 'none' && e.style.visibility !== 'hidden' && canSelectRecursive(e.parentNode);
|
||||
}
|
||||
function canSelect(el) {
|
||||
return /INPUT|TEXTAREA|BUTTON/.test(el.tagName) && global$2.get(e.id) && el.tabIndex !== -1 && canSelectRecursive(el);
|
||||
}
|
||||
global$5.each(el, function (e, i) {
|
||||
if (e.id === editor.id) {
|
||||
x = i;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (direction > 0) {
|
||||
for (i = x + 1; i < el.length; i++) {
|
||||
if (canSelect(el[i])) {
|
||||
return el[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = x - 1; i >= 0; i--) {
|
||||
if (canSelect(el[i])) {
|
||||
return el[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
v = global$5.explode(Settings.getTabFocus(editor));
|
||||
if (v.length === 1) {
|
||||
v[1] = v[0];
|
||||
v[0] = ':prev';
|
||||
}
|
||||
if (e.shiftKey) {
|
||||
if (v[0] === ':prev') {
|
||||
el = find(-1);
|
||||
} else {
|
||||
el = DOM.get(v[0]);
|
||||
}
|
||||
} else {
|
||||
if (v[1] === ':next') {
|
||||
el = find(1);
|
||||
} else {
|
||||
el = DOM.get(v[1]);
|
||||
}
|
||||
}
|
||||
if (el) {
|
||||
var focusEditor = global$2.get(el.id || el.name);
|
||||
if (el.id && focusEditor) {
|
||||
focusEditor.focus();
|
||||
} else {
|
||||
global$4.setTimeout(function () {
|
||||
if (!global$3.webkit) {
|
||||
domGlobals.window.focus();
|
||||
}
|
||||
el.focus();
|
||||
}, 10);
|
||||
}
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
editor.on('init', function () {
|
||||
if (editor.inline) {
|
||||
DOM.setAttrib(editor.getBody(), 'tabIndex', null);
|
||||
}
|
||||
editor.on('keyup', tabCancel);
|
||||
if (global$3.gecko) {
|
||||
editor.on('keypress keydown', tabHandler);
|
||||
} else {
|
||||
editor.on('keydown', tabHandler);
|
||||
}
|
||||
});
|
||||
};
|
||||
var Keyboard = { setup: setup };
|
||||
|
||||
global.add('tabfocus', function (editor) {
|
||||
Keyboard.setup(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
return Plugin;
|
||||
|
||||
}(window));
|
||||
})();
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/tabfocus/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/tabfocus/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(c){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),s=tinymce.util.Tools.resolve("tinymce.EditorManager"),a=tinymce.util.Tools.resolve("tinymce.Env"),y=tinymce.util.Tools.resolve("tinymce.util.Delay"),f=tinymce.util.Tools.resolve("tinymce.util.Tools"),d=tinymce.util.Tools.resolve("tinymce.util.VK"),m=function(e){return e.getParam("tab_focus",e.getParam("tabfocus_elements",":prev,:next"))},v=t.DOM,n=function(e){e.keyCode!==d.TAB||e.ctrlKey||e.altKey||e.metaKey||e.preventDefault()},i=function(r){function e(n){var i,o,e,l;if(!(n.keyCode!==d.TAB||n.ctrlKey||n.altKey||n.metaKey||n.isDefaultPrevented())&&(1===(e=f.explode(m(r))).length&&(e[1]=e[0],e[0]=":prev"),o=n.shiftKey?":prev"===e[0]?u(-1):v.get(e[0]):":next"===e[1]?u(1):v.get(e[1]))){var t=s.get(o.id||o.name);o.id&&t?t.focus():y.setTimeout(function(){a.webkit||c.window.focus(),o.focus()},10),n.preventDefault()}function u(e){function t(t){return/INPUT|TEXTAREA|BUTTON/.test(t.tagName)&&s.get(n.id)&&-1!==t.tabIndex&&function e(t){return"BODY"===t.nodeName||"hidden"!==t.type&&"none"!==t.style.display&&"hidden"!==t.style.visibility&&e(t.parentNode)}(t)}if(o=v.select(":input:enabled,*[tabindex]:not(iframe)"),f.each(o,function(e,t){if(e.id===r.id)return i=t,!1}),0<e){for(l=i+1;l<o.length;l++)if(t(o[l]))return o[l]}else for(l=i-1;0<=l;l--)if(t(o[l]))return o[l];return null}}r.on("init",function(){r.inline&&v.setAttrib(r.getBody(),"tabIndex",null),r.on("keyup",n),a.gecko?r.on("keypress keydown",e):r.on("keydown",e)})};e.add("tabfocus",function(e){i(e)})}(window);
|
@ -0,0 +1,346 @@
|
||||
(function () {
|
||||
var textcolor = (function () {
|
||||
'use strict';
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
var getCurrentColor = function (editor, format) {
|
||||
var color;
|
||||
editor.dom.getParents(editor.selection.getStart(), function (elm) {
|
||||
var value;
|
||||
if (value = elm.style[format === 'forecolor' ? 'color' : 'background-color']) {
|
||||
color = color ? color : value;
|
||||
}
|
||||
});
|
||||
return color;
|
||||
};
|
||||
var mapColors = function (colorMap) {
|
||||
var i;
|
||||
var colors = [];
|
||||
for (i = 0; i < colorMap.length; i += 2) {
|
||||
colors.push({
|
||||
text: colorMap[i + 1],
|
||||
color: '#' + colorMap[i]
|
||||
});
|
||||
}
|
||||
return colors;
|
||||
};
|
||||
var applyFormat = function (editor, format, value) {
|
||||
editor.undoManager.transact(function () {
|
||||
editor.focus();
|
||||
editor.formatter.apply(format, { value: value });
|
||||
editor.nodeChanged();
|
||||
});
|
||||
};
|
||||
var removeFormat = function (editor, format) {
|
||||
editor.undoManager.transact(function () {
|
||||
editor.focus();
|
||||
editor.formatter.remove(format, { value: null }, null, true);
|
||||
editor.nodeChanged();
|
||||
});
|
||||
};
|
||||
var TextColor = {
|
||||
getCurrentColor: getCurrentColor,
|
||||
mapColors: mapColors,
|
||||
applyFormat: applyFormat,
|
||||
removeFormat: removeFormat
|
||||
};
|
||||
|
||||
var register = function (editor) {
|
||||
editor.addCommand('mceApplyTextcolor', function (format, value) {
|
||||
TextColor.applyFormat(editor, format, value);
|
||||
});
|
||||
editor.addCommand('mceRemoveTextcolor', function (format) {
|
||||
TextColor.removeFormat(editor, format);
|
||||
});
|
||||
};
|
||||
var Commands = { register: register };
|
||||
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
||||
|
||||
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
||||
|
||||
var defaultColorMap = [
|
||||
'000000',
|
||||
'Black',
|
||||
'993300',
|
||||
'Burnt orange',
|
||||
'333300',
|
||||
'Dark olive',
|
||||
'003300',
|
||||
'Dark green',
|
||||
'003366',
|
||||
'Dark azure',
|
||||
'000080',
|
||||
'Navy Blue',
|
||||
'333399',
|
||||
'Indigo',
|
||||
'333333',
|
||||
'Very dark gray',
|
||||
'800000',
|
||||
'Maroon',
|
||||
'FF6600',
|
||||
'Orange',
|
||||
'808000',
|
||||
'Olive',
|
||||
'008000',
|
||||
'Green',
|
||||
'008080',
|
||||
'Teal',
|
||||
'0000FF',
|
||||
'Blue',
|
||||
'666699',
|
||||
'Grayish blue',
|
||||
'808080',
|
||||
'Gray',
|
||||
'FF0000',
|
||||
'Red',
|
||||
'FF9900',
|
||||
'Amber',
|
||||
'99CC00',
|
||||
'Yellow green',
|
||||
'339966',
|
||||
'Sea green',
|
||||
'33CCCC',
|
||||
'Turquoise',
|
||||
'3366FF',
|
||||
'Royal blue',
|
||||
'800080',
|
||||
'Purple',
|
||||
'999999',
|
||||
'Medium gray',
|
||||
'FF00FF',
|
||||
'Magenta',
|
||||
'FFCC00',
|
||||
'Gold',
|
||||
'FFFF00',
|
||||
'Yellow',
|
||||
'00FF00',
|
||||
'Lime',
|
||||
'00FFFF',
|
||||
'Aqua',
|
||||
'00CCFF',
|
||||
'Sky blue',
|
||||
'993366',
|
||||
'Red violet',
|
||||
'FFFFFF',
|
||||
'White',
|
||||
'FF99CC',
|
||||
'Pink',
|
||||
'FFCC99',
|
||||
'Peach',
|
||||
'FFFF99',
|
||||
'Light yellow',
|
||||
'CCFFCC',
|
||||
'Pale green',
|
||||
'CCFFFF',
|
||||
'Pale cyan',
|
||||
'99CCFF',
|
||||
'Light sky blue',
|
||||
'CC99FF',
|
||||
'Plum'
|
||||
];
|
||||
var getTextColorMap = function (editor) {
|
||||
return editor.getParam('textcolor_map', defaultColorMap);
|
||||
};
|
||||
var getForeColorMap = function (editor) {
|
||||
return editor.getParam('forecolor_map', getTextColorMap(editor));
|
||||
};
|
||||
var getBackColorMap = function (editor) {
|
||||
return editor.getParam('backcolor_map', getTextColorMap(editor));
|
||||
};
|
||||
var getTextColorRows = function (editor) {
|
||||
return editor.getParam('textcolor_rows', 5);
|
||||
};
|
||||
var getTextColorCols = function (editor) {
|
||||
return editor.getParam('textcolor_cols', 8);
|
||||
};
|
||||
var getForeColorRows = function (editor) {
|
||||
return editor.getParam('forecolor_rows', getTextColorRows(editor));
|
||||
};
|
||||
var getBackColorRows = function (editor) {
|
||||
return editor.getParam('backcolor_rows', getTextColorRows(editor));
|
||||
};
|
||||
var getForeColorCols = function (editor) {
|
||||
return editor.getParam('forecolor_cols', getTextColorCols(editor));
|
||||
};
|
||||
var getBackColorCols = function (editor) {
|
||||
return editor.getParam('backcolor_cols', getTextColorCols(editor));
|
||||
};
|
||||
var getColorPickerCallback = function (editor) {
|
||||
return editor.getParam('color_picker_callback', null);
|
||||
};
|
||||
var hasColorPicker = function (editor) {
|
||||
return typeof getColorPickerCallback(editor) === 'function';
|
||||
};
|
||||
var Settings = {
|
||||
getForeColorMap: getForeColorMap,
|
||||
getBackColorMap: getBackColorMap,
|
||||
getForeColorRows: getForeColorRows,
|
||||
getBackColorRows: getBackColorRows,
|
||||
getForeColorCols: getForeColorCols,
|
||||
getBackColorCols: getBackColorCols,
|
||||
getColorPickerCallback: getColorPickerCallback,
|
||||
hasColorPicker: hasColorPicker
|
||||
};
|
||||
|
||||
var global$3 = tinymce.util.Tools.resolve('tinymce.util.I18n');
|
||||
|
||||
var getHtml = function (cols, rows, colorMap, hasColorPicker) {
|
||||
var colors, color, html, last, x, y, i, count = 0;
|
||||
var id = global$1.DOM.uniqueId('mcearia');
|
||||
var getColorCellHtml = function (color, title) {
|
||||
var isNoColor = color === 'transparent';
|
||||
return '<td class="mce-grid-cell' + (isNoColor ? ' mce-colorbtn-trans' : '') + '">' + '<div id="' + id + '-' + count++ + '"' + ' data-mce-color="' + (color ? color : '') + '"' + ' role="option"' + ' tabIndex="-1"' + ' style="' + (color ? 'background-color: ' + color : '') + '"' + ' title="' + global$3.translate(title) + '">' + (isNoColor ? '×' : '') + '</div>' + '</td>';
|
||||
};
|
||||
colors = TextColor.mapColors(colorMap);
|
||||
colors.push({
|
||||
text: global$3.translate('No color'),
|
||||
color: 'transparent'
|
||||
});
|
||||
html = '<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>';
|
||||
last = colors.length - 1;
|
||||
for (y = 0; y < rows; y++) {
|
||||
html += '<tr>';
|
||||
for (x = 0; x < cols; x++) {
|
||||
i = y * cols + x;
|
||||
if (i > last) {
|
||||
html += '<td></td>';
|
||||
} else {
|
||||
color = colors[i];
|
||||
html += getColorCellHtml(color.color, color.text);
|
||||
}
|
||||
}
|
||||
html += '</tr>';
|
||||
}
|
||||
if (hasColorPicker) {
|
||||
html += '<tr>' + '<td colspan="' + cols + '" class="mce-custom-color-btn">' + '<div id="' + id + '-c" class="mce-widget mce-btn mce-btn-small mce-btn-flat" ' + 'role="button" tabindex="-1" aria-labelledby="' + id + '-c" style="width: 100%">' + '<button type="button" role="presentation" tabindex="-1">' + global$3.translate('Custom...') + '</button>' + '</div>' + '</td>' + '</tr>';
|
||||
html += '<tr>';
|
||||
for (x = 0; x < cols; x++) {
|
||||
html += getColorCellHtml('', 'Custom color');
|
||||
}
|
||||
html += '</tr>';
|
||||
}
|
||||
html += '</tbody></table>';
|
||||
return html;
|
||||
};
|
||||
var ColorPickerHtml = { getHtml: getHtml };
|
||||
|
||||
var setDivColor = function setDivColor(div, value) {
|
||||
div.style.background = value;
|
||||
div.setAttribute('data-mce-color', value);
|
||||
};
|
||||
var onButtonClick = function (editor) {
|
||||
return function (e) {
|
||||
var ctrl = e.control;
|
||||
if (ctrl._color) {
|
||||
editor.execCommand('mceApplyTextcolor', ctrl.settings.format, ctrl._color);
|
||||
} else {
|
||||
editor.execCommand('mceRemoveTextcolor', ctrl.settings.format);
|
||||
}
|
||||
};
|
||||
};
|
||||
var onPanelClick = function (editor, cols) {
|
||||
return function (e) {
|
||||
var buttonCtrl = this.parent();
|
||||
var value;
|
||||
var currentColor = TextColor.getCurrentColor(editor, buttonCtrl.settings.format);
|
||||
var selectColor = function (value) {
|
||||
editor.execCommand('mceApplyTextcolor', buttonCtrl.settings.format, value);
|
||||
buttonCtrl.hidePanel();
|
||||
buttonCtrl.color(value);
|
||||
};
|
||||
var resetColor = function () {
|
||||
editor.execCommand('mceRemoveTextcolor', buttonCtrl.settings.format);
|
||||
buttonCtrl.hidePanel();
|
||||
buttonCtrl.resetColor();
|
||||
};
|
||||
if (global$1.DOM.getParent(e.target, '.mce-custom-color-btn')) {
|
||||
buttonCtrl.hidePanel();
|
||||
var colorPickerCallback = Settings.getColorPickerCallback(editor);
|
||||
colorPickerCallback.call(editor, function (value) {
|
||||
var tableElm = buttonCtrl.panel.getEl().getElementsByTagName('table')[0];
|
||||
var customColorCells, div, i;
|
||||
customColorCells = global$2.map(tableElm.rows[tableElm.rows.length - 1].childNodes, function (elm) {
|
||||
return elm.firstChild;
|
||||
});
|
||||
for (i = 0; i < customColorCells.length; i++) {
|
||||
div = customColorCells[i];
|
||||
if (!div.getAttribute('data-mce-color')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i === cols) {
|
||||
for (i = 0; i < cols - 1; i++) {
|
||||
setDivColor(customColorCells[i], customColorCells[i + 1].getAttribute('data-mce-color'));
|
||||
}
|
||||
}
|
||||
setDivColor(div, value);
|
||||
selectColor(value);
|
||||
}, currentColor);
|
||||
}
|
||||
value = e.target.getAttribute('data-mce-color');
|
||||
if (value) {
|
||||
if (this.lastId) {
|
||||
global$1.DOM.get(this.lastId).setAttribute('aria-selected', 'false');
|
||||
}
|
||||
e.target.setAttribute('aria-selected', true);
|
||||
this.lastId = e.target.id;
|
||||
if (value === 'transparent') {
|
||||
resetColor();
|
||||
} else {
|
||||
selectColor(value);
|
||||
}
|
||||
} else if (value !== null) {
|
||||
buttonCtrl.hidePanel();
|
||||
}
|
||||
};
|
||||
};
|
||||
var renderColorPicker = function (editor, foreColor) {
|
||||
return function () {
|
||||
var cols = foreColor ? Settings.getForeColorCols(editor) : Settings.getBackColorCols(editor);
|
||||
var rows = foreColor ? Settings.getForeColorRows(editor) : Settings.getBackColorRows(editor);
|
||||
var colorMap = foreColor ? Settings.getForeColorMap(editor) : Settings.getBackColorMap(editor);
|
||||
var hasColorPicker = Settings.hasColorPicker(editor);
|
||||
return ColorPickerHtml.getHtml(cols, rows, colorMap, hasColorPicker);
|
||||
};
|
||||
};
|
||||
var register$1 = function (editor) {
|
||||
editor.addButton('forecolor', {
|
||||
type: 'colorbutton',
|
||||
tooltip: 'Text color',
|
||||
format: 'forecolor',
|
||||
panel: {
|
||||
role: 'application',
|
||||
ariaRemember: true,
|
||||
html: renderColorPicker(editor, true),
|
||||
onclick: onPanelClick(editor, Settings.getForeColorCols(editor))
|
||||
},
|
||||
onclick: onButtonClick(editor)
|
||||
});
|
||||
editor.addButton('backcolor', {
|
||||
type: 'colorbutton',
|
||||
tooltip: 'Background color',
|
||||
format: 'hilitecolor',
|
||||
panel: {
|
||||
role: 'application',
|
||||
ariaRemember: true,
|
||||
html: renderColorPicker(editor, false),
|
||||
onclick: onPanelClick(editor, Settings.getBackColorCols(editor))
|
||||
},
|
||||
onclick: onButtonClick(editor)
|
||||
});
|
||||
};
|
||||
var Buttons = { register: register$1 };
|
||||
|
||||
global.add('textcolor', function (editor) {
|
||||
Commands.register(editor);
|
||||
Buttons.register(editor);
|
||||
});
|
||||
function Plugin () {
|
||||
}
|
||||
|
||||
return Plugin;
|
||||
|
||||
}());
|
||||
})();
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/textcolor/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/textcolor/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),n=function(t,o){var r;return t.dom.getParents(t.selection.getStart(),function(t){var e;(e=t.style["forecolor"===o?"color":"background-color"])&&(r=r||e)}),r},g=function(t){var e,o=[];for(e=0;e<t.length;e+=2)o.push({text:t[e+1],color:"#"+t[e]});return o},r=function(t,e,o){t.undoManager.transact(function(){t.focus(),t.formatter.apply(e,{value:o}),t.nodeChanged()})},e=function(t,e){t.undoManager.transact(function(){t.focus(),t.formatter.remove(e,{value:null},null,!0),t.nodeChanged()})},o=function(o){o.addCommand("mceApplyTextcolor",function(t,e){r(o,t,e)}),o.addCommand("mceRemoveTextcolor",function(t){e(o,t)})},F=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),i=tinymce.util.Tools.resolve("tinymce.util.Tools"),a=["000000","Black","993300","Burnt orange","333300","Dark olive","003300","Dark green","003366","Dark azure","000080","Navy Blue","333399","Indigo","333333","Very dark gray","800000","Maroon","FF6600","Orange","808000","Olive","008000","Green","008080","Teal","0000FF","Blue","666699","Grayish blue","808080","Gray","FF0000","Red","FF9900","Amber","99CC00","Yellow green","339966","Sea green","33CCCC","Turquoise","3366FF","Royal blue","800080","Purple","999999","Medium gray","FF00FF","Magenta","FFCC00","Gold","FFFF00","Yellow","00FF00","Lime","00FFFF","Aqua","00CCFF","Sky blue","993366","Red violet","FFFFFF","White","FF99CC","Pink","FFCC99","Peach","FFFF99","Light yellow","CCFFCC","Pale green","CCFFFF","Pale cyan","99CCFF","Light sky blue","CC99FF","Plum"],l=function(t){return t.getParam("textcolor_map",a)},c=function(t){return t.getParam("textcolor_rows",5)},u=function(t){return t.getParam("textcolor_cols",8)},m=function(t){return t.getParam("color_picker_callback",null)},s=function(t){return t.getParam("forecolor_map",l(t))},d=function(t){return t.getParam("backcolor_map",l(t))},f=function(t){return t.getParam("forecolor_rows",c(t))},b=function(t){return t.getParam("backcolor_rows",c(t))},p=function(t){return t.getParam("forecolor_cols",u(t))},C=function(t){return t.getParam("backcolor_cols",u(t))},y=m,v=function(t){return"function"==typeof m(t)},h=tinymce.util.Tools.resolve("tinymce.util.I18n"),P=function(t,e,o,r){var n,a,l,c,i,u,m,s=0,d=F.DOM.uniqueId("mcearia"),f=function(t,e){var o="transparent"===t;return'<td class="mce-grid-cell'+(o?" mce-colorbtn-trans":"")+'"><div id="'+d+"-"+s+++'" data-mce-color="'+(t||"")+'" role="option" tabIndex="-1" style="'+(t?"background-color: "+t:"")+'" title="'+h.translate(e)+'">'+(o?"×":"")+"</div></td>"};for((n=g(o)).push({text:h.translate("No color"),color:"transparent"}),l='<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>',c=n.length-1,u=0;u<e;u++){for(l+="<tr>",i=0;i<t;i++)l+=c<(m=u*t+i)?"<td></td>":f((a=n[m]).color,a.text);l+="</tr>"}if(r){for(l+='<tr><td colspan="'+t+'" class="mce-custom-color-btn"><div id="'+d+'-c" class="mce-widget mce-btn mce-btn-small mce-btn-flat" role="button" tabindex="-1" aria-labelledby="'+d+'-c" style="width: 100%"><button type="button" role="presentation" tabindex="-1">'+h.translate("Custom...")+"</button></div></td></tr>",l+="<tr>",i=0;i<t;i++)l+=f("","Custom color");l+="</tr>"}return l+="</tbody></table>"},k=function(t,e){t.style.background=e,t.setAttribute("data-mce-color",e)},x=function(o){return function(t){var e=t.control;e._color?o.execCommand("mceApplyTextcolor",e.settings.format,e._color):o.execCommand("mceRemoveTextcolor",e.settings.format)}},T=function(r,c){return function(t){var e,a=this.parent(),o=n(r,a.settings.format),l=function(t){r.execCommand("mceApplyTextcolor",a.settings.format,t),a.hidePanel(),a.color(t)};F.DOM.getParent(t.target,".mce-custom-color-btn")&&(a.hidePanel(),y(r).call(r,function(t){var e,o,r,n=a.panel.getEl().getElementsByTagName("table")[0];for(e=i.map(n.rows[n.rows.length-1].childNodes,function(t){return t.firstChild}),r=0;r<e.length&&(o=e[r]).getAttribute("data-mce-color");r++);if(r===c)for(r=0;r<c-1;r++)k(e[r],e[r+1].getAttribute("data-mce-color"));k(o,t),l(t)},o)),(e=t.target.getAttribute("data-mce-color"))?(this.lastId&&F.DOM.get(this.lastId).setAttribute("aria-selected","false"),t.target.setAttribute("aria-selected",!0),this.lastId=t.target.id,"transparent"===e?(r.execCommand("mceRemoveTextcolor",a.settings.format),a.hidePanel(),a.resetColor()):l(e)):null!==e&&a.hidePanel()}},_=function(n,a){return function(){var t=a?p(n):C(n),e=a?f(n):b(n),o=a?s(n):d(n),r=v(n);return P(t,e,o,r)}},A=function(t){t.addButton("forecolor",{type:"colorbutton",tooltip:"Text color",format:"forecolor",panel:{role:"application",ariaRemember:!0,html:_(t,!0),onclick:T(t,p(t))},onclick:x(t)}),t.addButton("backcolor",{type:"colorbutton",tooltip:"Background color",format:"hilitecolor",panel:{role:"application",ariaRemember:!0,html:_(t,!1),onclick:T(t,C(t))},onclick:x(t)})};t.add("textcolor",function(t){o(t),A(t)})}();
|
1207
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wordpress/plugin.js
Normal file
1207
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wordpress/plugin.js
Normal file
File diff suppressed because it is too large
Load Diff
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wordpress/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wordpress/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,207 @@
|
||||
/**
|
||||
* plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
// Forked for WordPress so it can be turned on/off after loading.
|
||||
|
||||
/*global tinymce:true */
|
||||
/*eslint no-nested-ternary:0 */
|
||||
|
||||
/**
|
||||
* Auto Resize
|
||||
*
|
||||
* This plugin automatically resizes the content area to fit its content height.
|
||||
* It will retain a minimum height, which is the height of the content area when
|
||||
* it's initialized.
|
||||
*/
|
||||
tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
var settings = editor.settings,
|
||||
oldSize = 300,
|
||||
isActive = false;
|
||||
|
||||
if ( editor.settings.inline || tinymce.Env.iOS ) {
|
||||
return;
|
||||
}
|
||||
|
||||
function isFullscreen() {
|
||||
return editor.plugins.fullscreen && editor.plugins.fullscreen.isFullscreen();
|
||||
}
|
||||
|
||||
function getInt( n ) {
|
||||
return parseInt( n, 10 ) || 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets executed each time the editor needs to resize.
|
||||
*/
|
||||
function resize( e ) {
|
||||
var deltaSize, doc, body, docElm, DOM = tinymce.DOM, resizeHeight, myHeight,
|
||||
marginTop, marginBottom, paddingTop, paddingBottom, borderTop, borderBottom;
|
||||
|
||||
if ( ! isActive ) {
|
||||
return;
|
||||
}
|
||||
|
||||
doc = editor.getDoc();
|
||||
if ( ! doc ) {
|
||||
return;
|
||||
}
|
||||
|
||||
e = e || {};
|
||||
body = doc.body;
|
||||
docElm = doc.documentElement;
|
||||
resizeHeight = settings.autoresize_min_height;
|
||||
|
||||
if ( ! body || ( e && e.type === 'setcontent' && e.initial ) || isFullscreen() ) {
|
||||
if ( body && docElm ) {
|
||||
body.style.overflowY = 'auto';
|
||||
docElm.style.overflowY = 'auto'; // Old IE.
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate outer height of the body element using CSS styles.
|
||||
marginTop = editor.dom.getStyle( body, 'margin-top', true );
|
||||
marginBottom = editor.dom.getStyle( body, 'margin-bottom', true );
|
||||
paddingTop = editor.dom.getStyle( body, 'padding-top', true );
|
||||
paddingBottom = editor.dom.getStyle( body, 'padding-bottom', true );
|
||||
borderTop = editor.dom.getStyle( body, 'border-top-width', true );
|
||||
borderBottom = editor.dom.getStyle( body, 'border-bottom-width', true );
|
||||
myHeight = body.offsetHeight + getInt( marginTop ) + getInt( marginBottom ) +
|
||||
getInt( paddingTop ) + getInt( paddingBottom ) +
|
||||
getInt( borderTop ) + getInt( borderBottom );
|
||||
|
||||
// IE < 11, other?
|
||||
if ( myHeight && myHeight < docElm.offsetHeight ) {
|
||||
myHeight = docElm.offsetHeight;
|
||||
}
|
||||
|
||||
// Make sure we have a valid height.
|
||||
if ( isNaN( myHeight ) || myHeight <= 0 ) {
|
||||
// Get height differently depending on the browser used.
|
||||
myHeight = tinymce.Env.ie ? body.scrollHeight : ( tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight );
|
||||
}
|
||||
|
||||
// Don't make it smaller than the minimum height.
|
||||
if ( myHeight > settings.autoresize_min_height ) {
|
||||
resizeHeight = myHeight;
|
||||
}
|
||||
|
||||
// If a maximum height has been defined don't exceed this height.
|
||||
if ( settings.autoresize_max_height && myHeight > settings.autoresize_max_height ) {
|
||||
resizeHeight = settings.autoresize_max_height;
|
||||
body.style.overflowY = 'auto';
|
||||
docElm.style.overflowY = 'auto'; // Old IE.
|
||||
} else {
|
||||
body.style.overflowY = 'hidden';
|
||||
docElm.style.overflowY = 'hidden'; // Old IE.
|
||||
body.scrollTop = 0;
|
||||
}
|
||||
|
||||
// Resize content element.
|
||||
if (resizeHeight !== oldSize) {
|
||||
deltaSize = resizeHeight - oldSize;
|
||||
DOM.setStyle( editor.iframeElement, 'height', resizeHeight + 'px' );
|
||||
oldSize = resizeHeight;
|
||||
|
||||
// WebKit doesn't decrease the size of the body element until the iframe gets resized.
|
||||
// So we need to continue to resize the iframe down until the size gets fixed.
|
||||
if ( tinymce.isWebKit && deltaSize < 0 ) {
|
||||
resize( e );
|
||||
}
|
||||
|
||||
editor.fire( 'wp-autoresize', { height: resizeHeight, deltaHeight: e.type === 'nodechange' ? deltaSize : null } );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the resize x times in 100ms intervals. We can't wait for load events since
|
||||
* the CSS files might load async.
|
||||
*/
|
||||
function wait( times, interval, callback ) {
|
||||
setTimeout( function() {
|
||||
resize();
|
||||
|
||||
if ( times-- ) {
|
||||
wait( times, interval, callback );
|
||||
} else if ( callback ) {
|
||||
callback();
|
||||
}
|
||||
}, interval );
|
||||
}
|
||||
|
||||
// Define minimum height.
|
||||
settings.autoresize_min_height = parseInt(editor.getParam( 'autoresize_min_height', editor.getElement().offsetHeight), 10 );
|
||||
|
||||
// Define maximum height.
|
||||
settings.autoresize_max_height = parseInt(editor.getParam( 'autoresize_max_height', 0), 10 );
|
||||
|
||||
function on() {
|
||||
if ( ! editor.dom.hasClass( editor.getBody(), 'wp-autoresize' ) ) {
|
||||
isActive = true;
|
||||
editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
|
||||
// Add appropriate listeners for resizing the content area.
|
||||
editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
resize();
|
||||
}
|
||||
}
|
||||
|
||||
function off() {
|
||||
var doc;
|
||||
|
||||
// Don't turn off if the setting is 'on'.
|
||||
if ( ! settings.wp_autoresize_on ) {
|
||||
isActive = false;
|
||||
doc = editor.getDoc();
|
||||
editor.dom.removeClass( editor.getBody(), 'wp-autoresize' );
|
||||
editor.off( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
doc.body.style.overflowY = 'auto';
|
||||
doc.documentElement.style.overflowY = 'auto'; // Old IE.
|
||||
oldSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( settings.wp_autoresize_on ) {
|
||||
// Turn resizing on when the editor loads.
|
||||
isActive = true;
|
||||
|
||||
editor.on( 'init', function() {
|
||||
editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
|
||||
});
|
||||
|
||||
editor.on( 'nodechange keyup FullscreenStateChanged', resize );
|
||||
|
||||
editor.on( 'setcontent', function() {
|
||||
wait( 3, 100 );
|
||||
});
|
||||
|
||||
if ( editor.getParam( 'autoresize_on_init', true ) ) {
|
||||
editor.on( 'init', function() {
|
||||
// Hit it 10 times in 200 ms intervals.
|
||||
wait( 10, 200, function() {
|
||||
// Hit it 5 times in 1 sec intervals.
|
||||
wait( 5, 1000 );
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the stored size.
|
||||
editor.on( 'show', function() {
|
||||
oldSize = 0;
|
||||
});
|
||||
|
||||
// Register the command.
|
||||
editor.addCommand( 'wpAutoResize', resize );
|
||||
|
||||
// On/off.
|
||||
editor.addCommand( 'wpAutoResizeOn', on );
|
||||
editor.addCommand( 'wpAutoResizeOff', off );
|
||||
});
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpautoresize/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpautoresize/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("wpautoresize",function(g){var m=g.settings,h=300,c=!1;function f(e){return parseInt(e,10)||0}function y(e){var t,o,n,i,a,s,l,u,r,d=tinymce.DOM;c&&(r=g.getDoc())&&(e=e||{},t=r.body,o=r.documentElement,n=m.autoresize_min_height,!t||e&&"setcontent"===e.type&&e.initial||g.plugins.fullscreen&&g.plugins.fullscreen.isFullscreen()?t&&o&&(t.style.overflowY="auto",o.style.overflowY="auto"):(i=g.dom.getStyle(t,"margin-top",!0),a=g.dom.getStyle(t,"margin-bottom",!0),s=g.dom.getStyle(t,"padding-top",!0),l=g.dom.getStyle(t,"padding-bottom",!0),u=g.dom.getStyle(t,"border-top-width",!0),r=g.dom.getStyle(t,"border-bottom-width",!0),(r=t.offsetHeight+f(i)+f(a)+f(s)+f(l)+f(u)+f(r))&&r<o.offsetHeight&&(r=o.offsetHeight),(r=isNaN(r)||r<=0?tinymce.Env.ie?t.scrollHeight:tinymce.Env.webkit&&0===t.clientHeight?0:t.offsetHeight:r)>m.autoresize_min_height&&(n=r),m.autoresize_max_height&&r>m.autoresize_max_height?(n=m.autoresize_max_height,t.style.overflowY="auto",o.style.overflowY="auto"):(t.style.overflowY="hidden",o.style.overflowY="hidden",t.scrollTop=0),n!==h&&(t=n-h,d.setStyle(g.iframeElement,"height",n+"px"),h=n,tinymce.isWebKit&&t<0&&y(e),g.fire("wp-autoresize",{height:n,deltaHeight:"nodechange"===e.type?t:null}))))}function n(e,t,o){setTimeout(function(){y(),e--?n(e,t,o):o&&o()},t)}g.settings.inline||tinymce.Env.iOS||(m.autoresize_min_height=parseInt(g.getParam("autoresize_min_height",g.getElement().offsetHeight),10),m.autoresize_max_height=parseInt(g.getParam("autoresize_max_height",0),10),m.wp_autoresize_on&&(c=!0,g.on("init",function(){g.dom.addClass(g.getBody(),"wp-autoresize")}),g.on("nodechange keyup FullscreenStateChanged",y),g.on("setcontent",function(){n(3,100)}),g.getParam("autoresize_on_init",!0)&&g.on("init",function(){n(10,200,function(){n(5,1e3)})})),g.on("show",function(){h=0}),g.addCommand("wpAutoResize",y),g.addCommand("wpAutoResizeOn",function(){g.dom.hasClass(g.getBody(),"wp-autoresize")||(c=!0,g.dom.addClass(g.getBody(),"wp-autoresize"),g.on("nodechange setcontent keyup FullscreenStateChanged",y),y())}),g.addCommand("wpAutoResizeOff",function(){var e;m.wp_autoresize_on||(c=!1,e=g.getDoc(),g.dom.removeClass(g.getBody(),"wp-autoresize"),g.off("nodechange setcontent keyup FullscreenStateChanged",y),e.body.style.overflowY="auto",e.documentElement.style.overflowY="auto",h=0)}))});
|
@ -0,0 +1,92 @@
|
||||
/* global tinymce */
|
||||
/**
|
||||
* Included for back-compat.
|
||||
* The default WindowManager in TinyMCE 4.0 supports three types of dialogs:
|
||||
* - With HTML created from JS.
|
||||
* - With inline HTML (like WPWindowManager).
|
||||
* - Old type iframe based dialogs.
|
||||
* For examples see the default plugins: https://github.com/tinymce/tinymce/tree/master/js/tinymce/plugins
|
||||
*/
|
||||
tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) {
|
||||
if ( this.wp ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
this.wp = {};
|
||||
this.parent = editor.windowManager;
|
||||
this.editor = editor;
|
||||
|
||||
tinymce.extend( this, this.parent );
|
||||
|
||||
this.open = function( args, params ) {
|
||||
var $element,
|
||||
self = this,
|
||||
wp = this.wp;
|
||||
|
||||
if ( ! args.wpDialog ) {
|
||||
return this.parent.open.apply( this, arguments );
|
||||
} else if ( ! args.id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( typeof jQuery === 'undefined' || ! jQuery.wp || ! jQuery.wp.wpdialog ) {
|
||||
// wpdialog.js is not loaded.
|
||||
if ( window.console && window.console.error ) {
|
||||
window.console.error('wpdialog.js is not loaded. Please set "wpdialogs" as dependency for your script when calling wp_enqueue_script(). You may also want to enqueue the "wp-jquery-ui-dialog" stylesheet.');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
wp.$element = $element = jQuery( '#' + args.id );
|
||||
|
||||
if ( ! $element.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( window.console && window.console.log ) {
|
||||
window.console.log('tinymce.WPWindowManager is deprecated. Use the default editor.windowManager to open dialogs with inline HTML.');
|
||||
}
|
||||
|
||||
wp.features = args;
|
||||
wp.params = params;
|
||||
|
||||
// Store selection. Takes a snapshot in the FocusManager of the selection before focus is moved to the dialog.
|
||||
editor.nodeChanged();
|
||||
|
||||
// Create the dialog if necessary.
|
||||
if ( ! $element.data('wpdialog') ) {
|
||||
$element.wpdialog({
|
||||
title: args.title,
|
||||
width: args.width,
|
||||
height: args.height,
|
||||
modal: true,
|
||||
dialogClass: 'wp-dialog',
|
||||
zIndex: 300000
|
||||
});
|
||||
}
|
||||
|
||||
$element.wpdialog('open');
|
||||
|
||||
$element.on( 'wpdialogclose', function() {
|
||||
if ( self.wp.$element ) {
|
||||
self.wp = {};
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.close = function() {
|
||||
if ( ! this.wp.features || ! this.wp.features.wpDialog ) {
|
||||
return this.parent.close.apply( this, arguments );
|
||||
}
|
||||
|
||||
this.wp.$element.wpdialog('close');
|
||||
};
|
||||
};
|
||||
|
||||
tinymce.PluginManager.add( 'wpdialogs', function( editor ) {
|
||||
// Replace window manager.
|
||||
editor.on( 'init', function() {
|
||||
editor.windowManager = new tinymce.WPWindowManager( editor );
|
||||
});
|
||||
});
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpdialogs/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpdialogs/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
tinymce.WPWindowManager=tinymce.InlineWindowManager=function(a){if(this.wp)return this;this.wp={},this.parent=a.windowManager,this.editor=a,tinymce.extend(this,this.parent),this.open=function(e,i){var n,o=this,t=this.wp;if(!e.wpDialog)return this.parent.open.apply(this,arguments);e.id&&("undefined"!=typeof jQuery&&jQuery.wp&&jQuery.wp.wpdialog?(t.$element=n=jQuery("#"+e.id),n.length&&(window.console&&window.console.log&&window.console.log("tinymce.WPWindowManager is deprecated. Use the default editor.windowManager to open dialogs with inline HTML."),t.features=e,t.params=i,a.nodeChanged(),n.data("wpdialog")||n.wpdialog({title:e.title,width:e.width,height:e.height,modal:!0,dialogClass:"wp-dialog",zIndex:3e5}),n.wpdialog("open"),n.on("wpdialogclose",function(){o.wp.$element&&(o.wp={})}))):window.console&&window.console.error&&window.console.error('wpdialog.js is not loaded. Please set "wpdialogs" as dependency for your script when calling wp_enqueue_script(). You may also want to enqueue the "wp-jquery-ui-dialog" stylesheet.'))},this.close=function(){if(!this.wp.features||!this.wp.features.wpDialog)return this.parent.close.apply(this,arguments);this.wp.$element.wpdialog("close")}},tinymce.PluginManager.add("wpdialogs",function(e){e.on("init",function(){e.windowManager=new tinymce.WPWindowManager(e)})});
|
@ -0,0 +1,900 @@
|
||||
/* global tinymce */
|
||||
tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
var toolbar, serializer, touchOnImage, pasteInCaption,
|
||||
each = tinymce.each,
|
||||
trim = tinymce.trim,
|
||||
iOS = tinymce.Env.iOS;
|
||||
|
||||
function isPlaceholder( node ) {
|
||||
return !! ( editor.dom.getAttrib( node, 'data-mce-placeholder' ) || editor.dom.getAttrib( node, 'data-mce-object' ) );
|
||||
}
|
||||
|
||||
editor.addButton( 'wp_img_remove', {
|
||||
tooltip: 'Remove',
|
||||
icon: 'dashicon dashicons-no',
|
||||
onclick: function() {
|
||||
removeImage( editor.selection.getNode() );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_img_edit', {
|
||||
tooltip: 'Edit|button', // '|button' is not displayed, only used for context.
|
||||
icon: 'dashicon dashicons-edit',
|
||||
onclick: function() {
|
||||
editImage( editor.selection.getNode() );
|
||||
}
|
||||
} );
|
||||
|
||||
each( {
|
||||
alignleft: 'Align left',
|
||||
aligncenter: 'Align center',
|
||||
alignright: 'Align right',
|
||||
alignnone: 'No alignment'
|
||||
}, function( tooltip, name ) {
|
||||
var direction = name.slice( 5 );
|
||||
|
||||
editor.addButton( 'wp_img_' + name, {
|
||||
tooltip: tooltip,
|
||||
icon: 'dashicon dashicons-align-' + direction,
|
||||
cmd: 'alignnone' === name ? 'wpAlignNone' : 'Justify' + direction.slice( 0, 1 ).toUpperCase() + direction.slice( 1 ),
|
||||
onPostRender: function() {
|
||||
var self = this;
|
||||
|
||||
editor.on( 'NodeChange', function( event ) {
|
||||
var node;
|
||||
|
||||
// Don't bother.
|
||||
if ( event.element.nodeName !== 'IMG' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
node = editor.dom.getParent( event.element, '.wp-caption' ) || event.element;
|
||||
|
||||
if ( 'alignnone' === name ) {
|
||||
self.active( ! /\balign(left|center|right)\b/.test( node.className ) );
|
||||
} else {
|
||||
self.active( editor.dom.hasClass( node, name ) );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
editor.once( 'preinit', function() {
|
||||
if ( editor.wp && editor.wp._createToolbar ) {
|
||||
toolbar = editor.wp._createToolbar( [
|
||||
'wp_img_alignleft',
|
||||
'wp_img_aligncenter',
|
||||
'wp_img_alignright',
|
||||
'wp_img_alignnone',
|
||||
'wp_img_edit',
|
||||
'wp_img_remove'
|
||||
] );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.on( 'wptoolbar', function( event ) {
|
||||
if ( event.element.nodeName === 'IMG' && ! isPlaceholder( event.element ) ) {
|
||||
event.toolbar = toolbar;
|
||||
}
|
||||
} );
|
||||
|
||||
function isNonEditable( node ) {
|
||||
var parent = editor.$( node ).parents( '[contenteditable]' );
|
||||
return parent && parent.attr( 'contenteditable' ) === 'false';
|
||||
}
|
||||
|
||||
// Safari on iOS fails to select images in contentEditoble mode on touch.
|
||||
// Select them again.
|
||||
if ( iOS ) {
|
||||
editor.on( 'init', function() {
|
||||
editor.on( 'touchstart', function( event ) {
|
||||
if ( event.target.nodeName === 'IMG' && ! isNonEditable( event.target ) ) {
|
||||
touchOnImage = true;
|
||||
}
|
||||
});
|
||||
|
||||
editor.dom.bind( editor.getDoc(), 'touchmove', function() {
|
||||
touchOnImage = false;
|
||||
});
|
||||
|
||||
editor.on( 'touchend', function( event ) {
|
||||
if ( touchOnImage && event.target.nodeName === 'IMG' && ! isNonEditable( event.target ) ) {
|
||||
var node = event.target;
|
||||
|
||||
touchOnImage = false;
|
||||
|
||||
window.setTimeout( function() {
|
||||
editor.selection.select( node );
|
||||
editor.nodeChanged();
|
||||
}, 100 );
|
||||
} else if ( toolbar ) {
|
||||
toolbar.hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function parseShortcode( content ) {
|
||||
return content.replace( /(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g, function( a, b, c ) {
|
||||
var id, align, classes, caption, img, width;
|
||||
|
||||
id = b.match( /id=['"]([^'"]*)['"] ?/ );
|
||||
if ( id ) {
|
||||
b = b.replace( id[0], '' );
|
||||
}
|
||||
|
||||
align = b.match( /align=['"]([^'"]*)['"] ?/ );
|
||||
if ( align ) {
|
||||
b = b.replace( align[0], '' );
|
||||
}
|
||||
|
||||
classes = b.match( /class=['"]([^'"]*)['"] ?/ );
|
||||
if ( classes ) {
|
||||
b = b.replace( classes[0], '' );
|
||||
}
|
||||
|
||||
width = b.match( /width=['"]([0-9]*)['"] ?/ );
|
||||
if ( width ) {
|
||||
b = b.replace( width[0], '' );
|
||||
}
|
||||
|
||||
c = trim( c );
|
||||
img = c.match( /((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)([\s\S]*)/i );
|
||||
|
||||
if ( img && img[2] ) {
|
||||
caption = trim( img[2] );
|
||||
img = trim( img[1] );
|
||||
} else {
|
||||
// Old captions shortcode style.
|
||||
caption = trim( b ).replace( /caption=['"]/, '' ).replace( /['"]$/, '' );
|
||||
img = c;
|
||||
}
|
||||
|
||||
id = ( id && id[1] ) ? id[1].replace( /[<>&]+/g, '' ) : '';
|
||||
align = ( align && align[1] ) ? align[1] : 'alignnone';
|
||||
classes = ( classes && classes[1] ) ? ' ' + classes[1].replace( /[<>&]+/g, '' ) : '';
|
||||
|
||||
if ( ! width && img ) {
|
||||
width = img.match( /width=['"]([0-9]*)['"]/ );
|
||||
}
|
||||
|
||||
if ( width && width[1] ) {
|
||||
width = width[1];
|
||||
}
|
||||
|
||||
if ( ! width || ! caption ) {
|
||||
return c;
|
||||
}
|
||||
|
||||
width = parseInt( width, 10 );
|
||||
if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
|
||||
width += 10;
|
||||
}
|
||||
|
||||
return '<div class="mceTemp"><dl id="' + id + '" class="wp-caption ' + align + classes + '" style="width: ' + width + 'px">' +
|
||||
'<dt class="wp-caption-dt">'+ img +'</dt><dd class="wp-caption-dd">'+ caption +'</dd></dl></div>';
|
||||
});
|
||||
}
|
||||
|
||||
function getShortcode( content ) {
|
||||
return content.replace( /(?:<div [^>]+mceTemp[^>]+>)?\s*(<dl [^>]+wp-caption[^>]+>[\s\S]+?<\/dl>)\s*(?:<\/div>)?/g, function( all, dl ) {
|
||||
var out = '';
|
||||
|
||||
if ( dl.indexOf('<img ') === -1 || dl.indexOf('</p>') !== -1 ) {
|
||||
// Broken caption. The user managed to drag the image out or type in the wrapper div?
|
||||
// Remove the <dl>, <dd> and <dt> and return the remaining text.
|
||||
return dl.replace( /<d[ldt]( [^>]+)?>/g, '' ).replace( /<\/d[ldt]>/g, '' );
|
||||
}
|
||||
|
||||
out = dl.replace( /\s*<dl ([^>]+)>\s*<dt [^>]+>([\s\S]+?)<\/dt>\s*<dd [^>]+>([\s\S]*?)<\/dd>\s*<\/dl>\s*/gi, function( a, b, c, caption ) {
|
||||
var id, classes, align, width;
|
||||
|
||||
width = c.match( /width="([0-9]*)"/ );
|
||||
width = ( width && width[1] ) ? width[1] : '';
|
||||
|
||||
classes = b.match( /class="([^"]*)"/ );
|
||||
classes = ( classes && classes[1] ) ? classes[1] : '';
|
||||
align = classes.match( /align[a-z]+/i ) || 'alignnone';
|
||||
|
||||
if ( ! width || ! caption ) {
|
||||
if ( 'alignnone' !== align[0] ) {
|
||||
c = c.replace( /><img/, ' class="' + align[0] + '"><img' );
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
id = b.match( /id="([^"]*)"/ );
|
||||
id = ( id && id[1] ) ? id[1] : '';
|
||||
|
||||
classes = classes.replace( /wp-caption ?|align[a-z]+ ?/gi, '' );
|
||||
|
||||
if ( classes ) {
|
||||
classes = ' class="' + classes + '"';
|
||||
}
|
||||
|
||||
caption = caption.replace( /\r\n|\r/g, '\n' ).replace( /<[a-zA-Z0-9]+( [^<>]+)?>/g, function( a ) {
|
||||
// No line breaks inside HTML tags.
|
||||
return a.replace( /[\r\n\t]+/, ' ' );
|
||||
});
|
||||
|
||||
// Convert remaining line breaks to <br>.
|
||||
caption = caption.replace( /\s*\n\s*/g, '<br />' );
|
||||
|
||||
return '[caption id="' + id + '" align="' + align + '" width="' + width + '"' + classes + ']' + c + ' ' + caption + '[/caption]';
|
||||
});
|
||||
|
||||
if ( out.indexOf('[caption') === -1 ) {
|
||||
// The caption html seems broken, try to find the image that may be wrapped in a link
|
||||
// and may be followed by <p> with the caption text.
|
||||
out = dl.replace( /[\s\S]*?((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)(<p>[\s\S]*<\/p>)?[\s\S]*/gi, '<p>$1</p>$2' );
|
||||
}
|
||||
|
||||
return out;
|
||||
});
|
||||
}
|
||||
|
||||
function extractImageData( imageNode ) {
|
||||
var classes, extraClasses, metadata, captionBlock, caption, link, width, height,
|
||||
captionClassName = [],
|
||||
dom = editor.dom,
|
||||
isIntRegExp = /^\d+$/;
|
||||
|
||||
// Default attributes.
|
||||
metadata = {
|
||||
attachment_id: false,
|
||||
size: 'custom',
|
||||
caption: '',
|
||||
align: 'none',
|
||||
extraClasses: '',
|
||||
link: false,
|
||||
linkUrl: '',
|
||||
linkClassName: '',
|
||||
linkTargetBlank: false,
|
||||
linkRel: '',
|
||||
title: ''
|
||||
};
|
||||
|
||||
metadata.url = dom.getAttrib( imageNode, 'src' );
|
||||
metadata.alt = dom.getAttrib( imageNode, 'alt' );
|
||||
metadata.title = dom.getAttrib( imageNode, 'title' );
|
||||
|
||||
width = dom.getAttrib( imageNode, 'width' );
|
||||
height = dom.getAttrib( imageNode, 'height' );
|
||||
|
||||
if ( ! isIntRegExp.test( width ) || parseInt( width, 10 ) < 1 ) {
|
||||
width = imageNode.naturalWidth || imageNode.width;
|
||||
}
|
||||
|
||||
if ( ! isIntRegExp.test( height ) || parseInt( height, 10 ) < 1 ) {
|
||||
height = imageNode.naturalHeight || imageNode.height;
|
||||
}
|
||||
|
||||
metadata.customWidth = metadata.width = width;
|
||||
metadata.customHeight = metadata.height = height;
|
||||
|
||||
classes = tinymce.explode( imageNode.className, ' ' );
|
||||
extraClasses = [];
|
||||
|
||||
tinymce.each( classes, function( name ) {
|
||||
|
||||
if ( /^wp-image/.test( name ) ) {
|
||||
metadata.attachment_id = parseInt( name.replace( 'wp-image-', '' ), 10 );
|
||||
} else if ( /^align/.test( name ) ) {
|
||||
metadata.align = name.replace( 'align', '' );
|
||||
} else if ( /^size/.test( name ) ) {
|
||||
metadata.size = name.replace( 'size-', '' );
|
||||
} else {
|
||||
extraClasses.push( name );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
metadata.extraClasses = extraClasses.join( ' ' );
|
||||
|
||||
// Extract caption.
|
||||
captionBlock = dom.getParents( imageNode, '.wp-caption' );
|
||||
|
||||
if ( captionBlock.length ) {
|
||||
captionBlock = captionBlock[0];
|
||||
|
||||
classes = captionBlock.className.split( ' ' );
|
||||
tinymce.each( classes, function( name ) {
|
||||
if ( /^align/.test( name ) ) {
|
||||
metadata.align = name.replace( 'align', '' );
|
||||
} else if ( name && name !== 'wp-caption' ) {
|
||||
captionClassName.push( name );
|
||||
}
|
||||
} );
|
||||
|
||||
metadata.captionClassName = captionClassName.join( ' ' );
|
||||
|
||||
caption = dom.select( 'dd.wp-caption-dd', captionBlock );
|
||||
if ( caption.length ) {
|
||||
caption = caption[0];
|
||||
|
||||
metadata.caption = editor.serializer.serialize( caption )
|
||||
.replace( /<br[^>]*>/g, '$&\n' ).replace( /^<p>/, '' ).replace( /<\/p>$/, '' );
|
||||
}
|
||||
}
|
||||
|
||||
// Extract linkTo.
|
||||
if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' ) {
|
||||
link = imageNode.parentNode;
|
||||
metadata.linkUrl = dom.getAttrib( link, 'href' );
|
||||
metadata.linkTargetBlank = dom.getAttrib( link, 'target' ) === '_blank' ? true : false;
|
||||
metadata.linkRel = dom.getAttrib( link, 'rel' );
|
||||
metadata.linkClassName = link.className;
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
function hasTextContent( node ) {
|
||||
return node && !! ( node.textContent || node.innerText ).replace( /\ufeff/g, '' );
|
||||
}
|
||||
|
||||
// Verify HTML in captions.
|
||||
function verifyHTML( caption ) {
|
||||
if ( ! caption || ( caption.indexOf( '<' ) === -1 && caption.indexOf( '>' ) === -1 ) ) {
|
||||
return caption;
|
||||
}
|
||||
|
||||
if ( ! serializer ) {
|
||||
serializer = new tinymce.html.Serializer( {}, editor.schema );
|
||||
}
|
||||
|
||||
return serializer.serialize( editor.parser.parse( caption, { forced_root_block: false } ) );
|
||||
}
|
||||
|
||||
function updateImage( $imageNode, imageData ) {
|
||||
var classes, className, node, html, parent, wrap, linkNode, imageNode,
|
||||
captionNode, dd, dl, id, attrs, linkAttrs, width, height, align,
|
||||
$imageNode, srcset, src,
|
||||
dom = editor.dom;
|
||||
|
||||
if ( ! $imageNode || ! $imageNode.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
imageNode = $imageNode[0];
|
||||
classes = tinymce.explode( imageData.extraClasses, ' ' );
|
||||
|
||||
if ( ! classes ) {
|
||||
classes = [];
|
||||
}
|
||||
|
||||
if ( ! imageData.caption ) {
|
||||
classes.push( 'align' + imageData.align );
|
||||
}
|
||||
|
||||
if ( imageData.attachment_id ) {
|
||||
classes.push( 'wp-image-' + imageData.attachment_id );
|
||||
if ( imageData.size && imageData.size !== 'custom' ) {
|
||||
classes.push( 'size-' + imageData.size );
|
||||
}
|
||||
}
|
||||
|
||||
width = imageData.width;
|
||||
height = imageData.height;
|
||||
|
||||
if ( imageData.size === 'custom' ) {
|
||||
width = imageData.customWidth;
|
||||
height = imageData.customHeight;
|
||||
}
|
||||
|
||||
attrs = {
|
||||
src: imageData.url,
|
||||
width: width || null,
|
||||
height: height || null,
|
||||
title: imageData.title || null,
|
||||
'class': classes.join( ' ' ) || null
|
||||
};
|
||||
|
||||
dom.setAttribs( imageNode, attrs );
|
||||
|
||||
// Preserve empty alt attributes.
|
||||
$imageNode.attr( 'alt', imageData.alt || '' );
|
||||
|
||||
linkAttrs = {
|
||||
href: imageData.linkUrl,
|
||||
rel: imageData.linkRel || null,
|
||||
target: imageData.linkTargetBlank ? '_blank': null,
|
||||
'class': imageData.linkClassName || null
|
||||
};
|
||||
|
||||
if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) {
|
||||
// Update or remove an existing link wrapped around the image.
|
||||
if ( imageData.linkUrl ) {
|
||||
dom.setAttribs( imageNode.parentNode, linkAttrs );
|
||||
} else {
|
||||
dom.remove( imageNode.parentNode, true );
|
||||
}
|
||||
} else if ( imageData.linkUrl ) {
|
||||
if ( linkNode = dom.getParent( imageNode, 'a' ) ) {
|
||||
// The image is inside a link together with other nodes,
|
||||
// or is nested in another node, move it out.
|
||||
dom.insertAfter( imageNode, linkNode );
|
||||
}
|
||||
|
||||
// Add link wrapped around the image.
|
||||
linkNode = dom.create( 'a', linkAttrs );
|
||||
imageNode.parentNode.insertBefore( linkNode, imageNode );
|
||||
linkNode.appendChild( imageNode );
|
||||
}
|
||||
|
||||
captionNode = editor.dom.getParent( imageNode, '.mceTemp' );
|
||||
|
||||
if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) {
|
||||
node = imageNode.parentNode;
|
||||
} else {
|
||||
node = imageNode;
|
||||
}
|
||||
|
||||
if ( imageData.caption ) {
|
||||
imageData.caption = verifyHTML( imageData.caption );
|
||||
|
||||
id = imageData.attachment_id ? 'attachment_' + imageData.attachment_id : null;
|
||||
align = 'align' + ( imageData.align || 'none' );
|
||||
className = 'wp-caption ' + align;
|
||||
|
||||
if ( imageData.captionClassName ) {
|
||||
className += ' ' + imageData.captionClassName.replace( /[<>&]+/g, '' );
|
||||
}
|
||||
|
||||
if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
|
||||
width = parseInt( width, 10 );
|
||||
width += 10;
|
||||
}
|
||||
|
||||
if ( captionNode ) {
|
||||
dl = dom.select( 'dl.wp-caption', captionNode );
|
||||
|
||||
if ( dl.length ) {
|
||||
dom.setAttribs( dl, {
|
||||
id: id,
|
||||
'class': className,
|
||||
style: 'width: ' + width + 'px'
|
||||
} );
|
||||
}
|
||||
|
||||
dd = dom.select( '.wp-caption-dd', captionNode );
|
||||
|
||||
if ( dd.length ) {
|
||||
dom.setHTML( dd[0], imageData.caption );
|
||||
}
|
||||
|
||||
} else {
|
||||
id = id ? 'id="'+ id +'" ' : '';
|
||||
|
||||
// Should create a new function for generating the caption markup.
|
||||
html = '<dl ' + id + 'class="' + className +'" style="width: '+ width +'px">' +
|
||||
'<dt class="wp-caption-dt"></dt><dd class="wp-caption-dd">'+ imageData.caption +'</dd></dl>';
|
||||
|
||||
wrap = dom.create( 'div', { 'class': 'mceTemp' }, html );
|
||||
|
||||
if ( parent = dom.getParent( node, 'p' ) ) {
|
||||
parent.parentNode.insertBefore( wrap, parent );
|
||||
} else {
|
||||
node.parentNode.insertBefore( wrap, node );
|
||||
}
|
||||
|
||||
editor.$( wrap ).find( 'dt.wp-caption-dt' ).append( node );
|
||||
|
||||
if ( parent && dom.isEmpty( parent ) ) {
|
||||
dom.remove( parent );
|
||||
}
|
||||
}
|
||||
} else if ( captionNode ) {
|
||||
// Remove the caption wrapper and place the image in new paragraph.
|
||||
parent = dom.create( 'p' );
|
||||
captionNode.parentNode.insertBefore( parent, captionNode );
|
||||
parent.appendChild( node );
|
||||
dom.remove( captionNode );
|
||||
}
|
||||
|
||||
$imageNode = editor.$( imageNode );
|
||||
srcset = $imageNode.attr( 'srcset' );
|
||||
src = $imageNode.attr( 'src' );
|
||||
|
||||
// Remove srcset and sizes if the image file was edited or the image was replaced.
|
||||
if ( srcset && src ) {
|
||||
src = src.replace( /[?#].*/, '' );
|
||||
|
||||
if ( srcset.indexOf( src ) === -1 ) {
|
||||
$imageNode.attr( 'srcset', null ).attr( 'sizes', null );
|
||||
}
|
||||
}
|
||||
|
||||
if ( wp.media.events ) {
|
||||
wp.media.events.trigger( 'editor:image-update', {
|
||||
editor: editor,
|
||||
metadata: imageData,
|
||||
image: imageNode
|
||||
} );
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
}
|
||||
|
||||
function editImage( img ) {
|
||||
var frame, callback, metadata, imageNode;
|
||||
|
||||
if ( typeof wp === 'undefined' || ! wp.media ) {
|
||||
editor.execCommand( 'mceImage' );
|
||||
return;
|
||||
}
|
||||
|
||||
metadata = extractImageData( img );
|
||||
|
||||
// Mark the image node so we can select it later.
|
||||
editor.$( img ).attr( 'data-wp-editing', 1 );
|
||||
|
||||
// Manipulate the metadata by reference that is fed into the PostImage model used in the media modal.
|
||||
wp.media.events.trigger( 'editor:image-edit', {
|
||||
editor: editor,
|
||||
metadata: metadata,
|
||||
image: img
|
||||
} );
|
||||
|
||||
frame = wp.media({
|
||||
frame: 'image',
|
||||
state: 'image-details',
|
||||
metadata: metadata
|
||||
} );
|
||||
|
||||
wp.media.events.trigger( 'editor:frame-create', { frame: frame } );
|
||||
|
||||
callback = function( imageData ) {
|
||||
editor.undoManager.transact( function() {
|
||||
updateImage( imageNode, imageData );
|
||||
} );
|
||||
frame.detach();
|
||||
};
|
||||
|
||||
frame.state('image-details').on( 'update', callback );
|
||||
frame.state('replace-image').on( 'replace', callback );
|
||||
frame.on( 'close', function() {
|
||||
editor.focus();
|
||||
frame.detach();
|
||||
|
||||
/*
|
||||
* `close` fires first...
|
||||
* To be able to update the image node, we need to find it here,
|
||||
* and use it in the callback.
|
||||
*/
|
||||
imageNode = editor.$( 'img[data-wp-editing]' )
|
||||
imageNode.removeAttr( 'data-wp-editing' );
|
||||
});
|
||||
|
||||
frame.open();
|
||||
}
|
||||
|
||||
function removeImage( node ) {
|
||||
var wrap = editor.dom.getParent( node, 'div.mceTemp' );
|
||||
|
||||
if ( ! wrap && node.nodeName === 'IMG' ) {
|
||||
wrap = editor.dom.getParent( node, 'a' );
|
||||
}
|
||||
|
||||
if ( wrap ) {
|
||||
if ( wrap.nextSibling ) {
|
||||
editor.selection.select( wrap.nextSibling );
|
||||
} else if ( wrap.previousSibling ) {
|
||||
editor.selection.select( wrap.previousSibling );
|
||||
} else {
|
||||
editor.selection.select( wrap.parentNode );
|
||||
}
|
||||
|
||||
editor.selection.collapse( true );
|
||||
editor.dom.remove( wrap );
|
||||
} else {
|
||||
editor.dom.remove( node );
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
editor.undoManager.add();
|
||||
}
|
||||
|
||||
editor.on( 'init', function() {
|
||||
var dom = editor.dom,
|
||||
captionClass = editor.getParam( 'wpeditimage_html5_captions' ) ? 'html5-captions' : 'html4-captions';
|
||||
|
||||
dom.addClass( editor.getBody(), captionClass );
|
||||
|
||||
// Prevent IE11 from making dl.wp-caption resizable.
|
||||
if ( tinymce.Env.ie && tinymce.Env.ie > 10 ) {
|
||||
// The 'mscontrolselect' event is supported only in IE11+.
|
||||
dom.bind( editor.getBody(), 'mscontrolselect', function( event ) {
|
||||
if ( event.target.nodeName === 'IMG' && dom.getParent( event.target, '.wp-caption' ) ) {
|
||||
// Hide the thick border with resize handles around dl.wp-caption.
|
||||
editor.getBody().focus(); // :(
|
||||
} else if ( event.target.nodeName === 'DL' && dom.hasClass( event.target, 'wp-caption' ) ) {
|
||||
// Trigger the thick border with resize handles...
|
||||
// This will make the caption text editable.
|
||||
event.target.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'ObjectResized', function( event ) {
|
||||
var node = event.target;
|
||||
|
||||
if ( node.nodeName === 'IMG' ) {
|
||||
editor.undoManager.transact( function() {
|
||||
var parent, width,
|
||||
dom = editor.dom;
|
||||
|
||||
node.className = node.className.replace( /\bsize-[^ ]+/, '' );
|
||||
|
||||
if ( parent = dom.getParent( node, '.wp-caption' ) ) {
|
||||
width = event.width || dom.getAttrib( node, 'width' );
|
||||
|
||||
if ( width ) {
|
||||
width = parseInt( width, 10 );
|
||||
|
||||
if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
|
||||
width += 10;
|
||||
}
|
||||
|
||||
dom.setStyle( parent, 'width', width + 'px' );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'pastePostProcess', function( event ) {
|
||||
// Pasting in a caption node.
|
||||
if ( editor.dom.getParent( editor.selection.getNode(), 'dd.wp-caption-dd' ) ) {
|
||||
// Remove "non-block" elements that should not be in captions.
|
||||
editor.$( 'img, audio, video, object, embed, iframe, script, style', event.node ).remove();
|
||||
|
||||
editor.$( '*', event.node ).each( function( i, node ) {
|
||||
if ( editor.dom.isBlock( node ) ) {
|
||||
// Insert <br> where the blocks used to be. Makes it look better after pasting in the caption.
|
||||
if ( tinymce.trim( node.textContent || node.innerText ) ) {
|
||||
editor.dom.insertAfter( editor.dom.create( 'br' ), node );
|
||||
editor.dom.remove( node, true );
|
||||
} else {
|
||||
editor.dom.remove( node );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Trim <br> tags.
|
||||
editor.$( 'br', event.node ).each( function( i, node ) {
|
||||
if ( ! node.nextSibling || node.nextSibling.nodeName === 'BR' ||
|
||||
! node.previousSibling || node.previousSibling.nodeName === 'BR' ) {
|
||||
|
||||
editor.dom.remove( node );
|
||||
}
|
||||
} );
|
||||
|
||||
// Pasted HTML is cleaned up for inserting in the caption.
|
||||
pasteInCaption = true;
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'BeforeExecCommand', function( event ) {
|
||||
var node, p, DL, align, replacement, captionParent,
|
||||
cmd = event.command,
|
||||
dom = editor.dom;
|
||||
|
||||
if ( cmd === 'mceInsertContent' || cmd === 'Indent' || cmd === 'Outdent' ) {
|
||||
node = editor.selection.getNode();
|
||||
captionParent = dom.getParent( node, 'div.mceTemp' );
|
||||
|
||||
if ( captionParent ) {
|
||||
if ( cmd === 'mceInsertContent' ) {
|
||||
if ( pasteInCaption ) {
|
||||
pasteInCaption = false;
|
||||
/*
|
||||
* We are in the caption element, and in 'paste' context,
|
||||
* and the pasted HTML was cleaned up on 'pastePostProcess' above.
|
||||
* Let it be pasted in the caption.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* The paste is somewhere else in the caption DL element.
|
||||
* Prevent pasting in there as it will break the caption.
|
||||
* Make new paragraph under the caption DL and move the caret there.
|
||||
*/
|
||||
p = dom.create( 'p' );
|
||||
dom.insertAfter( p, captionParent );
|
||||
editor.selection.setCursorLocation( p, 0 );
|
||||
|
||||
/*
|
||||
* If the image is selected and the user pastes "over" it,
|
||||
* replace both the image and the caption elements with the pasted content.
|
||||
* This matches the behavior when pasting over non-caption images.
|
||||
*/
|
||||
if ( node.nodeName === 'IMG' ) {
|
||||
editor.$( captionParent ).remove();
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
} else {
|
||||
// Clicking Indent or Outdent while an image with a caption is selected breaks the caption.
|
||||
// See #38313.
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if ( cmd === 'JustifyLeft' || cmd === 'JustifyRight' || cmd === 'JustifyCenter' || cmd === 'wpAlignNone' ) {
|
||||
node = editor.selection.getNode();
|
||||
align = 'align' + cmd.slice( 7 ).toLowerCase();
|
||||
DL = editor.dom.getParent( node, '.wp-caption' );
|
||||
|
||||
if ( node.nodeName !== 'IMG' && ! DL ) {
|
||||
return;
|
||||
}
|
||||
|
||||
node = DL || node;
|
||||
|
||||
if ( editor.dom.hasClass( node, align ) ) {
|
||||
replacement = ' alignnone';
|
||||
} else {
|
||||
replacement = ' ' + align;
|
||||
}
|
||||
|
||||
node.className = trim( node.className.replace( / ?align(left|center|right|none)/g, '' ) + replacement );
|
||||
|
||||
editor.nodeChanged();
|
||||
event.preventDefault();
|
||||
|
||||
if ( toolbar ) {
|
||||
toolbar.reposition();
|
||||
}
|
||||
|
||||
editor.fire( 'ExecCommand', {
|
||||
command: cmd,
|
||||
ui: event.ui,
|
||||
value: event.value
|
||||
} );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'keydown', function( event ) {
|
||||
var node, wrap, P, spacer,
|
||||
selection = editor.selection,
|
||||
keyCode = event.keyCode,
|
||||
dom = editor.dom,
|
||||
VK = tinymce.util.VK;
|
||||
|
||||
if ( keyCode === VK.ENTER ) {
|
||||
// When pressing Enter inside a caption move the caret to a new parapraph under it.
|
||||
node = selection.getNode();
|
||||
wrap = dom.getParent( node, 'div.mceTemp' );
|
||||
|
||||
if ( wrap ) {
|
||||
dom.events.cancel( event ); // Doesn't cancel all :(
|
||||
|
||||
// Remove any extra dt and dd cleated on pressing Enter...
|
||||
tinymce.each( dom.select( 'dt, dd', wrap ), function( element ) {
|
||||
if ( dom.isEmpty( element ) ) {
|
||||
dom.remove( element );
|
||||
}
|
||||
});
|
||||
|
||||
spacer = tinymce.Env.ie && tinymce.Env.ie < 11 ? '' : '<br data-mce-bogus="1" />';
|
||||
P = dom.create( 'p', null, spacer );
|
||||
|
||||
if ( node.nodeName === 'DD' ) {
|
||||
dom.insertAfter( P, wrap );
|
||||
} else {
|
||||
wrap.parentNode.insertBefore( P, wrap );
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
selection.setCursorLocation( P, 0 );
|
||||
}
|
||||
} else if ( keyCode === VK.DELETE || keyCode === VK.BACKSPACE ) {
|
||||
node = selection.getNode();
|
||||
|
||||
if ( node.nodeName === 'DIV' && dom.hasClass( node, 'mceTemp' ) ) {
|
||||
wrap = node;
|
||||
} else if ( node.nodeName === 'IMG' || node.nodeName === 'DT' || node.nodeName === 'A' ) {
|
||||
wrap = dom.getParent( node, 'div.mceTemp' );
|
||||
}
|
||||
|
||||
if ( wrap ) {
|
||||
dom.events.cancel( event );
|
||||
removeImage( node );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* After undo/redo FF seems to set the image height very slowly when it is set to 'auto' in the CSS.
|
||||
* This causes image.getBoundingClientRect() to return wrong values and the resize handles are shown in wrong places.
|
||||
* Collapse the selection to remove the resize handles.
|
||||
*/
|
||||
if ( tinymce.Env.gecko ) {
|
||||
editor.on( 'undo redo', function() {
|
||||
if ( editor.selection.getNode().nodeName === 'IMG' ) {
|
||||
editor.selection.collapse();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
editor.wpSetImgCaption = function( content ) {
|
||||
return parseShortcode( content );
|
||||
};
|
||||
|
||||
editor.wpGetImgCaption = function( content ) {
|
||||
return getShortcode( content );
|
||||
};
|
||||
|
||||
editor.on( 'beforeGetContent', function( event ) {
|
||||
if ( event.format !== 'raw' ) {
|
||||
editor.$( 'img[id="__wp-temp-img-id"]' ).removeAttr( 'id' );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'BeforeSetContent', function( event ) {
|
||||
if ( event.format !== 'raw' ) {
|
||||
event.content = editor.wpSetImgCaption( event.content );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'PostProcess', function( event ) {
|
||||
if ( event.get ) {
|
||||
event.content = editor.wpGetImgCaption( event.content );
|
||||
}
|
||||
});
|
||||
|
||||
( function() {
|
||||
var wrap;
|
||||
|
||||
editor.on( 'dragstart', function() {
|
||||
var node = editor.selection.getNode();
|
||||
|
||||
if ( node.nodeName === 'IMG' ) {
|
||||
wrap = editor.dom.getParent( node, '.mceTemp' );
|
||||
|
||||
if ( ! wrap && node.parentNode.nodeName === 'A' && ! hasTextContent( node.parentNode ) ) {
|
||||
wrap = node.parentNode;
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
editor.on( 'drop', function( event ) {
|
||||
var dom = editor.dom,
|
||||
rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint( event.clientX, event.clientY, editor.getDoc() );
|
||||
|
||||
// Don't allow anything to be dropped in a captioned image.
|
||||
if ( rng && dom.getParent( rng.startContainer, '.mceTemp' ) ) {
|
||||
event.preventDefault();
|
||||
} else if ( wrap ) {
|
||||
event.preventDefault();
|
||||
|
||||
editor.undoManager.transact( function() {
|
||||
if ( rng ) {
|
||||
editor.selection.setRng( rng );
|
||||
}
|
||||
|
||||
editor.selection.setNode( wrap );
|
||||
dom.remove( wrap );
|
||||
} );
|
||||
}
|
||||
|
||||
wrap = null;
|
||||
} );
|
||||
} )();
|
||||
|
||||
// Add to editor.wp.
|
||||
editor.wp = editor.wp || {};
|
||||
editor.wp.isPlaceholder = isPlaceholder;
|
||||
|
||||
// Back-compat.
|
||||
return {
|
||||
_do_shcode: parseShortcode,
|
||||
_get_shcode: getShortcode
|
||||
};
|
||||
});
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpeditimage/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpeditimage/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
134
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpemoji/plugin.js
Normal file
134
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpemoji/plugin.js
Normal file
@ -0,0 +1,134 @@
|
||||
( function( tinymce ) {
|
||||
tinymce.PluginManager.add( 'wpemoji', function( editor ) {
|
||||
var typing,
|
||||
wp = window.wp,
|
||||
settings = window._wpemojiSettings,
|
||||
env = tinymce.Env,
|
||||
ua = window.navigator.userAgent,
|
||||
isWin = ua.indexOf( 'Windows' ) > -1,
|
||||
isWin8 = ( function() {
|
||||
var match = ua.match( /Windows NT 6\.(\d)/ );
|
||||
|
||||
if ( match && match[1] > 1 ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}());
|
||||
|
||||
if ( ! wp || ! wp.emoji || settings.supports.everything ) {
|
||||
return;
|
||||
}
|
||||
|
||||
function setImgAttr( image ) {
|
||||
image.className = 'emoji';
|
||||
image.setAttribute( 'data-mce-resize', 'false' );
|
||||
image.setAttribute( 'data-mce-placeholder', '1' );
|
||||
image.setAttribute( 'data-wp-emoji', '1' );
|
||||
}
|
||||
|
||||
function replaceEmoji( node ) {
|
||||
var imgAttr = {
|
||||
'data-mce-resize': 'false',
|
||||
'data-mce-placeholder': '1',
|
||||
'data-wp-emoji': '1'
|
||||
};
|
||||
|
||||
wp.emoji.parse( node, { imgAttr: imgAttr } );
|
||||
}
|
||||
|
||||
// Test if the node text contains emoji char(s) and replace.
|
||||
function parseNode( node ) {
|
||||
var selection, bookmark;
|
||||
|
||||
if ( node && window.twemoji && window.twemoji.test( node.textContent || node.innerText ) ) {
|
||||
if ( env.webkit ) {
|
||||
selection = editor.selection;
|
||||
bookmark = selection.getBookmark();
|
||||
}
|
||||
|
||||
replaceEmoji( node );
|
||||
|
||||
if ( env.webkit ) {
|
||||
selection.moveToBookmark( bookmark );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isWin8 ) {
|
||||
/*
|
||||
* Windows 8+ emoji can be "typed" with the onscreen keyboard.
|
||||
* That triggers the normal keyboard events, but not the 'input' event.
|
||||
* Thankfully it sets keyCode 231 when the onscreen keyboard inserts any emoji.
|
||||
*/
|
||||
editor.on( 'keyup', function( event ) {
|
||||
if ( event.keyCode === 231 ) {
|
||||
parseNode( editor.selection.getNode() );
|
||||
}
|
||||
} );
|
||||
} else if ( ! isWin ) {
|
||||
/*
|
||||
* In MacOS inserting emoji doesn't trigger the stanradr keyboard events.
|
||||
* Thankfully it triggers the 'input' event.
|
||||
* This works in Android and iOS as well.
|
||||
*/
|
||||
editor.on( 'keydown keyup', function( event ) {
|
||||
typing = ( event.type === 'keydown' );
|
||||
} );
|
||||
|
||||
editor.on( 'input', function() {
|
||||
if ( typing ) {
|
||||
return;
|
||||
}
|
||||
|
||||
parseNode( editor.selection.getNode() );
|
||||
});
|
||||
}
|
||||
|
||||
editor.on( 'setcontent', function( event ) {
|
||||
var selection = editor.selection,
|
||||
node = selection.getNode();
|
||||
|
||||
if ( window.twemoji && window.twemoji.test( node.textContent || node.innerText ) ) {
|
||||
replaceEmoji( node );
|
||||
|
||||
// In IE all content in the editor is left selected after wp.emoji.parse()...
|
||||
// Collapse the selection to the beginning.
|
||||
if ( env.ie && env.ie < 9 && event.load && node && node.nodeName === 'BODY' ) {
|
||||
selection.collapse( true );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// Convert Twemoji compatible pasted emoji replacement images into our format.
|
||||
editor.on( 'PastePostProcess', function( event ) {
|
||||
if ( window.twemoji ) {
|
||||
tinymce.each( editor.dom.$( 'img.emoji', event.node ), function( image ) {
|
||||
if ( image.alt && window.twemoji.test( image.alt ) ) {
|
||||
setImgAttr( image );
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'postprocess', function( event ) {
|
||||
if ( event.content ) {
|
||||
event.content = event.content.replace( /<img[^>]+data-wp-emoji="[^>]+>/g, function( img ) {
|
||||
var alt = img.match( /alt="([^"]+)"/ );
|
||||
|
||||
if ( alt && alt[1] ) {
|
||||
return alt[1];
|
||||
}
|
||||
|
||||
return img;
|
||||
});
|
||||
}
|
||||
} );
|
||||
|
||||
editor.on( 'resolvename', function( event ) {
|
||||
if ( event.target.nodeName === 'IMG' && editor.dom.getAttrib( event.target, 'data-wp-emoji' ) ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} )( window.tinymce );
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpemoji/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpemoji/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(m){m.PluginManager.add("wpemoji",function(n){var t,o=window.wp,e=window._wpemojiSettings,i=m.Env,a=window.navigator.userAgent,w=-1<a.indexOf("Windows"),a=!!((a=a.match(/Windows NT 6\.(\d)/))&&1<a[1]);function d(e){o.emoji.parse(e,{imgAttr:{"data-mce-resize":"false","data-mce-placeholder":"1","data-wp-emoji":"1"}})}function c(e){var t,o;e&&window.twemoji&&window.twemoji.test(e.textContent||e.innerText)&&(i.webkit&&(o=(t=n.selection).getBookmark()),d(e),i.webkit&&t.moveToBookmark(o))}o&&o.emoji&&!e.supports.everything&&(a?n.on("keyup",function(e){231===e.keyCode&&c(n.selection.getNode())}):w||(n.on("keydown keyup",function(e){t="keydown"===e.type}),n.on("input",function(){t||c(n.selection.getNode())})),n.on("setcontent",function(e){var t=n.selection,o=t.getNode();window.twemoji&&window.twemoji.test(o.textContent||o.innerText)&&(d(o),i.ie&&i.ie<9&&e.load&&o&&"BODY"===o.nodeName&&t.collapse(!0))}),n.on("PastePostProcess",function(e){window.twemoji&&m.each(n.dom.$("img.emoji",e.node),function(e){e.alt&&window.twemoji.test(e.alt)&&((e=e).className="emoji",e.setAttribute("data-mce-resize","false"),e.setAttribute("data-mce-placeholder","1"),e.setAttribute("data-wp-emoji","1"))})}),n.on("postprocess",function(e){e.content&&(e.content=e.content.replace(/<img[^>]+data-wp-emoji="[^>]+>/g,function(e){var t=e.match(/alt="([^"]+)"/);return t&&t[1]?t[1]:e}))}),n.on("resolvename",function(e){"IMG"===e.target.nodeName&&n.dom.getAttrib(e.target,"data-wp-emoji")&&e.preventDefault()}))})}(window.tinymce);
|
@ -0,0 +1,112 @@
|
||||
/* global tinymce */
|
||||
tinymce.PluginManager.add('wpgallery', function( editor ) {
|
||||
|
||||
function replaceGalleryShortcodes( content ) {
|
||||
return content.replace( /\[gallery([^\]]*)\]/g, function( match ) {
|
||||
return html( 'wp-gallery', match );
|
||||
});
|
||||
}
|
||||
|
||||
function html( cls, data ) {
|
||||
data = window.encodeURIComponent( data );
|
||||
return '<img src="' + tinymce.Env.transparentSrc + '" class="wp-media mceItem ' + cls + '" ' +
|
||||
'data-wp-media="' + data + '" data-mce-resize="false" data-mce-placeholder="1" alt="" />';
|
||||
}
|
||||
|
||||
function restoreMediaShortcodes( content ) {
|
||||
function getAttr( str, name ) {
|
||||
name = new RegExp( name + '=\"([^\"]+)\"' ).exec( str );
|
||||
return name ? window.decodeURIComponent( name[1] ) : '';
|
||||
}
|
||||
|
||||
return content.replace( /(?:<p(?: [^>]+)?>)*(<img [^>]+>)(?:<\/p>)*/g, function( match, image ) {
|
||||
var data = getAttr( image, 'data-wp-media' );
|
||||
|
||||
if ( data ) {
|
||||
return '<p>' + data + '</p>';
|
||||
}
|
||||
|
||||
return match;
|
||||
});
|
||||
}
|
||||
|
||||
function editMedia( node ) {
|
||||
var gallery, frame, data;
|
||||
|
||||
if ( node.nodeName !== 'IMG' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the `wp.media` API exists.
|
||||
if ( typeof wp === 'undefined' || ! wp.media ) {
|
||||
return;
|
||||
}
|
||||
|
||||
data = window.decodeURIComponent( editor.dom.getAttrib( node, 'data-wp-media' ) );
|
||||
|
||||
// Make sure we've selected a gallery node.
|
||||
if ( editor.dom.hasClass( node, 'wp-gallery' ) && wp.media.gallery ) {
|
||||
gallery = wp.media.gallery;
|
||||
frame = gallery.edit( data );
|
||||
|
||||
frame.state('gallery-edit').on( 'update', function( selection ) {
|
||||
var shortcode = gallery.shortcode( selection ).string();
|
||||
editor.dom.setAttrib( node, 'data-wp-media', window.encodeURIComponent( shortcode ) );
|
||||
frame.detach();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...').
|
||||
editor.addCommand( 'WP_Gallery', function() {
|
||||
editMedia( editor.selection.getNode() );
|
||||
});
|
||||
|
||||
editor.on( 'mouseup', function( event ) {
|
||||
var dom = editor.dom,
|
||||
node = event.target;
|
||||
|
||||
function unselect() {
|
||||
dom.removeClass( dom.select( 'img.wp-media-selected' ), 'wp-media-selected' );
|
||||
}
|
||||
|
||||
if ( node.nodeName === 'IMG' && dom.getAttrib( node, 'data-wp-media' ) ) {
|
||||
// Don't trigger on right-click.
|
||||
if ( event.button !== 2 ) {
|
||||
if ( dom.hasClass( node, 'wp-media-selected' ) ) {
|
||||
editMedia( node );
|
||||
} else {
|
||||
unselect();
|
||||
dom.addClass( node, 'wp-media-selected' );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unselect();
|
||||
}
|
||||
});
|
||||
|
||||
// Display gallery, audio or video instead of img in the element path.
|
||||
editor.on( 'ResolveName', function( event ) {
|
||||
var dom = editor.dom,
|
||||
node = event.target;
|
||||
|
||||
if ( node.nodeName === 'IMG' && dom.getAttrib( node, 'data-wp-media' ) ) {
|
||||
if ( dom.hasClass( node, 'wp-gallery' ) ) {
|
||||
event.name = 'gallery';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'BeforeSetContent', function( event ) {
|
||||
// 'wpview' handles the gallery shortcode when present.
|
||||
if ( ! editor.plugins.wpview || typeof wp === 'undefined' || ! wp.mce ) {
|
||||
event.content = replaceGalleryShortcodes( event.content );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'PostProcess', function( event ) {
|
||||
if ( event.get ) {
|
||||
event.content = restoreMediaShortcodes( event.content );
|
||||
}
|
||||
});
|
||||
});
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpgallery/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpgallery/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("wpgallery",function(d){function t(e){return e.replace(/\[gallery([^\]]*)\]/g,function(e){return t="wp-gallery",n=e,n=window.encodeURIComponent(e),'<img src="'+tinymce.Env.transparentSrc+'" class="wp-media mceItem '+t+'" data-wp-media="'+n+'" data-mce-resize="false" data-mce-placeholder="1" alt="" />';var t,n})}function n(e){return e.replace(/(?:<p(?: [^>]+)?>)*(<img [^>]+>)(?:<\/p>)*/g,function(e,t){var n,t=(n=t,t="data-wp-media",(t=new RegExp(t+'="([^"]+)"').exec(n))?window.decodeURIComponent(t[1]):"");return t?"<p>"+t+"</p>":e})}function o(t){var n,a,e;"IMG"===t.nodeName&&"undefined"!=typeof wp&&wp.media&&(e=window.decodeURIComponent(d.dom.getAttrib(t,"data-wp-media")),d.dom.hasClass(t,"wp-gallery")&&wp.media.gallery&&(n=wp.media.gallery,(a=n.edit(e)).state("gallery-edit").on("update",function(e){e=n.shortcode(e).string();d.dom.setAttrib(t,"data-wp-media",window.encodeURIComponent(e)),a.detach()})))}d.addCommand("WP_Gallery",function(){o(d.selection.getNode())}),d.on("mouseup",function(e){var t=d.dom,n=e.target;function a(){t.removeClass(t.select("img.wp-media-selected"),"wp-media-selected")}"IMG"===n.nodeName&&t.getAttrib(n,"data-wp-media")?2!==e.button&&(t.hasClass(n,"wp-media-selected")?o(n):(a(),t.addClass(n,"wp-media-selected"))):a()}),d.on("ResolveName",function(e){var t=d.dom,n=e.target;"IMG"===n.nodeName&&t.getAttrib(n,"data-wp-media")&&t.hasClass(n,"wp-gallery")&&(e.name="gallery")}),d.on("BeforeSetContent",function(e){d.plugins.wpview&&"undefined"!=typeof wp&&wp.mce||(e.content=t(e.content))}),d.on("PostProcess",function(e){e.get&&(e.content=n(e.content))})});
|
610
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wplink/plugin.js
Normal file
610
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wplink/plugin.js
Normal file
@ -0,0 +1,610 @@
|
||||
( function( tinymce ) {
|
||||
tinymce.ui.Factory.add( 'WPLinkPreview', tinymce.ui.Control.extend( {
|
||||
url: '#',
|
||||
renderHtml: function() {
|
||||
return (
|
||||
'<div id="' + this._id + '" class="wp-link-preview">' +
|
||||
'<a href="' + this.url + '" target="_blank" rel="noopener" tabindex="-1">' + this.url + '</a>' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
setURL: function( url ) {
|
||||
var index, lastIndex;
|
||||
|
||||
if ( this.url !== url ) {
|
||||
this.url = url;
|
||||
|
||||
url = window.decodeURIComponent( url );
|
||||
|
||||
url = url.replace( /^(?:https?:)?\/\/(?:www\.)?/, '' );
|
||||
|
||||
if ( ( index = url.indexOf( '?' ) ) !== -1 ) {
|
||||
url = url.slice( 0, index );
|
||||
}
|
||||
|
||||
if ( ( index = url.indexOf( '#' ) ) !== -1 ) {
|
||||
url = url.slice( 0, index );
|
||||
}
|
||||
|
||||
url = url.replace( /(?:index)?\.html$/, '' );
|
||||
|
||||
if ( url.charAt( url.length - 1 ) === '/' ) {
|
||||
url = url.slice( 0, -1 );
|
||||
}
|
||||
|
||||
// If nothing's left (maybe the URL was just a fragment), use the whole URL.
|
||||
if ( url === '' ) {
|
||||
url = this.url;
|
||||
}
|
||||
|
||||
// If the URL is longer that 40 chars, concatenate the beginning (after the domain) and ending with '...'.
|
||||
if ( url.length > 40 && ( index = url.indexOf( '/' ) ) !== -1 && ( lastIndex = url.lastIndexOf( '/' ) ) !== -1 && lastIndex !== index ) {
|
||||
// If the beginning + ending are shorter that 40 chars, show more of the ending.
|
||||
if ( index + url.length - lastIndex < 40 ) {
|
||||
lastIndex = -( 40 - ( index + 1 ) );
|
||||
}
|
||||
|
||||
url = url.slice( 0, index + 1 ) + '\u2026' + url.slice( lastIndex );
|
||||
}
|
||||
|
||||
tinymce.$( this.getEl().firstChild ).attr( 'href', this.url ).text( url );
|
||||
}
|
||||
}
|
||||
} ) );
|
||||
|
||||
tinymce.ui.Factory.add( 'WPLinkInput', tinymce.ui.Control.extend( {
|
||||
renderHtml: function() {
|
||||
return (
|
||||
'<div id="' + this._id + '" class="wp-link-input">' +
|
||||
'<input type="text" value="" placeholder="' + tinymce.translate( 'Paste URL or type to search' ) + '" />' +
|
||||
'<input type="text" style="display:none" value="" />' +
|
||||
'</div>'
|
||||
);
|
||||
},
|
||||
setURL: function( url ) {
|
||||
this.getEl().firstChild.value = url;
|
||||
},
|
||||
getURL: function() {
|
||||
return tinymce.trim( this.getEl().firstChild.value );
|
||||
},
|
||||
getLinkText: function() {
|
||||
var text = this.getEl().firstChild.nextSibling.value;
|
||||
|
||||
if ( ! tinymce.trim( text ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return text.replace( /[\r\n\t ]+/g, ' ' );
|
||||
},
|
||||
reset: function() {
|
||||
var urlInput = this.getEl().firstChild;
|
||||
|
||||
urlInput.value = '';
|
||||
urlInput.nextSibling.value = '';
|
||||
}
|
||||
} ) );
|
||||
|
||||
tinymce.PluginManager.add( 'wplink', function( editor ) {
|
||||
var toolbar;
|
||||
var editToolbar;
|
||||
var previewInstance;
|
||||
var inputInstance;
|
||||
var linkNode;
|
||||
var doingUndoRedo;
|
||||
var doingUndoRedoTimer;
|
||||
var $ = window.jQuery;
|
||||
var emailRegex = /^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i;
|
||||
var urlRegex1 = /^https?:\/\/([^\s/?.#-][^\s\/?.#]*\.?)+(\/[^\s"]*)?$/i;
|
||||
var urlRegex2 = /^https?:\/\/[^\/]+\.[^\/]+($|\/)/i;
|
||||
var speak = ( typeof window.wp !== 'undefined' && window.wp.a11y && window.wp.a11y.speak ) ? window.wp.a11y.speak : function() {};
|
||||
var hasLinkError = false;
|
||||
|
||||
function getSelectedLink() {
|
||||
var href, html,
|
||||
node = editor.selection.getStart(),
|
||||
link = editor.dom.getParent( node, 'a[href]' );
|
||||
|
||||
if ( ! link ) {
|
||||
html = editor.selection.getContent({ format: 'raw' });
|
||||
|
||||
if ( html && html.indexOf( '</a>' ) !== -1 ) {
|
||||
href = html.match( /href="([^">]+)"/ );
|
||||
|
||||
if ( href && href[1] ) {
|
||||
link = editor.$( 'a[href="' + href[1] + '"]', node )[0];
|
||||
}
|
||||
|
||||
if ( link ) {
|
||||
editor.selection.select( link );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
function removePlaceholders() {
|
||||
editor.$( 'a' ).each( function( i, element ) {
|
||||
var $element = editor.$( element );
|
||||
|
||||
if ( $element.attr( 'href' ) === '_wp_link_placeholder' ) {
|
||||
editor.dom.remove( element, true );
|
||||
} else if ( $element.attr( 'data-wplink-edit' ) ) {
|
||||
$element.attr( 'data-wplink-edit', null );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function removePlaceholderStrings( content, dataAttr ) {
|
||||
return content.replace( /(<a [^>]+>)([\s\S]*?)<\/a>/g, function( all, tag, text ) {
|
||||
if ( tag.indexOf( ' href="_wp_link_placeholder"' ) > -1 ) {
|
||||
return text;
|
||||
}
|
||||
|
||||
if ( dataAttr ) {
|
||||
tag = tag.replace( / data-wplink-edit="true"/g, '' );
|
||||
}
|
||||
|
||||
tag = tag.replace( / data-wplink-url-error="true"/g, '' );
|
||||
|
||||
return tag + text + '</a>';
|
||||
});
|
||||
}
|
||||
|
||||
function checkLink( node ) {
|
||||
var $link = editor.$( node );
|
||||
var href = $link.attr( 'href' );
|
||||
|
||||
if ( ! href || typeof $ === 'undefined' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
hasLinkError = false;
|
||||
|
||||
if ( /^http/i.test( href ) && ( ! urlRegex1.test( href ) || ! urlRegex2.test( href ) ) ) {
|
||||
hasLinkError = true;
|
||||
$link.attr( 'data-wplink-url-error', 'true' );
|
||||
speak( editor.translate( 'Warning: the link has been inserted but may have errors. Please test it.' ), 'assertive' );
|
||||
} else {
|
||||
$link.removeAttr( 'data-wplink-url-error' );
|
||||
}
|
||||
}
|
||||
|
||||
editor.on( 'preinit', function() {
|
||||
if ( editor.wp && editor.wp._createToolbar ) {
|
||||
toolbar = editor.wp._createToolbar( [
|
||||
'wp_link_preview',
|
||||
'wp_link_edit',
|
||||
'wp_link_remove'
|
||||
], true );
|
||||
|
||||
var editButtons = [
|
||||
'wp_link_input',
|
||||
'wp_link_apply'
|
||||
];
|
||||
|
||||
if ( typeof window.wpLink !== 'undefined' ) {
|
||||
editButtons.push( 'wp_link_advanced' );
|
||||
}
|
||||
|
||||
editToolbar = editor.wp._createToolbar( editButtons, true );
|
||||
|
||||
editToolbar.on( 'show', function() {
|
||||
if ( typeof window.wpLink === 'undefined' || ! window.wpLink.modalOpen ) {
|
||||
window.setTimeout( function() {
|
||||
var element = editToolbar.$el.find( 'input.ui-autocomplete-input' )[0],
|
||||
selection = linkNode && ( linkNode.textContent || linkNode.innerText );
|
||||
|
||||
if ( element ) {
|
||||
if ( ! element.value && selection && typeof window.wpLink !== 'undefined' ) {
|
||||
element.value = window.wpLink.getUrlFromSelection( selection );
|
||||
}
|
||||
|
||||
if ( ! doingUndoRedo ) {
|
||||
element.focus();
|
||||
element.select();
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
editToolbar.on( 'hide', function() {
|
||||
if ( ! editToolbar.scrolling ) {
|
||||
editor.execCommand( 'wp_link_cancel' );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addCommand( 'WP_Link', function() {
|
||||
if ( tinymce.Env.ie && tinymce.Env.ie < 10 && typeof window.wpLink !== 'undefined' ) {
|
||||
window.wpLink.open( editor.id );
|
||||
return;
|
||||
}
|
||||
|
||||
linkNode = getSelectedLink();
|
||||
editToolbar.tempHide = false;
|
||||
|
||||
if ( ! linkNode ) {
|
||||
removePlaceholders();
|
||||
editor.execCommand( 'mceInsertLink', false, { href: '_wp_link_placeholder' } );
|
||||
|
||||
linkNode = editor.$( 'a[href="_wp_link_placeholder"]' )[0];
|
||||
editor.nodeChanged();
|
||||
}
|
||||
|
||||
editor.dom.setAttribs( linkNode, { 'data-wplink-edit': true } );
|
||||
} );
|
||||
|
||||
editor.addCommand( 'wp_link_apply', function() {
|
||||
if ( editToolbar.scrolling ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var href, text;
|
||||
|
||||
if ( linkNode ) {
|
||||
href = inputInstance.getURL();
|
||||
text = inputInstance.getLinkText();
|
||||
editor.focus();
|
||||
|
||||
var parser = document.createElement( 'a' );
|
||||
parser.href = href;
|
||||
|
||||
if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line
|
||||
href = '';
|
||||
}
|
||||
|
||||
if ( ! href ) {
|
||||
editor.dom.remove( linkNode, true );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( href ) && ! emailRegex.test( href ) ) {
|
||||
href = 'http://' + href;
|
||||
}
|
||||
|
||||
editor.dom.setAttribs( linkNode, { href: href, 'data-wplink-edit': null } );
|
||||
|
||||
if ( ! tinymce.trim( linkNode.innerHTML ) ) {
|
||||
editor.$( linkNode ).text( text || href );
|
||||
}
|
||||
|
||||
checkLink( linkNode );
|
||||
}
|
||||
|
||||
inputInstance.reset();
|
||||
editor.nodeChanged();
|
||||
|
||||
// Audible confirmation message when a link has been inserted in the Editor.
|
||||
if ( typeof window.wpLinkL10n !== 'undefined' && ! hasLinkError ) {
|
||||
speak( window.wpLinkL10n.linkInserted );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addCommand( 'wp_link_cancel', function() {
|
||||
inputInstance.reset();
|
||||
|
||||
if ( ! editToolbar.tempHide ) {
|
||||
removePlaceholders();
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addCommand( 'wp_unlink', function() {
|
||||
editor.execCommand( 'unlink' );
|
||||
editToolbar.tempHide = false;
|
||||
editor.execCommand( 'wp_link_cancel' );
|
||||
} );
|
||||
|
||||
// WP default shortcuts.
|
||||
editor.addShortcut( 'access+a', '', 'WP_Link' );
|
||||
editor.addShortcut( 'access+s', '', 'wp_unlink' );
|
||||
// The "de-facto standard" shortcut, see #27305.
|
||||
editor.addShortcut( 'meta+k', '', 'WP_Link' );
|
||||
|
||||
editor.addButton( 'link', {
|
||||
icon: 'link',
|
||||
tooltip: 'Insert/edit link',
|
||||
cmd: 'WP_Link',
|
||||
stateSelector: 'a[href]'
|
||||
});
|
||||
|
||||
editor.addButton( 'unlink', {
|
||||
icon: 'unlink',
|
||||
tooltip: 'Remove link',
|
||||
cmd: 'unlink'
|
||||
});
|
||||
|
||||
editor.addMenuItem( 'link', {
|
||||
icon: 'link',
|
||||
text: 'Insert/edit link',
|
||||
cmd: 'WP_Link',
|
||||
stateSelector: 'a[href]',
|
||||
context: 'insert',
|
||||
prependToContext: true
|
||||
});
|
||||
|
||||
editor.on( 'pastepreprocess', function( event ) {
|
||||
var pastedStr = event.content,
|
||||
regExp = /^(?:https?:)?\/\/\S+$/i;
|
||||
|
||||
if ( ! editor.selection.isCollapsed() && ! regExp.test( editor.selection.getContent() ) ) {
|
||||
pastedStr = pastedStr.replace( /<[^>]+>/g, '' );
|
||||
pastedStr = tinymce.trim( pastedStr );
|
||||
|
||||
if ( regExp.test( pastedStr ) ) {
|
||||
editor.execCommand( 'mceInsertLink', false, {
|
||||
href: editor.dom.decode( pastedStr )
|
||||
} );
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// Remove any remaining placeholders on saving.
|
||||
editor.on( 'savecontent', function( event ) {
|
||||
event.content = removePlaceholderStrings( event.content, true );
|
||||
});
|
||||
|
||||
// Prevent adding undo levels on inserting link placeholder.
|
||||
editor.on( 'BeforeAddUndo', function( event ) {
|
||||
if ( event.lastLevel && event.lastLevel.content && event.level.content &&
|
||||
event.lastLevel.content === removePlaceholderStrings( event.level.content ) ) {
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
// When doing undo and redo with keyboard shortcuts (Ctrl|Cmd+Z, Ctrl|Cmd+Shift+Z, Ctrl|Cmd+Y),
|
||||
// set a flag to not focus the inline dialog. The editor has to remain focused so the users can do consecutive undo/redo.
|
||||
editor.on( 'keydown', function( event ) {
|
||||
if ( event.keyCode === 27 ) { // Esc
|
||||
editor.execCommand( 'wp_link_cancel' );
|
||||
}
|
||||
|
||||
if ( event.altKey || ( tinymce.Env.mac && ( ! event.metaKey || event.ctrlKey ) ) ||
|
||||
( ! tinymce.Env.mac && ! event.ctrlKey ) ) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( event.keyCode === 89 || event.keyCode === 90 ) { // Y or Z
|
||||
doingUndoRedo = true;
|
||||
|
||||
window.clearTimeout( doingUndoRedoTimer );
|
||||
doingUndoRedoTimer = window.setTimeout( function() {
|
||||
doingUndoRedo = false;
|
||||
}, 500 );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_link_preview', {
|
||||
type: 'WPLinkPreview',
|
||||
onPostRender: function() {
|
||||
previewInstance = this;
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_link_input', {
|
||||
type: 'WPLinkInput',
|
||||
onPostRender: function() {
|
||||
var element = this.getEl(),
|
||||
input = element.firstChild,
|
||||
$input, cache, last;
|
||||
|
||||
inputInstance = this;
|
||||
|
||||
if ( $ && $.ui && $.ui.autocomplete ) {
|
||||
$input = $( input );
|
||||
|
||||
$input.on( 'keydown', function() {
|
||||
$input.removeAttr( 'aria-activedescendant' );
|
||||
} )
|
||||
.autocomplete( {
|
||||
source: function( request, response ) {
|
||||
if ( last === request.term ) {
|
||||
response( cache );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( /^https?:/.test( request.term ) || request.term.indexOf( '.' ) !== -1 ) {
|
||||
return response();
|
||||
}
|
||||
|
||||
$.post( window.ajaxurl, {
|
||||
action: 'wp-link-ajax',
|
||||
page: 1,
|
||||
search: request.term,
|
||||
_ajax_linking_nonce: $( '#_ajax_linking_nonce' ).val()
|
||||
}, function( data ) {
|
||||
cache = data;
|
||||
response( data );
|
||||
}, 'json' );
|
||||
|
||||
last = request.term;
|
||||
},
|
||||
focus: function( event, ui ) {
|
||||
$input.attr( 'aria-activedescendant', 'mce-wp-autocomplete-' + ui.item.ID );
|
||||
/*
|
||||
* Don't empty the URL input field, when using the arrow keys to
|
||||
* highlight items. See api.jqueryui.com/autocomplete/#event-focus
|
||||
*/
|
||||
event.preventDefault();
|
||||
},
|
||||
select: function( event, ui ) {
|
||||
$input.val( ui.item.permalink );
|
||||
$( element.firstChild.nextSibling ).val( ui.item.title );
|
||||
|
||||
if ( 9 === event.keyCode && typeof window.wpLinkL10n !== 'undefined' ) {
|
||||
// Audible confirmation message when a link has been selected.
|
||||
speak( window.wpLinkL10n.linkSelected );
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
open: function() {
|
||||
$input.attr( 'aria-expanded', 'true' );
|
||||
editToolbar.blockHide = true;
|
||||
},
|
||||
close: function() {
|
||||
$input.attr( 'aria-expanded', 'false' );
|
||||
editToolbar.blockHide = false;
|
||||
},
|
||||
minLength: 2,
|
||||
position: {
|
||||
my: 'left top+2'
|
||||
},
|
||||
messages: {
|
||||
noResults: ( typeof window.uiAutocompleteL10n !== 'undefined' ) ? window.uiAutocompleteL10n.noResults : '',
|
||||
results: function( number ) {
|
||||
if ( typeof window.uiAutocompleteL10n !== 'undefined' ) {
|
||||
if ( number > 1 ) {
|
||||
return window.uiAutocompleteL10n.manyResults.replace( '%d', number );
|
||||
}
|
||||
|
||||
return window.uiAutocompleteL10n.oneResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
} ).autocomplete( 'instance' )._renderItem = function( ul, item ) {
|
||||
var fallbackTitle = ( typeof window.wpLinkL10n !== 'undefined' ) ? window.wpLinkL10n.noTitle : '',
|
||||
title = item.title ? item.title : fallbackTitle;
|
||||
|
||||
return $( '<li role="option" id="mce-wp-autocomplete-' + item.ID + '">' )
|
||||
.append( '<span>' + title + '</span> <span class="wp-editor-float-right">' + item.info + '</span>' )
|
||||
.appendTo( ul );
|
||||
};
|
||||
|
||||
$input.attr( {
|
||||
'role': 'combobox',
|
||||
'aria-autocomplete': 'list',
|
||||
'aria-expanded': 'false',
|
||||
'aria-owns': $input.autocomplete( 'widget' ).attr( 'id' )
|
||||
} )
|
||||
.on( 'focus', function() {
|
||||
var inputValue = $input.val();
|
||||
/*
|
||||
* Don't trigger a search if the URL field already has a link or is empty.
|
||||
* Also, avoids screen readers announce `No search results`.
|
||||
*/
|
||||
if ( inputValue && ! /^https?:/.test( inputValue ) ) {
|
||||
$input.autocomplete( 'search' );
|
||||
}
|
||||
} )
|
||||
// Returns a jQuery object containing the menu element.
|
||||
.autocomplete( 'widget' )
|
||||
.addClass( 'wplink-autocomplete' )
|
||||
.attr( 'role', 'listbox' )
|
||||
.removeAttr( 'tabindex' ) // Remove the `tabindex=0` attribute added by jQuery UI.
|
||||
/*
|
||||
* Looks like Safari and VoiceOver need an `aria-selected` attribute. See ticket #33301.
|
||||
* The `menufocus` and `menublur` events are the same events used to add and remove
|
||||
* the `ui-state-focus` CSS class on the menu items. See jQuery UI Menu Widget.
|
||||
*/
|
||||
.on( 'menufocus', function( event, ui ) {
|
||||
ui.item.attr( 'aria-selected', 'true' );
|
||||
})
|
||||
.on( 'menublur', function() {
|
||||
/*
|
||||
* The `menublur` event returns an object where the item is `null`
|
||||
* so we need to find the active item with other means.
|
||||
*/
|
||||
$( this ).find( '[aria-selected="true"]' ).removeAttr( 'aria-selected' );
|
||||
});
|
||||
}
|
||||
|
||||
tinymce.$( input ).on( 'keydown', function( event ) {
|
||||
if ( event.keyCode === 13 ) {
|
||||
editor.execCommand( 'wp_link_apply' );
|
||||
event.preventDefault();
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.on( 'wptoolbar', function( event ) {
|
||||
var linkNode = editor.dom.getParent( event.element, 'a' ),
|
||||
$linkNode, href, edit;
|
||||
|
||||
if ( typeof window.wpLink !== 'undefined' && window.wpLink.modalOpen ) {
|
||||
editToolbar.tempHide = true;
|
||||
return;
|
||||
}
|
||||
|
||||
editToolbar.tempHide = false;
|
||||
|
||||
if ( linkNode ) {
|
||||
$linkNode = editor.$( linkNode );
|
||||
href = $linkNode.attr( 'href' );
|
||||
edit = $linkNode.attr( 'data-wplink-edit' );
|
||||
|
||||
if ( href === '_wp_link_placeholder' || edit ) {
|
||||
if ( href !== '_wp_link_placeholder' && ! inputInstance.getURL() ) {
|
||||
inputInstance.setURL( href );
|
||||
}
|
||||
|
||||
event.element = linkNode;
|
||||
event.toolbar = editToolbar;
|
||||
} else if ( href && ! $linkNode.find( 'img' ).length ) {
|
||||
previewInstance.setURL( href );
|
||||
event.element = linkNode;
|
||||
event.toolbar = toolbar;
|
||||
|
||||
if ( $linkNode.attr( 'data-wplink-url-error' ) === 'true' ) {
|
||||
toolbar.$el.find( '.wp-link-preview a' ).addClass( 'wplink-url-error' );
|
||||
} else {
|
||||
toolbar.$el.find( '.wp-link-preview a' ).removeClass( 'wplink-url-error' );
|
||||
hasLinkError = false;
|
||||
}
|
||||
}
|
||||
} else if ( editToolbar.visible() ) {
|
||||
editor.execCommand( 'wp_link_cancel' );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_link_edit', {
|
||||
tooltip: 'Edit|button', // '|button' is not displayed, only used for context.
|
||||
icon: 'dashicon dashicons-edit',
|
||||
cmd: 'WP_Link'
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_link_remove', {
|
||||
tooltip: 'Remove link',
|
||||
icon: 'dashicon dashicons-editor-unlink',
|
||||
cmd: 'wp_unlink'
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_link_advanced', {
|
||||
tooltip: 'Link options',
|
||||
icon: 'dashicon dashicons-admin-generic',
|
||||
onclick: function() {
|
||||
if ( typeof window.wpLink !== 'undefined' ) {
|
||||
var url = inputInstance.getURL() || null,
|
||||
text = inputInstance.getLinkText() || null;
|
||||
|
||||
window.wpLink.open( editor.id, url, text );
|
||||
|
||||
editToolbar.tempHide = true;
|
||||
editToolbar.hide();
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_link_apply', {
|
||||
tooltip: 'Apply',
|
||||
icon: 'dashicon dashicons-editor-break',
|
||||
cmd: 'wp_link_apply',
|
||||
classes: 'widget btn primary'
|
||||
} );
|
||||
|
||||
return {
|
||||
close: function() {
|
||||
editToolbar.tempHide = false;
|
||||
editor.execCommand( 'wp_link_cancel' );
|
||||
},
|
||||
checkLink: checkLink
|
||||
};
|
||||
} );
|
||||
} )( window.tinymce );
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wplink/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wplink/plugin.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,348 @@
|
||||
/**
|
||||
* Text pattern plugin for TinyMCE
|
||||
*
|
||||
* @since 4.3.0
|
||||
*
|
||||
* This plugin can automatically format text patterns as you type. It includes several groups of patterns.
|
||||
*
|
||||
* Start of line patterns:
|
||||
* As-you-type:
|
||||
* - Unordered list (`* ` and `- `).
|
||||
* - Ordered list (`1. ` and `1) `).
|
||||
*
|
||||
* On enter:
|
||||
* - h2 (## ).
|
||||
* - h3 (### ).
|
||||
* - h4 (#### ).
|
||||
* - h5 (##### ).
|
||||
* - h6 (###### ).
|
||||
* - blockquote (> ).
|
||||
* - hr (---).
|
||||
*
|
||||
* Inline patterns:
|
||||
* - <code> (`) (backtick).
|
||||
*
|
||||
* If the transformation in unwanted, the user can undo the change by pressing backspace,
|
||||
* using the undo shortcut, or the undo button in the toolbar.
|
||||
*
|
||||
* Setting for the patterns can be overridden by plugins by using the `tiny_mce_before_init` PHP filter.
|
||||
* The setting name is `wptextpattern` and the value is an object containing override arrays for each
|
||||
* patterns group. There are three groups: "space", "enter", and "inline". Example (PHP):
|
||||
*
|
||||
* add_filter( 'tiny_mce_before_init', 'my_mce_init_wptextpattern' );
|
||||
* function my_mce_init_wptextpattern( $init ) {
|
||||
* $init['wptextpattern'] = wp_json_encode( array(
|
||||
* 'inline' => array(
|
||||
* array( 'delimiter' => '**', 'format' => 'bold' ),
|
||||
* array( 'delimiter' => '__', 'format' => 'italic' ),
|
||||
* ),
|
||||
* ) );
|
||||
*
|
||||
* return $init;
|
||||
* }
|
||||
*
|
||||
* Note that setting this will override the default text patterns. You will need to include them
|
||||
* in your settings array if you want to keep them working.
|
||||
*/
|
||||
( function( tinymce, setTimeout ) {
|
||||
if ( tinymce.Env.ie && tinymce.Env.ie < 9 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes characters for use in a Regular Expression.
|
||||
*
|
||||
* @param {String} string Characters to escape
|
||||
*
|
||||
* @return {String} Escaped characters
|
||||
*/
|
||||
function escapeRegExp( string ) {
|
||||
return string.replace( /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&' );
|
||||
}
|
||||
|
||||
tinymce.PluginManager.add( 'wptextpattern', function( editor ) {
|
||||
var VK = tinymce.util.VK;
|
||||
var settings = editor.settings.wptextpattern || {};
|
||||
|
||||
var spacePatterns = settings.space || [
|
||||
{ regExp: /^[*-]\s/, cmd: 'InsertUnorderedList' },
|
||||
{ regExp: /^1[.)]\s/, cmd: 'InsertOrderedList' }
|
||||
];
|
||||
|
||||
var enterPatterns = settings.enter || [
|
||||
{ start: '##', format: 'h2' },
|
||||
{ start: '###', format: 'h3' },
|
||||
{ start: '####', format: 'h4' },
|
||||
{ start: '#####', format: 'h5' },
|
||||
{ start: '######', format: 'h6' },
|
||||
{ start: '>', format: 'blockquote' },
|
||||
{ regExp: /^(-){3,}$/, element: 'hr' }
|
||||
];
|
||||
|
||||
var inlinePatterns = settings.inline || [
|
||||
{ delimiter: '`', format: 'code' }
|
||||
];
|
||||
|
||||
var canUndo;
|
||||
|
||||
editor.on( 'selectionchange', function() {
|
||||
canUndo = null;
|
||||
} );
|
||||
|
||||
editor.on( 'keydown', function( event ) {
|
||||
if ( ( canUndo && event.keyCode === 27 /* ESCAPE */ ) || ( canUndo === 'space' && event.keyCode === VK.BACKSPACE ) ) {
|
||||
editor.undoManager.undo();
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
if ( VK.metaKeyPressed( event ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( event.keyCode === VK.ENTER ) {
|
||||
enter();
|
||||
// Wait for the browser to insert the character.
|
||||
} else if ( event.keyCode === VK.SPACEBAR ) {
|
||||
setTimeout( space );
|
||||
} else if ( event.keyCode > 47 && ! ( event.keyCode >= 91 && event.keyCode <= 93 ) ) {
|
||||
setTimeout( inline );
|
||||
}
|
||||
}, true );
|
||||
|
||||
function inline() {
|
||||
var rng = editor.selection.getRng();
|
||||
var node = rng.startContainer;
|
||||
var offset = rng.startOffset;
|
||||
var startOffset;
|
||||
var endOffset;
|
||||
var pattern;
|
||||
var format;
|
||||
var zero;
|
||||
|
||||
// We need a non-empty text node with an offset greater than zero.
|
||||
if ( ! node || node.nodeType !== 3 || ! node.data.length || ! offset ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var string = node.data.slice( 0, offset );
|
||||
var lastChar = node.data.charAt( offset - 1 );
|
||||
|
||||
tinymce.each( inlinePatterns, function( p ) {
|
||||
// Character before selection should be delimiter.
|
||||
if ( lastChar !== p.delimiter.slice( -1 ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var escDelimiter = escapeRegExp( p.delimiter );
|
||||
var delimiterFirstChar = p.delimiter.charAt( 0 );
|
||||
var regExp = new RegExp( '(.*)' + escDelimiter + '.+' + escDelimiter + '$' );
|
||||
var match = string.match( regExp );
|
||||
|
||||
if ( ! match ) {
|
||||
return;
|
||||
}
|
||||
|
||||
startOffset = match[1].length;
|
||||
endOffset = offset - p.delimiter.length;
|
||||
|
||||
var before = string.charAt( startOffset - 1 );
|
||||
var after = string.charAt( startOffset + p.delimiter.length );
|
||||
|
||||
// test*test* => format applied.
|
||||
// test *test* => applied.
|
||||
// test* test* => not applied.
|
||||
if ( startOffset && /\S/.test( before ) ) {
|
||||
if ( /\s/.test( after ) || before === delimiterFirstChar ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Do not replace when only whitespace and delimiter characters.
|
||||
if ( ( new RegExp( '^[\\s' + escapeRegExp( delimiterFirstChar ) + ']+$' ) ).test( string.slice( startOffset, endOffset ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
pattern = p;
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
||||
if ( ! pattern ) {
|
||||
return;
|
||||
}
|
||||
|
||||
format = editor.formatter.get( pattern.format );
|
||||
|
||||
if ( format && format[0].inline ) {
|
||||
editor.undoManager.add();
|
||||
|
||||
editor.undoManager.transact( function() {
|
||||
node.insertData( offset, '\uFEFF' );
|
||||
|
||||
node = node.splitText( startOffset );
|
||||
zero = node.splitText( offset - startOffset );
|
||||
|
||||
node.deleteData( 0, pattern.delimiter.length );
|
||||
node.deleteData( node.data.length - pattern.delimiter.length, pattern.delimiter.length );
|
||||
|
||||
editor.formatter.apply( pattern.format, {}, node );
|
||||
|
||||
editor.selection.setCursorLocation( zero, 1 );
|
||||
} );
|
||||
|
||||
// We need to wait for native events to be triggered.
|
||||
setTimeout( function() {
|
||||
canUndo = 'space';
|
||||
|
||||
editor.once( 'selectionchange', function() {
|
||||
var offset;
|
||||
|
||||
if ( zero ) {
|
||||
offset = zero.data.indexOf( '\uFEFF' );
|
||||
|
||||
if ( offset !== -1 ) {
|
||||
zero.deleteData( offset, offset + 1 );
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
function firstTextNode( node ) {
|
||||
var parent = editor.dom.getParent( node, 'p' ),
|
||||
child;
|
||||
|
||||
if ( ! parent ) {
|
||||
return;
|
||||
}
|
||||
|
||||
while ( child = parent.firstChild ) {
|
||||
if ( child.nodeType !== 3 ) {
|
||||
parent = child;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! child ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! child.data ) {
|
||||
if ( child.nextSibling && child.nextSibling.nodeType === 3 ) {
|
||||
child = child.nextSibling;
|
||||
} else {
|
||||
child = null;
|
||||
}
|
||||
}
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
function space() {
|
||||
var rng = editor.selection.getRng(),
|
||||
node = rng.startContainer,
|
||||
parent,
|
||||
text;
|
||||
|
||||
if ( ! node || firstTextNode( node ) !== node ) {
|
||||
return;
|
||||
}
|
||||
|
||||
parent = node.parentNode;
|
||||
text = node.data;
|
||||
|
||||
tinymce.each( spacePatterns, function( pattern ) {
|
||||
var match = text.match( pattern.regExp );
|
||||
|
||||
if ( ! match || rng.startOffset !== match[0].length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
editor.undoManager.add();
|
||||
|
||||
editor.undoManager.transact( function() {
|
||||
node.deleteData( 0, match[0].length );
|
||||
|
||||
if ( ! parent.innerHTML ) {
|
||||
parent.appendChild( document.createElement( 'br' ) );
|
||||
}
|
||||
|
||||
editor.selection.setCursorLocation( parent );
|
||||
editor.execCommand( pattern.cmd );
|
||||
} );
|
||||
|
||||
// We need to wait for native events to be triggered.
|
||||
setTimeout( function() {
|
||||
canUndo = 'space';
|
||||
} );
|
||||
|
||||
return false;
|
||||
} );
|
||||
}
|
||||
|
||||
function enter() {
|
||||
var rng = editor.selection.getRng(),
|
||||
start = rng.startContainer,
|
||||
node = firstTextNode( start ),
|
||||
i = enterPatterns.length,
|
||||
text, pattern, parent;
|
||||
|
||||
if ( ! node ) {
|
||||
return;
|
||||
}
|
||||
|
||||
text = node.data;
|
||||
|
||||
while ( i-- ) {
|
||||
if ( enterPatterns[ i ].start ) {
|
||||
if ( text.indexOf( enterPatterns[ i ].start ) === 0 ) {
|
||||
pattern = enterPatterns[ i ];
|
||||
break;
|
||||
}
|
||||
} else if ( enterPatterns[ i ].regExp ) {
|
||||
if ( enterPatterns[ i ].regExp.test( text ) ) {
|
||||
pattern = enterPatterns[ i ];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! pattern ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( node === start && tinymce.trim( text ) === pattern.start ) {
|
||||
return;
|
||||
}
|
||||
|
||||
editor.once( 'keyup', function() {
|
||||
editor.undoManager.add();
|
||||
|
||||
editor.undoManager.transact( function() {
|
||||
if ( pattern.format ) {
|
||||
editor.formatter.apply( pattern.format, {}, node );
|
||||
node.replaceData( 0, node.data.length, ltrim( node.data.slice( pattern.start.length ) ) );
|
||||
} else if ( pattern.element ) {
|
||||
parent = node.parentNode && node.parentNode.parentNode;
|
||||
|
||||
if ( parent ) {
|
||||
parent.replaceChild( document.createElement( pattern.element ), node.parentNode );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// We need to wait for native events to be triggered.
|
||||
setTimeout( function() {
|
||||
canUndo = 'enter';
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
function ltrim( text ) {
|
||||
return text ? text.replace( /^\s+/, '' ) : '';
|
||||
}
|
||||
} );
|
||||
} )( window.tinymce, window.setTimeout );
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wptextpattern/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(u,m){function p(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}u.Env.ie&&u.Env.ie<9||u.PluginManager.add("wptextpattern",function(s){var f,t=u.util.VK,e=s.settings.wptextpattern||{},o=e.space||[{regExp:/^[*-]\s/,cmd:"InsertUnorderedList"},{regExp:/^1[.)]\s/,cmd:"InsertOrderedList"}],d=e.enter||[{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:">",format:"blockquote"},{regExp:/^(-){3,}$/,element:"hr"}],g=e.inline||[{delimiter:"`",format:"code"}];function n(){var r,i,o,e,t,d,l,n=s.selection.getRng(),a=n.startContainer,c=n.startOffset;a&&3===a.nodeType&&a.data.length&&c&&(d=a.data.slice(0,c),l=a.data.charAt(c-1),u.each(g,function(e){if(l===e.delimiter.slice(-1)){var t=p(e.delimiter),n=e.delimiter.charAt(0),a=new RegExp("(.*)"+t+".+"+t+"$"),t=d.match(a);if(t){r=t[1].length,i=c-e.delimiter.length;a=d.charAt(r-1),t=d.charAt(r+e.delimiter.length);if(!(r&&/\S/.test(a)&&(/\s/.test(t)||a===n)||new RegExp("^[\\s"+p(n)+"]+$").test(d.slice(r,i))))return o=e,!1}}}),o&&(e=s.formatter.get(o.format))&&e[0].inline&&(s.undoManager.add(),s.undoManager.transact(function(){a.insertData(c,"\ufeff"),a=a.splitText(r),t=a.splitText(c-r),a.deleteData(0,o.delimiter.length),a.deleteData(a.data.length-o.delimiter.length,o.delimiter.length),s.formatter.apply(o.format,{},a),s.selection.setCursorLocation(t,1)}),m(function(){f="space",s.once("selectionchange",function(){var e;t&&-1!==(e=t.data.indexOf("\ufeff"))&&t.deleteData(e,e+1)})})))}function l(e){var t,n=s.dom.getParent(e,"p");if(n){for(;(t=n.firstChild)&&3!==t.nodeType;)n=t;if(t)return t=!t.data?t.nextSibling&&3===t.nextSibling.nodeType?t.nextSibling:null:t}}function a(){var n,a,r=s.selection.getRng(),i=r.startContainer;i&&l(i)===i&&(n=i.parentNode,a=i.data,u.each(o,function(e){var t=a.match(e.regExp);if(t&&r.startOffset===t[0].length)return s.undoManager.add(),s.undoManager.transact(function(){i.deleteData(0,t[0].length),n.innerHTML||n.appendChild(document.createElement("br")),s.selection.setCursorLocation(n),s.execCommand(e.cmd)}),m(function(){f="space"}),!1}))}s.on("selectionchange",function(){f=null}),s.on("keydown",function(e){(f&&27===e.keyCode||"space"===f&&e.keyCode===t.BACKSPACE)&&(s.undoManager.undo(),e.preventDefault(),e.stopImmediatePropagation()),t.metaKeyPressed(e)||(e.keyCode===t.ENTER?function(){var e,t,n,a=s.selection.getRng().startContainer,r=l(a),i=d.length;if(r){for(e=r.data;i--;)if(d[i].start){if(0===e.indexOf(d[i].start)){t=d[i];break}}else if(d[i].regExp&&d[i].regExp.test(e)){t=d[i];break}t&&(r===a&&u.trim(e)===t.start||s.once("keyup",function(){s.undoManager.add(),s.undoManager.transact(function(){var e;t.format?(s.formatter.apply(t.format,{},r),r.replaceData(0,r.data.length,(e=r.data.slice(t.start.length))?e.replace(/^\s+/,""):"")):t.element&&(n=r.parentNode&&r.parentNode.parentNode)&&n.replaceChild(document.createElement(t.element),r.parentNode)}),m(function(){f="enter"})}))}}():e.keyCode===t.SPACEBAR?m(a):47<e.keyCode&&!(91<=e.keyCode&&e.keyCode<=93)&&m(n))},!0)})}(window.tinymce,window.setTimeout);
|
225
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpview/plugin.js
Normal file
225
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpview/plugin.js
Normal file
@ -0,0 +1,225 @@
|
||||
/**
|
||||
* WordPress View plugin.
|
||||
*/
|
||||
( function( tinymce ) {
|
||||
tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||
function noop () {}
|
||||
|
||||
// Set this here as wp-tinymce.js may be loaded too early.
|
||||
var wp = window.wp;
|
||||
|
||||
if ( ! wp || ! wp.mce || ! wp.mce.views ) {
|
||||
return {
|
||||
getView: noop
|
||||
};
|
||||
}
|
||||
|
||||
// Check if a node is a view or not.
|
||||
function isView( node ) {
|
||||
return editor.dom.hasClass( node, 'wpview' );
|
||||
}
|
||||
|
||||
// Replace view tags with their text.
|
||||
function resetViews( content ) {
|
||||
function callback( match, $1 ) {
|
||||
return '<p>' + window.decodeURIComponent( $1 ) + '</p>';
|
||||
}
|
||||
|
||||
if ( ! content || content.indexOf( ' data-wpview-' ) === -1 ) {
|
||||
return content;
|
||||
}
|
||||
|
||||
return content
|
||||
.replace( /<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:\.|[\s\S]+?wpview-end[^>]+>\s*<\/span>\s*)?<\/div>/g, callback )
|
||||
.replace( /<p[^>]+data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g, callback );
|
||||
}
|
||||
|
||||
editor.on( 'init', function() {
|
||||
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
||||
|
||||
if ( MutationObserver ) {
|
||||
new MutationObserver( function() {
|
||||
editor.fire( 'wp-body-class-change' );
|
||||
} )
|
||||
.observe( editor.getBody(), {
|
||||
attributes: true,
|
||||
attributeFilter: ['class']
|
||||
} );
|
||||
}
|
||||
|
||||
// Pass on body class name changes from the editor to the wpView iframes.
|
||||
editor.on( 'wp-body-class-change', function() {
|
||||
var className = editor.getBody().className;
|
||||
|
||||
editor.$( 'iframe[class="wpview-sandbox"]' ).each( function( i, iframe ) {
|
||||
// Make sure it is a local iframe.
|
||||
// jshint scripturl: true
|
||||
if ( ! iframe.src || iframe.src === 'javascript:""' ) {
|
||||
try {
|
||||
iframe.contentWindow.document.body.className = className;
|
||||
} catch( er ) {}
|
||||
}
|
||||
});
|
||||
} );
|
||||
});
|
||||
|
||||
// Scan new content for matching view patterns and replace them with markers.
|
||||
editor.on( 'beforesetcontent', function( event ) {
|
||||
var node;
|
||||
|
||||
if ( ! event.selection ) {
|
||||
wp.mce.views.unbind();
|
||||
}
|
||||
|
||||
if ( ! event.content ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! event.load ) {
|
||||
node = editor.selection.getNode();
|
||||
|
||||
if ( node && node !== editor.getBody() && /^\s*https?:\/\/\S+\s*$/i.test( event.content ) ) {
|
||||
// When a url is pasted or inserted, only try to embed it when it is in an empty paragraph.
|
||||
node = editor.dom.getParent( node, 'p' );
|
||||
|
||||
if ( node && /^[\s\uFEFF\u00A0]*$/.test( editor.$( node ).text() || '' ) ) {
|
||||
// Make sure there are no empty inline elements in the <p>.
|
||||
node.innerHTML = '';
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event.content = wp.mce.views.setMarkers( event.content, editor );
|
||||
} );
|
||||
|
||||
// Replace any new markers nodes with views.
|
||||
editor.on( 'setcontent', function() {
|
||||
wp.mce.views.render();
|
||||
} );
|
||||
|
||||
// Empty view nodes for easier processing.
|
||||
editor.on( 'preprocess hide', function( event ) {
|
||||
editor.$( 'div[data-wpview-text], p[data-wpview-marker]', event.node ).each( function( i, node ) {
|
||||
node.innerHTML = '.';
|
||||
} );
|
||||
}, true );
|
||||
|
||||
// Replace views with their text.
|
||||
editor.on( 'postprocess', function( event ) {
|
||||
event.content = resetViews( event.content );
|
||||
} );
|
||||
|
||||
// Prevent adding of undo levels when replacing wpview markers
|
||||
// or when there are changes only in the (non-editable) previews.
|
||||
editor.on( 'beforeaddundo', function( event ) {
|
||||
var lastContent;
|
||||
var newContent = event.level.content || ( event.level.fragments && event.level.fragments.join( '' ) );
|
||||
|
||||
if ( ! event.lastLevel ) {
|
||||
lastContent = editor.startContent;
|
||||
} else {
|
||||
lastContent = event.lastLevel.content || ( event.lastLevel.fragments && event.lastLevel.fragments.join( '' ) );
|
||||
}
|
||||
|
||||
if (
|
||||
! newContent ||
|
||||
! lastContent ||
|
||||
newContent.indexOf( ' data-wpview-' ) === -1 ||
|
||||
lastContent.indexOf( ' data-wpview-' ) === -1
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( resetViews( lastContent ) === resetViews( newContent ) ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
} );
|
||||
|
||||
// Make sure views are copied as their text.
|
||||
editor.on( 'drop objectselected', function( event ) {
|
||||
if ( isView( event.targetClone ) ) {
|
||||
event.targetClone = editor.getDoc().createTextNode(
|
||||
window.decodeURIComponent( editor.dom.getAttrib( event.targetClone, 'data-wpview-text' ) )
|
||||
);
|
||||
}
|
||||
} );
|
||||
|
||||
// Clean up URLs for easier processing.
|
||||
editor.on( 'pastepreprocess', function( event ) {
|
||||
var content = event.content;
|
||||
|
||||
if ( content ) {
|
||||
content = tinymce.trim( content.replace( /<[^>]+>/g, '' ) );
|
||||
|
||||
if ( /^https?:\/\/\S+$/i.test( content ) ) {
|
||||
event.content = content;
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
// Show the view type in the element path.
|
||||
editor.on( 'resolvename', function( event ) {
|
||||
if ( isView( event.target ) ) {
|
||||
event.name = editor.dom.getAttrib( event.target, 'data-wpview-type' ) || 'object';
|
||||
}
|
||||
} );
|
||||
|
||||
// See `media` plugin.
|
||||
editor.on( 'click keyup', function() {
|
||||
var node = editor.selection.getNode();
|
||||
|
||||
if ( isView( node ) ) {
|
||||
if ( editor.dom.getAttrib( node, 'data-mce-selected' ) ) {
|
||||
node.setAttribute( 'data-mce-selected', '2' );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_view_edit', {
|
||||
tooltip: 'Edit|button', // '|button' is not displayed, only used for context.
|
||||
icon: 'dashicon dashicons-edit',
|
||||
onclick: function() {
|
||||
var node = editor.selection.getNode();
|
||||
|
||||
if ( isView( node ) ) {
|
||||
wp.mce.views.edit( editor, node );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_view_remove', {
|
||||
tooltip: 'Remove',
|
||||
icon: 'dashicon dashicons-no',
|
||||
onclick: function() {
|
||||
editor.fire( 'cut' );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.once( 'preinit', function() {
|
||||
var toolbar;
|
||||
|
||||
if ( editor.wp && editor.wp._createToolbar ) {
|
||||
toolbar = editor.wp._createToolbar( [
|
||||
'wp_view_edit',
|
||||
'wp_view_remove'
|
||||
] );
|
||||
|
||||
editor.on( 'wptoolbar', function( event ) {
|
||||
if ( ! event.collapsed && isView( event.element ) ) {
|
||||
event.toolbar = toolbar;
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.wp = editor.wp || {};
|
||||
editor.wp.getView = noop;
|
||||
editor.wp.setViewCursor = noop;
|
||||
|
||||
return {
|
||||
getView: noop
|
||||
};
|
||||
} );
|
||||
} )( window.tinymce );
|
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpview/plugin.min.js
vendored
Normal file
1
hamrokhaanpaan/wp-includes/js/tinymce/plugins/wpview/plugin.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(c){c.PluginManager.add("wpview",function(o){function e(){}var n=window.wp;return n&&n.mce&&n.mce.views?(o.on("init",function(){var e=window.MutationObserver||window.WebKitMutationObserver;e&&new e(function(){o.fire("wp-body-class-change")}).observe(o.getBody(),{attributes:!0,attributeFilter:["class"]}),o.on("wp-body-class-change",function(){var n=o.getBody().className;o.$('iframe[class="wpview-sandbox"]').each(function(e,t){if(!t.src||'javascript:""'===t.src)try{t.contentWindow.document.body.className=n}catch(e){}})})}),o.on("beforesetcontent",function(e){var t;if(e.selection||n.mce.views.unbind(),e.content){if(!e.load&&(t=o.selection.getNode())&&t!==o.getBody()&&/^\s*https?:\/\/\S+\s*$/i.test(e.content)){if(!(t=o.dom.getParent(t,"p"))||!/^[\s\uFEFF\u00A0]*$/.test(o.$(t).text()||""))return;t.innerHTML=""}e.content=n.mce.views.setMarkers(e.content,o)}}),o.on("setcontent",function(){n.mce.views.render()}),o.on("preprocess hide",function(e){o.$("div[data-wpview-text], p[data-wpview-marker]",e.node).each(function(e,t){t.innerHTML="."})},!0),o.on("postprocess",function(e){e.content=a(e.content)}),o.on("beforeaddundo",function(e){var t=e.level.content||e.level.fragments&&e.level.fragments.join(""),n=e.lastLevel?e.lastLevel.content||e.lastLevel.fragments&&e.lastLevel.fragments.join(""):o.startContent;t&&n&&-1!==t.indexOf(" data-wpview-")&&-1!==n.indexOf(" data-wpview-")&&a(n)===a(t)&&e.preventDefault()}),o.on("drop objectselected",function(e){i(e.targetClone)&&(e.targetClone=o.getDoc().createTextNode(window.decodeURIComponent(o.dom.getAttrib(e.targetClone,"data-wpview-text"))))}),o.on("pastepreprocess",function(e){var t=e.content;t&&(t=c.trim(t.replace(/<[^>]+>/g,"")),/^https?:\/\/\S+$/i.test(t)&&(e.content=t))}),o.on("resolvename",function(e){i(e.target)&&(e.name=o.dom.getAttrib(e.target,"data-wpview-type")||"object")}),o.on("click keyup",function(){var e=o.selection.getNode();i(e)&&o.dom.getAttrib(e,"data-mce-selected")&&e.setAttribute("data-mce-selected","2")}),o.addButton("wp_view_edit",{tooltip:"Edit|button",icon:"dashicon dashicons-edit",onclick:function(){var e=o.selection.getNode();i(e)&&n.mce.views.edit(o,e)}}),o.addButton("wp_view_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",onclick:function(){o.fire("cut")}}),o.once("preinit",function(){var t;o.wp&&o.wp._createToolbar&&(t=o.wp._createToolbar(["wp_view_edit","wp_view_remove"]),o.on("wptoolbar",function(e){!e.collapsed&&i(e.element)&&(e.toolbar=t)}))}),o.wp=o.wp||{},o.wp.getView=e,{getView:o.wp.setViewCursor=e}):{getView:e};function i(e){return o.dom.hasClass(e,"wpview")}function a(e){function t(e,t){return"<p>"+window.decodeURIComponent(t)+"</p>"}return e&&-1!==e.indexOf(" data-wpview-")?e.replace(/<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:\.|[\s\S]+?wpview-end[^>]+>\s*<\/span>\s*)?<\/div>/g,t).replace(/<p[^>]+data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g,t):e}})}(window.tinymce);
|
Reference in New Issue
Block a user