JR Utily

- renamed lib in resources

- test using passthrough elements
Showing 662 changed files with 0 additions and 5013 deletions
1 -tinymce.PluginManager.add("example_dependency",function(){},["example"]);
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*global tinymce:true */
12 -
13 -tinymce.PluginManager.add('fullscreen', function(editor) {
14 - var fullscreenState = false, DOM = tinymce.DOM, iframeWidth, iframeHeight, resizeHandler;
15 - var containerWidth, containerHeight, scrollPos;
16 -
17 - if (editor.settings.inline) {
18 - return;
19 - }
20 -
21 - function getWindowSize() {
22 - var w, h, win = window, doc = document;
23 - var body = doc.body;
24 -
25 - // Old IE
26 - if (body.offsetWidth) {
27 - w = body.offsetWidth;
28 - h = body.offsetHeight;
29 - }
30 -
31 - // Modern browsers
32 - if (win.innerWidth && win.innerHeight) {
33 - w = win.innerWidth;
34 - h = win.innerHeight;
35 - }
36 -
37 - return {w: w, h: h};
38 - }
39 -
40 - function getScrollPos() {
41 - var vp = tinymce.DOM.getViewPort();
42 -
43 - return {
44 - x: vp.x,
45 - y: vp.y
46 - };
47 - }
48 -
49 - function setScrollPos(pos) {
50 - scrollTo(pos.x, pos.y);
51 - }
52 -
53 - function toggleFullscreen() {
54 - var body = document.body, documentElement = document.documentElement, editorContainerStyle;
55 - var editorContainer, iframe, iframeStyle;
56 -
57 - function resize() {
58 - DOM.setStyle(iframe, 'height', getWindowSize().h - (editorContainer.clientHeight - iframe.clientHeight));
59 - }
60 -
61 - fullscreenState = !fullscreenState;
62 -
63 - editorContainer = editor.getContainer();
64 - editorContainerStyle = editorContainer.style;
65 - iframe = editor.getContentAreaContainer().firstChild;
66 - iframeStyle = iframe.style;
67 -
68 - if (fullscreenState) {
69 - scrollPos = getScrollPos();
70 - iframeWidth = iframeStyle.width;
71 - iframeHeight = iframeStyle.height;
72 - iframeStyle.width = iframeStyle.height = '100%';
73 - containerWidth = editorContainerStyle.width;
74 - containerHeight = editorContainerStyle.height;
75 - editorContainerStyle.width = editorContainerStyle.height = '';
76 -
77 - DOM.addClass(body, 'mce-fullscreen');
78 - DOM.addClass(documentElement, 'mce-fullscreen');
79 - DOM.addClass(editorContainer, 'mce-fullscreen');
80 -
81 - DOM.bind(window, 'resize', resize);
82 - resize();
83 - resizeHandler = resize;
84 - } else {
85 - iframeStyle.width = iframeWidth;
86 - iframeStyle.height = iframeHeight;
87 -
88 - if (containerWidth) {
89 - editorContainerStyle.width = containerWidth;
90 - }
91 -
92 - if (containerHeight) {
93 - editorContainerStyle.height = containerHeight;
94 - }
95 -
96 - DOM.removeClass(body, 'mce-fullscreen');
97 - DOM.removeClass(documentElement, 'mce-fullscreen');
98 - DOM.removeClass(editorContainer, 'mce-fullscreen');
99 - DOM.unbind(window, 'resize', resizeHandler);
100 - setScrollPos(scrollPos);
101 - }
102 -
103 - editor.fire('FullscreenStateChanged', {state: fullscreenState});
104 - }
105 -
106 - editor.on('init', function() {
107 - editor.addShortcut('Ctrl+Shift+F', '', toggleFullscreen);
108 - });
109 -
110 - editor.on('remove', function() {
111 - if (resizeHandler) {
112 - DOM.unbind(window, 'resize', resizeHandler);
113 - }
114 - });
115 -
116 - editor.addCommand('mceFullScreen', toggleFullscreen);
117 -
118 - editor.addMenuItem('fullscreen', {
119 - text: 'Fullscreen',
120 - shortcut: 'Ctrl+Shift+F',
121 - selectable: true,
122 - onClick: function() {
123 - toggleFullscreen();
124 - editor.focus();
125 - },
126 - onPostRender: function() {
127 - var self = this;
128 -
129 - editor.on('FullscreenStateChanged', function(e) {
130 - self.active(e.state);
131 - });
132 - },
133 - context: 'view'
134 - });
135 -
136 - editor.addButton('fullscreen', {
137 - tooltip: 'Fullscreen',
138 - shortcut: 'Ctrl+Shift+F',
139 - onClick: toggleFullscreen,
140 - onPostRender: function() {
141 - var self = this;
142 -
143 - editor.on('FullscreenStateChanged', function(e) {
144 - self.active(e.state);
145 - });
146 - }
147 - });
148 -
149 - return {
150 - isFullscreen: function() {
151 - return fullscreenState;
152 - }
153 - };
154 -});
1 -tinymce.PluginManager.add("fullscreen",function(a){function b(){var a,b,c=window,d=document,e=d.body;return e.offsetWidth&&(a=e.offsetWidth,b=e.offsetHeight),c.innerWidth&&c.innerHeight&&(a=c.innerWidth,b=c.innerHeight),{w:a,h:b}}function c(){var a=tinymce.DOM.getViewPort();return{x:a.x,y:a.y}}function d(a){scrollTo(a.x,a.y)}function e(){function e(){m.setStyle(p,"height",b().h-(o.clientHeight-p.clientHeight))}var n,o,p,q,r=document.body,s=document.documentElement;l=!l,o=a.getContainer(),n=o.style,p=a.getContentAreaContainer().firstChild,q=p.style,l?(k=c(),f=q.width,g=q.height,q.width=q.height="100%",i=n.width,j=n.height,n.width=n.height="",m.addClass(r,"mce-fullscreen"),m.addClass(s,"mce-fullscreen"),m.addClass(o,"mce-fullscreen"),m.bind(window,"resize",e),e(),h=e):(q.width=f,q.height=g,i&&(n.width=i),j&&(n.height=j),m.removeClass(r,"mce-fullscreen"),m.removeClass(s,"mce-fullscreen"),m.removeClass(o,"mce-fullscreen"),m.unbind(window,"resize",h),d(k)),a.fire("FullscreenStateChanged",{state:l})}var f,g,h,i,j,k,l=!1,m=tinymce.DOM;return a.settings.inline?void 0:(a.on("init",function(){a.addShortcut("Ctrl+Shift+F","",e)}),a.on("remove",function(){h&&m.unbind(window,"resize",h)}),a.addCommand("mceFullScreen",e),a.addMenuItem("fullscreen",{text:"Fullscreen",shortcut:"Ctrl+Shift+F",selectable:!0,onClick:function(){e(),a.focus()},onPostRender:function(){var b=this;a.on("FullscreenStateChanged",function(a){b.active(a.state)})},context:"view"}),a.addButton("fullscreen",{tooltip:"Fullscreen",shortcut:"Ctrl+Shift+F",onClick:e,onPostRender:function(){var b=this;a.on("FullscreenStateChanged",function(a){b.active(a.state)})}}),{isFullscreen:function(){return l}})});
...\ No newline at end of file ...\ No newline at end of file
1 -configure({
2 - configs: [
3 - './test.js',
4 - './prod.js'
5 - ]
6 -});
1 -configure({
2 - configs: [
3 - './test.js',
4 - './prod.js'
5 - ]
6 -});
1 -/**
2 - * Demo.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*eslint no-console:0 */
12 -
13 -define("tinymce/imagetoolsplugin/Demo", [
14 - "tinymce/imagetoolsplugin/Plugin",
15 - "global!tinymce",
16 - "global!tinymce.dom.DomQuery",
17 - "global!console"
18 -], function(Plugin, tinymce, $, console) {
19 - return function() {
20 - var imgSrc = '../../../../../../../tests/manual/img/dogleft.jpg';
21 -
22 - $(
23 - '<textarea class="tinymce">' +
24 - '<p>' +
25 - '<img src="' + imgSrc + '" width="160" height="100">' +
26 - '<img src="' + imgSrc + '" style="width: 160px; height: 100px">' +
27 - '<img src="' + imgSrc + '" style="width: 20%">' +
28 - '<img src="' + imgSrc + '">' +
29 - '<img src="http://moxiecode.cachefly.net/tinymce/v9/images/logo.png">' +
30 - '</p>' +
31 - '</textarea>'
32 - ).appendTo('#ephox-ui');
33 -
34 - tinymce.init({
35 - //imagetools_cors_hosts: ["moxiecode.cachefly.net"],
36 - //imagetools_proxy: "proxy.php",
37 - //imagetools_api_key: '123',
38 -
39 - //images_upload_url: 'postAcceptor.php',
40 - //images_upload_base_path: 'base/path',
41 - //images_upload_credentials: true,
42 -
43 - selector: "textarea.tinymce",
44 - theme: "modern",
45 - plugins: [
46 - "imagetools paste"
47 - ],
48 - add_unload_trigger: false,
49 - //images_replace_blob_uris: false,
50 - paste_data_images: true,
51 - image_caption: true,
52 - height: 600,
53 - toolbar1: "undo redo | styleselect | alignleft aligncenter alignright alignjustify | link image | media | emoticons",
54 - images_upload_handler: function(data, success, failure, progress) {
55 - console.log('blob upload [started]', data.id());
56 -
57 - progress(0);
58 -
59 - setTimeout(function() {
60 - console.log('blob upload [ended]', data.id());
61 - success(data.id() + '.png');
62 - progress(100);
63 - }, 1000);
64 - }
65 - });
66 -
67 - function send() {
68 - tinymce.activeEditor.uploadImages(function() {
69 - console.log('saving:', tinymce.activeEditor.getContent());
70 - });
71 - }
72 -
73 - function upload() {
74 - console.log('upload [started]');
75 -
76 - tinymce.activeEditor.uploadImages(function(success) {
77 - console.log('upload [ended]', success);
78 - });
79 - }
80 -
81 - function dump() {
82 - var content = tinymce.activeEditor.getContent();
83 -
84 - $('#view').html(content);
85 - console.log(content);
86 - }
87 -
88 - $('<button>send()</button>').appendTo('#ephox-ui').on('click', send);
89 - $('<button>upload()</button>').appendTo('#ephox-ui').on('click', upload);
90 - $('<button>dump()</button>').appendTo('#ephox-ui').on('click', dump);
91 - };
92 -});
1 -/**
2 - * ImagePanel.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/**
12 - * ...
13 - *
14 - * @-x-less ImagePanel.less
15 - */
16 -define("tinymce/imagetoolsplugin/ImagePanel", [
17 - "global!tinymce.ui.Control",
18 - "global!tinymce.ui.DragHelper",
19 - "global!tinymce.geom.Rect",
20 - "global!tinymce.util.Tools",
21 - "global!tinymce.util.Promise",
22 - "tinymce/imagetoolsplugin/CropRect"
23 -], function(Control, DragHelper, Rect, Tools, Promise, CropRect) {
24 - function loadImage(image) {
25 - return new Promise(function(resolve) {
26 - function loaded() {
27 - image.removeEventListener('load', loaded);
28 - resolve(image);
29 - }
30 -
31 - if (image.complete) {
32 - resolve(image);
33 - } else {
34 - image.addEventListener('load', loaded);
35 - }
36 - });
37 - }
38 -
39 - return Control.extend({
40 - Defaults: {
41 - classes: "imagepanel"
42 - },
43 -
44 - selection: function(rect) {
45 - if (arguments.length) {
46 - this.state.set('rect', rect);
47 - return this;
48 - }
49 -
50 - return this.state.get('rect');
51 - },
52 -
53 - imageSize: function() {
54 - var viewRect = this.state.get('viewRect');
55 -
56 - return {
57 - w: viewRect.w,
58 - h: viewRect.h
59 - };
60 - },
61 -
62 - toggleCropRect: function(state) {
63 - this.state.set('cropEnabled', state);
64 - },
65 -
66 - imageSrc: function(url) {
67 - var self = this, img = new Image();
68 -
69 - img.src = url;
70 -
71 - loadImage(img).then(function() {
72 - var rect, $img, lastRect = self.state.get('viewRect');
73 -
74 - $img = self.$el.find('img');
75 - if ($img[0]) {
76 - $img.replaceWith(img);
77 - } else {
78 - self.getEl().appendChild(img);
79 - }
80 -
81 - rect = {x: 0, y: 0, w: img.naturalWidth, h: img.naturalHeight};
82 - self.state.set('viewRect', rect);
83 - self.state.set('rect', Rect.inflate(rect, -20, -20));
84 -
85 - if (!lastRect || lastRect.w != rect.w || lastRect.h != rect.h) {
86 - self.zoomFit();
87 - }
88 -
89 - self.repaintImage();
90 - self.fire('load');
91 - });
92 - },
93 -
94 - zoom: function(value) {
95 - if (arguments.length) {
96 - this.state.set('zoom', value);
97 - return this;
98 - }
99 -
100 - return this.state.get('zoom');
101 - },
102 -
103 - postRender: function() {
104 - this.imageSrc(this.settings.imageSrc);
105 - return this._super();
106 - },
107 -
108 - zoomFit: function() {
109 - var self = this, $img, pw, ph, w, h, zoom, padding;
110 -
111 - padding = 10;
112 - $img = self.$el.find('img');
113 - pw = self.getEl().clientWidth;
114 - ph = self.getEl().clientHeight;
115 - w = $img[0].naturalWidth;
116 - h = $img[0].naturalHeight;
117 - zoom = Math.min((pw - padding) / w, (ph - padding) / h);
118 -
119 - if (zoom >= 1) {
120 - zoom = 1;
121 - }
122 -
123 - self.zoom(zoom);
124 - },
125 -
126 - repaintImage: function() {
127 - var x, y, w, h, pw, ph, $img, zoom, rect, elm;
128 -
129 - elm = this.getEl();
130 - zoom = this.zoom();
131 - rect = this.state.get('rect');
132 - $img = this.$el.find('img');
133 - pw = elm.offsetWidth;
134 - ph = elm.offsetHeight;
135 - w = $img[0].naturalWidth * zoom;
136 - h = $img[0].naturalHeight * zoom;
137 - x = Math.max(0, pw / 2 - w / 2);
138 - y = Math.max(0, ph / 2 - h / 2);
139 -
140 - $img.css({
141 - left: x,
142 - top: y,
143 - width: w,
144 - height: h
145 - });
146 -
147 - if (this.cropRect) {
148 - this.cropRect.setRect({
149 - x: rect.x * zoom + x,
150 - y: rect.y * zoom + y,
151 - w: rect.w * zoom,
152 - h: rect.h * zoom
153 - });
154 -
155 - this.cropRect.setClampRect({
156 - x: x,
157 - y: y,
158 - w: w,
159 - h: h
160 - });
161 -
162 - this.cropRect.setViewPortRect({
163 - x: 0,
164 - y: 0,
165 - w: pw,
166 - h: ph
167 - });
168 - }
169 - },
170 -
171 - bindStates: function() {
172 - var self = this;
173 -
174 - function setupCropRect(rect) {
175 - self.cropRect = new CropRect(
176 - rect,
177 - self.state.get('viewRect'),
178 - self.state.get('viewRect'),
179 - self.getEl(),
180 - function() {
181 - self.fire('crop');
182 - }
183 - );
184 -
185 - self.cropRect.on('updateRect', function(e) {
186 - var rect = e.rect, zoom = self.zoom();
187 -
188 - rect = {
189 - x: Math.round(rect.x / zoom),
190 - y: Math.round(rect.y / zoom),
191 - w: Math.round(rect.w / zoom),
192 - h: Math.round(rect.h / zoom)
193 - };
194 -
195 - self.state.set('rect', rect);
196 - });
197 -
198 - self.on('remove', self.cropRect.destroy);
199 - }
200 -
201 - self.state.on('change:cropEnabled', function(e) {
202 - self.cropRect.toggleVisibility(e.value);
203 - self.repaintImage();
204 - });
205 -
206 - self.state.on('change:zoom', function() {
207 - self.repaintImage();
208 - });
209 -
210 - self.state.on('change:rect', function(e) {
211 - var rect = e.value;
212 -
213 - if (!self.cropRect) {
214 - setupCropRect(rect);
215 - }
216 -
217 - self.cropRect.setRect(rect);
218 - });
219 - }
220 - });
221 -});
1 -/**
2 - * ImageSize.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -define("tinymce/imagetoolsplugin/ImageSize", [
12 -], function() {
13 - function getImageSize(img) {
14 - var width, height;
15 -
16 - function isPxValue(value) {
17 - return /^[0-9\.]+px$/.test(value);
18 - }
19 -
20 - width = img.style.width;
21 - height = img.style.height;
22 - if (width || height) {
23 - if (isPxValue(width) && isPxValue(height)) {
24 - return {
25 - w: parseInt(width, 10),
26 - h: parseInt(height, 10)
27 - };
28 - }
29 -
30 - return null;
31 - }
32 -
33 - width = img.width;
34 - height = img.height;
35 -
36 - if (width && height) {
37 - return {
38 - w: parseInt(width, 10),
39 - h: parseInt(height, 10)
40 - };
41 - }
42 -
43 - return null;
44 - }
45 -
46 - function setImageSize(img, size) {
47 - var width, height;
48 -
49 - if (size) {
50 - width = img.style.width;
51 - height = img.style.height;
52 -
53 - if (width || height) {
54 - img.style.width = size.w + 'px';
55 - img.style.height = size.h + 'px';
56 - img.removeAttribute('data-mce-style');
57 - }
58 -
59 - width = img.width;
60 - height = img.height;
61 -
62 - if (width || height) {
63 - img.setAttribute('width', size.w);
64 - img.setAttribute('height', size.h);
65 - }
66 - }
67 - }
68 -
69 - function getNaturalImageSize(img) {
70 - return {
71 - w: img.naturalWidth,
72 - h: img.naturalHeight
73 - };
74 - }
75 -
76 - return {
77 - getImageSize: getImageSize,
78 - setImageSize: setImageSize,
79 - getNaturalImageSize: getNaturalImageSize
80 - };
81 -});
1 -/**
2 - * Plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/**
12 - *
13 - * Settings:
14 - * imagetools_cors_hosts - Array of remote domains that has CORS setup.
15 - * imagetools_proxy - Url to proxy that streams images from remote host to local host.
16 - * imagetools_toolbar - Toolbar items to render when an editable image is selected.
17 - */
18 -define("tinymce/imagetoolsplugin/Plugin", [
19 - "global!tinymce.PluginManager",
20 - "global!tinymce.Env",
21 - "global!tinymce.util.Promise",
22 - "global!tinymce.util.URI",
23 - "global!tinymce.util.Tools",
24 - "global!tinymce.util.Delay",
25 - "ephox/imagetools/api/ImageTransformations",
26 - "ephox/imagetools/api/BlobConversions",
27 - "tinymce/imagetoolsplugin/Dialog",
28 - "tinymce/imagetoolsplugin/ImageSize",
29 - "tinymce/imagetoolsplugin/Proxy"
30 -], function(PluginManager, Env, Promise, URI, Tools, Delay, ImageTransformations, BlobConversions, Dialog, ImageSize, Proxy) {
31 - var plugin = function(editor) {
32 - var count = 0, imageUploadTimer, lastSelectedImage;
33 -
34 - if (!Env.fileApi) {
35 - return;
36 - }
37 -
38 - function displayError(error) {
39 - editor.notificationManager.open({
40 - text: error,
41 - type: 'error'
42 - });
43 - }
44 -
45 - function getSelectedImage() {
46 - return editor.selection.getNode();
47 - }
48 -
49 - function createId() {
50 - return 'imagetools' + count++;
51 - }
52 -
53 - function isLocalImage(img) {
54 - var url = img.src;
55 -
56 - return url.indexOf('data:') === 0 || url.indexOf('blob:') === 0 || new URI(url).host === editor.documentBaseURI.host;
57 - }
58 -
59 - function isCorsImage(img) {
60 - return Tools.inArray(editor.settings.imagetools_cors_hosts, new URI(img.src).host) !== -1;
61 - }
62 -
63 - function getApiKey() {
64 - return editor.settings.api_key || editor.settings.imagetools_api_key;
65 - }
66 -
67 - function imageToBlob(img) {
68 - var src = img.src, apiKey;
69 -
70 - if (isCorsImage(img)) {
71 - return Proxy.getUrl(img.src, null);
72 - }
73 -
74 - if (!isLocalImage(img)) {
75 - src = editor.settings.imagetools_proxy;
76 - src += (src.indexOf('?') === -1 ? '?' : '&') + 'url=' + encodeURIComponent(img.src);
77 - apiKey = getApiKey();
78 - return Proxy.getUrl(src, apiKey);
79 - }
80 -
81 - return BlobConversions.imageToBlob(img);
82 - }
83 -
84 - function findSelectedBlob() {
85 - var blobInfo;
86 -
87 - blobInfo = editor.editorUpload.blobCache.getByUri(getSelectedImage().src);
88 - if (blobInfo) {
89 - return blobInfo.blob();
90 - }
91 -
92 - return imageToBlob(getSelectedImage());
93 - }
94 -
95 - function startTimedUpload() {
96 - imageUploadTimer = Delay.setEditorTimeout(editor, function() {
97 - editor.editorUpload.uploadImagesAuto();
98 - }, 30000);
99 - }
100 -
101 - function cancelTimedUpload() {
102 - clearTimeout(imageUploadTimer);
103 - }
104 -
105 - function updateSelectedImage(blob, uploadImmediately) {
106 - return BlobConversions.blobToDataUri(blob).then(function(dataUri) {
107 - var id, base64, blobCache, blobInfo, selectedImage;
108 -
109 - selectedImage = getSelectedImage();
110 - id = createId();
111 - blobCache = editor.editorUpload.blobCache;
112 - base64 = URI.parseDataUri(dataUri).data;
113 -
114 - blobInfo = blobCache.create(id, blob, base64);
115 - blobCache.add(blobInfo);
116 -
117 - editor.undoManager.transact(function() {
118 - function imageLoadedHandler() {
119 - editor.$(selectedImage).off('load', imageLoadedHandler);
120 - editor.nodeChanged();
121 -
122 - if (uploadImmediately) {
123 - editor.editorUpload.uploadImagesAuto();
124 - } else {
125 - cancelTimedUpload();
126 - startTimedUpload();
127 - }
128 - }
129 -
130 - editor.$(selectedImage).on('load', imageLoadedHandler);
131 -
132 - editor.$(selectedImage).attr({
133 - src: blobInfo.blobUri()
134 - }).removeAttr('data-mce-src');
135 - });
136 -
137 - return blobInfo;
138 - });
139 - }
140 -
141 - function selectedImageOperation(fn) {
142 - return function() {
143 - return editor._scanForImages().then(findSelectedBlob).then(fn).then(updateSelectedImage, displayError);
144 - };
145 - }
146 -
147 - function rotate(angle) {
148 - return function() {
149 - return selectedImageOperation(function(blob) {
150 - var size = ImageSize.getImageSize(getSelectedImage());
151 -
152 - if (size) {
153 - ImageSize.setImageSize(getSelectedImage(), {
154 - w: size.h,
155 - h: size.w
156 - });
157 - }
158 -
159 - return ImageTransformations.rotate(blob, angle);
160 - })();
161 - };
162 - }
163 -
164 - function flip(axis) {
165 - return function() {
166 - return selectedImageOperation(function(blob) {
167 - return ImageTransformations.flip(blob, axis);
168 - })();
169 - };
170 - }
171 -
172 - function editImageDialog() {
173 - var img = getSelectedImage(), originalSize = ImageSize.getNaturalImageSize(img);
174 - var handleDialogBlob = function(blob) {
175 - return new Promise(function(resolve) {
176 - BlobConversions.blobToImage(blob).then(function(newImage) {
177 - var newSize = ImageSize.getNaturalImageSize(newImage);
178 -
179 - if (originalSize.w != newSize.w || originalSize.h != newSize.h) {
180 - if (ImageSize.getImageSize(img)) {
181 - ImageSize.setImageSize(img, newSize);
182 - }
183 - }
184 -
185 - URL.revokeObjectURL(newImage.src);
186 - resolve(blob);
187 - });
188 - });
189 - };
190 -
191 - var openDialog = function (blob) {
192 - return Dialog.edit(blob).then(handleDialogBlob).then(function(blob) {
193 - updateSelectedImage(blob, true);
194 - }, function () {
195 - // Close dialog
196 - });
197 - };
198 -
199 - if (img) {
200 - imageToBlob(img).then(openDialog, displayError);
201 - }
202 - }
203 -
204 - function addButtons() {
205 - editor.addButton('rotateleft', {
206 - title: 'Rotate counterclockwise',
207 - onclick: rotate(-90)
208 - });
209 -
210 - editor.addButton('rotateright', {
211 - title: 'Rotate clockwise',
212 - onclick: rotate(90)
213 - });
214 -
215 - editor.addButton('flipv', {
216 - title: 'Flip vertically',
217 - onclick: flip('v')
218 - });
219 -
220 - editor.addButton('fliph', {
221 - title: 'Flip horizontally',
222 - onclick: flip('h')
223 - });
224 -
225 - editor.addButton('editimage', {
226 - title: 'Edit image',
227 - onclick: editImageDialog
228 - });
229 -
230 - editor.addButton('imageoptions', {
231 - title: 'Image options',
232 - icon: 'options',
233 - cmd: 'mceImage'
234 - });
235 -
236 - /*
237 - editor.addButton('crop', {
238 - title: 'Crop',
239 - onclick: startCrop
240 - });
241 - */
242 - }
243 -
244 - function addEvents() {
245 - editor.on('NodeChange', function(e) {
246 - //If the last node we selected was an image
247 - //And had a source that doesn't match the current blob url
248 - //We need to attempt to upload it
249 - if (lastSelectedImage && lastSelectedImage.src != e.element.src) {
250 - cancelTimedUpload();
251 - editor.editorUpload.uploadImagesAuto();
252 - lastSelectedImage = undefined;
253 - }
254 -
255 - //Set up the lastSelectedImage
256 - if (isEditableImage(e.element)) {
257 - lastSelectedImage = e.element;
258 - }
259 - });
260 - }
261 -
262 - function isEditableImage(img) {
263 - var selectorMatched = editor.dom.is(img, 'img:not([data-mce-object],[data-mce-placeholder])');
264 -
265 - return selectorMatched && (isLocalImage(img) || isCorsImage(img) || editor.settings.imagetools_proxy);
266 - }
267 -
268 - function addToolbars() {
269 - var toolbarItems = editor.settings.imagetools_toolbar;
270 -
271 - if (!toolbarItems) {
272 - toolbarItems = 'rotateleft rotateright | flipv fliph | crop editimage imageoptions';
273 - }
274 -
275 - editor.addContextToolbar(
276 - isEditableImage,
277 - toolbarItems
278 - );
279 - }
280 -
281 - addButtons();
282 - addToolbars();
283 - addEvents();
284 -
285 - editor.addCommand('mceEditImage', editImageDialog);
286 - };
287 -
288 - PluginManager.add('imagetools', plugin);
289 -
290 - return function() {};
291 -});
1 -/**
2 - * Proxy.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/**
12 - * Handles loading images though a proxy for working around cors.
13 - */
14 -define("tinymce/imagetoolsplugin/Proxy", [
15 - "global!tinymce.util.Promise",
16 - "global!tinymce.util.Tools",
17 - "tinymce/imagetoolsplugin/Utils"
18 -], function(Promise, Tools, Utils) {
19 - var isServiceErrorCode = function (code) {
20 - return code === 400 || code === 403 || code === 500;
21 - };
22 -
23 - var handleHttpError = function (status) {
24 - return Promise.reject("ImageProxy HTTP error: " + status);
25 - };
26 -
27 - var proxyServiceError = function (error) {
28 - Promise.reject("ImageProxy Service error: " + error);
29 - };
30 -
31 - var handleServiceError = function (status, blob) {
32 - return Utils.readBlob(blob).then(function(text) {
33 - var serviceError = Utils.parseJson(text);
34 - var errorType = Utils.traverse(serviceError, ['error', 'type']);
35 - return errorType ? proxyServiceError(errorType) : proxyServiceError('Invalid JSON');
36 - });
37 - };
38 -
39 - var handleServiceErrorResponse = function (status, blob) {
40 - return isServiceErrorCode(status) ? handleServiceError(status, blob) : handleHttpError(status);
41 - };
42 -
43 - var requestServiceBlob = function (url, apiKey) {
44 - return Utils.requestUrlAsBlob(url, {
45 - 'Content-Type': 'application/json;charset=UTF-8',
46 - 'tiny-api-key': apiKey
47 - }).then(function (result) {
48 - return result.status >= 400 ? handleServiceErrorResponse(result.status, result.blob) : Promise.resolve(result.blob);
49 - });
50 - };
51 -
52 - function requestBlob(url) {
53 - return Utils.requestUrlAsBlob(url, {}).then(function (result) {
54 - return result.status >= 400 ? handleHttpError(result.status) : Promise.resolve(result.blob);
55 - });
56 - }
57 -
58 - var getUrl = function (url, apiKey) {
59 - return apiKey ? requestServiceBlob(url, apiKey) : requestBlob(url);
60 - };
61 -
62 - return {
63 - getUrl: getUrl
64 - };
65 -});
1 -/**
2 - * Utils.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -define("tinymce/imagetoolsplugin/Utils", [
12 - "global!tinymce.util.Promise",
13 - "global!tinymce.util.Tools"
14 -], function(Promise, Tools) {
15 - var isValue = function (obj) {
16 - return obj !== null && obj !== undefined;
17 - };
18 -
19 - var traverse = function (json, path) {
20 - var value;
21 -
22 - value = path.reduce(function(result, key) {
23 - return isValue(result) ? result[key] : undefined;
24 - }, json);
25 -
26 - return isValue(value) ? value : null;
27 - };
28 -
29 - var requestUrlAsBlob = function (url, headers) {
30 - return new Promise(function(resolve) {
31 - var xhr;
32 -
33 - xhr = new XMLHttpRequest();
34 -
35 - xhr.onreadystatechange = function () {
36 - if (xhr.readyState === 4) {
37 - resolve({
38 - status: xhr.status,
39 - blob: this.response
40 - });
41 - }
42 - };
43 -
44 - xhr.open('GET', url, true);
45 -
46 - Tools.each(headers, function (value, key) {
47 - xhr.setRequestHeader(key, value);
48 - });
49 -
50 - xhr.responseType = 'blob';
51 - xhr.send();
52 - });
53 - };
54 -
55 - var readBlob = function (blob) {
56 - return new Promise(function(resolve) {
57 - var fr = new FileReader();
58 -
59 - fr.onload = function (e) {
60 - var data = e.target;
61 - resolve(data.result);
62 - };
63 -
64 - fr.readAsText(blob);
65 - });
66 - };
67 -
68 - var parseJson = function (text) {
69 - var json;
70 -
71 - try {
72 - json = JSON.parse(text);
73 - } catch (ex) {
74 - // Ignore
75 - }
76 -
77 - return json;
78 - };
79 -
80 - return {
81 - traverse: traverse,
82 - readBlob: readBlob,
83 - requestUrlAsBlob: requestUrlAsBlob,
84 - parseJson: parseJson
85 - };
86 -});
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*global tinymce:true */
12 -
13 -tinymce.PluginManager.add('importcss', function(editor) {
14 - var self = this, each = tinymce.each;
15 -
16 - function removeCacheSuffix(url) {
17 - var cacheSuffix = tinymce.Env.cacheSuffix;
18 -
19 - if (typeof url == 'string') {
20 - url = url.replace('?' + cacheSuffix, '').replace('&' + cacheSuffix, '');
21 - }
22 -
23 - return url;
24 - }
25 -
26 - function isSkinContentCss(href) {
27 - var settings = editor.settings, skin = settings.skin !== false ? settings.skin || 'lightgray' : false;
28 -
29 - if (skin) {
30 - var skinUrl = settings.skin_url;
31 -
32 - if (skinUrl) {
33 - skinUrl = editor.documentBaseURI.toAbsolute(skinUrl);
34 - } else {
35 - skinUrl = tinymce.baseURL + '/skins/' + skin;
36 - }
37 -
38 - return href === skinUrl + '/content' + (editor.inline ? '.inline' : '') + '.min.css';
39 - }
40 -
41 - return false;
42 - }
43 -
44 - function compileFilter(filter) {
45 - if (typeof filter == "string") {
46 - return function(value) {
47 - return value.indexOf(filter) !== -1;
48 - };
49 - } else if (filter instanceof RegExp) {
50 - return function(value) {
51 - return filter.test(value);
52 - };
53 - }
54 -
55 - return filter;
56 - }
57 -
58 - function getSelectors(doc, fileFilter) {
59 - var selectors = [], contentCSSUrls = {};
60 -
61 - function append(styleSheet, imported) {
62 - var href = styleSheet.href, rules;
63 -
64 - href = removeCacheSuffix(href);
65 -
66 - if (!href || !fileFilter(href, imported) || isSkinContentCss(href)) {
67 - return;
68 - }
69 -
70 - each(styleSheet.imports, function(styleSheet) {
71 - append(styleSheet, true);
72 - });
73 -
74 - try {
75 - rules = styleSheet.cssRules || styleSheet.rules;
76 - } catch (e) {
77 - // Firefox fails on rules to remote domain for example:
78 - // @import url(//fonts.googleapis.com/css?family=Pathway+Gothic+One);
79 - }
80 -
81 - each(rules, function(cssRule) {
82 - if (cssRule.styleSheet) {
83 - append(cssRule.styleSheet, true);
84 - } else if (cssRule.selectorText) {
85 - each(cssRule.selectorText.split(','), function(selector) {
86 - selectors.push(tinymce.trim(selector));
87 - });
88 - }
89 - });
90 - }
91 -
92 - each(editor.contentCSS, function(url) {
93 - contentCSSUrls[url] = true;
94 - });
95 -
96 - if (!fileFilter) {
97 - fileFilter = function(href, imported) {
98 - return imported || contentCSSUrls[href];
99 - };
100 - }
101 -
102 - try {
103 - each(doc.styleSheets, function(styleSheet) {
104 - append(styleSheet);
105 - });
106 - } catch (e) {
107 - // Ignore
108 - }
109 -
110 - return selectors;
111 - }
112 -
113 - function defaultConvertSelectorToFormat(selectorText) {
114 - var format;
115 -
116 - // Parse simple element.class1, .class1
117 - var selector = /^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(selectorText);
118 - if (!selector) {
119 - return;
120 - }
121 -
122 - var elementName = selector[1];
123 - var classes = selector[2].substr(1).split('.').join(' ');
124 - var inlineSelectorElements = tinymce.makeMap('a,img');
125 -
126 - // element.class - Produce block formats
127 - if (selector[1]) {
128 - format = {
129 - title: selectorText
130 - };
131 -
132 - if (editor.schema.getTextBlockElements()[elementName]) {
133 - // Text block format ex: h1.class1
134 - format.block = elementName;
135 - } else if (editor.schema.getBlockElements()[elementName] || inlineSelectorElements[elementName.toLowerCase()]) {
136 - // Block elements such as table.class and special inline elements such as a.class or img.class
137 - format.selector = elementName;
138 - } else {
139 - // Inline format strong.class1
140 - format.inline = elementName;
141 - }
142 - } else if (selector[2]) {
143 - // .class - Produce inline span with classes
144 - format = {
145 - inline: 'span',
146 - title: selectorText.substr(1),
147 - classes: classes
148 - };
149 - }
150 -
151 - // Append to or override class attribute
152 - if (editor.settings.importcss_merge_classes !== false) {
153 - format.classes = classes;
154 - } else {
155 - format.attributes = {"class": classes};
156 - }
157 -
158 - return format;
159 - }
160 -
161 - function getGroupsBySelector(groups, selector) {
162 - return tinymce.util.Tools.grep(groups, function (group) {
163 - return !group.filter || group.filter(selector);
164 - });
165 - }
166 -
167 - function compileUserDefinedGroups(groups) {
168 - return tinymce.util.Tools.map(groups, function(group) {
169 - return tinymce.util.Tools.extend({}, group, {
170 - original: group,
171 - selectors: {},
172 - filter: compileFilter(group.filter),
173 - item: {
174 - text: group.title,
175 - menu: []
176 - }
177 - });
178 - });
179 - }
180 -
181 - function isExclusiveMode(editor, group) {
182 - // Exclusive mode can only be disabled when there are groups allowing the same style to be present in multiple groups
183 - return group === null || editor.settings.importcss_exclusive !== false;
184 - }
185 -
186 - function isUniqueSelector(selector, group, globallyUniqueSelectors) {
187 - return !(isExclusiveMode(editor, group) ? selector in globallyUniqueSelectors : selector in group.selectors);
188 - }
189 -
190 - function markUniqueSelector(selector, group, globallyUniqueSelectors) {
191 - if (isExclusiveMode(editor, group)) {
192 - globallyUniqueSelectors[selector] = true;
193 - } else {
194 - group.selectors[selector] = true;
195 - }
196 - }
197 -
198 - function convertSelectorToFormat(plugin, selector, group) {
199 - var selectorConverter, settings = editor.settings;
200 -
201 - if (group && group.selector_converter) {
202 - selectorConverter = group.selector_converter;
203 - } else if (settings.importcss_selector_converter) {
204 - selectorConverter = settings.importcss_selector_converter;
205 - } else {
206 - selectorConverter = defaultConvertSelectorToFormat;
207 - }
208 -
209 - return selectorConverter.call(plugin, selector, group);
210 - }
211 -
212 - editor.on('renderFormatsMenu', function(e) {
213 - var settings = editor.settings, globallyUniqueSelectors = {};
214 - var selectorFilter = compileFilter(settings.importcss_selector_filter), ctrl = e.control;
215 - var groups = compileUserDefinedGroups(settings.importcss_groups);
216 -
217 - var processSelector = function (selector, group) {
218 - if (isUniqueSelector(selector, group, globallyUniqueSelectors)) {
219 - markUniqueSelector(selector, group, globallyUniqueSelectors);
220 -
221 - var format = convertSelectorToFormat(self, selector, group);
222 - if (format) {
223 - var formatName = format.name || tinymce.DOM.uniqueId();
224 - editor.formatter.register(formatName, format);
225 -
226 - return tinymce.extend({}, ctrl.settings.itemDefaults, {
227 - text: format.title,
228 - format: formatName
229 - });
230 - }
231 - }
232 -
233 - return null;
234 - };
235 -
236 - if (!editor.settings.importcss_append) {
237 - ctrl.items().remove();
238 - }
239 -
240 - each(getSelectors(e.doc || editor.getDoc(), compileFilter(settings.importcss_file_filter)), function(selector) {
241 - if (selector.indexOf('.mce-') === -1) {
242 - if (!selectorFilter || selectorFilter(selector)) {
243 - var selectorGroups = getGroupsBySelector(groups, selector);
244 -
245 - if (selectorGroups.length > 0) {
246 - tinymce.util.Tools.each(selectorGroups, function (group) {
247 - var menuItem = processSelector(selector, group);
248 - if (menuItem) {
249 - group.item.menu.push(menuItem);
250 - }
251 - });
252 - } else {
253 - var menuItem = processSelector(selector, null);
254 - if (menuItem) {
255 - ctrl.add(menuItem);
256 - }
257 - }
258 - }
259 - }
260 - });
261 -
262 - each(groups, function(group) {
263 - if (group.item.menu.length > 0) {
264 - ctrl.add(group.item);
265 - }
266 - });
267 -
268 - e.control.renderNew();
269 - });
270 -
271 - // Expose default convertSelectorToFormat implementation
272 - self.convertSelectorToFormat = defaultConvertSelectorToFormat;
273 -});
1 -tinymce.PluginManager.add("importcss",function(a){function b(a){var b=tinymce.Env.cacheSuffix;return"string"==typeof a&&(a=a.replace("?"+b,"").replace("&"+b,"")),a}function c(b){var c=a.settings,d=c.skin!==!1?c.skin||"lightgray":!1;if(d){var e=c.skin_url;return e=e?a.documentBaseURI.toAbsolute(e):tinymce.baseURL+"/skins/"+d,b===e+"/content"+(a.inline?".inline":"")+".min.css"}return!1}function d(a){return"string"==typeof a?function(b){return-1!==b.indexOf(a)}:a instanceof RegExp?function(b){return a.test(b)}:a}function e(d,e){function f(a,d){var h,i=a.href;if(i=b(i),i&&e(i,d)&&!c(i)){n(a.imports,function(a){f(a,!0)});try{h=a.cssRules||a.rules}catch(j){}n(h,function(a){a.styleSheet?f(a.styleSheet,!0):a.selectorText&&n(a.selectorText.split(","),function(a){g.push(tinymce.trim(a))})})}}var g=[],h={};n(a.contentCSS,function(a){h[a]=!0}),e||(e=function(a,b){return b||h[a]});try{n(d.styleSheets,function(a){f(a)})}catch(i){}return g}function f(b){var c,d=/^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(b);if(d){var e=d[1],f=d[2].substr(1).split(".").join(" "),g=tinymce.makeMap("a,img");return d[1]?(c={title:b},a.schema.getTextBlockElements()[e]?c.block=e:a.schema.getBlockElements()[e]||g[e.toLowerCase()]?c.selector=e:c.inline=e):d[2]&&(c={inline:"span",title:b.substr(1),classes:f}),a.settings.importcss_merge_classes!==!1?c.classes=f:c.attributes={"class":f},c}}function g(a,b){return tinymce.util.Tools.grep(a,function(a){return!a.filter||a.filter(b)})}function h(a){return tinymce.util.Tools.map(a,function(a){return tinymce.util.Tools.extend({},a,{original:a,selectors:{},filter:d(a.filter),item:{text:a.title,menu:[]}})})}function i(a,b){return null===b||a.settings.importcss_exclusive!==!1}function j(b,c,d){return!(i(a,c)?b in d:b in c.selectors)}function k(b,c,d){i(a,c)?d[b]=!0:c.selectors[b]=!0}function l(b,c,d){var e,g=a.settings;return e=d&&d.selector_converter?d.selector_converter:g.importcss_selector_converter?g.importcss_selector_converter:f,e.call(b,c,d)}var m=this,n=tinymce.each;a.on("renderFormatsMenu",function(b){var c=a.settings,f={},i=d(c.importcss_selector_filter),o=b.control,p=h(c.importcss_groups),q=function(b,c){if(j(b,c,f)){k(b,c,f);var d=l(m,b,c);if(d){var e=d.name||tinymce.DOM.uniqueId();return a.formatter.register(e,d),tinymce.extend({},o.settings.itemDefaults,{text:d.title,format:e})}}return null};a.settings.importcss_append||o.items().remove(),n(e(b.doc||a.getDoc(),d(c.importcss_file_filter)),function(a){if(-1===a.indexOf(".mce-")&&(!i||i(a))){var b=g(p,a);if(b.length>0)tinymce.util.Tools.each(b,function(b){var c=q(a,b);c&&b.item.menu.push(c)});else{var c=q(a,null);c&&o.add(c)}}}),n(p,function(a){a.item.menu.length>0&&o.add(a.item)}),b.control.renderNew()}),m.convertSelectorToFormat=f});
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*global tinymce:true */
12 -
13 -tinymce.PluginManager.add('insertdatetime', function(editor) {
14 - var daysShort = "Sun Mon Tue Wed Thu Fri Sat Sun".split(' ');
15 - var daysLong = "Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(' ');
16 - var monthsShort = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(' ');
17 - var monthsLong = "January February March April May June July August September October November December".split(' ');
18 - var menuItems = [], lastFormat, defaultButtonTimeFormat;
19 -
20 - function getDateTime(fmt, date) {
21 - function addZeros(value, len) {
22 - value = "" + value;
23 -
24 - if (value.length < len) {
25 - for (var i = 0; i < (len - value.length); i++) {
26 - value = "0" + value;
27 - }
28 - }
29 -
30 - return value;
31 - }
32 -
33 - date = date || new Date();
34 -
35 - fmt = fmt.replace("%D", "%m/%d/%Y");
36 - fmt = fmt.replace("%r", "%I:%M:%S %p");
37 - fmt = fmt.replace("%Y", "" + date.getFullYear());
38 - fmt = fmt.replace("%y", "" + date.getYear());
39 - fmt = fmt.replace("%m", addZeros(date.getMonth() + 1, 2));
40 - fmt = fmt.replace("%d", addZeros(date.getDate(), 2));
41 - fmt = fmt.replace("%H", "" + addZeros(date.getHours(), 2));
42 - fmt = fmt.replace("%M", "" + addZeros(date.getMinutes(), 2));
43 - fmt = fmt.replace("%S", "" + addZeros(date.getSeconds(), 2));
44 - fmt = fmt.replace("%I", "" + ((date.getHours() + 11) % 12 + 1));
45 - fmt = fmt.replace("%p", "" + (date.getHours() < 12 ? "AM" : "PM"));
46 - fmt = fmt.replace("%B", "" + editor.translate(monthsLong[date.getMonth()]));
47 - fmt = fmt.replace("%b", "" + editor.translate(monthsShort[date.getMonth()]));
48 - fmt = fmt.replace("%A", "" + editor.translate(daysLong[date.getDay()]));
49 - fmt = fmt.replace("%a", "" + editor.translate(daysShort[date.getDay()]));
50 - fmt = fmt.replace("%%", "%");
51 -
52 - return fmt;
53 - }
54 -
55 - function insertDateTime(format) {
56 - var html = getDateTime(format);
57 -
58 - if (editor.settings.insertdatetime_element) {
59 - var computerTime;
60 -
61 - if (/%[HMSIp]/.test(format)) {
62 - computerTime = getDateTime("%Y-%m-%dT%H:%M");
63 - } else {
64 - computerTime = getDateTime("%Y-%m-%d");
65 - }
66 -
67 - html = '<time datetime="' + computerTime + '">' + html + '</time>';
68 -
69 - var timeElm = editor.dom.getParent(editor.selection.getStart(), 'time');
70 - if (timeElm) {
71 - editor.dom.setOuterHTML(timeElm, html);
72 - return;
73 - }
74 - }
75 -
76 - editor.insertContent(html);
77 - }
78 -
79 - editor.addCommand('mceInsertDate', function() {
80 - insertDateTime(editor.getParam("insertdatetime_dateformat", editor.translate("%Y-%m-%d")));
81 - });
82 -
83 - editor.addCommand('mceInsertTime', function() {
84 - insertDateTime(editor.getParam("insertdatetime_timeformat", editor.translate('%H:%M:%S')));
85 - });
86 -
87 - editor.addButton('insertdatetime', {
88 - type: 'splitbutton',
89 - title: 'Insert date/time',
90 - onclick: function() {
91 - insertDateTime(lastFormat || defaultButtonTimeFormat);
92 - },
93 - menu: menuItems
94 - });
95 -
96 - tinymce.each(editor.settings.insertdatetime_formats || [
97 - "%H:%M:%S",
98 - "%Y-%m-%d",
99 - "%I:%M:%S %p",
100 - "%D"
101 - ], function(fmt) {
102 - if (!defaultButtonTimeFormat) {
103 - defaultButtonTimeFormat = fmt;
104 - }
105 -
106 - menuItems.push({
107 - text: getDateTime(fmt),
108 - onclick: function() {
109 - lastFormat = fmt;
110 - insertDateTime(fmt);
111 - }
112 - });
113 - });
114 -
115 - editor.addMenuItem('insertdatetime', {
116 - icon: 'date',
117 - text: 'Insert date/time',
118 - menu: menuItems,
119 - context: 'insert'
120 - });
121 -});
1 -tinymce.PluginManager.add("insertdatetime",function(a){function b(b,c){function d(a,b){if(a=""+a,a.length<b)for(var c=0;c<b-a.length;c++)a="0"+a;return a}return c=c||new Date,b=b.replace("%D","%m/%d/%Y"),b=b.replace("%r","%I:%M:%S %p"),b=b.replace("%Y",""+c.getFullYear()),b=b.replace("%y",""+c.getYear()),b=b.replace("%m",d(c.getMonth()+1,2)),b=b.replace("%d",d(c.getDate(),2)),b=b.replace("%H",""+d(c.getHours(),2)),b=b.replace("%M",""+d(c.getMinutes(),2)),b=b.replace("%S",""+d(c.getSeconds(),2)),b=b.replace("%I",""+((c.getHours()+11)%12+1)),b=b.replace("%p",""+(c.getHours()<12?"AM":"PM")),b=b.replace("%B",""+a.translate(i[c.getMonth()])),b=b.replace("%b",""+a.translate(h[c.getMonth()])),b=b.replace("%A",""+a.translate(g[c.getDay()])),b=b.replace("%a",""+a.translate(f[c.getDay()])),b=b.replace("%%","%")}function c(c){var d=b(c);if(a.settings.insertdatetime_element){var e;e=b(/%[HMSIp]/.test(c)?"%Y-%m-%dT%H:%M":"%Y-%m-%d"),d='<time datetime="'+e+'">'+d+"</time>";var f=a.dom.getParent(a.selection.getStart(),"time");if(f)return void a.dom.setOuterHTML(f,d)}a.insertContent(d)}var d,e,f="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),g="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),h="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),i="January February March April May June July August September October November December".split(" "),j=[];a.addCommand("mceInsertDate",function(){c(a.getParam("insertdatetime_dateformat",a.translate("%Y-%m-%d")))}),a.addCommand("mceInsertTime",function(){c(a.getParam("insertdatetime_timeformat",a.translate("%H:%M:%S")))}),a.addButton("insertdatetime",{type:"splitbutton",title:"Insert date/time",onclick:function(){c(d||e)},menu:j}),tinymce.each(a.settings.insertdatetime_formats||["%H:%M:%S","%Y-%m-%d","%I:%M:%S %p","%D"],function(a){e||(e=a),j.push({text:b(a),onclick:function(){d=a,c(a)}})}),a.addMenuItem("insertdatetime",{icon:"date",text:"Insert date/time",menu:j,context:"insert"})});
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*global tinymce:true */
12 -
13 -tinymce.PluginManager.add('layer', function(editor) {
14 - function getParentLayer(node) {
15 - do {
16 - if (node.className && node.className.indexOf('mceItemLayer') != -1) {
17 - return node;
18 - }
19 - } while ((node = node.parentNode));
20 - }
21 -
22 - function visualAid(e) {
23 - var dom = editor.dom;
24 -
25 - tinymce.each(dom.select('div,p', e), function(e) {
26 - if (/^(absolute|relative|fixed)$/i.test(e.style.position)) {
27 - if (e.hasVisual) {
28 - dom.addClass(e, 'mceItemVisualAid');
29 - } else {
30 - dom.removeClass(e, 'mceItemVisualAid');
31 - }
32 -
33 - dom.addClass(e, 'mceItemLayer');
34 - }
35 - });
36 - }
37 -
38 - function move(d) {
39 - var i, z = [], le = getParentLayer(editor.selection.getNode()), ci = -1, fi = -1, nl;
40 -
41 - nl = [];
42 - tinymce.walk(editor.getBody(), function(n) {
43 - if (n.nodeType == 1 && /^(absolute|relative|static)$/i.test(n.style.position)) {
44 - nl.push(n);
45 - }
46 - }, 'childNodes');
47 -
48 - // Find z-indexes
49 - for (i = 0; i < nl.length; i++) {
50 - z[i] = nl[i].style.zIndex ? parseInt(nl[i].style.zIndex, 10) : 0;
51 -
52 - if (ci < 0 && nl[i] == le) {
53 - ci = i;
54 - }
55 - }
56 -
57 - if (d < 0) {
58 - // Move back
59 -
60 - // Try find a lower one
61 - for (i = 0; i < z.length; i++) {
62 - if (z[i] < z[ci]) {
63 - fi = i;
64 - break;
65 - }
66 - }
67 -
68 - if (fi > -1) {
69 - nl[ci].style.zIndex = z[fi];
70 - nl[fi].style.zIndex = z[ci];
71 - } else {
72 - if (z[ci] > 0) {
73 - nl[ci].style.zIndex = z[ci] - 1;
74 - }
75 - }
76 - } else {
77 - // Move forward
78 -
79 - // Try find a higher one
80 - for (i = 0; i < z.length; i++) {
81 - if (z[i] > z[ci]) {
82 - fi = i;
83 - break;
84 - }
85 - }
86 -
87 - if (fi > -1) {
88 - nl[ci].style.zIndex = z[fi];
89 - nl[fi].style.zIndex = z[ci];
90 - } else {
91 - nl[ci].style.zIndex = z[ci] + 1;
92 - }
93 - }
94 -
95 - editor.execCommand('mceRepaint');
96 - }
97 -
98 - function insertLayer() {
99 - var dom = editor.dom, p = dom.getPos(dom.getParent(editor.selection.getNode(), '*'));
100 - var body = editor.getBody();
101 -
102 - editor.dom.add(body, 'div', {
103 - style: {
104 - position: 'absolute',
105 - left: p.x,
106 - top: (p.y > 20 ? p.y : 20),
107 - width: 100,
108 - height: 100
109 - },
110 - 'class': 'mceItemVisualAid mceItemLayer'
111 - }, editor.selection.getContent() || editor.getLang('layer.content'));
112 -
113 - // Workaround for IE where it messes up the JS engine if you insert a layer on IE 6,7
114 - if (tinymce.Env.ie) {
115 - dom.setHTML(body, body.innerHTML);
116 - }
117 - }
118 -
119 - function toggleAbsolute() {
120 - var le = getParentLayer(editor.selection.getNode());
121 -
122 - if (!le) {
123 - le = editor.dom.getParent(editor.selection.getNode(), 'DIV,P,IMG');
124 - }
125 -
126 - if (le) {
127 - if (le.style.position.toLowerCase() == "absolute") {
128 - editor.dom.setStyles(le, {
129 - position: '',
130 - left: '',
131 - top: '',
132 - width: '',
133 - height: ''
134 - });
135 -
136 - editor.dom.removeClass(le, 'mceItemVisualAid');
137 - editor.dom.removeClass(le, 'mceItemLayer');
138 - } else {
139 - if (!le.style.left) {
140 - le.style.left = 20 + 'px';
141 - }
142 -
143 - if (!le.style.top) {
144 - le.style.top = 20 + 'px';
145 - }
146 -
147 - if (!le.style.width) {
148 - le.style.width = le.width ? (le.width + 'px') : '100px';
149 - }
150 -
151 - if (!le.style.height) {
152 - le.style.height = le.height ? (le.height + 'px') : '100px';
153 - }
154 -
155 - le.style.position = "absolute";
156 -
157 - editor.dom.setAttrib(le, 'data-mce-style', '');
158 - editor.addVisual(editor.getBody());
159 - }
160 -
161 - editor.execCommand('mceRepaint');
162 - editor.nodeChanged();
163 - }
164 - }
165 -
166 - // Register commands
167 - editor.addCommand('mceInsertLayer', insertLayer);
168 -
169 - editor.addCommand('mceMoveForward', function() {
170 - move(1);
171 - });
172 -
173 - editor.addCommand('mceMoveBackward', function() {
174 - move(-1);
175 - });
176 -
177 - editor.addCommand('mceMakeAbsolute', function() {
178 - toggleAbsolute();
179 - });
180 -
181 - // Register buttons
182 - editor.addButton('moveforward', {title: 'layer.forward_desc', cmd: 'mceMoveForward'});
183 - editor.addButton('movebackward', {title: 'layer.backward_desc', cmd: 'mceMoveBackward'});
184 - editor.addButton('absolute', {title: 'layer.absolute_desc', cmd: 'mceMakeAbsolute'});
185 - editor.addButton('insertlayer', {title: 'layer.insertlayer_desc', cmd: 'mceInsertLayer'});
186 -
187 - editor.on('init', function() {
188 - if (tinymce.Env.ie) {
189 - editor.getDoc().execCommand('2D-Position', false, true);
190 - }
191 - });
192 -
193 - // Remove serialized styles when selecting a layer since it might be changed by a drag operation
194 - editor.on('mouseup', function(e) {
195 - var layer = getParentLayer(e.target);
196 -
197 - if (layer) {
198 - editor.dom.setAttrib(layer, 'data-mce-style', '');
199 - }
200 - });
201 -
202 - // Fixes edit focus issues with layers on Gecko
203 - // This will enable designMode while inside a layer and disable it when outside
204 - editor.on('mousedown', function(e) {
205 - var node = e.target, doc = editor.getDoc(), parent;
206 -
207 - if (tinymce.Env.gecko) {
208 - if (getParentLayer(node)) {
209 - if (doc.designMode !== 'on') {
210 - doc.designMode = 'on';
211 -
212 - // Repaint caret
213 - node = doc.body;
214 - parent = node.parentNode;
215 - parent.removeChild(node);
216 - parent.appendChild(node);
217 - }
218 - } else if (doc.designMode == 'on') {
219 - doc.designMode = 'off';
220 - }
221 - }
222 - });
223 -
224 - editor.on('NodeChange', visualAid);
225 -});
1 -tinymce.PluginManager.add("layer",function(a){function b(a){do if(a.className&&-1!=a.className.indexOf("mceItemLayer"))return a;while(a=a.parentNode)}function c(b){var c=a.dom;tinymce.each(c.select("div,p",b),function(a){/^(absolute|relative|fixed)$/i.test(a.style.position)&&(a.hasVisual?c.addClass(a,"mceItemVisualAid"):c.removeClass(a,"mceItemVisualAid"),c.addClass(a,"mceItemLayer"))})}function d(c){var d,e,f=[],g=b(a.selection.getNode()),h=-1,i=-1;for(e=[],tinymce.walk(a.getBody(),function(a){1==a.nodeType&&/^(absolute|relative|static)$/i.test(a.style.position)&&e.push(a)},"childNodes"),d=0;d<e.length;d++)f[d]=e[d].style.zIndex?parseInt(e[d].style.zIndex,10):0,0>h&&e[d]==g&&(h=d);if(0>c){for(d=0;d<f.length;d++)if(f[d]<f[h]){i=d;break}i>-1?(e[h].style.zIndex=f[i],e[i].style.zIndex=f[h]):f[h]>0&&(e[h].style.zIndex=f[h]-1)}else{for(d=0;d<f.length;d++)if(f[d]>f[h]){i=d;break}i>-1?(e[h].style.zIndex=f[i],e[i].style.zIndex=f[h]):e[h].style.zIndex=f[h]+1}a.execCommand("mceRepaint")}function e(){var b=a.dom,c=b.getPos(b.getParent(a.selection.getNode(),"*")),d=a.getBody();a.dom.add(d,"div",{style:{position:"absolute",left:c.x,top:c.y>20?c.y:20,width:100,height:100},"class":"mceItemVisualAid mceItemLayer"},a.selection.getContent()||a.getLang("layer.content")),tinymce.Env.ie&&b.setHTML(d,d.innerHTML)}function f(){var c=b(a.selection.getNode());c||(c=a.dom.getParent(a.selection.getNode(),"DIV,P,IMG")),c&&("absolute"==c.style.position.toLowerCase()?(a.dom.setStyles(c,{position:"",left:"",top:"",width:"",height:""}),a.dom.removeClass(c,"mceItemVisualAid"),a.dom.removeClass(c,"mceItemLayer")):(c.style.left||(c.style.left="20px"),c.style.top||(c.style.top="20px"),c.style.width||(c.style.width=c.width?c.width+"px":"100px"),c.style.height||(c.style.height=c.height?c.height+"px":"100px"),c.style.position="absolute",a.dom.setAttrib(c,"data-mce-style",""),a.addVisual(a.getBody())),a.execCommand("mceRepaint"),a.nodeChanged())}a.addCommand("mceInsertLayer",e),a.addCommand("mceMoveForward",function(){d(1)}),a.addCommand("mceMoveBackward",function(){d(-1)}),a.addCommand("mceMakeAbsolute",function(){f()}),a.addButton("moveforward",{title:"layer.forward_desc",cmd:"mceMoveForward"}),a.addButton("movebackward",{title:"layer.backward_desc",cmd:"mceMoveBackward"}),a.addButton("absolute",{title:"layer.absolute_desc",cmd:"mceMakeAbsolute"}),a.addButton("insertlayer",{title:"layer.insertlayer_desc",cmd:"mceInsertLayer"}),a.on("init",function(){tinymce.Env.ie&&a.getDoc().execCommand("2D-Position",!1,!0)}),a.on("mouseup",function(c){var d=b(c.target);d&&a.dom.setAttrib(d,"data-mce-style","")}),a.on("mousedown",function(c){var d,e=c.target,f=a.getDoc();tinymce.Env.gecko&&(b(e)?"on"!==f.designMode&&(f.designMode="on",e=f.body,d=e.parentNode,d.removeChild(e),d.appendChild(e)):"on"==f.designMode&&(f.designMode="off"))}),a.on("NodeChange",c)});
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - *
10 - * This plugin will force TinyMCE to produce deprecated legacy output such as font elements, u elements, align
11 - * attributes and so forth. There are a few cases where these old items might be needed for example in email applications or with Flash
12 - *
13 - * However you should NOT use this plugin if you are building some system that produces web contents such as a CMS. All these elements are
14 - * not apart of the newer specifications for HTML and XHTML.
15 - */
16 -
17 -/*global tinymce:true */
18 -
19 -(function(tinymce) {
20 - tinymce.PluginManager.add('legacyoutput', function(editor, url, $) {
21 - editor.settings.inline_styles = false;
22 -
23 - editor.on('init', function() {
24 - var alignElements = 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img',
25 - fontSizes = tinymce.explode(editor.settings.font_size_style_values),
26 - schema = editor.schema;
27 -
28 - // Override some internal formats to produce legacy elements and attributes
29 - editor.formatter.register({
30 - // Change alignment formats to use the deprecated align attribute
31 - alignleft: {selector: alignElements, attributes: {align: 'left'}},
32 - aligncenter: {selector: alignElements, attributes: {align: 'center'}},
33 - alignright: {selector: alignElements, attributes: {align: 'right'}},
34 - alignjustify: {selector: alignElements, attributes: {align: 'justify'}},
35 -
36 - // Change the basic formatting elements to use deprecated element types
37 - bold: [
38 - {inline: 'b', remove: 'all'},
39 - {inline: 'strong', remove: 'all'},
40 - {inline: 'span', styles: {fontWeight: 'bold'}}
41 - ],
42 - italic: [
43 - {inline: 'i', remove: 'all'},
44 - {inline: 'em', remove: 'all'},
45 - {inline: 'span', styles: {fontStyle: 'italic'}}
46 - ],
47 - underline: [
48 - {inline: 'u', remove: 'all'},
49 - {inline: 'span', styles: {textDecoration: 'underline'}, exact: true}
50 - ],
51 - strikethrough: [
52 - {inline: 'strike', remove: 'all'},
53 - {inline: 'span', styles: {textDecoration: 'line-through'}, exact: true}
54 - ],
55 -
56 - // Change font size and font family to use the deprecated font element
57 - fontname: {inline: 'font', attributes: {face: '%value'}},
58 - fontsize: {
59 - inline: 'font',
60 - attributes: {
61 - size: function(vars) {
62 - return tinymce.inArray(fontSizes, vars.value) + 1;
63 - }
64 - }
65 - },
66 -
67 - // Setup font elements for colors as well
68 - forecolor: {inline: 'font', attributes: {color: '%value'}},
69 - hilitecolor: {inline: 'font', styles: {backgroundColor: '%value'}}
70 - });
71 -
72 - // Check that deprecated elements are allowed if not add them
73 - tinymce.each('b,i,u,strike'.split(','), function(name) {
74 - schema.addValidElements(name + '[*]');
75 - });
76 -
77 - // Add font element if it's missing
78 - if (!schema.getElementRule("font")) {
79 - schema.addValidElements("font[face|size|color|style]");
80 - }
81 -
82 - // Add the missing and depreacted align attribute for the serialization engine
83 - tinymce.each(alignElements.split(','), function(name) {
84 - var rule = schema.getElementRule(name);
85 -
86 - if (rule) {
87 - if (!rule.attributes.align) {
88 - rule.attributes.align = {};
89 - rule.attributesOrder.push('align');
90 - }
91 - }
92 - });
93 - });
94 -
95 - editor.addButton('fontsizeselect', function() {
96 - var items = [], defaultFontsizeFormats = '8pt=1 10pt=2 12pt=3 14pt=4 18pt=5 24pt=6 36pt=7';
97 - var fontsize_formats = editor.settings.fontsize_formats || defaultFontsizeFormats;
98 -
99 - editor.$.each(fontsize_formats.split(' '), function(i, item) {
100 - var text = item, value = item;
101 - var values = item.split('=');
102 -
103 - if (values.length > 1) {
104 - text = values[0];
105 - value = values[1];
106 - }
107 -
108 - items.push({text: text, value: value});
109 - });
110 -
111 - return {
112 - type: 'listbox',
113 - text: 'Font Sizes',
114 - tooltip: 'Font Sizes',
115 - values: items,
116 - fixedWidth: true,
117 - onPostRender: function() {
118 - var self = this;
119 -
120 - editor.on('NodeChange', function() {
121 - var fontElm;
122 -
123 - fontElm = editor.dom.getParent(editor.selection.getNode(), 'font');
124 - if (fontElm) {
125 - self.value(fontElm.size);
126 - } else {
127 - self.value('');
128 - }
129 - });
130 - },
131 - onclick: function(e) {
132 - if (e.control.settings.value) {
133 - editor.execCommand('FontSize', false, e.control.settings.value);
134 - }
135 - }
136 - };
137 - });
138 -
139 - editor.addButton('fontselect', function() {
140 - function createFormats(formats) {
141 - formats = formats.replace(/;$/, '').split(';');
142 -
143 - var i = formats.length;
144 - while (i--) {
145 - formats[i] = formats[i].split('=');
146 - }
147 -
148 - return formats;
149 - }
150 -
151 - var defaultFontsFormats =
152 - 'Andale Mono=andale mono,monospace;' +
153 - 'Arial=arial,helvetica,sans-serif;' +
154 - 'Arial Black=arial black,sans-serif;' +
155 - 'Book Antiqua=book antiqua,palatino,serif;' +
156 - 'Comic Sans MS=comic sans ms,sans-serif;' +
157 - 'Courier New=courier new,courier,monospace;' +
158 - 'Georgia=georgia,palatino,serif;' +
159 - 'Helvetica=helvetica,arial,sans-serif;' +
160 - 'Impact=impact,sans-serif;' +
161 - 'Symbol=symbol;' +
162 - 'Tahoma=tahoma,arial,helvetica,sans-serif;' +
163 - 'Terminal=terminal,monaco,monospace;' +
164 - 'Times New Roman=times new roman,times,serif;' +
165 - 'Trebuchet MS=trebuchet ms,geneva,sans-serif;' +
166 - 'Verdana=verdana,geneva,sans-serif;' +
167 - 'Webdings=webdings;' +
168 - 'Wingdings=wingdings,zapf dingbats';
169 -
170 - var items = [], fonts = createFormats(editor.settings.font_formats || defaultFontsFormats);
171 -
172 - $.each(fonts, function(i, font) {
173 - items.push({
174 - text: {raw: font[0]},
175 - value: font[1],
176 - textStyle: font[1].indexOf('dings') == -1 ? 'font-family:' + font[1] : ''
177 - });
178 - });
179 -
180 - return {
181 - type: 'listbox',
182 - text: 'Font Family',
183 - tooltip: 'Font Family',
184 - values: items,
185 - fixedWidth: true,
186 - onPostRender: function() {
187 - var self = this;
188 -
189 - editor.on('NodeChange', function() {
190 - var fontElm;
191 -
192 - fontElm = editor.dom.getParent(editor.selection.getNode(), 'font');
193 - if (fontElm) {
194 - self.value(fontElm.face);
195 - } else {
196 - self.value('');
197 - }
198 - });
199 - },
200 - onselect: function(e) {
201 - if (e.control.settings.value) {
202 - editor.execCommand('FontName', false, e.control.settings.value);
203 - }
204 - }
205 - };
206 - });
207 - });
208 -})(tinymce);
1 -!function(a){a.PluginManager.add("legacyoutput",function(b,c,d){b.settings.inline_styles=!1,b.on("init",function(){var c="p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",d=a.explode(b.settings.font_size_style_values),e=b.schema;b.formatter.register({alignleft:{selector:c,attributes:{align:"left"}},aligncenter:{selector:c,attributes:{align:"center"}},alignright:{selector:c,attributes:{align:"right"}},alignjustify:{selector:c,attributes:{align:"justify"}},bold:[{inline:"b",remove:"all"},{inline:"strong",remove:"all"},{inline:"span",styles:{fontWeight:"bold"}}],italic:[{inline:"i",remove:"all"},{inline:"em",remove:"all"},{inline:"span",styles:{fontStyle:"italic"}}],underline:[{inline:"u",remove:"all"},{inline:"span",styles:{textDecoration:"underline"},exact:!0}],strikethrough:[{inline:"strike",remove:"all"},{inline:"span",styles:{textDecoration:"line-through"},exact:!0}],fontname:{inline:"font",attributes:{face:"%value"}},fontsize:{inline:"font",attributes:{size:function(b){return a.inArray(d,b.value)+1}}},forecolor:{inline:"font",attributes:{color:"%value"}},hilitecolor:{inline:"font",styles:{backgroundColor:"%value"}}}),a.each("b,i,u,strike".split(","),function(a){e.addValidElements(a+"[*]")}),e.getElementRule("font")||e.addValidElements("font[face|size|color|style]"),a.each(c.split(","),function(a){var b=e.getElementRule(a);b&&(b.attributes.align||(b.attributes.align={},b.attributesOrder.push("align")))})}),b.addButton("fontsizeselect",function(){var a=[],c="8pt=1 10pt=2 12pt=3 14pt=4 18pt=5 24pt=6 36pt=7",d=b.settings.fontsize_formats||c;return b.$.each(d.split(" "),function(b,c){var d=c,e=c,f=c.split("=");f.length>1&&(d=f[0],e=f[1]),a.push({text:d,value:e})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:a,fixedWidth:!0,onPostRender:function(){var a=this;b.on("NodeChange",function(){var c;c=b.dom.getParent(b.selection.getNode(),"font"),c?a.value(c.size):a.value("")})},onclick:function(a){a.control.settings.value&&b.execCommand("FontSize",!1,a.control.settings.value)}}}),b.addButton("fontselect",function(){function a(a){a=a.replace(/;$/,"").split(";");for(var b=a.length;b--;)a[b]=a[b].split("=");return a}var c="Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats",e=[],f=a(b.settings.font_formats||c);return d.each(f,function(a,b){e.push({text:{raw:b[0]},value:b[1],textStyle:-1==b[1].indexOf("dings")?"font-family:"+b[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:e,fixedWidth:!0,onPostRender:function(){var a=this;b.on("NodeChange",function(){var c;c=b.dom.getParent(b.selection.getNode(),"font"),c?a.value(c.face):a.value("")})},onselect:function(a){a.control.settings.value&&b.execCommand("FontName",!1,a.control.settings.value)}}})})}(tinymce);
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*global tinymce:true */
12 -
13 -tinymce.PluginManager.add('link', function(editor) {
14 - function createLinkList(callback) {
15 - return function() {
16 - var linkList = editor.settings.link_list;
17 -
18 - if (typeof linkList == "string") {
19 - tinymce.util.XHR.send({
20 - url: linkList,
21 - success: function(text) {
22 - callback(tinymce.util.JSON.parse(text));
23 - }
24 - });
25 - } else if (typeof linkList == "function") {
26 - linkList(callback);
27 - } else {
28 - callback(linkList);
29 - }
30 - };
31 - }
32 -
33 - function buildListItems(inputList, itemCallback, startItems) {
34 - function appendItems(values, output) {
35 - output = output || [];
36 -
37 - tinymce.each(values, function(item) {
38 - var menuItem = {text: item.text || item.title};
39 -
40 - if (item.menu) {
41 - menuItem.menu = appendItems(item.menu);
42 - } else {
43 - menuItem.value = item.value;
44 -
45 - if (itemCallback) {
46 - itemCallback(menuItem);
47 - }
48 - }
49 -
50 - output.push(menuItem);
51 - });
52 -
53 - return output;
54 - }
55 -
56 - return appendItems(inputList, startItems || []);
57 - }
58 -
59 - function showDialog(linkList) {
60 - var data = {}, selection = editor.selection, dom = editor.dom, selectedElm, anchorElm, initialText;
61 - var win, onlyText, textListCtrl, linkListCtrl, relListCtrl, targetListCtrl, classListCtrl, linkTitleCtrl, value;
62 -
63 - function linkListChangeHandler(e) {
64 - var textCtrl = win.find('#text');
65 -
66 - if (!textCtrl.value() || (e.lastControl && textCtrl.value() == e.lastControl.text())) {
67 - textCtrl.value(e.control.text());
68 - }
69 -
70 - win.find('#href').value(e.control.value());
71 - }
72 -
73 - function buildAnchorListControl(url) {
74 - var anchorList = [];
75 -
76 - tinymce.each(editor.dom.select('a:not([href])'), function(anchor) {
77 - var id = anchor.name || anchor.id;
78 -
79 - if (id) {
80 - anchorList.push({
81 - text: id,
82 - value: '#' + id,
83 - selected: url.indexOf('#' + id) != -1
84 - });
85 - }
86 - });
87 -
88 - if (anchorList.length) {
89 - anchorList.unshift({text: 'None', value: ''});
90 -
91 - return {
92 - name: 'anchor',
93 - type: 'listbox',
94 - label: 'Anchors',
95 - values: anchorList,
96 - onselect: linkListChangeHandler
97 - };
98 - }
99 - }
100 -
101 - function updateText() {
102 - if (!initialText && data.text.length === 0 && onlyText) {
103 - this.parent().parent().find('#text')[0].value(this.value());
104 - }
105 - }
106 -
107 - function urlChange(e) {
108 - var meta = e.meta || {};
109 -
110 - if (linkListCtrl) {
111 - linkListCtrl.value(editor.convertURL(this.value(), 'href'));
112 - }
113 -
114 - tinymce.each(e.meta, function(value, key) {
115 - win.find('#' + key).value(value);
116 - });
117 -
118 - if (!meta.text) {
119 - updateText.call(this);
120 - }
121 - }
122 -
123 - function isOnlyTextSelected(anchorElm) {
124 - var html = selection.getContent();
125 -
126 - // Partial html and not a fully selected anchor element
127 - if (/</.test(html) && (!/^<a [^>]+>[^<]+<\/a>$/.test(html) || html.indexOf('href=') == -1)) {
128 - return false;
129 - }
130 -
131 - if (anchorElm) {
132 - var nodes = anchorElm.childNodes, i;
133 -
134 - if (nodes.length === 0) {
135 - return false;
136 - }
137 -
138 - for (i = nodes.length - 1; i >= 0; i--) {
139 - if (nodes[i].nodeType != 3) {
140 - return false;
141 - }
142 - }
143 - }
144 -
145 - return true;
146 - }
147 -
148 - selectedElm = selection.getNode();
149 - anchorElm = dom.getParent(selectedElm, 'a[href]');
150 - onlyText = isOnlyTextSelected();
151 -
152 - data.text = initialText = anchorElm ? (anchorElm.innerText || anchorElm.textContent) : selection.getContent({format: 'text'});
153 - data.href = anchorElm ? dom.getAttrib(anchorElm, 'href') : '';
154 -
155 - if (anchorElm) {
156 - data.target = dom.getAttrib(anchorElm, 'target');
157 - } else if (editor.settings.default_link_target) {
158 - data.target = editor.settings.default_link_target;
159 - }
160 -
161 - if ((value = dom.getAttrib(anchorElm, 'rel'))) {
162 - data.rel = value;
163 - }
164 -
165 - if ((value = dom.getAttrib(anchorElm, 'class'))) {
166 - data['class'] = value;
167 - }
168 -
169 - if ((value = dom.getAttrib(anchorElm, 'title'))) {
170 - data.title = value;
171 - }
172 -
173 - if (onlyText) {
174 - textListCtrl = {
175 - name: 'text',
176 - type: 'textbox',
177 - size: 40,
178 - label: 'Text to display',
179 - onchange: function() {
180 - data.text = this.value();
181 - }
182 - };
183 - }
184 -
185 - if (linkList) {
186 - linkListCtrl = {
187 - type: 'listbox',
188 - label: 'Link list',
189 - values: buildListItems(
190 - linkList,
191 - function(item) {
192 - item.value = editor.convertURL(item.value || item.url, 'href');
193 - },
194 - [{text: 'None', value: ''}]
195 - ),
196 - onselect: linkListChangeHandler,
197 - value: editor.convertURL(data.href, 'href'),
198 - onPostRender: function() {
199 - /*eslint consistent-this:0*/
200 - linkListCtrl = this;
201 - }
202 - };
203 - }
204 -
205 - if (editor.settings.target_list !== false) {
206 - if (!editor.settings.target_list) {
207 - editor.settings.target_list = [
208 - {text: 'None', value: ''},
209 - {text: 'New window', value: '_blank'}
210 - ];
211 - }
212 -
213 - targetListCtrl = {
214 - name: 'target',
215 - type: 'listbox',
216 - label: 'Target',
217 - values: buildListItems(editor.settings.target_list)
218 - };
219 - }
220 -
221 - if (editor.settings.rel_list) {
222 - relListCtrl = {
223 - name: 'rel',
224 - type: 'listbox',
225 - label: 'Rel',
226 - values: buildListItems(editor.settings.rel_list)
227 - };
228 - }
229 -
230 - if (editor.settings.link_class_list) {
231 - classListCtrl = {
232 - name: 'class',
233 - type: 'listbox',
234 - label: 'Class',
235 - values: buildListItems(
236 - editor.settings.link_class_list,
237 - function(item) {
238 - if (item.value) {
239 - item.textStyle = function() {
240 - return editor.formatter.getCssText({inline: 'a', classes: [item.value]});
241 - };
242 - }
243 - }
244 - )
245 - };
246 - }
247 -
248 - if (editor.settings.link_title !== false) {
249 - linkTitleCtrl = {
250 - name: 'title',
251 - type: 'textbox',
252 - label: 'Title',
253 - value: data.title
254 - };
255 - }
256 -
257 - win = editor.windowManager.open({
258 - title: 'Insert link',
259 - data: data,
260 - body: [
261 - {
262 - name: 'href',
263 - type: 'filepicker',
264 - filetype: 'file',
265 - size: 40,
266 - autofocus: true,
267 - label: 'Url',
268 - onchange: urlChange,
269 - onkeyup: updateText
270 - },
271 - textListCtrl,
272 - linkTitleCtrl,
273 - buildAnchorListControl(data.href),
274 - linkListCtrl,
275 - relListCtrl,
276 - targetListCtrl,
277 - classListCtrl
278 - ],
279 - onSubmit: function(e) {
280 - /*eslint dot-notation: 0*/
281 - var href;
282 -
283 - data = tinymce.extend(data, e.data);
284 - href = data.href;
285 -
286 - // Delay confirm since onSubmit will move focus
287 - function delayedConfirm(message, callback) {
288 - var rng = editor.selection.getRng();
289 -
290 - tinymce.util.Delay.setEditorTimeout(editor, function() {
291 - editor.windowManager.confirm(message, function(state) {
292 - editor.selection.setRng(rng);
293 - callback(state);
294 - });
295 - });
296 - }
297 -
298 - function insertLink() {
299 - var linkAttrs = {
300 - href: href,
301 - target: data.target ? data.target : null,
302 - rel: data.rel ? data.rel : null,
303 - "class": data["class"] ? data["class"] : null,
304 - title: data.title ? data.title : null
305 - };
306 -
307 - if (anchorElm) {
308 - editor.focus();
309 -
310 - if (onlyText && data.text != initialText) {
311 - if ("innerText" in anchorElm) {
312 - anchorElm.innerText = data.text;
313 - } else {
314 - anchorElm.textContent = data.text;
315 - }
316 - }
317 -
318 - dom.setAttribs(anchorElm, linkAttrs);
319 -
320 - selection.select(anchorElm);
321 - editor.undoManager.add();
322 - } else {
323 - if (onlyText) {
324 - editor.insertContent(dom.createHTML('a', linkAttrs, dom.encode(data.text)));
325 - } else {
326 - editor.execCommand('mceInsertLink', false, linkAttrs);
327 - }
328 - }
329 - }
330 -
331 - if (!href) {
332 - editor.execCommand('unlink');
333 - return;
334 - }
335 -
336 - // Is email and not //user@domain.com
337 - if (href.indexOf('@') > 0 && href.indexOf('//') == -1 && href.indexOf('mailto:') == -1) {
338 - delayedConfirm(
339 - 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?',
340 - function(state) {
341 - if (state) {
342 - href = 'mailto:' + href;
343 - }
344 -
345 - insertLink();
346 - }
347 - );
348 -
349 - return;
350 - }
351 -
352 - // Is not protocol prefixed
353 - if ((editor.settings.link_assume_external_targets && !/^\w+:/i.test(href)) ||
354 - (!editor.settings.link_assume_external_targets && /^\s*www[\.|\d\.]/i.test(href))) {
355 - delayedConfirm(
356 - 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?',
357 - function(state) {
358 - if (state) {
359 - href = 'http://' + href;
360 - }
361 -
362 - insertLink();
363 - }
364 - );
365 -
366 - return;
367 - }
368 -
369 - insertLink();
370 - }
371 - });
372 - }
373 -
374 - editor.addButton('link', {
375 - icon: 'link',
376 - tooltip: 'Insert/edit link',
377 - shortcut: 'Meta+K',
378 - onclick: createLinkList(showDialog),
379 - stateSelector: 'a[href]'
380 - });
381 -
382 - editor.addButton('unlink', {
383 - icon: 'unlink',
384 - tooltip: 'Remove link',
385 - cmd: 'unlink',
386 - stateSelector: 'a[href]'
387 - });
388 -
389 - editor.addShortcut('Meta+K', '', createLinkList(showDialog));
390 - editor.addCommand('mceLink', createLinkList(showDialog));
391 -
392 - this.showDialog = showDialog;
393 -
394 - editor.addMenuItem('link', {
395 - icon: 'link',
396 - text: 'Insert/edit link',
397 - shortcut: 'Meta+K',
398 - onclick: createLinkList(showDialog),
399 - stateSelector: 'a[href]',
400 - context: 'insert',
401 - prependToContext: true
402 - });
403 -});
1 -tinymce.PluginManager.add("link",function(a){function b(b){return function(){var c=a.settings.link_list;"string"==typeof c?tinymce.util.XHR.send({url:c,success:function(a){b(tinymce.util.JSON.parse(a))}}):"function"==typeof c?c(b):b(c)}}function c(a,b,c){function d(a,c){return c=c||[],tinymce.each(a,function(a){var e={text:a.text||a.title};a.menu?e.menu=d(a.menu):(e.value=a.value,b&&b(e)),c.push(e)}),c}return d(a,c||[])}function d(b){function d(a){var b=l.find("#text");(!b.value()||a.lastControl&&b.value()==a.lastControl.text())&&b.value(a.control.text()),l.find("#href").value(a.control.value())}function e(b){var c=[];return tinymce.each(a.dom.select("a:not([href])"),function(a){var d=a.name||a.id;d&&c.push({text:d,value:"#"+d,selected:-1!=b.indexOf("#"+d)})}),c.length?(c.unshift({text:"None",value:""}),{name:"anchor",type:"listbox",label:"Anchors",values:c,onselect:d}):void 0}function f(){!k&&0===u.text.length&&m&&this.parent().parent().find("#text")[0].value(this.value())}function g(b){var c=b.meta||{};o&&o.value(a.convertURL(this.value(),"href")),tinymce.each(b.meta,function(a,b){l.find("#"+b).value(a)}),c.text||f.call(this)}function h(a){var b=v.getContent();if(/</.test(b)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(b)||-1==b.indexOf("href=")))return!1;if(a){var c,d=a.childNodes;if(0===d.length)return!1;for(c=d.length-1;c>=0;c--)if(3!=d[c].nodeType)return!1}return!0}var i,j,k,l,m,n,o,p,q,r,s,t,u={},v=a.selection,w=a.dom;i=v.getNode(),j=w.getParent(i,"a[href]"),m=h(),u.text=k=j?j.innerText||j.textContent:v.getContent({format:"text"}),u.href=j?w.getAttrib(j,"href"):"",j?u.target=w.getAttrib(j,"target"):a.settings.default_link_target&&(u.target=a.settings.default_link_target),(t=w.getAttrib(j,"rel"))&&(u.rel=t),(t=w.getAttrib(j,"class"))&&(u["class"]=t),(t=w.getAttrib(j,"title"))&&(u.title=t),m&&(n={name:"text",type:"textbox",size:40,label:"Text to display",onchange:function(){u.text=this.value()}}),b&&(o={type:"listbox",label:"Link list",values:c(b,function(b){b.value=a.convertURL(b.value||b.url,"href")},[{text:"None",value:""}]),onselect:d,value:a.convertURL(u.href,"href"),onPostRender:function(){o=this}}),a.settings.target_list!==!1&&(a.settings.target_list||(a.settings.target_list=[{text:"None",value:""},{text:"New window",value:"_blank"}]),q={name:"target",type:"listbox",label:"Target",values:c(a.settings.target_list)}),a.settings.rel_list&&(p={name:"rel",type:"listbox",label:"Rel",values:c(a.settings.rel_list)}),a.settings.link_class_list&&(r={name:"class",type:"listbox",label:"Class",values:c(a.settings.link_class_list,function(b){b.value&&(b.textStyle=function(){return a.formatter.getCssText({inline:"a",classes:[b.value]})})})}),a.settings.link_title!==!1&&(s={name:"title",type:"textbox",label:"Title",value:u.title}),l=a.windowManager.open({title:"Insert link",data:u,body:[{name:"href",type:"filepicker",filetype:"file",size:40,autofocus:!0,label:"Url",onchange:g,onkeyup:f},n,s,e(u.href),o,p,q,r],onSubmit:function(b){function c(b,c){var d=a.selection.getRng();tinymce.util.Delay.setEditorTimeout(a,function(){a.windowManager.confirm(b,function(b){a.selection.setRng(d),c(b)})})}function d(){var b={href:e,target:u.target?u.target:null,rel:u.rel?u.rel:null,"class":u["class"]?u["class"]:null,title:u.title?u.title:null};j?(a.focus(),m&&u.text!=k&&("innerText"in j?j.innerText=u.text:j.textContent=u.text),w.setAttribs(j,b),v.select(j),a.undoManager.add()):m?a.insertContent(w.createHTML("a",b,w.encode(u.text))):a.execCommand("mceInsertLink",!1,b)}var e;return u=tinymce.extend(u,b.data),(e=u.href)?e.indexOf("@")>0&&-1==e.indexOf("//")&&-1==e.indexOf("mailto:")?void c("The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",function(a){a&&(e="mailto:"+e),d()}):a.settings.link_assume_external_targets&&!/^\w+:/i.test(e)||!a.settings.link_assume_external_targets&&/^\s*www[\.|\d\.]/i.test(e)?void c("The URL you entered seems to be an external link. Do you want to add the required http:// prefix?",function(a){a&&(e="http://"+e),d()}):void d():void a.execCommand("unlink")}})}a.addButton("link",{icon:"link",tooltip:"Insert/edit link",shortcut:"Meta+K",onclick:b(d),stateSelector:"a[href]"}),a.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink",stateSelector:"a[href]"}),a.addShortcut("Meta+K","",b(d)),a.addCommand("mceLink",b(d)),this.showDialog=d,a.addMenuItem("link",{icon:"link",text:"Insert/edit link",shortcut:"Meta+K",onclick:b(d),stateSelector:"a[href]",context:"insert",prependToContext:!0})});
...\ No newline at end of file ...\ No newline at end of file
1 -tinymce.PluginManager.add("lists",function(a){function b(b){return a.$.contains(a.getBody(),b)}function c(a){return a&&"BR"==a.nodeName}function d(a){return a&&/^(OL|UL|DL)$/.test(a.nodeName)&&b(a)}function e(a){return a&&/^(LI|DT|DD)$/.test(a.nodeName)}function f(a){return a.parentNode.firstChild==a}function g(a){return a.parentNode.lastChild==a}function h(b){return b&&!!a.schema.getTextBlockElements()[b.nodeName]}function i(b){return b===a.getBody()}function j(a){return a&&3===a.nodeType}function k(a,b){var c=tinymce.dom.RangeUtils.getNode(a,b);if(e(a)&&j(c)){var d=b>=a.childNodes.length?c.data.length:0;return{container:c,offset:d}}return{container:a,offset:b}}function l(a){var b=a.cloneRange(),c=k(a.startContainer,a.startOffset);b.setStart(c.container,c.offset);var d=k(a.endContainer,a.endOffset);return b.setEnd(d.container,d.offset),b}var m=this;a.on("init",function(){function j(a,b){var c=H.isEmpty(a);return b&&H.select("span[data-mce-type=bookmark]").length>0?!1:c}function k(a){function b(b){var d,e,f;e=a[b?"startContainer":"endContainer"],f=a[b?"startOffset":"endOffset"],1==e.nodeType&&(d=H.create("span",{"data-mce-type":"bookmark"}),e.hasChildNodes()?(f=Math.min(f,e.childNodes.length-1),b?e.insertBefore(d,e.childNodes[f]):H.insertAfter(d,e.childNodes[f])):e.appendChild(d),e=d,f=0),c[b?"startContainer":"endContainer"]=e,c[b?"startOffset":"endOffset"]=f}var c={};return b(!0),a.collapsed||b(),c}function n(a){function b(b){function c(a){for(var b=a.parentNode.firstChild,c=0;b;){if(b==a)return c;1==b.nodeType&&"bookmark"==b.getAttribute("data-mce-type")||c++,b=b.nextSibling}return-1}var d,e,f;d=f=a[b?"startContainer":"endContainer"],e=a[b?"startOffset":"endOffset"],d&&(1==d.nodeType&&(e=c(d),d=d.parentNode,H.remove(f)),a[b?"startContainer":"endContainer"]=d,a[b?"startOffset":"endOffset"]=e)}b(!0),b();var c=H.createRng();c.setStart(a.startContainer,a.startOffset),a.endContainer&&c.setEnd(a.endContainer,a.endOffset),I.setRng(l(c))}function o(b,c){var d,e,f,g=H.createFragment(),h=a.schema.getBlockElements();if(a.settings.forced_root_block&&(c=c||a.settings.forced_root_block),c&&(e=H.create(c),e.tagName===a.settings.forced_root_block&&H.setAttribs(e,a.settings.forced_root_block_attrs),g.appendChild(e)),b)for(;d=b.firstChild;){var i=d.nodeName;f||"SPAN"==i&&"bookmark"==d.getAttribute("data-mce-type")||(f=!0),h[i]?(g.appendChild(d),e=null):c?(e||(e=H.create(c),g.appendChild(e)),e.appendChild(d)):g.appendChild(d)}return a.settings.forced_root_block?f||tinymce.Env.ie&&!(tinymce.Env.ie>10)||e.appendChild(H.create("br",{"data-mce-bogus":"1"})):g.appendChild(H.create("br")),g}function p(){return tinymce.grep(I.getSelectedBlocks(),function(a){return e(a)})}function q(a,b,c){function d(a){tinymce.each(g,function(c){a.parentNode.insertBefore(c,b.parentNode)}),H.remove(a)}var e,f,g,h;for(g=H.select('span[data-mce-type="bookmark"]',a),c=c||o(b),e=H.createRng(),e.setStartAfter(b),e.setEndAfter(a),f=e.extractContents(),h=f.firstChild;h;h=h.firstChild)if("LI"==h.nodeName&&H.isEmpty(h)){H.remove(h);break}H.isEmpty(f)||H.insertAfter(f,a),H.insertAfter(c,a),j(b.parentNode)&&d(b.parentNode),H.remove(b),j(a)&&H.remove(a)}function r(a){var b,c;if(b=a.nextSibling,b&&d(b)&&b.nodeName==a.nodeName&&J(a,b)){for(;c=b.firstChild;)a.appendChild(c);H.remove(b)}if(b=a.previousSibling,b&&d(b)&&b.nodeName==a.nodeName&&J(a,b)){for(;c=b.firstChild;)a.insertBefore(c,a.firstChild);H.remove(b)}}function s(a){tinymce.each(tinymce.grep(H.select("ol,ul",a)),t)}function t(a){var b,c=a.parentNode;"LI"==c.nodeName&&c.firstChild==a&&(b=c.previousSibling,b&&"LI"==b.nodeName?(b.appendChild(a),j(c)&&H.remove(c)):H.setStyle(c,"listStyleType","none")),d(c)&&(b=c.previousSibling,b&&"LI"==b.nodeName&&b.appendChild(a))}function u(a){function b(a){j(a)&&H.remove(a)}var c,e=a.parentNode,h=e.parentNode;return i(e)?!0:"DD"==a.nodeName?(H.rename(a,"DT"),!0):f(a)&&g(a)?("LI"==h.nodeName?(H.insertAfter(a,h),b(h),H.remove(e)):d(h)?H.remove(e,!0):(h.insertBefore(o(a),e),H.remove(e)),!0):f(a)?("LI"==h.nodeName?(H.insertAfter(a,h),a.appendChild(e),b(h)):d(h)?h.insertBefore(a,e):(h.insertBefore(o(a),e),H.remove(a)),!0):g(a)?("LI"==h.nodeName?H.insertAfter(a,h):d(h)?H.insertAfter(a,e):(H.insertAfter(o(a),e),H.remove(a)),!0):("LI"==h.nodeName?(e=h,c=o(a,"LI")):c=d(h)?o(a,"LI"):o(a),q(e,a,c),s(e.parentNode),!0)}function v(a){function b(b,c){var e;if(d(b)){for(;e=a.lastChild.firstChild;)c.appendChild(e);H.remove(b)}}var c,e,f;return"DT"==a.nodeName?(H.rename(a,"DD"),!0):(c=a.previousSibling,c&&d(c)?(c.appendChild(a),!0):c&&"LI"==c.nodeName&&d(c.lastChild)?(c.lastChild.appendChild(a),b(a.lastChild,c.lastChild),!0):(c=a.nextSibling,c&&d(c)?(c.insertBefore(a,c.firstChild),!0):(c=a.previousSibling,c&&"LI"==c.nodeName?(e=H.create(a.parentNode.nodeName),f=H.getStyle(a.parentNode,"listStyleType"),f&&H.setStyle(e,"listStyleType",f),c.appendChild(e),e.appendChild(a),b(a.lastChild,e),!0):!1)))}function w(){var b=p();if(b.length){for(var c=k(I.getRng(!0)),d=0;d<b.length&&(v(b[d])||0!==d);d++);return n(c),a.nodeChanged(),!0}}function x(){var b=p();if(b.length){var c,d,e=k(I.getRng(!0)),f=a.getBody();for(c=b.length;c--;)for(var g=b[c].parentNode;g&&g!=f;){for(d=b.length;d--;)if(b[d]===g){b.splice(c,1);break}g=g.parentNode}for(c=0;c<b.length&&(u(b[c])||0!==c);c++);return n(e),a.nodeChanged(),!0}}function y(b,e){function f(){function b(a){var b,c;for(b=i[a?"startContainer":"endContainer"],c=i[a?"startOffset":"endOffset"],1==b.nodeType&&(b=b.childNodes[Math.min(c,b.childNodes.length-1)]||b);b.parentNode!=f;){if(h(b))return b;if(/^(TD|TH)$/.test(b.parentNode.nodeName))return b;b=b.parentNode}return b}for(var d,e=[],f=a.getBody(),g=b(!0),j=b(),k=[],l=g;l&&(k.push(l),l!=j);l=l.nextSibling);return tinymce.each(k,function(a){if(h(a))return e.push(a),void(d=null);if(H.isBlock(a)||c(a))return c(a)&&H.remove(a),void(d=null);var b=a.nextSibling;return tinymce.dom.BookmarkManager.isBookmarkNode(a)&&(h(b)||!b&&a.parentNode==f)?void(d=null):(d||(d=H.create("p"),a.parentNode.insertBefore(d,a),e.push(d)),void d.appendChild(a))}),e}var g,i=I.getRng(!0),j="LI";"false"!==H.getContentEditable(I.getNode())&&(b=b.toUpperCase(),"DL"==b&&(j="DT"),g=k(i),tinymce.each(f(),function(a){var c,f,g=function(a){var b=H.getStyle(a,"list-style-type"),c=e?e["list-style-type"]:"";return c=null===c?"":c,b===c};f=a.previousSibling,f&&d(f)&&f.nodeName==b&&g(f)?(c=f,a=H.rename(a,j),f.appendChild(a)):(c=H.create(b),a.parentNode.insertBefore(c,a),c.appendChild(a),a=H.rename(a,j)),K(c,e),r(c)}),n(g))}function z(){var b=k(I.getRng(!0)),c=a.getBody();tinymce.each(p(),function(a){var b,e;if(!i(a.parentNode)){if(j(a))return void u(a);for(b=a;b&&b!=c;b=b.parentNode)d(b)&&(e=b);q(e,a),s(e.parentNode)}}),n(b)}function A(a,b){var c=H.getParent(I.getStart(),"OL,UL,DL");if(!i(c))if(c)if(c.nodeName==a)z(a);else{var d=k(I.getRng(!0));K(c,b),r(H.rename(c,a)),n(d)}else y(a,b)}function B(b){return function(){var c=H.getParent(a.selection.getStart(),"UL,OL,DL");return c&&c.nodeName==b}}function C(a){return c(a)?!(!H.isBlock(a.nextSibling)||c(a.previousSibling)):!1}function D(b,c){var d,e,f=b.startContainer,g=b.startOffset;if(3==f.nodeType&&(c?g<f.data.length:g>0))return f;for(d=a.schema.getNonEmptyElements(),1==f.nodeType&&(f=tinymce.dom.RangeUtils.getNode(f,g)),e=new tinymce.dom.TreeWalker(f,a.getBody()),c&&C(f)&&e.next();f=e[c?"next":"prev2"]();){if("LI"==f.nodeName&&!f.hasChildNodes())return f;if(d[f.nodeName])return f;if(3==f.nodeType&&f.data.length>0)return f}}function E(a,e){var f,g,h=a.parentNode;if(b(a)&&b(e)){if(d(e.lastChild)&&(g=e.lastChild),h==e.lastChild&&c(h.previousSibling)&&H.remove(h.previousSibling),f=e.lastChild,f&&c(f)&&a.hasChildNodes()&&H.remove(f),j(e,!0)&&H.$(e).empty(),!j(a,!0))for(;f=a.firstChild;)e.appendChild(f);g&&e.appendChild(g),H.remove(a),j(h)&&!i(h)&&H.remove(h)}}function F(a){var b,c,d,e=H.getParent(I.getStart(),"LI");if(e){if(b=e.parentNode,i(b)&&H.isEmpty(b))return!0;if(c=l(I.getRng(!0)),d=H.getParent(D(c,a),"LI"),d&&d!=e){var f=k(c);return a?E(d,e):E(e,d),n(f),!0}if(!d&&!a&&z(b.nodeName))return!0}}function G(){var b=a.dom.getParent(a.selection.getStart(),"LI,DT,DD");return b||p().length>0?(a.undoManager.transact(function(){a.execCommand("Delete"),s(a.getBody())}),!0):!1}var H=a.dom,I=a.selection,J=function(b,c){var d=a.dom.getStyle(b,"list-style-type",!0),e=a.dom.getStyle(c,"list-style-type",!0);return d===e},K=function(a,b){H.setStyle(a,"list-style-type",b?b["list-style-type"]:null)};m.backspaceDelete=function(a){return I.isCollapsed()?F(a):G()},a.on("BeforeExecCommand",function(b){var c,d=b.command.toLowerCase();return"indent"==d?w()&&(c=!0):"outdent"==d&&x()&&(c=!0),c?(a.fire("ExecCommand",{command:b.command}),b.preventDefault(),!0):void 0}),a.addCommand("InsertUnorderedList",function(a,b){A("UL",b)}),a.addCommand("InsertOrderedList",function(a,b){A("OL",b)}),a.addCommand("InsertDefinitionList",function(a,b){A("DL",b)}),a.addQueryStateHandler("InsertUnorderedList",B("UL")),a.addQueryStateHandler("InsertOrderedList",B("OL")),a.addQueryStateHandler("InsertDefinitionList",B("DL")),a.on("keydown",function(b){9!=b.keyCode||tinymce.util.VK.metaKeyPressed(b)||a.dom.getParent(a.selection.getStart(),"LI,DT,DD")&&(b.preventDefault(),b.shiftKey?x():w())})}),a.addButton("indent",{icon:"indent",title:"Increase indent",cmd:"Indent",onPostRender:function(){var b=this;a.on("nodechange",function(){for(var c=a.selection.getSelectedBlocks(),d=!1,e=0,g=c.length;!d&&g>e;e++){var h=c[e].nodeName;d="LI"==h&&f(c[e])||"UL"==h||"OL"==h||"DD"==h}b.disabled(d)})}}),a.on("keydown",function(a){a.keyCode==tinymce.util.VK.BACKSPACE?m.backspaceDelete()&&a.preventDefault():a.keyCode==tinymce.util.VK.DELETE&&m.backspaceDelete(!0)&&a.preventDefault()})});
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*global tinymce:true */
12 -
13 -tinymce.PluginManager.add('nonbreaking', function(editor) {
14 - var setting = editor.getParam('nonbreaking_force_tab');
15 -
16 - editor.addCommand('mceNonBreaking', function() {
17 - editor.insertContent(
18 - (editor.plugins.visualchars && editor.plugins.visualchars.state) ?
19 - '<span class="mce-nbsp">&nbsp;</span>' : '&nbsp;'
20 - );
21 -
22 - editor.dom.setAttrib(editor.dom.select('span.mce-nbsp'), 'data-mce-bogus', '1');
23 - });
24 -
25 - editor.addButton('nonbreaking', {
26 - title: 'Nonbreaking space',
27 - cmd: 'mceNonBreaking'
28 - });
29 -
30 - editor.addMenuItem('nonbreaking', {
31 - text: 'Nonbreaking space',
32 - cmd: 'mceNonBreaking',
33 - context: 'insert'
34 - });
35 -
36 - if (setting) {
37 - var spaces = +setting > 1 ? +setting : 3; // defaults to 3 spaces if setting is true (or 1)
38 -
39 - editor.on('keydown', function(e) {
40 - if (e.keyCode == 9) {
41 -
42 - if (e.shiftKey) {
43 - return;
44 - }
45 -
46 - e.preventDefault();
47 - for (var i = 0; i < spaces; i++) {
48 - editor.execCommand('mceNonBreaking');
49 - }
50 - }
51 - });
52 - }
53 -});
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*global tinymce:true */
12 -
13 -tinymce.PluginManager.add('noneditable', function(editor) {
14 - var editClass, nonEditClass, nonEditableRegExps, contentEditableAttrName = 'contenteditable';
15 -
16 - function hasClass(checkClassName) {
17 - return function(node) {
18 - return (" " + node.attr("class") + " ").indexOf(checkClassName) !== -1;
19 - };
20 - }
21 -
22 - function convertRegExpsToNonEditable(e) {
23 - var i = nonEditableRegExps.length, content = e.content, cls = tinymce.trim(nonEditClass);
24 -
25 - function replaceMatchWithSpan(match) {
26 - var args = arguments, index = args[args.length - 2];
27 -
28 - // Is value inside an attribute then don't replace
29 - if (index > 0 && content.charAt(index - 1) == '"') {
30 - return match;
31 - }
32 -
33 - return (
34 - '<span class="' + cls + '" data-mce-content="' + editor.dom.encode(args[0]) + '">' +
35 - editor.dom.encode(typeof args[1] === "string" ? args[1] : args[0]) + '</span>'
36 - );
37 - }
38 -
39 - // Don't replace the variables when raw is used for example on undo/redo
40 - if (e.format == "raw") {
41 - return;
42 - }
43 -
44 - while (i--) {
45 - content = content.replace(nonEditableRegExps[i], replaceMatchWithSpan);
46 - }
47 -
48 - e.content = content;
49 - }
50 -
51 - editClass = " " + tinymce.trim(editor.getParam("noneditable_editable_class", "mceEditable")) + " ";
52 - nonEditClass = " " + tinymce.trim(editor.getParam("noneditable_noneditable_class", "mceNonEditable")) + " ";
53 -
54 - var hasEditClass = hasClass(editClass);
55 - var hasNonEditClass = hasClass(nonEditClass);
56 -
57 - nonEditableRegExps = editor.getParam("noneditable_regexp");
58 - if (nonEditableRegExps && !nonEditableRegExps.length) {
59 - nonEditableRegExps = [nonEditableRegExps];
60 - }
61 -
62 - editor.on('PreInit', function() {
63 - if (nonEditableRegExps) {
64 - editor.on('BeforeSetContent', convertRegExpsToNonEditable);
65 - }
66 -
67 - editor.parser.addAttributeFilter('class', function(nodes) {
68 - var i = nodes.length, node;
69 -
70 - while (i--) {
71 - node = nodes[i];
72 -
73 - if (hasEditClass(node)) {
74 - node.attr(contentEditableAttrName, "true");
75 - } else if (hasNonEditClass(node)) {
76 - node.attr(contentEditableAttrName, "false");
77 - }
78 - }
79 - });
80 -
81 - editor.serializer.addAttributeFilter(contentEditableAttrName, function(nodes) {
82 - var i = nodes.length, node;
83 -
84 - while (i--) {
85 - node = nodes[i];
86 - if (!hasEditClass(node) && !hasNonEditClass(node)) {
87 - continue;
88 - }
89 -
90 - if (nonEditableRegExps && node.attr('data-mce-content')) {
91 - node.name = "#text";
92 - node.type = 3;
93 - node.raw = true;
94 - node.value = node.attr('data-mce-content');
95 - } else {
96 - node.attr(contentEditableAttrName, null);
97 - }
98 - }
99 - });
100 - });
101 -});
...\ No newline at end of file ...\ No newline at end of file
1 -tinymce.PluginManager.add("noneditable",function(a){function b(a){return function(b){return-1!==(" "+b.attr("class")+" ").indexOf(a)}}function c(b){function c(b){var c=arguments,d=c[c.length-2];return d>0&&'"'==g.charAt(d-1)?b:'<span class="'+h+'" data-mce-content="'+a.dom.encode(c[0])+'">'+a.dom.encode("string"==typeof c[1]?c[1]:c[0])+"</span>"}var d=f.length,g=b.content,h=tinymce.trim(e);if("raw"!=b.format){for(;d--;)g=g.replace(f[d],c);b.content=g}}var d,e,f,g="contenteditable";d=" "+tinymce.trim(a.getParam("noneditable_editable_class","mceEditable"))+" ",e=" "+tinymce.trim(a.getParam("noneditable_noneditable_class","mceNonEditable"))+" ";var h=b(d),i=b(e);f=a.getParam("noneditable_regexp"),f&&!f.length&&(f=[f]),a.on("PreInit",function(){f&&a.on("BeforeSetContent",c),a.parser.addAttributeFilter("class",function(a){for(var b,c=a.length;c--;)b=a[c],h(b)?b.attr(g,"true"):i(b)&&b.attr(g,"false")}),a.serializer.addAttributeFilter(g,function(a){for(var b,c=a.length;c--;)b=a[c],(h(b)||i(b))&&(f&&b.attr("data-mce-content")?(b.name="#text",b.type=3,b.raw=!0,b.value=b.attr("data-mce-content")):b.attr(g,null))})})});
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*global tinymce:true */
12 -
13 -tinymce.PluginManager.add('pagebreak', function(editor) {
14 - var pageBreakClass = 'mce-pagebreak', separatorHtml = editor.getParam('pagebreak_separator', '<!-- pagebreak -->');
15 -
16 - var pageBreakSeparatorRegExp = new RegExp(separatorHtml.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {
17 - return '\\' + a;
18 - }), 'gi');
19 -
20 - var pageBreakPlaceHolderHtml = '<img src="' + tinymce.Env.transparentSrc + '" class="' +
21 - pageBreakClass + '" data-mce-resize="false" data-mce-placeholder />';
22 -
23 - // Register commands
24 - editor.addCommand('mcePageBreak', function() {
25 - if (editor.settings.pagebreak_split_block) {
26 - editor.insertContent('<p>' + pageBreakPlaceHolderHtml + '</p>');
27 - } else {
28 - editor.insertContent(pageBreakPlaceHolderHtml);
29 - }
30 - });
31 -
32 - // Register buttons
33 - editor.addButton('pagebreak', {
34 - title: 'Page break',
35 - cmd: 'mcePageBreak'
36 - });
37 -
38 - editor.addMenuItem('pagebreak', {
39 - text: 'Page break',
40 - icon: 'pagebreak',
41 - cmd: 'mcePageBreak',
42 - context: 'insert'
43 - });
44 -
45 - editor.on('ResolveName', function(e) {
46 - if (e.target.nodeName == 'IMG' && editor.dom.hasClass(e.target, pageBreakClass)) {
47 - e.name = 'pagebreak';
48 - }
49 - });
50 -
51 - editor.on('click', function(e) {
52 - e = e.target;
53 -
54 - if (e.nodeName === 'IMG' && editor.dom.hasClass(e, pageBreakClass)) {
55 - editor.selection.select(e);
56 - }
57 - });
58 -
59 - editor.on('BeforeSetContent', function(e) {
60 - e.content = e.content.replace(pageBreakSeparatorRegExp, pageBreakPlaceHolderHtml);
61 - });
62 -
63 - editor.on('PreInit', function() {
64 - editor.serializer.addNodeFilter('img', function(nodes) {
65 - var i = nodes.length, node, className;
66 -
67 - while (i--) {
68 - node = nodes[i];
69 - className = node.attr('class');
70 - if (className && className.indexOf('mce-pagebreak') !== -1) {
71 - // Replace parent block node if pagebreak_split_block is enabled
72 - var parentNode = node.parent;
73 - if (editor.schema.getBlockElements()[parentNode.name] && editor.settings.pagebreak_split_block) {
74 - parentNode.type = 3;
75 - parentNode.value = separatorHtml;
76 - parentNode.raw = true;
77 - node.remove();
78 - continue;
79 - }
80 -
81 - node.type = 3;
82 - node.value = separatorHtml;
83 - node.raw = true;
84 - }
85 - }
86 - });
87 - });
88 -});
1 -tinymce.PluginManager.add("pagebreak",function(a){var b="mce-pagebreak",c=a.getParam("pagebreak_separator","<!-- pagebreak -->"),d=new RegExp(c.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g,function(a){return"\\"+a}),"gi"),e='<img src="'+tinymce.Env.transparentSrc+'" class="'+b+'" data-mce-resize="false" data-mce-placeholder />';a.addCommand("mcePageBreak",function(){a.settings.pagebreak_split_block?a.insertContent("<p>"+e+"</p>"):a.insertContent(e)}),a.addButton("pagebreak",{title:"Page break",cmd:"mcePageBreak"}),a.addMenuItem("pagebreak",{text:"Page break",icon:"pagebreak",cmd:"mcePageBreak",context:"insert"}),a.on("ResolveName",function(c){"IMG"==c.target.nodeName&&a.dom.hasClass(c.target,b)&&(c.name="pagebreak")}),a.on("click",function(c){c=c.target,"IMG"===c.nodeName&&a.dom.hasClass(c,b)&&a.selection.select(c)}),a.on("BeforeSetContent",function(a){a.content=a.content.replace(d,e)}),a.on("PreInit",function(){a.serializer.addNodeFilter("img",function(b){for(var d,e,f=b.length;f--;)if(d=b[f],e=d.attr("class"),e&&-1!==e.indexOf("mce-pagebreak")){var g=d.parent;if(a.schema.getBlockElements()[g.name]&&a.settings.pagebreak_split_block){g.type=3,g.value=c,g.raw=!0,d.remove();continue}d.type=3,d.value=c,d.raw=!0}})})});
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * Plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/**
12 - * This class contains the tinymce plugin logic for the paste plugin.
13 - *
14 - * @class tinymce.pasteplugin.Plugin
15 - * @private
16 - */
17 -define("tinymce/pasteplugin/Plugin", [
18 - "tinymce/PluginManager",
19 - "tinymce/pasteplugin/Clipboard",
20 - "tinymce/pasteplugin/WordFilter",
21 - "tinymce/pasteplugin/Quirks"
22 -], function(PluginManager, Clipboard, WordFilter, Quirks) {
23 - var userIsInformed;
24 -
25 - PluginManager.add('paste', function(editor) {
26 - var self = this, clipboard, settings = editor.settings;
27 -
28 - function isUserInformedAboutPlainText() {
29 - return userIsInformed || editor.settings.paste_plaintext_inform === false;
30 - }
31 -
32 - function togglePlainTextPaste() {
33 - if (clipboard.pasteFormat == "text") {
34 - this.active(false);
35 - clipboard.pasteFormat = "html";
36 - editor.fire('PastePlainTextToggle', {state: false});
37 - } else {
38 - clipboard.pasteFormat = "text";
39 - this.active(true);
40 -
41 - if (!isUserInformedAboutPlainText()) {
42 - var message = editor.translate('Paste is now in plain text mode. Contents will now ' +
43 - 'be pasted as plain text until you toggle this option off.');
44 -
45 - editor.notificationManager.open({
46 - text: message,
47 - type: 'info'
48 - });
49 -
50 - userIsInformed = true;
51 - editor.fire('PastePlainTextToggle', {state: true});
52 - }
53 - }
54 -
55 - editor.focus();
56 - }
57 -
58 - // draw back if power version is requested and registered
59 - if (/(^|[ ,])powerpaste([, ]|$)/.test(settings.plugins) && PluginManager.get('powerpaste')) {
60 - /*eslint no-console:0 */
61 - if (typeof console !== "undefined" && console.log) {
62 - console.log("PowerPaste is incompatible with Paste plugin! Remove 'paste' from the 'plugins' option.");
63 - }
64 - return;
65 - }
66 -
67 - self.clipboard = clipboard = new Clipboard(editor);
68 - self.quirks = new Quirks(editor);
69 - self.wordFilter = new WordFilter(editor);
70 -
71 - if (editor.settings.paste_as_text) {
72 - self.clipboard.pasteFormat = "text";
73 - }
74 -
75 - if (settings.paste_preprocess) {
76 - editor.on('PastePreProcess', function(e) {
77 - settings.paste_preprocess.call(self, self, e);
78 - });
79 - }
80 -
81 - if (settings.paste_postprocess) {
82 - editor.on('PastePostProcess', function(e) {
83 - settings.paste_postprocess.call(self, self, e);
84 - });
85 - }
86 -
87 - editor.addCommand('mceInsertClipboardContent', function(ui, value) {
88 - if (value.content) {
89 - self.clipboard.pasteHtml(value.content);
90 - }
91 -
92 - if (value.text) {
93 - self.clipboard.pasteText(value.text);
94 - }
95 - });
96 -
97 - // Block all drag/drop events
98 - if (editor.settings.paste_block_drop) {
99 - editor.on('dragend dragover draggesture dragdrop drop drag', function(e) {
100 - e.preventDefault();
101 - e.stopPropagation();
102 - });
103 - }
104 -
105 - // Prevent users from dropping data images on Gecko
106 - if (!editor.settings.paste_data_images) {
107 - editor.on('drop', function(e) {
108 - var dataTransfer = e.dataTransfer;
109 -
110 - if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
111 - e.preventDefault();
112 - }
113 - });
114 - }
115 -
116 - editor.addButton('pastetext', {
117 - icon: 'pastetext',
118 - tooltip: 'Paste as text',
119 - onclick: togglePlainTextPaste,
120 - active: self.clipboard.pasteFormat == "text"
121 - });
122 -
123 - editor.addMenuItem('pastetext', {
124 - text: 'Paste as text',
125 - selectable: true,
126 - active: clipboard.pasteFormat,
127 - onclick: togglePlainTextPaste
128 - });
129 - });
130 -});
1 -/**
2 - * Quirks.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/**
12 - * This class contains various fixes for browsers. These issues can not be feature
13 - * detected since we have no direct control over the clipboard. However we might be able
14 - * to remove some of these fixes once the browsers gets updated/fixed.
15 - *
16 - * @class tinymce.pasteplugin.Quirks
17 - * @private
18 - */
19 -define("tinymce/pasteplugin/Quirks", [
20 - "tinymce/Env",
21 - "tinymce/util/Tools",
22 - "tinymce/pasteplugin/WordFilter",
23 - "tinymce/pasteplugin/Utils"
24 -], function(Env, Tools, WordFilter, Utils) {
25 - "use strict";
26 -
27 - return function(editor) {
28 - function addPreProcessFilter(filterFunc) {
29 - editor.on('BeforePastePreProcess', function(e) {
30 - e.content = filterFunc(e.content);
31 - });
32 - }
33 -
34 - /**
35 - * Removes BR elements after block elements. IE9 has a nasty bug where it puts a BR element after each
36 - * block element when pasting from word. This removes those elements.
37 - *
38 - * This:
39 - * <p>a</p><br><p>b</p>
40 - *
41 - * Becomes:
42 - * <p>a</p><p>b</p>
43 - */
44 - function removeExplorerBrElementsAfterBlocks(html) {
45 - // Only filter word specific content
46 - if (!WordFilter.isWordContent(html)) {
47 - return html;
48 - }
49 -
50 - // Produce block regexp based on the block elements in schema
51 - var blockElements = [];
52 -
53 - Tools.each(editor.schema.getBlockElements(), function(block, blockName) {
54 - blockElements.push(blockName);
55 - });
56 -
57 - var explorerBlocksRegExp = new RegExp(
58 - '(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*',
59 - 'g'
60 - );
61 -
62 - // Remove BR:s from: <BLOCK>X</BLOCK><BR>
63 - html = Utils.filter(html, [
64 - [explorerBlocksRegExp, '$1']
65 - ]);
66 -
67 - // IE9 also adds an extra BR element for each soft-linefeed and it also adds a BR for each word wrap break
68 - html = Utils.filter(html, [
69 - [/<br><br>/g, '<BR><BR>'], // Replace multiple BR elements with uppercase BR to keep them intact
70 - [/<br>/g, ' '], // Replace single br elements with space since they are word wrap BR:s
71 - [/<BR><BR>/g, '<br>'] // Replace back the double brs but into a single BR
72 - ]);
73 -
74 - return html;
75 - }
76 -
77 - /**
78 - * WebKit has a nasty bug where the all computed styles gets added to style attributes when copy/pasting contents.
79 - * This fix solves that by simply removing the whole style attribute.
80 - *
81 - * The paste_webkit_styles option can be set to specify what to keep:
82 - * paste_webkit_styles: "none" // Keep no styles
83 - * paste_webkit_styles: "all", // Keep all of them
84 - * paste_webkit_styles: "font-weight color" // Keep specific ones
85 - *
86 - * @param {String} content Content that needs to be processed.
87 - * @return {String} Processed contents.
88 - */
89 - function removeWebKitStyles(content) {
90 - // Passthrough all styles from Word and let the WordFilter handle that junk
91 - if (WordFilter.isWordContent(content)) {
92 - return content;
93 - }
94 -
95 - // Filter away styles that isn't matching the target node
96 - var webKitStyles = editor.settings.paste_webkit_styles;
97 -
98 - if (editor.settings.paste_remove_styles_if_webkit === false || webKitStyles == "all") {
99 - return content;
100 - }
101 -
102 - if (webKitStyles) {
103 - webKitStyles = webKitStyles.split(/[, ]/);
104 - }
105 -
106 - // Keep specific styles that doesn't match the current node computed style
107 - if (webKitStyles) {
108 - var dom = editor.dom, node = editor.selection.getNode();
109 -
110 - content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, function(all, before, value, after) {
111 - var inputStyles = dom.parseStyle(value, 'span'), outputStyles = {};
112 -
113 - if (webKitStyles === "none") {
114 - return before + after;
115 - }
116 -
117 - for (var i = 0; i < webKitStyles.length; i++) {
118 - var inputValue = inputStyles[webKitStyles[i]], currentValue = dom.getStyle(node, webKitStyles[i], true);
119 -
120 - if (/color/.test(webKitStyles[i])) {
121 - inputValue = dom.toHex(inputValue);
122 - currentValue = dom.toHex(currentValue);
123 - }
124 -
125 - if (currentValue != inputValue) {
126 - outputStyles[webKitStyles[i]] = inputValue;
127 - }
128 - }
129 -
130 - outputStyles = dom.serializeStyle(outputStyles, 'span');
131 - if (outputStyles) {
132 - return before + ' style="' + outputStyles + '"' + after;
133 - }
134 -
135 - return before + after;
136 - });
137 - } else {
138 - // Remove all external styles
139 - content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, '$1$3');
140 - }
141 -
142 - // Keep internal styles
143 - content = content.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi, function(all, before, value, after) {
144 - return before + ' style="' + value + '"' + after;
145 - });
146 -
147 - return content;
148 - }
149 -
150 - // Sniff browsers and apply fixes since we can't feature detect
151 - if (Env.webkit) {
152 - addPreProcessFilter(removeWebKitStyles);
153 - }
154 -
155 - if (Env.ie) {
156 - addPreProcessFilter(removeExplorerBrElementsAfterBlocks);
157 - }
158 - };
159 -});
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * SmartPaste.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/**
12 - * Tries to be smart depending on what the user pastes if it looks like an url
13 - * it will make a link out of the current selection. If it's an image url that looks
14 - * like an image it will check if it's an image and insert it as an image.
15 - *
16 - * @class tinymce.pasteplugin.SmartPaste
17 - * @private
18 - */
19 -define("tinymce/pasteplugin/SmartPaste", [
20 - "tinymce/util/Tools"
21 -], function (Tools) {
22 - var isAbsoluteUrl = function (url) {
23 - return /^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(url);
24 - };
25 -
26 - var isImageUrl = function (url) {
27 - return isAbsoluteUrl(url) && /.(gif|jpe?g|png)$/.test(url);
28 - };
29 -
30 - var createImage = function (editor, url, pasteHtml) {
31 - editor.undoManager.extra(function () {
32 - pasteHtml(editor, url);
33 - }, function () {
34 - editor.insertContent('<img src="' + url + '">');
35 - });
36 -
37 - return true;
38 - };
39 -
40 - var createLink = function (editor, url, pasteHtml) {
41 - editor.undoManager.extra(function () {
42 - pasteHtml(editor, url);
43 - }, function () {
44 - editor.execCommand('mceInsertLink', false, url);
45 - });
46 -
47 - return true;
48 - };
49 -
50 - var linkSelection = function (editor, html, pasteHtml) {
51 - return editor.selection.isCollapsed() === false && isAbsoluteUrl(html) ? createLink(editor, html, pasteHtml) : false;
52 - };
53 -
54 - var insertImage = function (editor, html, pasteHtml) {
55 - return isImageUrl(html) ? createImage(editor, html, pasteHtml) : false;
56 - };
57 -
58 - var pasteHtml = function (editor, html) {
59 - editor.insertContent(html, {
60 - merge: editor.settings.paste_merge_formats !== false,
61 - paste: true
62 - });
63 -
64 - return true;
65 - };
66 -
67 - var smartInsertContent = function (editor, html) {
68 - Tools.each([
69 - linkSelection,
70 - insertImage,
71 - pasteHtml
72 - ], function (action) {
73 - return action(editor, html, pasteHtml) !== true;
74 - });
75 - };
76 -
77 - var insertContent = function (editor, html) {
78 - if (editor.settings.smart_paste === false) {
79 - pasteHtml(editor, html);
80 - } else {
81 - smartInsertContent(editor, html);
82 - }
83 - };
84 -
85 - return {
86 - isImageUrl: isImageUrl,
87 - isAbsoluteUrl: isAbsoluteUrl,
88 - insertContent: insertContent
89 - };
90 -});
1 -/**
2 - * Utils.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/**
12 - * This class contails various utility functions for the paste plugin.
13 - *
14 - * @class tinymce.pasteplugin.Utils
15 - */
16 -define("tinymce/pasteplugin/Utils", [
17 - "tinymce/util/Tools",
18 - "tinymce/html/DomParser",
19 - "tinymce/html/Schema"
20 -], function(Tools, DomParser, Schema) {
21 - function filter(content, items) {
22 - Tools.each(items, function(v) {
23 - if (v.constructor == RegExp) {
24 - content = content.replace(v, '');
25 - } else {
26 - content = content.replace(v[0], v[1]);
27 - }
28 - });
29 -
30 - return content;
31 - }
32 -
33 - /**
34 - * Gets the innerText of the specified element. It will handle edge cases
35 - * and works better than textContent on Gecko.
36 - *
37 - * @param {String} html HTML string to get text from.
38 - * @return {String} String of text with line feeds.
39 - */
40 - function innerText(html) {
41 - var schema = new Schema(), domParser = new DomParser({}, schema), text = '';
42 - var shortEndedElements = schema.getShortEndedElements();
43 - var ignoreElements = Tools.makeMap('script noscript style textarea video audio iframe object', ' ');
44 - var blockElements = schema.getBlockElements();
45 -
46 - function walk(node) {
47 - var name = node.name, currentNode = node;
48 -
49 - if (name === 'br') {
50 - text += '\n';
51 - return;
52 - }
53 -
54 - // img/input/hr
55 - if (shortEndedElements[name]) {
56 - text += ' ';
57 - }
58 -
59 - // Ingore script, video contents
60 - if (ignoreElements[name]) {
61 - text += ' ';
62 - return;
63 - }
64 -
65 - if (node.type == 3) {
66 - text += node.value;
67 - }
68 -
69 - // Walk all children
70 - if (!node.shortEnded) {
71 - if ((node = node.firstChild)) {
72 - do {
73 - walk(node);
74 - } while ((node = node.next));
75 - }
76 - }
77 -
78 - // Add \n or \n\n for blocks or P
79 - if (blockElements[name] && currentNode.next) {
80 - text += '\n';
81 -
82 - if (name == 'p') {
83 - text += '\n';
84 - }
85 - }
86 - }
87 -
88 - html = filter(html, [
89 - /<!\[[^\]]+\]>/g // Conditional comments
90 - ]);
91 -
92 - walk(domParser.parse(html));
93 -
94 - return text;
95 - }
96 -
97 - /**
98 - * Trims the specified HTML by removing all WebKit fragments, all elements wrapping the body trailing BR elements etc.
99 - *
100 - * @param {String} html Html string to trim contents on.
101 - * @return {String} Html contents that got trimmed.
102 - */
103 - function trimHtml(html) {
104 - function trimSpaces(all, s1, s2) {
105 - // WebKit &nbsp; meant to preserve multiple spaces but instead inserted around all inline tags,
106 - // including the spans with inline styles created on paste
107 - if (!s1 && !s2) {
108 - return ' ';
109 - }
110 -
111 - return '\u00a0';
112 - }
113 -
114 - html = filter(html, [
115 - /^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/g, // Remove anything but the contents within the BODY element
116 - /<!--StartFragment-->|<!--EndFragment-->/g, // Inner fragments (tables from excel on mac)
117 - [/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g, trimSpaces],
118 - /<br class="Apple-interchange-newline">/g,
119 - /<br>$/i // Trailing BR elements
120 - ]);
121 -
122 - return html;
123 - }
124 -
125 - // TODO: Should be in some global class
126 - function createIdGenerator(prefix) {
127 - var count = 0;
128 -
129 - return function() {
130 - return prefix + (count++);
131 - };
132 - }
133 -
134 - return {
135 - filter: filter,
136 - innerText: innerText,
137 - trimHtml: trimHtml,
138 - createIdGenerator: createIdGenerator
139 - };
140 -});
1 -/**
2 - * Inline development version. Only to be used while developing since it uses document.write to load scripts.
3 - */
4 -
5 -/*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */
6 -/*globals $code */
7 -
8 -(function(exports) {
9 - "use strict";
10 -
11 - var html = "", baseDir;
12 - var modules = {}, exposedModules = [], moduleCount = 0;
13 -
14 - var scripts = document.getElementsByTagName('script');
15 - for (var i = 0; i < scripts.length; i++) {
16 - var src = scripts[i].src;
17 -
18 - if (src.indexOf('/plugin.dev.js') != -1) {
19 - baseDir = src.substring(0, src.lastIndexOf('/'));
20 - }
21 - }
22 -
23 - function require(ids, callback) {
24 - var module, defs = [];
25 -
26 - for (var i = 0; i < ids.length; ++i) {
27 - module = modules[ids[i]] || resolve(ids[i]);
28 - if (!module) {
29 - throw 'module definition dependecy not found: ' + ids[i];
30 - }
31 -
32 - defs.push(module);
33 - }
34 -
35 - callback.apply(null, defs);
36 - }
37 -
38 - function resolve(id) {
39 - if (exports.privateModules && id in exports.privateModules) {
40 - return;
41 - }
42 -
43 - var target = exports;
44 - var fragments = id.split(/[.\/]/);
45 -
46 - for (var fi = 0; fi < fragments.length; ++fi) {
47 - if (!target[fragments[fi]]) {
48 - return;
49 - }
50 -
51 - target = target[fragments[fi]];
52 - }
53 -
54 - return target;
55 - }
56 -
57 - function register(id) {
58 - var target = exports;
59 - var fragments = id.split(/[.\/]/);
60 -
61 - for (var fi = 0; fi < fragments.length - 1; ++fi) {
62 - if (target[fragments[fi]] === undefined) {
63 - target[fragments[fi]] = {};
64 - }
65 -
66 - target = target[fragments[fi]];
67 - }
68 -
69 - target[fragments[fragments.length - 1]] = modules[id];
70 - }
71 -
72 - function define(id, dependencies, definition) {
73 - var privateModules, i;
74 -
75 - if (typeof id !== 'string') {
76 - throw 'invalid module definition, module id must be defined and be a string';
77 - }
78 -
79 - if (dependencies === undefined) {
80 - throw 'invalid module definition, dependencies must be specified';
81 - }
82 -
83 - if (definition === undefined) {
84 - throw 'invalid module definition, definition function must be specified';
85 - }
86 -
87 - require(dependencies, function() {
88 - modules[id] = definition.apply(null, arguments);
89 - });
90 -
91 - if (--moduleCount === 0) {
92 - for (i = 0; i < exposedModules.length; i++) {
93 - register(exposedModules[i]);
94 - }
95 - }
96 -
97 - // Expose private modules for unit tests
98 - if (exports.AMDLC_TESTS) {
99 - privateModules = exports.privateModules || {};
100 -
101 - for (id in modules) {
102 - privateModules[id] = modules[id];
103 - }
104 -
105 - for (i = 0; i < exposedModules.length; i++) {
106 - delete privateModules[exposedModules[i]];
107 - }
108 -
109 - exports.privateModules = privateModules;
110 - }
111 -
112 - }
113 -
114 - function expose(ids) {
115 - exposedModules = ids;
116 - }
117 -
118 - function writeScripts() {
119 - document.write(html);
120 - }
121 -
122 - function load(path) {
123 - html += '<script type="text/javascript" src="' + baseDir + '/' + path + '"></script>\n';
124 - moduleCount++;
125 - }
126 -
127 - // Expose globally
128 - exports.define = define;
129 - exports.require = require;
130 -
131 - expose(["tinymce/pasteplugin/Utils"]);
132 -
133 - load('classes/Utils.js');
134 - load('classes/SmartPaste.js');
135 - load('classes/Clipboard.js');
136 - load('classes/WordFilter.js');
137 - load('classes/Quirks.js');
138 - load('classes/Plugin.js');
139 -
140 - writeScripts();
141 -})(this);
142 -
143 -// $hash: b44f5a1e3c57aa2f0306f05ae969c01f
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*global tinymce:true */
12 -
13 -tinymce.PluginManager.add('preview', function(editor) {
14 - var settings = editor.settings, sandbox = !tinymce.Env.ie;
15 -
16 - editor.addCommand('mcePreview', function() {
17 - editor.windowManager.open({
18 - title: 'Preview',
19 - width: parseInt(editor.getParam("plugin_preview_width", "650"), 10),
20 - height: parseInt(editor.getParam("plugin_preview_height", "500"), 10),
21 - html: '<iframe src="javascript:\'\'" frameborder="0"' + (sandbox ? ' sandbox="allow-scripts"' : '') + '></iframe>',
22 - buttons: {
23 - text: 'Close',
24 - onclick: function() {
25 - this.parent().parent().close();
26 - }
27 - },
28 - onPostRender: function() {
29 - var previewHtml, headHtml = '';
30 -
31 - headHtml += '<base href="' + editor.documentBaseURI.getURI() + '">';
32 -
33 - tinymce.each(editor.contentCSS, function(url) {
34 - headHtml += '<link type="text/css" rel="stylesheet" href="' + editor.documentBaseURI.toAbsolute(url) + '">';
35 - });
36 -
37 - var bodyId = settings.body_id || 'tinymce';
38 - if (bodyId.indexOf('=') != -1) {
39 - bodyId = editor.getParam('body_id', '', 'hash');
40 - bodyId = bodyId[editor.id] || bodyId;
41 - }
42 -
43 - var bodyClass = settings.body_class || '';
44 - if (bodyClass.indexOf('=') != -1) {
45 - bodyClass = editor.getParam('body_class', '', 'hash');
46 - bodyClass = bodyClass[editor.id] || '';
47 - }
48 -
49 - var preventClicksOnLinksScript = (
50 - '<script>' +
51 - 'document.addEventListener && document.addEventListener("click", function(e) {' +
52 - 'for (var elm = e.target; elm; elm = elm.parentNode) {' +
53 - 'if (elm.nodeName === "A") {' +
54 - 'e.preventDefault();' +
55 - '}' +
56 - '}' +
57 - '}, false);' +
58 - '</script> '
59 - );
60 -
61 - var dirAttr = editor.settings.directionality ? ' dir="' + editor.settings.directionality + '"' : '';
62 -
63 - previewHtml = (
64 - '<!DOCTYPE html>' +
65 - '<html>' +
66 - '<head>' +
67 - headHtml +
68 - '</head>' +
69 - '<body id="' + bodyId + '" class="mce-content-body ' + bodyClass + '"' + dirAttr + '>' +
70 - editor.getContent() +
71 - preventClicksOnLinksScript +
72 - '</body>' +
73 - '</html>'
74 - );
75 -
76 - if (!sandbox) {
77 - // IE 6-11 doesn't support data uris on iframes
78 - // so I guess they will have to be less secure since we can't sandbox on those
79 - // TODO: Use sandbox if future versions of IE supports iframes with data: uris.
80 - var doc = this.getEl('body').firstChild.contentWindow.document;
81 - doc.open();
82 - doc.write(previewHtml);
83 - doc.close();
84 - } else {
85 - this.getEl('body').firstChild.src = 'data:text/html;charset=utf-8,' + encodeURIComponent(previewHtml);
86 - }
87 - }
88 - });
89 - });
90 -
91 - editor.addButton('preview', {
92 - title: 'Preview',
93 - cmd: 'mcePreview'
94 - });
95 -
96 - editor.addMenuItem('preview', {
97 - text: 'Preview',
98 - cmd: 'mcePreview',
99 - context: 'view'
100 - });
101 -});
1 -tinymce.PluginManager.add("preview",function(a){var b=a.settings,c=!tinymce.Env.ie;a.addCommand("mcePreview",function(){a.windowManager.open({title:"Preview",width:parseInt(a.getParam("plugin_preview_width","650"),10),height:parseInt(a.getParam("plugin_preview_height","500"),10),html:'<iframe src="javascript:\'\'" frameborder="0"'+(c?' sandbox="allow-scripts"':"")+"></iframe>",buttons:{text:"Close",onclick:function(){this.parent().parent().close()}},onPostRender:function(){var d,e="";e+='<base href="'+a.documentBaseURI.getURI()+'">',tinymce.each(a.contentCSS,function(b){e+='<link type="text/css" rel="stylesheet" href="'+a.documentBaseURI.toAbsolute(b)+'">'});var f=b.body_id||"tinymce";-1!=f.indexOf("=")&&(f=a.getParam("body_id","","hash"),f=f[a.id]||f);var g=b.body_class||"";-1!=g.indexOf("=")&&(g=a.getParam("body_class","","hash"),g=g[a.id]||"");var h='<script>document.addEventListener && document.addEventListener("click", function(e) {for (var elm = e.target; elm; elm = elm.parentNode) {if (elm.nodeName === "A") {e.preventDefault();}}}, false);</script> ',i=a.settings.directionality?' dir="'+a.settings.directionality+'"':"";if(d="<!DOCTYPE html><html><head>"+e+'</head><body id="'+f+'" class="mce-content-body '+g+'"'+i+">"+a.getContent()+h+"</body></html>",c)this.getEl("body").firstChild.src="data:text/html;charset=utf-8,"+encodeURIComponent(d);else{var j=this.getEl("body").firstChild.contentWindow.document;j.open(),j.write(d),j.close()}}})}),a.addButton("preview",{title:"Preview",cmd:"mcePreview"}),a.addMenuItem("preview",{text:"Preview",cmd:"mcePreview",context:"view"})});
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*global tinymce:true */
12 -
13 -tinymce.PluginManager.add('save', function(editor) {
14 - function save() {
15 - var formObj;
16 -
17 - formObj = tinymce.DOM.getParent(editor.id, 'form');
18 -
19 - if (editor.getParam("save_enablewhendirty", true) && !editor.isDirty()) {
20 - return;
21 - }
22 -
23 - tinymce.triggerSave();
24 -
25 - // Use callback instead
26 - if (editor.getParam("save_onsavecallback")) {
27 - editor.execCallback('save_onsavecallback', editor);
28 - editor.nodeChanged();
29 - return;
30 - }
31 -
32 - if (formObj) {
33 - editor.setDirty(false);
34 -
35 - if (!formObj.onsubmit || formObj.onsubmit()) {
36 - if (typeof formObj.submit == "function") {
37 - formObj.submit();
38 - } else {
39 - displayErrorMessage(editor.translate("Error: Form submit field collision."));
40 - }
41 - }
42 -
43 - editor.nodeChanged();
44 - } else {
45 - displayErrorMessage(editor.translate("Error: No form element found."));
46 - }
47 - }
48 -
49 - function displayErrorMessage(message) {
50 - editor.notificationManager.open({
51 - text: message,
52 - type: 'error'
53 - });
54 - }
55 -
56 - function cancel() {
57 - var h = tinymce.trim(editor.startContent);
58 -
59 - // Use callback instead
60 - if (editor.getParam("save_oncancelcallback")) {
61 - editor.execCallback('save_oncancelcallback', editor);
62 - return;
63 - }
64 -
65 - editor.setContent(h);
66 - editor.undoManager.clear();
67 - editor.nodeChanged();
68 - }
69 -
70 - function stateToggle() {
71 - var self = this;
72 -
73 - editor.on('nodeChange dirty', function() {
74 - self.disabled(editor.getParam("save_enablewhendirty", true) && !editor.isDirty());
75 - });
76 - }
77 -
78 - editor.addCommand('mceSave', save);
79 - editor.addCommand('mceCancel', cancel);
80 -
81 - editor.addButton('save', {
82 - icon: 'save',
83 - text: 'Save',
84 - cmd: 'mceSave',
85 - disabled: true,
86 - onPostRender: stateToggle
87 - });
88 -
89 - editor.addButton('cancel', {
90 - text: 'Cancel',
91 - icon: false,
92 - cmd: 'mceCancel',
93 - disabled: true,
94 - onPostRender: stateToggle
95 - });
96 -
97 - editor.addShortcut('Meta+S', '', 'mceSave');
98 -});
1 -tinymce.PluginManager.add("save",function(a){function b(){var b;return b=tinymce.DOM.getParent(a.id,"form"),!a.getParam("save_enablewhendirty",!0)||a.isDirty()?(tinymce.triggerSave(),a.getParam("save_onsavecallback")?(a.execCallback("save_onsavecallback",a),void a.nodeChanged()):void(b?(a.setDirty(!1),b.onsubmit&&!b.onsubmit()||("function"==typeof b.submit?b.submit():c(a.translate("Error: Form submit field collision."))),a.nodeChanged()):c(a.translate("Error: No form element found.")))):void 0}function c(b){a.notificationManager.open({text:b,type:"error"})}function d(){var b=tinymce.trim(a.startContent);return a.getParam("save_oncancelcallback")?void a.execCallback("save_oncancelcallback",a):(a.setContent(b),a.undoManager.clear(),void a.nodeChanged())}function e(){var b=this;a.on("nodeChange dirty",function(){b.disabled(a.getParam("save_enablewhendirty",!0)&&!a.isDirty())})}a.addCommand("mceSave",b),a.addCommand("mceCancel",d),a.addButton("save",{icon:"save",text:"Save",cmd:"mceSave",disabled:!0,onPostRender:e}),a.addButton("cancel",{text:"Cancel",icon:!1,cmd:"mceCancel",disabled:!0,onPostRender:e}),a.addShortcut("Meta+S","","mceSave")});
...\ No newline at end of file ...\ No newline at end of file
1 -!function(){function a(a){return a&&1==a.nodeType&&"false"===a.contentEditable}function b(b,c,d,e,f){function g(a,b){if(b=b||0,!a[0])throw"findAndReplaceDOMText cannot handle zero-length matches";var c=a.index;if(b>0){var d=a[b];if(!d)throw"Invalid capture group";c+=a[0].indexOf(d),a[0]=d}return[c,c+a[0].length,[a[0]]]}function h(b){var c;if(3===b.nodeType)return b.data;if(o[b.nodeName]&&!n[b.nodeName])return"";if(c="",a(b))return"\n";if((n[b.nodeName]||p[b.nodeName])&&(c+="\n"),b=b.firstChild)do c+=h(b);while(b=b.nextSibling);return c}function i(b,c,d){var e,f,g,h,i=[],j=0,k=b,l=c.shift(),m=0;a:for(;;){if((n[k.nodeName]||p[k.nodeName]||a(k))&&j++,3===k.nodeType&&(!f&&k.length+j>=l[1]?(f=k,h=l[1]-j):e&&i.push(k),!e&&k.length+j>l[0]&&(e=k,g=l[0]-j),j+=k.length),e&&f){if(k=d({startNode:e,startNodeIndex:g,endNode:f,endNodeIndex:h,innerNodes:i,match:l[2],matchIndex:m}),j-=f.length-h,e=null,f=null,i=[],l=c.shift(),m++,!l)break}else if(o[k.nodeName]&&!n[k.nodeName]||!k.firstChild){if(k.nextSibling){k=k.nextSibling;continue}}else if(!a(k)){k=k.firstChild;continue}for(;;){if(k.nextSibling){k=k.nextSibling;break}if(k.parentNode===b)break a;k=k.parentNode}}}function j(a){var b;if("function"!=typeof a){var c=a.nodeType?a:m.createElement(a);b=function(a,b){var d=c.cloneNode(!1);return d.setAttribute("data-mce-index",b),a&&d.appendChild(m.createTextNode(a)),d}}else b=a;return function(a){var c,d,e,f=a.startNode,g=a.endNode,h=a.matchIndex;if(f===g){var i=f;e=i.parentNode,a.startNodeIndex>0&&(c=m.createTextNode(i.data.substring(0,a.startNodeIndex)),e.insertBefore(c,i));var j=b(a.match[0],h);return e.insertBefore(j,i),a.endNodeIndex<i.length&&(d=m.createTextNode(i.data.substring(a.endNodeIndex)),e.insertBefore(d,i)),i.parentNode.removeChild(i),j}c=m.createTextNode(f.data.substring(0,a.startNodeIndex)),d=m.createTextNode(g.data.substring(a.endNodeIndex));for(var k=b(f.data.substring(a.startNodeIndex),h),l=[],n=0,o=a.innerNodes.length;o>n;++n){var p=a.innerNodes[n],q=b(p.data,h);p.parentNode.replaceChild(q,p),l.push(q)}var r=b(g.data.substring(0,a.endNodeIndex),h);return e=f.parentNode,e.insertBefore(c,f),e.insertBefore(k,f),e.removeChild(f),e=g.parentNode,e.insertBefore(r,g),e.insertBefore(d,g),e.removeChild(g),r}}var k,l,m,n,o,p,q=[],r=0;if(m=c.ownerDocument,n=f.getBlockElements(),o=f.getWhiteSpaceElements(),p=f.getShortEndedElements(),l=h(c)){if(b.global)for(;k=b.exec(l);)q.push(g(k,e));else k=l.match(b),q.push(g(k,e));return q.length&&(r=q.length,i(c,q,j(d))),r}}function c(a){function c(){function b(){f.statusbar.find("#next").disabled(!g(l+1).length),f.statusbar.find("#prev").disabled(!g(l-1).length)}function c(){a.windowManager.alert("Could not find the specified string.",function(){f.find("#find")[0].focus()})}var d,e={};d=tinymce.trim(a.selection.getContent({format:"text"}));var f=a.windowManager.open({layout:"flex",pack:"center",align:"center",onClose:function(){a.focus(),k.done()},onSubmit:function(a){var d,h,i,j;return a.preventDefault(),h=f.find("#case").checked(),j=f.find("#words").checked(),i=f.find("#find").value(),i.length?e.text==i&&e.caseState==h&&e.wholeWord==j?0===g(l+1).length?void c():(k.next(),void b()):(d=k.find(i,h,j),d||c(),f.statusbar.items().slice(1).disabled(0===d),b(),void(e={text:i,caseState:h,wholeWord:j})):(k.done(!1),void f.statusbar.items().slice(1).disabled(!0))},buttons:[{text:"Find",subtype:"primary",onclick:function(){f.submit()}},{text:"Replace",disabled:!0,onclick:function(){k.replace(f.find("#replace").value())||(f.statusbar.items().slice(1).disabled(!0),l=-1,e={})}},{text:"Replace all",disabled:!0,onclick:function(){k.replace(f.find("#replace").value(),!0,!0),f.statusbar.items().slice(1).disabled(!0),e={}}},{type:"spacer",flex:1},{text:"Prev",name:"prev",disabled:!0,onclick:function(){k.prev(),b()}},{text:"Next",name:"next",disabled:!0,onclick:function(){k.next(),b()}}],title:"Find and replace",items:{type:"form",padding:20,labelGap:30,spacing:10,items:[{type:"textbox",name:"find",size:40,label:"Find",value:d},{type:"textbox",name:"replace",size:40,label:"Replace with"},{type:"checkbox",name:"case",text:"Match case",label:" "},{type:"checkbox",name:"words",text:"Whole words",label:" "}]}})}function d(a){var b=a.getAttribute("data-mce-index");return"number"==typeof b?""+b:b}function e(c){var d,e;return e=a.dom.create("span",{"data-mce-bogus":1}),e.className="mce-match-marker",d=a.getBody(),k.done(!1),b(c,d,e,!1,a.schema)}function f(a){var b=a.parentNode;a.firstChild&&b.insertBefore(a.firstChild,a),a.parentNode.removeChild(a)}function g(b){var c,e=[];if(c=tinymce.toArray(a.getBody().getElementsByTagName("span")),c.length)for(var f=0;f<c.length;f++){var g=d(c[f]);null!==g&&g.length&&g===b.toString()&&e.push(c[f])}return e}function h(b){var c=l,d=a.dom;b=b!==!1,b?c++:c--,d.removeClass(g(l),"mce-match-marker-selected");var e=g(c);return e.length?(d.addClass(g(c),"mce-match-marker-selected"),a.selection.scrollIntoView(e[0]),c):-1}function i(b){var c=a.dom,d=b.parentNode;c.remove(b),c.isEmpty(d)&&c.remove(d)}function j(a){var b=d(a);return null!==b&&b.length>0}var k=this,l=-1;k.init=function(a){a.addMenuItem("searchreplace",{text:"Find and replace",shortcut:"Meta+F",onclick:c,separator:"before",context:"edit"}),a.addButton("searchreplace",{tooltip:"Find and replace",shortcut:"Meta+F",onclick:c}),a.addCommand("SearchReplace",c),a.shortcuts.add("Meta+F","",c)},k.find=function(a,b,c){a=a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),a=c?"\\b"+a+"\\b":a;var d=e(new RegExp(a,b?"g":"gi"));return d&&(l=-1,l=h(!0)),d},k.next=function(){var a=h(!0);-1!==a&&(l=a)},k.prev=function(){var a=h(!1);-1!==a&&(l=a)},k.replace=function(b,c,e){var h,m,n,o,p,q,r=l;for(c=c!==!1,n=a.getBody(),m=tinymce.grep(tinymce.toArray(n.getElementsByTagName("span")),j),h=0;h<m.length;h++){var s=d(m[h]);if(o=p=parseInt(s,10),e||o===l){for(b.length?(m[h].firstChild.nodeValue=b,f(m[h])):i(m[h]);m[++h];){if(o=parseInt(d(m[h]),10),o!==p){h--;break}i(m[h])}c&&r--}else p>l&&m[h].setAttribute("data-mce-index",p-1)}return a.undoManager.add(),l=r,c?(q=g(r+1).length>0,k.next()):(q=g(r-1).length>0,k.prev()),!e&&q},k.done=function(b){var c,e,g,h;for(e=tinymce.toArray(a.getBody().getElementsByTagName("span")),c=0;c<e.length;c++){var i=d(e[c]);null!==i&&i.length&&(i===l.toString()&&(g||(g=e[c].firstChild),h=e[c].firstChild),f(e[c]))}if(g&&h){var j=a.dom.createRng();return j.setStart(g,0),j.setEnd(h,h.data.length),b!==!1&&a.selection.setRng(j),j}}}tinymce.PluginManager.add("searchreplace",c)}();
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * Inline development version. Only to be used while developing since it uses document.write to load scripts.
3 - */
4 -
5 -/*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */
6 -/*globals $code */
7 -
8 -(function(exports) {
9 - "use strict";
10 -
11 - var html = "", baseDir;
12 - var modules = {}, exposedModules = [], moduleCount = 0;
13 -
14 - var scripts = document.getElementsByTagName('script');
15 - for (var i = 0; i < scripts.length; i++) {
16 - var src = scripts[i].src;
17 -
18 - if (src.indexOf('/plugin.dev.js') != -1) {
19 - baseDir = src.substring(0, src.lastIndexOf('/'));
20 - }
21 - }
22 -
23 - function require(ids, callback) {
24 - var module, defs = [];
25 -
26 - for (var i = 0; i < ids.length; ++i) {
27 - module = modules[ids[i]] || resolve(ids[i]);
28 - if (!module) {
29 - throw 'module definition dependecy not found: ' + ids[i];
30 - }
31 -
32 - defs.push(module);
33 - }
34 -
35 - callback.apply(null, defs);
36 - }
37 -
38 - function resolve(id) {
39 - if (exports.privateModules && id in exports.privateModules) {
40 - return;
41 - }
42 -
43 - var target = exports;
44 - var fragments = id.split(/[.\/]/);
45 -
46 - for (var fi = 0; fi < fragments.length; ++fi) {
47 - if (!target[fragments[fi]]) {
48 - return;
49 - }
50 -
51 - target = target[fragments[fi]];
52 - }
53 -
54 - return target;
55 - }
56 -
57 - function register(id) {
58 - var target = exports;
59 - var fragments = id.split(/[.\/]/);
60 -
61 - for (var fi = 0; fi < fragments.length - 1; ++fi) {
62 - if (target[fragments[fi]] === undefined) {
63 - target[fragments[fi]] = {};
64 - }
65 -
66 - target = target[fragments[fi]];
67 - }
68 -
69 - target[fragments[fragments.length - 1]] = modules[id];
70 - }
71 -
72 - function define(id, dependencies, definition) {
73 - var privateModules, i;
74 -
75 - if (typeof id !== 'string') {
76 - throw 'invalid module definition, module id must be defined and be a string';
77 - }
78 -
79 - if (dependencies === undefined) {
80 - throw 'invalid module definition, dependencies must be specified';
81 - }
82 -
83 - if (definition === undefined) {
84 - throw 'invalid module definition, definition function must be specified';
85 - }
86 -
87 - require(dependencies, function() {
88 - modules[id] = definition.apply(null, arguments);
89 - });
90 -
91 - if (--moduleCount === 0) {
92 - for (i = 0; i < exposedModules.length; i++) {
93 - register(exposedModules[i]);
94 - }
95 - }
96 -
97 - // Expose private modules for unit tests
98 - if (exports.AMDLC_TESTS) {
99 - privateModules = exports.privateModules || {};
100 -
101 - for (id in modules) {
102 - privateModules[id] = modules[id];
103 - }
104 -
105 - for (i = 0; i < exposedModules.length; i++) {
106 - delete privateModules[exposedModules[i]];
107 - }
108 -
109 - exports.privateModules = privateModules;
110 - }
111 -
112 - }
113 -
114 - function expose(ids) {
115 - exposedModules = ids;
116 - }
117 -
118 - function writeScripts() {
119 - document.write(html);
120 - }
121 -
122 - function load(path) {
123 - html += '<script type="text/javascript" src="' + baseDir + '/' + path + '"></script>\n';
124 - moduleCount++;
125 - }
126 -
127 - // Expose globally
128 - exports.define = define;
129 - exports.require = require;
130 -
131 - expose(["tinymce/spellcheckerplugin/DomTextMatcher"]);
132 -
133 - load('classes/DomTextMatcher.js');
134 - load('classes/Plugin.js');
135 -
136 - writeScripts();
137 -})(this);
138 -
139 -// $hash: a894b80e97e733310c550dadb509e87a
...\ No newline at end of file ...\ No newline at end of file
1 -!function(a,b){"use strict";function c(a,b){for(var c,d=[],f=0;f<a.length;++f){if(c=g[a[f]]||e(a[f]),!c)throw"module definition dependecy not found: "+a[f];d.push(c)}b.apply(null,d)}function d(a,d,e){if("string"!=typeof a)throw"invalid module definition, module id must be defined and be a string";if(d===b)throw"invalid module definition, dependencies must be specified";if(e===b)throw"invalid module definition, definition function must be specified";c(d,function(){g[a]=e.apply(null,arguments)})}function e(b){for(var c=a,d=b.split(/[.\/]/),e=0;e<d.length;++e){if(!c[d[e]])return;c=c[d[e]]}return c}function f(c){var d,e,f,h,i;for(d=0;d<c.length;d++){e=a,f=c[d],h=f.split(/[.\/]/);for(var j=0;j<h.length-1;++j)e[h[j]]===b&&(e[h[j]]={}),e=e[h[j]];e[h[h.length-1]]=g[f]}if(a.AMDLC_TESTS){i=a.privateModules||{};for(f in g)i[f]=g[f];for(d=0;d<c.length;d++)delete i[c[d]];a.privateModules=i}}var g={};d("tinymce/spellcheckerplugin/DomTextMatcher",[],function(){function a(a){return a&&1==a.nodeType&&"false"===a.contentEditable}return function(b,c){function d(a,b){if(!a[0])throw"findAndReplaceDOMText cannot handle zero-length matches";return{start:a.index,end:a.index+a[0].length,text:a[0],data:b}}function e(b){var c;if(3===b.nodeType)return b.data;if(y[b.nodeName]&&!x[b.nodeName])return"";if(a(b))return"\n";if(c="",(x[b.nodeName]||z[b.nodeName])&&(c+="\n"),b=b.firstChild)do c+=e(b);while(b=b.nextSibling);return c}function f(b,c,d){var e,f,g,h,i,j=[],k=0,l=b,m=0;c=c.slice(0),c.sort(function(a,b){return a.start-b.start}),i=c.shift();a:for(;;){if((x[l.nodeName]||z[l.nodeName]||a(l))&&k++,3===l.nodeType&&(!f&&l.length+k>=i.end?(f=l,h=i.end-k):e&&j.push(l),!e&&l.length+k>i.start&&(e=l,g=i.start-k),k+=l.length),e&&f){if(l=d({startNode:e,startNodeIndex:g,endNode:f,endNodeIndex:h,innerNodes:j,match:i.text,matchIndex:m}),k-=f.length-h,e=null,f=null,j=[],i=c.shift(),m++,!i)break}else if(y[l.nodeName]&&!x[l.nodeName]||!l.firstChild){if(l.nextSibling){l=l.nextSibling;continue}}else if(!a(l)){l=l.firstChild;continue}for(;;){if(l.nextSibling){l=l.nextSibling;break}if(l.parentNode===b)break a;l=l.parentNode}}}function g(a){function b(b,c){var d=A[c];d.stencil||(d.stencil=a(d));var e=d.stencil.cloneNode(!1);return e.setAttribute("data-mce-index",c),b&&e.appendChild(B.doc.createTextNode(b)),e}return function(a){var c,d,e,f=a.startNode,g=a.endNode,h=a.matchIndex,i=B.doc;if(f===g){var j=f;e=j.parentNode,a.startNodeIndex>0&&(c=i.createTextNode(j.data.substring(0,a.startNodeIndex)),e.insertBefore(c,j));var k=b(a.match,h);return e.insertBefore(k,j),a.endNodeIndex<j.length&&(d=i.createTextNode(j.data.substring(a.endNodeIndex)),e.insertBefore(d,j)),j.parentNode.removeChild(j),k}c=i.createTextNode(f.data.substring(0,a.startNodeIndex)),d=i.createTextNode(g.data.substring(a.endNodeIndex));for(var l=b(f.data.substring(a.startNodeIndex),h),m=[],n=0,o=a.innerNodes.length;o>n;++n){var p=a.innerNodes[n],q=b(p.data,h);p.parentNode.replaceChild(q,p),m.push(q)}var r=b(g.data.substring(0,a.endNodeIndex),h);return e=f.parentNode,e.insertBefore(c,f),e.insertBefore(l,f),e.removeChild(f),e=g.parentNode,e.insertBefore(r,g),e.insertBefore(d,g),e.removeChild(g),r}}function h(a){var b=a.parentNode;b.insertBefore(a.firstChild,a),a.parentNode.removeChild(a)}function i(a){var c=b.getElementsByTagName("*"),d=[];a="number"==typeof a?""+a:null;for(var e=0;e<c.length;e++){var f=c[e],g=f.getAttribute("data-mce-index");null!==g&&g.length&&(g!==a&&null!==a||d.push(f))}return d}function j(a){for(var b=A.length;b--;)if(A[b]===a)return b;return-1}function k(a){var b=[];return l(function(c,d){a(c,d)&&b.push(c)}),A=b,this}function l(a){for(var b=0,c=A.length;c>b&&a(A[b],b)!==!1;b++);return this}function m(a){return A.length&&f(b,A,g(a)),this}function n(a,b){if(w&&a.global)for(;v=a.exec(w);)A.push(d(v,b));return this}function o(a){var b,c=i(a?j(a):null);for(b=c.length;b--;)h(c[b]);return this}function p(a){return A[a.getAttribute("data-mce-index")]}function q(a){return i(j(a))[0]}function r(a,b,c){return A.push({start:a,end:a+b,text:w.substr(a,b),data:c}),this}function s(a){var b=i(j(a)),d=c.dom.createRng();return d.setStartBefore(b[0]),d.setEndAfter(b[b.length-1]),d}function t(a,b){var d=s(a);return d.deleteContents(),b.length>0&&d.insertNode(c.dom.doc.createTextNode(b)),d}function u(){return A.splice(0,A.length),o(),this}var v,w,x,y,z,A=[],B=c.dom;return x=c.schema.getBlockElements(),y=c.schema.getWhiteSpaceElements(),z=c.schema.getShortEndedElements(),w=e(b),{text:w,matches:A,each:l,filter:k,reset:u,matchFromElement:p,elementFromMatch:q,find:n,add:r,wrap:m,unwrap:o,replace:t,rangeFromMatch:s,indexOf:j}}}),d("tinymce/spellcheckerplugin/Plugin",["tinymce/spellcheckerplugin/DomTextMatcher","tinymce/PluginManager","tinymce/util/Tools","tinymce/ui/Menu","tinymce/dom/DOMUtils","tinymce/util/XHR","tinymce/util/URI","tinymce/util/JSON"],function(a,b,c,d,e,f,g,h){b.add("spellchecker",function(i,j){function k(){return F.textMatcher||(F.textMatcher=new a(i.getBody(),i)),F.textMatcher}function l(a,b){var d=[];return c.each(b,function(a){d.push({selectable:!0,text:a.name,data:a.value})}),d}function m(a){for(var b in a)return!1;return!0}function n(a,b){var f=[],g=B[a];c.each(g,function(a){f.push({text:a,onclick:function(){i.insertContent(i.dom.encode(a)),i.dom.remove(b),s()}})}),f.push({text:"-"}),E&&f.push({text:"Add to Dictionary",onclick:function(){t(a,b)}}),f.push.apply(f,[{text:"Ignore",onclick:function(){u(a,b)}},{text:"Ignore all",onclick:function(){u(a,b,!0)}}]),D=new d({items:f,context:"contextmenu",onautohide:function(a){-1!=a.target.className.indexOf("spellchecker")&&a.preventDefault()},onhide:function(){D.remove(),D=null}}),D.renderTo(document.body);var h=e.DOM.getPos(i.getContentAreaContainer()),j=i.dom.getPos(b[0]),k=i.dom.getRoot();"BODY"==k.nodeName?(j.x-=k.ownerDocument.documentElement.scrollLeft||k.scrollLeft,j.y-=k.ownerDocument.documentElement.scrollTop||k.scrollTop):(j.x-=k.scrollLeft,j.y-=k.scrollTop),h.x+=j.x,h.y+=j.y,D.moveTo(h.x,h.y+b[0].offsetHeight)}function o(){return i.getParam("spellchecker_wordchar_pattern")||new RegExp('[^\\s!"#$%&()*+,-./:;<=>?@[\\]^_{|}`\xa7\xa9\xab\xae\xb1\xb6\xb7\xb8\xbb\xbc\xbd\xbe\xbf\xd7\xf7\xa4\u201d\u201c\u201e\xa0\u2002\u2003\u2009]+',"g")}function p(a,b,d,e){var k={method:a,lang:G.spellchecker_language},l="";k["addToDictionary"==a?"word":"text"]=b,c.each(k,function(a,b){l&&(l+="&"),l+=b+"="+encodeURIComponent(a)}),f.send({url:new g(j).toAbsolute(G.spellchecker_rpc_url),type:"post",content_type:"application/x-www-form-urlencoded",data:l,success:function(a){if(a=h.parse(a))a.error?e(a.error):d(a);else{var b=i.translate("Server response wasn't proper JSON.");e(b)}},error:function(){var a=i.translate("The spelling service was not found: (")+G.spellchecker_rpc_url+i.translate(")");e(a)}})}function q(a,b,c,d){var e=G.spellchecker_callback||p;e.call(F,a,b,c,d)}function r(){function a(a){i.notificationManager.open({text:a,type:"error"}),i.setProgressState(!1),v()}v()||(i.setProgressState(!0),q("spellcheck",k().text,z,a),i.focus())}function s(){i.dom.select("span.mce-spellchecker-word").length||v()}function t(a,b){i.setProgressState(!0),q("addToDictionary",a,function(){i.setProgressState(!1),i.dom.remove(b,!0),s()},function(a){i.notificationManager.open({text:a,type:"error"}),i.setProgressState(!1)})}function u(a,b,d){i.selection.collapse(),d?c.each(i.dom.select("span.mce-spellchecker-word"),function(b){b.getAttribute("data-mce-word")==a&&i.dom.remove(b,!0)}):i.dom.remove(b,!0),s()}function v(){return k().reset(),F.textMatcher=null,C?(C=!1,i.fire("SpellcheckEnd"),!0):void 0}function w(a){var b=a.getAttribute("data-mce-index");return"number"==typeof b?""+b:b}function x(a){var b,d=[];if(b=c.toArray(i.getBody().getElementsByTagName("span")),b.length)for(var e=0;e<b.length;e++){var f=w(b[e]);null!==f&&f.length&&f===a.toString()&&d.push(b[e])}return d}function y(a){var b=G.spellchecker_language;a.control.items().each(function(a){a.active(a.settings.data===b)})}function z(a){var b;if(a.words?(E=!!a.dictionary,b=a.words):b=a,i.setProgressState(!1),m(b)){var c=i.translate("No misspellings found.");return i.notificationManager.open({text:c,type:"info"}),void(C=!1)}B=b,k().find(o()).filter(function(a){return!!b[a.text]}).wrap(function(a){return i.dom.create("span",{"class":"mce-spellchecker-word","data-mce-bogus":1,"data-mce-word":a.text})}),C=!0,i.fire("SpellcheckStart")}var A,B,C,D,E,F=this,G=i.settings;if(/(^|[ ,])tinymcespellchecker([, ]|$)/.test(G.plugins)&&b.get("tinymcespellchecker"))return void("undefined"!=typeof console&&console.log&&console.log("Spell Checker Pro is incompatible with Spell Checker plugin! Remove 'spellchecker' from the 'plugins' option."));var H=G.spellchecker_languages||"English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr_FR,German=de,Italian=it,Polish=pl,Portuguese=pt_BR,Spanish=es,Swedish=sv";A=l("Language",c.map(H.split(","),function(a){return a=a.split("="),{name:a[0],value:a[1]}})),i.on("click",function(a){var b=a.target;if("mce-spellchecker-word"==b.className){a.preventDefault();var c=x(w(b));if(c.length>0){var d=i.dom.createRng();d.setStartBefore(c[0]),d.setEndAfter(c[c.length-1]),i.selection.setRng(d),n(b.getAttribute("data-mce-word"),c)}}}),i.addMenuItem("spellchecker",{text:"Spellcheck",context:"tools",onclick:r,selectable:!0,onPostRender:function(){var a=this;a.active(C),i.on("SpellcheckStart SpellcheckEnd",function(){a.active(C)})}});var I={tooltip:"Spellcheck",onclick:r,onPostRender:function(){var a=this;i.on("SpellcheckStart SpellcheckEnd",function(){a.active(C)})}};A.length>1&&(I.type="splitbutton",I.menu=A,I.onshow=y,I.onselect=function(a){G.spellchecker_language=a.control.settings.data}),i.addButton("spellchecker",I),i.addCommand("mceSpellCheck",r),i.on("remove",function(){D&&(D.remove(),D=null)}),i.on("change",s),this.getTextMatcher=k,this.getWordCharPattern=o,this.markErrors=z,this.getLanguage=function(){return G.spellchecker_language},G.spellchecker_language=G.spellchecker_language||G.language||"en"})}),f(["tinymce/spellcheckerplugin/DomTextMatcher"])}(this);
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*global tinymce:true */
12 -
13 -tinymce.PluginManager.add('tabfocus', function(editor) {
14 - var DOM = tinymce.DOM, each = tinymce.each, explode = tinymce.explode;
15 -
16 - function tabCancel(e) {
17 - if (e.keyCode === 9 && !e.ctrlKey && !e.altKey && !e.metaKey) {
18 - e.preventDefault();
19 - }
20 - }
21 -
22 - function tabHandler(e) {
23 - var x, el, v, i;
24 -
25 - if (e.keyCode !== 9 || e.ctrlKey || e.altKey || e.metaKey || e.isDefaultPrevented()) {
26 - return;
27 - }
28 -
29 - function find(direction) {
30 - el = DOM.select(':input:enabled,*[tabindex]:not(iframe)');
31 -
32 - function canSelectRecursive(e) {
33 - return e.nodeName === "BODY" || (e.type != 'hidden' &&
34 - e.style.display != "none" &&
35 - e.style.visibility != "hidden" && canSelectRecursive(e.parentNode));
36 - }
37 -
38 - function canSelect(el) {
39 - return /INPUT|TEXTAREA|BUTTON/.test(el.tagName) && tinymce.get(e.id) && el.tabIndex != -1 && canSelectRecursive(el);
40 - }
41 -
42 - each(el, function(e, i) {
43 - if (e.id == editor.id) {
44 - x = i;
45 - return false;
46 - }
47 - });
48 - if (direction > 0) {
49 - for (i = x + 1; i < el.length; i++) {
50 - if (canSelect(el[i])) {
51 - return el[i];
52 - }
53 - }
54 - } else {
55 - for (i = x - 1; i >= 0; i--) {
56 - if (canSelect(el[i])) {
57 - return el[i];
58 - }
59 - }
60 - }
61 -
62 - return null;
63 - }
64 -
65 - v = explode(editor.getParam('tab_focus', editor.getParam('tabfocus_elements', ':prev,:next')));
66 -
67 - if (v.length == 1) {
68 - v[1] = v[0];
69 - v[0] = ':prev';
70 - }
71 -
72 - // Find element to focus
73 - if (e.shiftKey) {
74 - if (v[0] == ':prev') {
75 - el = find(-1);
76 - } else {
77 - el = DOM.get(v[0]);
78 - }
79 - } else {
80 - if (v[1] == ':next') {
81 - el = find(1);
82 - } else {
83 - el = DOM.get(v[1]);
84 - }
85 - }
86 -
87 - if (el) {
88 - var focusEditor = tinymce.get(el.id || el.name);
89 -
90 - if (el.id && focusEditor) {
91 - focusEditor.focus();
92 - } else {
93 - tinymce.util.Delay.setTimeout(function() {
94 - if (!tinymce.Env.webkit) {
95 - window.focus();
96 - }
97 -
98 - el.focus();
99 - }, 10);
100 - }
101 -
102 - e.preventDefault();
103 - }
104 - }
105 -
106 - editor.on('init', function() {
107 - if (editor.inline) {
108 - // Remove default tabIndex in inline mode
109 - tinymce.DOM.setAttrib(editor.getBody(), 'tabIndex', null);
110 - }
111 -
112 - editor.on('keyup', tabCancel);
113 -
114 - if (tinymce.Env.gecko) {
115 - editor.on('keypress keydown', tabHandler);
116 - } else {
117 - editor.on('keydown', tabHandler);
118 - }
119 - });
120 -});
1 -tinymce.PluginManager.add("tabfocus",function(a){function b(a){9!==a.keyCode||a.ctrlKey||a.altKey||a.metaKey||a.preventDefault()}function c(b){function c(c){function f(a){return"BODY"===a.nodeName||"hidden"!=a.type&&"none"!=a.style.display&&"hidden"!=a.style.visibility&&f(a.parentNode)}function i(a){return/INPUT|TEXTAREA|BUTTON/.test(a.tagName)&&tinymce.get(b.id)&&-1!=a.tabIndex&&f(a)}if(h=d.select(":input:enabled,*[tabindex]:not(iframe)"),e(h,function(b,c){return b.id==a.id?(g=c,!1):void 0}),c>0){for(j=g+1;j<h.length;j++)if(i(h[j]))return h[j]}else for(j=g-1;j>=0;j--)if(i(h[j]))return h[j];return null}var g,h,i,j;if(!(9!==b.keyCode||b.ctrlKey||b.altKey||b.metaKey||b.isDefaultPrevented())&&(i=f(a.getParam("tab_focus",a.getParam("tabfocus_elements",":prev,:next"))),1==i.length&&(i[1]=i[0],i[0]=":prev"),h=b.shiftKey?":prev"==i[0]?c(-1):d.get(i[0]):":next"==i[1]?c(1):d.get(i[1]))){var k=tinymce.get(h.id||h.name);h.id&&k?k.focus():tinymce.util.Delay.setTimeout(function(){tinymce.Env.webkit||window.focus(),h.focus()},10),b.preventDefault()}}var d=tinymce.DOM,e=tinymce.each,f=tinymce.explode;a.on("init",function(){a.inline&&tinymce.DOM.setAttrib(a.getBody(),"tabIndex",null),a.on("keyup",b),tinymce.Env.gecko?a.on("keypress keydown",c):a.on("keydown",c)})});
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * CellSelection.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/**
12 - * This class handles table cell selection by faking it using a css class that gets applied
13 - * to cells when dragging the mouse from one cell to another.
14 - *
15 - * @class tinymce.tableplugin.CellSelection
16 - * @private
17 - */
18 -define("tinymce/tableplugin/CellSelection", [
19 - "tinymce/tableplugin/TableGrid",
20 - "tinymce/dom/TreeWalker",
21 - "tinymce/util/Tools"
22 -], function(TableGrid, TreeWalker, Tools) {
23 - return function(editor, selectionChange) {
24 - var dom = editor.dom, tableGrid, startCell, startTable, lastMouseOverTarget, hasCellSelection = true, resizing, dragging;
25 -
26 - function clear(force) {
27 - // Restore selection possibilities
28 - editor.getBody().style.webkitUserSelect = '';
29 -
30 - if (force || hasCellSelection) {
31 - editor.$('td[data-mce-selected],th[data-mce-selected]').removeAttr('data-mce-selected');
32 - hasCellSelection = false;
33 - }
34 - }
35 -
36 - var endSelection = function () {
37 - startCell = tableGrid = startTable = lastMouseOverTarget = null;
38 - selectionChange(false);
39 - };
40 -
41 - function isCellInTable(table, cell) {
42 - if (!table || !cell) {
43 - return false;
44 - }
45 -
46 - return table === dom.getParent(cell, 'table');
47 - }
48 -
49 - function cellSelectionHandler(e) {
50 - var sel, target = e.target, currentCell;
51 -
52 - if (resizing || dragging) {
53 - return;
54 - }
55 -
56 - // Fake mouse enter by keeping track of last mouse over
57 - if (target === lastMouseOverTarget) {
58 - return;
59 - }
60 -
61 - lastMouseOverTarget = target;
62 -
63 - if (startTable && startCell) {
64 - currentCell = dom.getParent(target, 'td,th');
65 -
66 - if (!isCellInTable(startTable, currentCell)) {
67 - currentCell = dom.getParent(startTable, 'td,th');
68 - }
69 -
70 - // Selection inside first cell is normal until we have expanted
71 - if (startCell === currentCell && !hasCellSelection) {
72 - return;
73 - }
74 -
75 - selectionChange(true);
76 -
77 - if (isCellInTable(startTable, currentCell)) {
78 - e.preventDefault();
79 -
80 - if (!tableGrid) {
81 - tableGrid = new TableGrid(editor, startTable, startCell);
82 - editor.getBody().style.webkitUserSelect = 'none';
83 - }
84 -
85 - tableGrid.setEndCell(currentCell);
86 - hasCellSelection = true;
87 -
88 - // Remove current selection
89 - sel = editor.selection.getSel();
90 -
91 - try {
92 - if (sel.removeAllRanges) {
93 - sel.removeAllRanges();
94 - } else {
95 - sel.empty();
96 - }
97 - } catch (ex) {
98 - // IE9 might throw errors here
99 - }
100 - }
101 - }
102 - }
103 -
104 - editor.on('SelectionChange', function(e) {
105 - if (hasCellSelection) {
106 - e.stopImmediatePropagation();
107 - }
108 - }, true);
109 -
110 - // Add cell selection logic
111 - editor.on('MouseDown', function(e) {
112 - if (e.button != 2 && !resizing && !dragging) {
113 - clear();
114 -
115 - startCell = dom.getParent(e.target, 'td,th');
116 - startTable = dom.getParent(startCell, 'table');
117 - }
118 - });
119 -
120 - editor.on('mouseover', cellSelectionHandler);
121 -
122 - editor.on('remove', function() {
123 - dom.unbind(editor.getDoc(), 'mouseover', cellSelectionHandler);
124 - clear();
125 - });
126 -
127 - editor.on('MouseUp', function() {
128 - var rng, sel = editor.selection, selectedCells, walker, node, lastNode;
129 -
130 - function setPoint(node, start) {
131 - var walker = new TreeWalker(node, node);
132 -
133 - do {
134 - // Text node
135 - if (node.nodeType == 3 && Tools.trim(node.nodeValue).length !== 0) {
136 - if (start) {
137 - rng.setStart(node, 0);
138 - } else {
139 - rng.setEnd(node, node.nodeValue.length);
140 - }
141 -
142 - return;
143 - }
144 -
145 - // BR element
146 - if (node.nodeName == 'BR') {
147 - if (start) {
148 - rng.setStartBefore(node);
149 - } else {
150 - rng.setEndBefore(node);
151 - }
152 -
153 - return;
154 - }
155 - } while ((node = (start ? walker.next() : walker.prev())));
156 - }
157 -
158 - // Move selection to startCell
159 - if (startCell) {
160 - if (tableGrid) {
161 - editor.getBody().style.webkitUserSelect = '';
162 - }
163 -
164 - // Try to expand text selection as much as we can only Gecko supports cell selection
165 - selectedCells = dom.select('td[data-mce-selected],th[data-mce-selected]');
166 - if (selectedCells.length > 0) {
167 - rng = dom.createRng();
168 - node = selectedCells[0];
169 - rng.setStartBefore(node);
170 - rng.setEndAfter(node);
171 -
172 - setPoint(node, 1);
173 - walker = new TreeWalker(node, dom.getParent(selectedCells[0], 'table'));
174 -
175 - do {
176 - if (node.nodeName == 'TD' || node.nodeName == 'TH') {
177 - if (!dom.getAttrib(node, 'data-mce-selected')) {
178 - break;
179 - }
180 -
181 - lastNode = node;
182 - }
183 - } while ((node = walker.next()));
184 -
185 - setPoint(lastNode);
186 -
187 - sel.setRng(rng);
188 - }
189 -
190 - editor.nodeChanged();
191 - endSelection();
192 - }
193 - });
194 -
195 - editor.on('KeyUp Drop SetContent', function(e) {
196 - clear(e.type == 'setcontent');
197 - endSelection();
198 - resizing = false;
199 - });
200 -
201 - editor.on('ObjectResizeStart ObjectResized', function(e) {
202 - resizing = e.type != 'objectresized';
203 - });
204 -
205 - editor.on('dragstart', function () {
206 - dragging = true;
207 - });
208 -
209 - editor.on('drop dragend', function () {
210 - dragging = false;
211 - });
212 -
213 - return {
214 - clear: clear
215 - };
216 - };
217 -});
1 -/**
2 - * SplitCols.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/**
12 - * Contains logic for handling splitting of merged rows.
13 - *
14 - * @class tinymce.tableplugin.SplitCols
15 - * @private
16 - */
17 -define("tinymce/tableplugin/SplitCols", [
18 - "tinymce/util/Tools",
19 - "tinymce/tableplugin/Utils"
20 -], function(Tools, Utils) {
21 - var getCellAt = function (grid, x, y) {
22 - return grid[y] ? grid[y][x] : null;
23 - };
24 -
25 - var getCellElmAt = function (grid, x, y) {
26 - var cell = getCellAt(grid, x, y);
27 - return cell ? cell.elm : null;
28 - };
29 -
30 - var countHoles = function (grid, x, y, delta) {
31 - var y2, cell, count = 0, elm = getCellElmAt(grid, x, y);
32 -
33 - for (y2 = y; delta > 0 ? y2 < grid.length : y2 >= 0; y2 += delta) {
34 - cell = getCellAt(grid, x, y2);
35 - if (elm !== cell.elm) {
36 - break;
37 - }
38 -
39 - count++;
40 - }
41 -
42 - return count;
43 - };
44 -
45 - var findRealElm = function (grid, x, y) {
46 - var cell, row = grid[y];
47 -
48 - for (var x2 = x; x2 < row.length; x2++) {
49 - cell = row[x2];
50 - if (cell.real) {
51 - return cell.elm;
52 - }
53 - }
54 -
55 - return null;
56 - };
57 -
58 - var getRowSplitInfo = function (grid, y) {
59 - var cell, result = [], row = grid[y];
60 -
61 - for (var x = 0; x < row.length; x++) {
62 - cell = row[x];
63 - result.push({
64 - elm: cell.elm,
65 - above: countHoles(grid, x, y, -1) - 1,
66 - below: countHoles(grid, x, y, 1) - 1
67 - });
68 -
69 - x += Utils.getColSpan(cell.elm) - 1;
70 - }
71 -
72 - return result;
73 - };
74 -
75 - var createCell = function (info, rowSpan) {
76 - var doc = info.elm.ownerDocument;
77 - var newCell = doc.createElement('td');
78 -
79 - Utils.setColSpan(newCell, Utils.getColSpan(info.elm));
80 - Utils.setRowSpan(newCell, rowSpan);
81 - Utils.paddCell(newCell);
82 -
83 - return newCell;
84 - };
85 -
86 - var insertOrAppendCell = function (grid, newCell, x, y) {
87 - var realCellElm = findRealElm(grid, x + 1, y);
88 -
89 - if (!realCellElm) {
90 - realCellElm = findRealElm(grid, 0, y);
91 - realCellElm.parentNode.appendChild(newCell);
92 - } else {
93 - realCellElm.parentNode.insertBefore(newCell, realCellElm);
94 - }
95 - };
96 -
97 - var splitAbove = function (grid, info, x, y) {
98 - if (info.above !== 0) {
99 - Utils.setRowSpan(info.elm, info.above);
100 - var cell = createCell(info, info.below + 1);
101 - insertOrAppendCell(grid, cell, x, y);
102 - return cell;
103 - }
104 -
105 - return null;
106 - };
107 -
108 - var splitBelow = function (grid, info, x, y) {
109 - if (info.below !== 0) {
110 - Utils.setRowSpan(info.elm, info.above + 1);
111 - var cell = createCell(info, info.below);
112 - insertOrAppendCell(grid, cell, x, y + 1);
113 - return cell;
114 - }
115 -
116 - return null;
117 - };
118 -
119 - var splitAt = function (grid, x, y, before) {
120 - var rowInfos = getRowSplitInfo(grid, y);
121 - var rowElm = getCellElmAt(grid, x, y).parentNode;
122 - var cells = [];
123 -
124 - Tools.each(rowInfos, function (info, x) {
125 - var cell = before ? splitAbove(grid, info, x, y) : splitBelow(grid, info, x, y);
126 - if (cell !== null) {
127 - cells.push(cells);
128 - }
129 - });
130 -
131 - return {
132 - cells: cells,
133 - row: rowElm
134 - };
135 - };
136 -
137 - return {
138 - splitAt: splitAt
139 - };
140 -});
1 -/**
2 - * Utils.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/**
12 - * Various utility functions.
13 - *
14 - * @class tinymce.tableplugin.Utils
15 - * @private
16 - */
17 -define("tinymce/tableplugin/Utils", [
18 - "tinymce/Env"
19 -], function(Env) {
20 - var setSpanVal = function (name) {
21 - return function (td, val) {
22 - if (td) {
23 - val = parseInt(val, 10);
24 -
25 - if (val === 1 || val === 0) {
26 - td.removeAttribute(name, 1);
27 - } else {
28 - td.setAttribute(name, val, 1);
29 - }
30 - }
31 - };
32 - };
33 -
34 - var getSpanVal = function (name) {
35 - return function (td) {
36 - return parseInt(td.getAttribute(name) || 1, 10);
37 - };
38 - };
39 -
40 - function paddCell(cell) {
41 - if (!Env.ie || Env.ie > 9) {
42 - if (!cell.hasChildNodes()) {
43 - cell.innerHTML = '<br data-mce-bogus="1" />';
44 - }
45 - }
46 - }
47 -
48 - return {
49 - setColSpan: setSpanVal('colSpan'),
50 - setRowSpan: setSpanVal('rowspan'),
51 - getColSpan: getSpanVal('colSpan'),
52 - getRowSpan: getSpanVal('rowSpan'),
53 - setSpanVal: function (td, name, value) {
54 - setSpanVal(name)(td, value);
55 - },
56 - getSpanVal: function (td, name) {
57 - return getSpanVal(name)(td);
58 - },
59 - paddCell: paddCell
60 - };
61 -});
1 -/**
2 - * Inline development version. Only to be used while developing since it uses document.write to load scripts.
3 - */
4 -
5 -/*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */
6 -/*globals $code */
7 -
8 -(function(exports) {
9 - "use strict";
10 -
11 - var html = "", baseDir;
12 - var modules = {}, exposedModules = [], moduleCount = 0;
13 -
14 - var scripts = document.getElementsByTagName('script');
15 - for (var i = 0; i < scripts.length; i++) {
16 - var src = scripts[i].src;
17 -
18 - if (src.indexOf('/plugin.dev.js') != -1) {
19 - baseDir = src.substring(0, src.lastIndexOf('/'));
20 - }
21 - }
22 -
23 - function require(ids, callback) {
24 - var module, defs = [];
25 -
26 - for (var i = 0; i < ids.length; ++i) {
27 - module = modules[ids[i]] || resolve(ids[i]);
28 - if (!module) {
29 - throw 'module definition dependecy not found: ' + ids[i];
30 - }
31 -
32 - defs.push(module);
33 - }
34 -
35 - callback.apply(null, defs);
36 - }
37 -
38 - function resolve(id) {
39 - if (exports.privateModules && id in exports.privateModules) {
40 - return;
41 - }
42 -
43 - var target = exports;
44 - var fragments = id.split(/[.\/]/);
45 -
46 - for (var fi = 0; fi < fragments.length; ++fi) {
47 - if (!target[fragments[fi]]) {
48 - return;
49 - }
50 -
51 - target = target[fragments[fi]];
52 - }
53 -
54 - return target;
55 - }
56 -
57 - function register(id) {
58 - var target = exports;
59 - var fragments = id.split(/[.\/]/);
60 -
61 - for (var fi = 0; fi < fragments.length - 1; ++fi) {
62 - if (target[fragments[fi]] === undefined) {
63 - target[fragments[fi]] = {};
64 - }
65 -
66 - target = target[fragments[fi]];
67 - }
68 -
69 - target[fragments[fragments.length - 1]] = modules[id];
70 - }
71 -
72 - function define(id, dependencies, definition) {
73 - var privateModules, i;
74 -
75 - if (typeof id !== 'string') {
76 - throw 'invalid module definition, module id must be defined and be a string';
77 - }
78 -
79 - if (dependencies === undefined) {
80 - throw 'invalid module definition, dependencies must be specified';
81 - }
82 -
83 - if (definition === undefined) {
84 - throw 'invalid module definition, definition function must be specified';
85 - }
86 -
87 - require(dependencies, function() {
88 - modules[id] = definition.apply(null, arguments);
89 - });
90 -
91 - if (--moduleCount === 0) {
92 - for (i = 0; i < exposedModules.length; i++) {
93 - register(exposedModules[i]);
94 - }
95 - }
96 -
97 - // Expose private modules for unit tests
98 - if (exports.AMDLC_TESTS) {
99 - privateModules = exports.privateModules || {};
100 -
101 - for (id in modules) {
102 - privateModules[id] = modules[id];
103 - }
104 -
105 - for (i = 0; i < exposedModules.length; i++) {
106 - delete privateModules[exposedModules[i]];
107 - }
108 -
109 - exports.privateModules = privateModules;
110 - }
111 -
112 - }
113 -
114 - function expose(ids) {
115 - exposedModules = ids;
116 - }
117 -
118 - function writeScripts() {
119 - document.write(html);
120 - }
121 -
122 - function load(path) {
123 - html += '<script type="text/javascript" src="' + baseDir + '/' + path + '"></script>\n';
124 - moduleCount++;
125 - }
126 -
127 - // Expose globally
128 - exports.define = define;
129 - exports.require = require;
130 -
131 - load('classes/Utils.js');
132 - load('classes/SplitCols.js');
133 - load('classes/TableGrid.js');
134 - load('classes/Quirks.js');
135 - load('classes/CellSelection.js');
136 - load('classes/Dialogs.js');
137 - load('classes/ResizeBars.js');
138 - load('classes/Plugin.js');
139 -
140 - writeScripts();
141 -})(this);
142 -
143 -// $hash: 0b5b0a5cbb1bb45bfd79c5a1388e01ff
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*global tinymce:true */
12 -
13 -tinymce.PluginManager.add('template', function(editor) {
14 - var each = tinymce.each;
15 -
16 - function createTemplateList(callback) {
17 - return function() {
18 - var templateList = editor.settings.templates;
19 -
20 - if (typeof templateList == "function") {
21 - templateList(callback);
22 - return;
23 - }
24 -
25 - if (typeof templateList == "string") {
26 - tinymce.util.XHR.send({
27 - url: templateList,
28 - success: function(text) {
29 - callback(tinymce.util.JSON.parse(text));
30 - }
31 - });
32 - } else {
33 - callback(templateList);
34 - }
35 - };
36 - }
37 -
38 - function showDialog(templateList) {
39 - var win, values = [], templateHtml;
40 -
41 - if (!templateList || templateList.length === 0) {
42 - var message = editor.translate('No templates defined.');
43 - editor.notificationManager.open({text: message, type: 'info'});
44 - return;
45 - }
46 -
47 - tinymce.each(templateList, function(template) {
48 - values.push({
49 - selected: !values.length,
50 - text: template.title,
51 - value: {
52 - url: template.url,
53 - content: template.content,
54 - description: template.description
55 - }
56 - });
57 - });
58 -
59 - function onSelectTemplate(e) {
60 - var value = e.control.value();
61 -
62 - function insertIframeHtml(html) {
63 - if (html.indexOf('<html>') == -1) {
64 - var contentCssLinks = '';
65 -
66 - tinymce.each(editor.contentCSS, function(url) {
67 - contentCssLinks += '<link type="text/css" rel="stylesheet" href="' + editor.documentBaseURI.toAbsolute(url) + '">';
68 - });
69 -
70 - var bodyClass = editor.settings.body_class || '';
71 - if (bodyClass.indexOf('=') != -1) {
72 - bodyClass = editor.getParam('body_class', '', 'hash');
73 - bodyClass = bodyClass[editor.id] || '';
74 - }
75 -
76 - html = (
77 - '<!DOCTYPE html>' +
78 - '<html>' +
79 - '<head>' +
80 - contentCssLinks +
81 - '</head>' +
82 - '<body class="' + bodyClass + '">' +
83 - html +
84 - '</body>' +
85 - '</html>'
86 - );
87 - }
88 -
89 - html = replaceTemplateValues(html, 'template_preview_replace_values');
90 -
91 - var doc = win.find('iframe')[0].getEl().contentWindow.document;
92 - doc.open();
93 - doc.write(html);
94 - doc.close();
95 - }
96 -
97 - if (value.url) {
98 - tinymce.util.XHR.send({
99 - url: value.url,
100 - success: function(html) {
101 - templateHtml = html;
102 - insertIframeHtml(templateHtml);
103 - }
104 - });
105 - } else {
106 - templateHtml = value.content;
107 - insertIframeHtml(templateHtml);
108 - }
109 -
110 - win.find('#description')[0].text(e.control.value().description);
111 - }
112 -
113 - win = editor.windowManager.open({
114 - title: 'Insert template',
115 - layout: 'flex',
116 - direction: 'column',
117 - align: 'stretch',
118 - padding: 15,
119 - spacing: 10,
120 -
121 - items: [
122 - {type: 'form', flex: 0, padding: 0, items: [
123 - {type: 'container', label: 'Templates', items: {
124 - type: 'listbox', label: 'Templates', name: 'template', values: values, onselect: onSelectTemplate
125 - }}
126 - ]},
127 - {type: 'label', name: 'description', label: 'Description', text: '\u00a0'},
128 - {type: 'iframe', flex: 1, border: 1}
129 - ],
130 -
131 - onsubmit: function() {
132 - insertTemplate(false, templateHtml);
133 - },
134 -
135 - minWidth: Math.min(tinymce.DOM.getViewPort().w, editor.getParam('template_popup_width', 600)),
136 - minHeight: Math.min(tinymce.DOM.getViewPort().h, editor.getParam('template_popup_height', 500))
137 - });
138 -
139 - win.find('listbox')[0].fire('select');
140 - }
141 -
142 - function getDateTime(fmt, date) {
143 - var daysShort = "Sun Mon Tue Wed Thu Fri Sat Sun".split(' ');
144 - var daysLong = "Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(' ');
145 - var monthsShort = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(' ');
146 - var monthsLong = "January February March April May June July August September October November December".split(' ');
147 -
148 - function addZeros(value, len) {
149 - value = "" + value;
150 -
151 - if (value.length < len) {
152 - for (var i = 0; i < (len - value.length); i++) {
153 - value = "0" + value;
154 - }
155 - }
156 -
157 - return value;
158 - }
159 -
160 - date = date || new Date();
161 -
162 - fmt = fmt.replace("%D", "%m/%d/%Y");
163 - fmt = fmt.replace("%r", "%I:%M:%S %p");
164 - fmt = fmt.replace("%Y", "" + date.getFullYear());
165 - fmt = fmt.replace("%y", "" + date.getYear());
166 - fmt = fmt.replace("%m", addZeros(date.getMonth() + 1, 2));
167 - fmt = fmt.replace("%d", addZeros(date.getDate(), 2));
168 - fmt = fmt.replace("%H", "" + addZeros(date.getHours(), 2));
169 - fmt = fmt.replace("%M", "" + addZeros(date.getMinutes(), 2));
170 - fmt = fmt.replace("%S", "" + addZeros(date.getSeconds(), 2));
171 - fmt = fmt.replace("%I", "" + ((date.getHours() + 11) % 12 + 1));
172 - fmt = fmt.replace("%p", "" + (date.getHours() < 12 ? "AM" : "PM"));
173 - fmt = fmt.replace("%B", "" + editor.translate(monthsLong[date.getMonth()]));
174 - fmt = fmt.replace("%b", "" + editor.translate(monthsShort[date.getMonth()]));
175 - fmt = fmt.replace("%A", "" + editor.translate(daysLong[date.getDay()]));
176 - fmt = fmt.replace("%a", "" + editor.translate(daysShort[date.getDay()]));
177 - fmt = fmt.replace("%%", "%");
178 -
179 - return fmt;
180 - }
181 -
182 - function replaceVals(e) {
183 - var dom = editor.dom, vl = editor.getParam('template_replace_values');
184 -
185 - each(dom.select('*', e), function(e) {
186 - each(vl, function(v, k) {
187 - if (dom.hasClass(e, k)) {
188 - if (typeof vl[k] == 'function') {
189 - vl[k](e);
190 - }
191 - }
192 - });
193 - });
194 - }
195 -
196 - function replaceTemplateValues(html, templateValuesOptionName) {
197 - each(editor.getParam(templateValuesOptionName), function(v, k) {
198 - if (typeof v == 'function') {
199 - v = v(k);
200 - }
201 -
202 - html = html.replace(new RegExp('\\{\\$' + k + '\\}', 'g'), v);
203 - });
204 -
205 - return html;
206 - }
207 -
208 - function insertTemplate(ui, html) {
209 - var el, n, dom = editor.dom, sel = editor.selection.getContent();
210 -
211 - html = replaceTemplateValues(html, 'template_replace_values');
212 - el = dom.create('div', null, html);
213 -
214 - // Find template element within div
215 - n = dom.select('.mceTmpl', el);
216 - if (n && n.length > 0) {
217 - el = dom.create('div', null);
218 - el.appendChild(n[0].cloneNode(true));
219 - }
220 -
221 - function hasClass(n, c) {
222 - return new RegExp('\\b' + c + '\\b', 'g').test(n.className);
223 - }
224 -
225 - each(dom.select('*', el), function(n) {
226 - // Replace cdate
227 - if (hasClass(n, editor.getParam('template_cdate_classes', 'cdate').replace(/\s+/g, '|'))) {
228 - n.innerHTML = getDateTime(editor.getParam("template_cdate_format", editor.getLang("template.cdate_format")));
229 - }
230 -
231 - // Replace mdate
232 - if (hasClass(n, editor.getParam('template_mdate_classes', 'mdate').replace(/\s+/g, '|'))) {
233 - n.innerHTML = getDateTime(editor.getParam("template_mdate_format", editor.getLang("template.mdate_format")));
234 - }
235 -
236 - // Replace selection
237 - if (hasClass(n, editor.getParam('template_selected_content_classes', 'selcontent').replace(/\s+/g, '|'))) {
238 - n.innerHTML = sel;
239 - }
240 - });
241 -
242 - replaceVals(el);
243 -
244 - editor.execCommand('mceInsertContent', false, el.innerHTML);
245 - editor.addVisual();
246 - }
247 -
248 - editor.addCommand('mceInsertTemplate', insertTemplate);
249 -
250 - editor.addButton('template', {
251 - title: 'Insert template',
252 - onclick: createTemplateList(showDialog)
253 - });
254 -
255 - editor.addMenuItem('template', {
256 - text: 'Insert template',
257 - onclick: createTemplateList(showDialog),
258 - context: 'insert'
259 - });
260 -
261 - editor.on('PreProcess', function(o) {
262 - var dom = editor.dom;
263 -
264 - each(dom.select('div', o.node), function(e) {
265 - if (dom.hasClass(e, 'mceTmpl')) {
266 - each(dom.select('*', e), function(e) {
267 - if (dom.hasClass(e, editor.getParam('template_mdate_classes', 'mdate').replace(/\s+/g, '|'))) {
268 - e.innerHTML = getDateTime(editor.getParam("template_mdate_format", editor.getLang("template.mdate_format")));
269 - }
270 - });
271 -
272 - replaceVals(e);
273 - }
274 - });
275 - });
276 -});
1 -tinymce.PluginManager.add("template",function(a){function b(b){return function(){var c=a.settings.templates;return"function"==typeof c?void c(b):void("string"==typeof c?tinymce.util.XHR.send({url:c,success:function(a){b(tinymce.util.JSON.parse(a))}}):b(c))}}function c(b){function c(b){function c(b){if(-1==b.indexOf("<html>")){var c="";tinymce.each(a.contentCSS,function(b){c+='<link type="text/css" rel="stylesheet" href="'+a.documentBaseURI.toAbsolute(b)+'">'});var e=a.settings.body_class||"";-1!=e.indexOf("=")&&(e=a.getParam("body_class","","hash"),e=e[a.id]||""),b="<!DOCTYPE html><html><head>"+c+'</head><body class="'+e+'">'+b+"</body></html>"}b=f(b,"template_preview_replace_values");var g=d.find("iframe")[0].getEl().contentWindow.document;g.open(),g.write(b),g.close()}var g=b.control.value();g.url?tinymce.util.XHR.send({url:g.url,success:function(a){e=a,c(e)}}):(e=g.content,c(e)),d.find("#description")[0].text(b.control.value().description)}var d,e,h=[];if(!b||0===b.length){var i=a.translate("No templates defined.");return void a.notificationManager.open({text:i,type:"info"})}tinymce.each(b,function(a){h.push({selected:!h.length,text:a.title,value:{url:a.url,content:a.content,description:a.description}})}),d=a.windowManager.open({title:"Insert template",layout:"flex",direction:"column",align:"stretch",padding:15,spacing:10,items:[{type:"form",flex:0,padding:0,items:[{type:"container",label:"Templates",items:{type:"listbox",label:"Templates",name:"template",values:h,onselect:c}}]},{type:"label",name:"description",label:"Description",text:"\xa0"},{type:"iframe",flex:1,border:1}],onsubmit:function(){g(!1,e)},minWidth:Math.min(tinymce.DOM.getViewPort().w,a.getParam("template_popup_width",600)),minHeight:Math.min(tinymce.DOM.getViewPort().h,a.getParam("template_popup_height",500))}),d.find("listbox")[0].fire("select")}function d(b,c){function d(a,b){if(a=""+a,a.length<b)for(var c=0;c<b-a.length;c++)a="0"+a;return a}var e="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),f="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),g="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),h="January February March April May June July August September October November December".split(" ");return c=c||new Date,b=b.replace("%D","%m/%d/%Y"),b=b.replace("%r","%I:%M:%S %p"),b=b.replace("%Y",""+c.getFullYear()),b=b.replace("%y",""+c.getYear()),b=b.replace("%m",d(c.getMonth()+1,2)),b=b.replace("%d",d(c.getDate(),2)),b=b.replace("%H",""+d(c.getHours(),2)),b=b.replace("%M",""+d(c.getMinutes(),2)),b=b.replace("%S",""+d(c.getSeconds(),2)),b=b.replace("%I",""+((c.getHours()+11)%12+1)),b=b.replace("%p",""+(c.getHours()<12?"AM":"PM")),b=b.replace("%B",""+a.translate(h[c.getMonth()])),b=b.replace("%b",""+a.translate(g[c.getMonth()])),b=b.replace("%A",""+a.translate(f[c.getDay()])),b=b.replace("%a",""+a.translate(e[c.getDay()])),b=b.replace("%%","%")}function e(b){var c=a.dom,d=a.getParam("template_replace_values");h(c.select("*",b),function(a){h(d,function(b,e){c.hasClass(a,e)&&"function"==typeof d[e]&&d[e](a)})})}function f(b,c){return h(a.getParam(c),function(a,c){"function"==typeof a&&(a=a(c)),b=b.replace(new RegExp("\\{\\$"+c+"\\}","g"),a)}),b}function g(b,c){function g(a,b){return new RegExp("\\b"+b+"\\b","g").test(a.className)}var i,j,k=a.dom,l=a.selection.getContent();c=f(c,"template_replace_values"),i=k.create("div",null,c),j=k.select(".mceTmpl",i),j&&j.length>0&&(i=k.create("div",null),i.appendChild(j[0].cloneNode(!0))),h(k.select("*",i),function(b){g(b,a.getParam("template_cdate_classes","cdate").replace(/\s+/g,"|"))&&(b.innerHTML=d(a.getParam("template_cdate_format",a.getLang("template.cdate_format")))),g(b,a.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(b.innerHTML=d(a.getParam("template_mdate_format",a.getLang("template.mdate_format")))),g(b,a.getParam("template_selected_content_classes","selcontent").replace(/\s+/g,"|"))&&(b.innerHTML=l)}),e(i),a.execCommand("mceInsertContent",!1,i.innerHTML),a.addVisual()}var h=tinymce.each;a.addCommand("mceInsertTemplate",g),a.addButton("template",{title:"Insert template",onclick:b(c)}),a.addMenuItem("template",{text:"Insert template",onclick:b(c),context:"insert"}),a.on("PreProcess",function(b){var c=a.dom;h(c.select("div",b.node),function(b){c.hasClass(b,"mceTmpl")&&(h(c.select("*",b),function(b){c.hasClass(b,a.getParam("template_mdate_classes","mdate").replace(/\s+/g,"|"))&&(b.innerHTML=d(a.getParam("template_mdate_format",a.getLang("template.mdate_format"))))}),e(b))})})});
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*global tinymce:true */
12 -/*eslint consistent-this:0 */
13 -
14 -tinymce.PluginManager.add('textcolor', function(editor) {
15 - var cols, rows;
16 -
17 - rows = {
18 - forecolor: editor.settings.forecolor_rows || editor.settings.textcolor_rows || 5,
19 - backcolor: editor.settings.backcolor_rows || editor.settings.textcolor_rows || 5
20 - };
21 - cols = {
22 - forecolor: editor.settings.forecolor_cols || editor.settings.textcolor_cols || 8,
23 - backcolor: editor.settings.backcolor_cols || editor.settings.textcolor_cols || 8
24 - };
25 -
26 - function getCurrentColor(format) {
27 - var color;
28 -
29 - editor.dom.getParents(editor.selection.getStart(), function(elm) {
30 - var value;
31 -
32 - if ((value = elm.style[format == 'forecolor' ? 'color' : 'background-color'])) {
33 - color = value;
34 - }
35 - });
36 -
37 - return color;
38 - }
39 -
40 - function mapColors(type) {
41 - var i, colors = [], colorMap;
42 -
43 - colorMap = [
44 - "000000", "Black",
45 - "993300", "Burnt orange",
46 - "333300", "Dark olive",
47 - "003300", "Dark green",
48 - "003366", "Dark azure",
49 - "000080", "Navy Blue",
50 - "333399", "Indigo",
51 - "333333", "Very dark gray",
52 - "800000", "Maroon",
53 - "FF6600", "Orange",
54 - "808000", "Olive",
55 - "008000", "Green",
56 - "008080", "Teal",
57 - "0000FF", "Blue",
58 - "666699", "Grayish blue",
59 - "808080", "Gray",
60 - "FF0000", "Red",
61 - "FF9900", "Amber",
62 - "99CC00", "Yellow green",
63 - "339966", "Sea green",
64 - "33CCCC", "Turquoise",
65 - "3366FF", "Royal blue",
66 - "800080", "Purple",
67 - "999999", "Medium gray",
68 - "FF00FF", "Magenta",
69 - "FFCC00", "Gold",
70 - "FFFF00", "Yellow",
71 - "00FF00", "Lime",
72 - "00FFFF", "Aqua",
73 - "00CCFF", "Sky blue",
74 - "993366", "Red violet",
75 - "FFFFFF", "White",
76 - "FF99CC", "Pink",
77 - "FFCC99", "Peach",
78 - "FFFF99", "Light yellow",
79 - "CCFFCC", "Pale green",
80 - "CCFFFF", "Pale cyan",
81 - "99CCFF", "Light sky blue",
82 - "CC99FF", "Plum"
83 - ];
84 -
85 - colorMap = editor.settings.textcolor_map || colorMap;
86 - colorMap = editor.settings[type + '_map'] || colorMap;
87 -
88 - for (i = 0; i < colorMap.length; i += 2) {
89 - colors.push({
90 - text: colorMap[i + 1],
91 - color: '#' + colorMap[i]
92 - });
93 - }
94 -
95 - return colors;
96 - }
97 -
98 - function renderColorPicker() {
99 - var ctrl = this, colors, color, html, last, x, y, i, id = ctrl._id, count = 0, type;
100 -
101 - type = ctrl.settings.origin;
102 -
103 - function getColorCellHtml(color, title) {
104 - var isNoColor = color == 'transparent';
105 -
106 - return (
107 - '<td class="mce-grid-cell' + (isNoColor ? ' mce-colorbtn-trans' : '') + '">' +
108 - '<div id="' + id + '-' + (count++) + '"' +
109 - ' data-mce-color="' + (color ? color : '') + '"' +
110 - ' role="option"' +
111 - ' tabIndex="-1"' +
112 - ' style="' + (color ? 'background-color: ' + color : '') + '"' +
113 - ' title="' + tinymce.translate(title) + '">' +
114 - (isNoColor ? '&#215;' : '') +
115 - '</div>' +
116 - '</td>'
117 - );
118 - }
119 -
120 - colors = mapColors(type);
121 - colors.push({
122 - text: tinymce.translate("No color"),
123 - color: "transparent"
124 - });
125 -
126 - html = '<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>';
127 - last = colors.length - 1;
128 -
129 - for (y = 0; y < rows[type]; y++) {
130 - html += '<tr>';
131 -
132 - for (x = 0; x < cols[type]; x++) {
133 - i = y * cols[type] + x;
134 -
135 - if (i > last) {
136 - html += '<td></td>';
137 - } else {
138 - color = colors[i];
139 - html += getColorCellHtml(color.color, color.text);
140 - }
141 - }
142 -
143 - html += '</tr>';
144 - }
145 -
146 - if (editor.settings.color_picker_callback) {
147 - html += (
148 - '<tr>' +
149 - '<td colspan="' + cols[type] + '" class="mce-custom-color-btn">' +
150 - '<div id="' + id + '-c" class="mce-widget mce-btn mce-btn-small mce-btn-flat" ' +
151 - 'role="button" tabindex="-1" aria-labelledby="' + id + '-c" style="width: 100%">' +
152 - '<button type="button" role="presentation" tabindex="-1">' + tinymce.translate('Custom...') + '</button>' +
153 - '</div>' +
154 - '</td>' +
155 - '</tr>'
156 - );
157 -
158 - html += '<tr>';
159 -
160 - for (x = 0; x < cols[type]; x++) {
161 - html += getColorCellHtml('', 'Custom color');
162 - }
163 -
164 - html += '</tr>';
165 - }
166 -
167 - html += '</tbody></table>';
168 -
169 - return html;
170 - }
171 -
172 - function applyFormat(format, value) {
173 - editor.undoManager.transact(function() {
174 - editor.focus();
175 - editor.formatter.apply(format, {value: value});
176 - editor.nodeChanged();
177 - });
178 - }
179 -
180 - function removeFormat(format) {
181 - editor.undoManager.transact(function() {
182 - editor.focus();
183 - editor.formatter.remove(format, {value: null}, null, true);
184 - editor.nodeChanged();
185 - });
186 - }
187 -
188 - function onPanelClick(e) {
189 - var buttonCtrl = this.parent(), value, type;
190 -
191 - type = buttonCtrl.settings.origin;
192 -
193 - function selectColor(value) {
194 - buttonCtrl.hidePanel();
195 - buttonCtrl.color(value);
196 - applyFormat(buttonCtrl.settings.format, value);
197 - }
198 -
199 - function resetColor() {
200 - buttonCtrl.hidePanel();
201 - buttonCtrl.resetColor();
202 - removeFormat(buttonCtrl.settings.format);
203 - }
204 -
205 - function setDivColor(div, value) {
206 - div.style.background = value;
207 - div.setAttribute('data-mce-color', value);
208 - }
209 -
210 - if (tinymce.DOM.getParent(e.target, '.mce-custom-color-btn')) {
211 - buttonCtrl.hidePanel();
212 -
213 - editor.settings.color_picker_callback.call(editor, function(value) {
214 - var tableElm = buttonCtrl.panel.getEl().getElementsByTagName('table')[0];
215 - var customColorCells, div, i;
216 -
217 - customColorCells = tinymce.map(tableElm.rows[tableElm.rows.length - 1].childNodes, function(elm) {
218 - return elm.firstChild;
219 - });
220 -
221 - for (i = 0; i < customColorCells.length; i++) {
222 - div = customColorCells[i];
223 - if (!div.getAttribute('data-mce-color')) {
224 - break;
225 - }
226 - }
227 -
228 - // Shift colors to the right
229 - // TODO: Might need to be the left on RTL
230 - if (i == cols[type]) {
231 - for (i = 0; i < cols[type] - 1; i++) {
232 - setDivColor(customColorCells[i], customColorCells[i + 1].getAttribute('data-mce-color'));
233 - }
234 - }
235 -
236 - setDivColor(div, value);
237 - selectColor(value);
238 - }, getCurrentColor(buttonCtrl.settings.format));
239 - }
240 -
241 - value = e.target.getAttribute('data-mce-color');
242 - if (value) {
243 - if (this.lastId) {
244 - document.getElementById(this.lastId).setAttribute('aria-selected', false);
245 - }
246 -
247 - e.target.setAttribute('aria-selected', true);
248 - this.lastId = e.target.id;
249 -
250 - if (value == 'transparent') {
251 - resetColor();
252 - } else {
253 - selectColor(value);
254 - }
255 - } else if (value !== null) {
256 - buttonCtrl.hidePanel();
257 - }
258 - }
259 -
260 - function onButtonClick() {
261 - var self = this;
262 -
263 - if (self._color) {
264 - applyFormat(self.settings.format, self._color);
265 - } else {
266 - removeFormat(self.settings.format);
267 - }
268 - }
269 -
270 - editor.addButton('forecolor', {
271 - type: 'colorbutton',
272 - tooltip: 'Text color',
273 - format: 'forecolor',
274 - panel: {
275 - origin: 'forecolor',
276 - role: 'application',
277 - ariaRemember: true,
278 - html: renderColorPicker,
279 - onclick: onPanelClick
280 - },
281 - onclick: onButtonClick
282 - });
283 -
284 - editor.addButton('backcolor', {
285 - type: 'colorbutton',
286 - tooltip: 'Background color',
287 - format: 'hilitecolor',
288 - panel: {
289 - origin: 'backcolor',
290 - role: 'application',
291 - ariaRemember: true,
292 - html: renderColorPicker,
293 - onclick: onPanelClick
294 - },
295 - onclick: onButtonClick
296 - });
297 -});
1 -tinymce.PluginManager.add("textcolor",function(a){function b(b){var c;return a.dom.getParents(a.selection.getStart(),function(a){var d;(d=a.style["forecolor"==b?"color":"background-color"])&&(c=d)}),c}function c(b){var c,d,e=[];for(d=["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"],d=a.settings.textcolor_map||d,d=a.settings[b+"_map"]||d,c=0;c<d.length;c+=2)e.push({text:d[c+1],color:"#"+d[c]});return e}function d(){function b(a,b){var c="transparent"==a;return'<td class="mce-grid-cell'+(c?" mce-colorbtn-trans":"")+'"><div id="'+o+"-"+p++ +'" data-mce-color="'+(a?a:"")+'" role="option" tabIndex="-1" style="'+(a?"background-color: "+a:"")+'" title="'+tinymce.translate(b)+'">'+(c?"&#215;":"")+"</div></td>"}var d,e,f,g,h,k,l,m,n=this,o=n._id,p=0;for(m=n.settings.origin,d=c(m),d.push({text:tinymce.translate("No color"),color:"transparent"}),f='<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>',g=d.length-1,k=0;k<j[m];k++){for(f+="<tr>",h=0;h<i[m];h++)l=k*i[m]+h,l>g?f+="<td></td>":(e=d[l],f+=b(e.color,e.text));f+="</tr>"}if(a.settings.color_picker_callback){for(f+='<tr><td colspan="'+i[m]+'" class="mce-custom-color-btn"><div id="'+o+'-c" class="mce-widget mce-btn mce-btn-small mce-btn-flat" role="button" tabindex="-1" aria-labelledby="'+o+'-c" style="width: 100%"><button type="button" role="presentation" tabindex="-1">'+tinymce.translate("Custom...")+"</button></div></td></tr>",f+="<tr>",h=0;h<i[m];h++)f+=b("","Custom color");f+="</tr>"}return f+="</tbody></table>"}function e(b,c){a.undoManager.transact(function(){a.focus(),a.formatter.apply(b,{value:c}),a.nodeChanged()})}function f(b){a.undoManager.transact(function(){a.focus(),a.formatter.remove(b,{value:null},null,!0),a.nodeChanged()})}function g(c){function d(a){l.hidePanel(),l.color(a),e(l.settings.format,a)}function g(){l.hidePanel(),l.resetColor(),f(l.settings.format)}function h(a,b){a.style.background=b,a.setAttribute("data-mce-color",b)}var j,k,l=this.parent();k=l.settings.origin,tinymce.DOM.getParent(c.target,".mce-custom-color-btn")&&(l.hidePanel(),a.settings.color_picker_callback.call(a,function(a){var b,c,e,f=l.panel.getEl().getElementsByTagName("table")[0];for(b=tinymce.map(f.rows[f.rows.length-1].childNodes,function(a){return a.firstChild}),e=0;e<b.length&&(c=b[e],c.getAttribute("data-mce-color"));e++);if(e==i[k])for(e=0;e<i[k]-1;e++)h(b[e],b[e+1].getAttribute("data-mce-color"));h(c,a),d(a)},b(l.settings.format))),j=c.target.getAttribute("data-mce-color"),j?(this.lastId&&document.getElementById(this.lastId).setAttribute("aria-selected",!1),c.target.setAttribute("aria-selected",!0),this.lastId=c.target.id,"transparent"==j?g():d(j)):null!==j&&l.hidePanel()}function h(){var a=this;a._color?e(a.settings.format,a._color):f(a.settings.format)}var i,j;j={forecolor:a.settings.forecolor_rows||a.settings.textcolor_rows||5,backcolor:a.settings.backcolor_rows||a.settings.textcolor_rows||5},i={forecolor:a.settings.forecolor_cols||a.settings.textcolor_cols||8,backcolor:a.settings.backcolor_cols||a.settings.textcolor_cols||8},a.addButton("forecolor",{type:"colorbutton",tooltip:"Text color",format:"forecolor",panel:{origin:"forecolor",role:"application",ariaRemember:!0,html:d,onclick:g},onclick:h}),a.addButton("backcolor",{type:"colorbutton",tooltip:"Background color",format:"hilitecolor",panel:{origin:"backcolor",role:"application",ariaRemember:!0,html:d,onclick:g},onclick:h})});
...\ No newline at end of file ...\ No newline at end of file
1 -/**
2 - * plugin.js
3 - *
4 - * Released under LGPL License.
5 - * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
6 - *
7 - * License: http://www.tinymce.com/license
8 - * Contributing: http://www.tinymce.com/contributing
9 - */
10 -
11 -/*global tinymce:true */
12 -
13 -tinymce.PluginManager.add('textpattern', function(editor) {
14 - var isPatternsDirty = true, patterns;
15 -
16 - patterns = editor.settings.textpattern_patterns || [
17 - {start: '*', end: '*', format: 'italic'},
18 - {start: '**', end: '**', format: 'bold'},
19 - {start: '#', format: 'h1'},
20 - {start: '##', format: 'h2'},
21 - {start: '###', format: 'h3'},
22 - {start: '####', format: 'h4'},
23 - {start: '#####', format: 'h5'},
24 - {start: '######', format: 'h6'},
25 - {start: '1. ', cmd: 'InsertOrderedList'},
26 - {start: '* ', cmd: 'InsertUnorderedList'},
27 - {start: '- ', cmd: 'InsertUnorderedList'}
28 - ];
29 -
30 - // Returns a sorted patterns list, ordered descending by start length
31 - function getPatterns() {
32 - if (isPatternsDirty) {
33 - patterns.sort(function(a, b) {
34 - if (a.start.length > b.start.length) {
35 - return -1;
36 - }
37 -
38 - if (a.start.length < b.start.length) {
39 - return 1;
40 - }
41 -
42 - return 0;
43 - });
44 -
45 - isPatternsDirty = false;
46 - }
47 -
48 - return patterns;
49 - }
50 -
51 - // Finds a matching pattern to the specified text
52 - function findPattern(text) {
53 - var patterns = getPatterns();
54 -
55 - for (var i = 0; i < patterns.length; i++) {
56 - if (text.indexOf(patterns[i].start) !== 0) {
57 - continue;
58 - }
59 -
60 - if (patterns[i].end && text.lastIndexOf(patterns[i].end) != text.length - patterns[i].end.length) {
61 - continue;
62 - }
63 -
64 - return patterns[i];
65 - }
66 - }
67 -
68 - // Finds the best matching end pattern
69 - function findEndPattern(text, offset, delta) {
70 - var patterns, pattern, i;
71 -
72 - // Find best matching end
73 - patterns = getPatterns();
74 - for (i = 0; i < patterns.length; i++) {
75 - pattern = patterns[i];
76 - if (pattern.end && text.substr(offset - pattern.end.length - delta, pattern.end.length) == pattern.end) {
77 - return pattern;
78 - }
79 - }
80 - }
81 -
82 - // Handles inline formats like *abc* and **abc**
83 - function applyInlineFormat(space) {
84 - var selection, dom, rng, container, offset, startOffset, text, patternRng, pattern, delta, format;
85 -
86 - function splitContainer() {
87 - // Split text node and remove start/end from text node
88 - container = container.splitText(startOffset);
89 - container.splitText(offset - startOffset - delta);
90 - container.deleteData(0, pattern.start.length);
91 - container.deleteData(container.data.length - pattern.end.length, pattern.end.length);
92 - }
93 -
94 - selection = editor.selection;
95 - dom = editor.dom;
96 -
97 - if (!selection.isCollapsed()) {
98 - return;
99 - }
100 -
101 - rng = selection.getRng(true);
102 - container = rng.startContainer;
103 - offset = rng.startOffset;
104 - text = container.data;
105 - delta = space ? 1 : 0;
106 -
107 - if (container.nodeType != 3) {
108 - return;
109 - }
110 -
111 - // Find best matching end
112 - pattern = findEndPattern(text, offset, delta);
113 - if (!pattern) {
114 - return;
115 - }
116 -
117 - // Find start of matched pattern
118 - // TODO: Might need to improve this if there is nested formats
119 - startOffset = Math.max(0, offset - delta);
120 - startOffset = text.lastIndexOf(pattern.start, startOffset - pattern.end.length - 1);
121 -
122 - if (startOffset === -1) {
123 - return;
124 - }
125 -
126 - // Setup a range for the matching word
127 - patternRng = dom.createRng();
128 - patternRng.setStart(container, startOffset);
129 - patternRng.setEnd(container, offset - delta);
130 - pattern = findPattern(patternRng.toString());
131 -
132 - if (!pattern || !pattern.end) {
133 - return;
134 - }
135 -
136 - // If container match doesn't have anything between start/end then do nothing
137 - if (container.data.length <= pattern.start.length + pattern.end.length) {
138 - return;
139 - }
140 -
141 - format = editor.formatter.get(pattern.format);
142 - if (format && format[0].inline) {
143 - splitContainer();
144 - editor.formatter.apply(pattern.format, {}, container);
145 - return container;
146 - }
147 - }
148 -
149 - // Handles block formats like ##abc or 1. abc
150 - function applyBlockFormat() {
151 - var selection, dom, container, firstTextNode, node, format, textBlockElm, pattern, walker, rng, offset;
152 -
153 - selection = editor.selection;
154 - dom = editor.dom;
155 -
156 - if (!selection.isCollapsed()) {
157 - return;
158 - }
159 -
160 - textBlockElm = dom.getParent(selection.getStart(), 'p');
161 - if (textBlockElm) {
162 - walker = new tinymce.dom.TreeWalker(textBlockElm, textBlockElm);
163 - while ((node = walker.next())) {
164 - if (node.nodeType == 3) {
165 - firstTextNode = node;
166 - break;
167 - }
168 - }
169 -
170 - if (firstTextNode) {
171 - pattern = findPattern(firstTextNode.data);
172 - if (!pattern) {
173 - return;
174 - }
175 -
176 - rng = selection.getRng(true);
177 - container = rng.startContainer;
178 - offset = rng.startOffset;
179 -
180 - if (firstTextNode == container) {
181 - offset = Math.max(0, offset - pattern.start.length);
182 - }
183 -
184 - if (tinymce.trim(firstTextNode.data).length == pattern.start.length) {
185 - return;
186 - }
187 -
188 - if (pattern.format) {
189 - format = editor.formatter.get(pattern.format);
190 - if (format && format[0].block) {
191 - firstTextNode.deleteData(0, pattern.start.length);
192 - editor.formatter.apply(pattern.format, {}, firstTextNode);
193 -
194 - rng.setStart(container, offset);
195 - rng.collapse(true);
196 - selection.setRng(rng);
197 - }
198 - }
199 -
200 - if (pattern.cmd) {
201 - editor.undoManager.transact(function() {
202 - firstTextNode.deleteData(0, pattern.start.length);
203 - editor.execCommand(pattern.cmd);
204 - });
205 - }
206 - }
207 - }
208 - }
209 -
210 - function handleEnter() {
211 - var rng, wrappedTextNode;
212 -
213 - wrappedTextNode = applyInlineFormat();
214 - if (wrappedTextNode) {
215 - rng = editor.dom.createRng();
216 - rng.setStart(wrappedTextNode, wrappedTextNode.data.length);
217 - rng.setEnd(wrappedTextNode, wrappedTextNode.data.length);
218 - editor.selection.setRng(rng);
219 - }
220 -
221 - applyBlockFormat();
222 - }
223 -
224 - function handleSpace() {
225 - var wrappedTextNode, lastChar, lastCharNode, rng, dom;
226 -
227 - wrappedTextNode = applyInlineFormat(true);
228 - if (wrappedTextNode) {
229 - dom = editor.dom;
230 - lastChar = wrappedTextNode.data.slice(-1);
231 -
232 - // Move space after the newly formatted node
233 - if (/[\u00a0 ]/.test(lastChar)) {
234 - wrappedTextNode.deleteData(wrappedTextNode.data.length - 1, 1);
235 - lastCharNode = dom.doc.createTextNode(lastChar);
236 -
237 - if (wrappedTextNode.nextSibling) {
238 - dom.insertAfter(lastCharNode, wrappedTextNode.nextSibling);
239 - } else {
240 - wrappedTextNode.parentNode.appendChild(lastCharNode);
241 - }
242 -
243 - rng = dom.createRng();
244 - rng.setStart(lastCharNode, 1);
245 - rng.setEnd(lastCharNode, 1);
246 - editor.selection.setRng(rng);
247 - }
248 - }
249 - }
250 -
251 - editor.on('keydown', function(e) {
252 - if (e.keyCode == 13 && !tinymce.util.VK.modifierPressed(e)) {
253 - handleEnter();
254 - }
255 - }, true);
256 -
257 - editor.on('keyup', function(e) {
258 - if (e.keyCode == 32 && !tinymce.util.VK.modifierPressed(e)) {
259 - handleSpace();
260 - }
261 - });
262 -
263 - this.getPatterns = getPatterns;
264 - this.setPatterns = function(newPatterns) {
265 - patterns = newPatterns;
266 - isPatternsDirty = true;
267 - };
268 -});
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.