mirror of
https://github.com/codex-team/editor.js
synced 2024-05-23 08:42:25 +02:00
Destroy module (#157)
* listeners module added
* Destroy method added
* Destroy method for plugins added
* Delete plugins properties from window obj
* Revert "Delete plugins properties from window obj"
This reverts commit 6c91f81229
.
* Twitter and instagram api's destroy
* Scripts destoy added
* Fix
* Replace regex with String.indexOf
* Settings for destroyer
This commit is contained in:
parent
e28349d3fb
commit
d2e755086a
|
@ -70,7 +70,8 @@
|
||||||
"MutationObserver": true,
|
"MutationObserver": true,
|
||||||
"FormData": true,
|
"FormData": true,
|
||||||
"XMLHttpRequest": true,
|
"XMLHttpRequest": true,
|
||||||
"ActiveXObject": true
|
"ActiveXObject": true,
|
||||||
|
"RegExp": true
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
3
codex.js
3
codex.js
|
@ -10,6 +10,7 @@ module.exports = (function (editor) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
editor.version = VERSION;
|
editor.version = VERSION;
|
||||||
|
editor.scriptPrefix = 'cdx-script-';
|
||||||
|
|
||||||
var init = function () {
|
var init = function () {
|
||||||
|
|
||||||
|
@ -28,6 +29,8 @@ module.exports = (function (editor) {
|
||||||
editor.parser = require('./modules/parser');
|
editor.parser = require('./modules/parser');
|
||||||
editor.sanitizer = require('./modules/sanitizer');
|
editor.sanitizer = require('./modules/sanitizer');
|
||||||
editor.anchors = require('./modules/anchors');
|
editor.anchors = require('./modules/anchors');
|
||||||
|
editor.listeners = require('./modules/listeners');
|
||||||
|
editor.destroyer = require('./modules/destroyer');
|
||||||
editor.paste = require('./modules/paste');
|
editor.paste = require('./modules/paste');
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
10
example.html
10
example.html
|
@ -62,6 +62,7 @@
|
||||||
render: paragraph.render,
|
render: paragraph.render,
|
||||||
validate: paragraph.validate,
|
validate: paragraph.validate,
|
||||||
save: paragraph.save,
|
save: paragraph.save,
|
||||||
|
destroy: paragraph.destroy,
|
||||||
allowedToPaste: true,
|
allowedToPaste: true,
|
||||||
showInlineToolbar: true,
|
showInlineToolbar: true,
|
||||||
allowRenderOnPaste: true
|
allowRenderOnPaste: true
|
||||||
|
@ -74,6 +75,7 @@
|
||||||
render: header.render,
|
render: header.render,
|
||||||
validate: header.validate,
|
validate: header.validate,
|
||||||
save: header.save,
|
save: header.save,
|
||||||
|
destroy: header.destroy,
|
||||||
displayInToolbox: true
|
displayInToolbox: true
|
||||||
},
|
},
|
||||||
code: {
|
code: {
|
||||||
|
@ -85,6 +87,7 @@
|
||||||
render: code.render,
|
render: code.render,
|
||||||
validate: code.validate,
|
validate: code.validate,
|
||||||
save: code.save,
|
save: code.save,
|
||||||
|
destroy: code.destroy,
|
||||||
displayInToolbox: true,
|
displayInToolbox: true,
|
||||||
enableLineBreaks: true
|
enableLineBreaks: true
|
||||||
},
|
},
|
||||||
|
@ -97,6 +100,7 @@
|
||||||
render: link.render,
|
render: link.render,
|
||||||
validate: link.validate,
|
validate: link.validate,
|
||||||
save: link.save,
|
save: link.save,
|
||||||
|
destroy: link.destroy,
|
||||||
displayInToolbox: true,
|
displayInToolbox: true,
|
||||||
enableLineBreaks: true
|
enableLineBreaks: true
|
||||||
},
|
},
|
||||||
|
@ -109,6 +113,7 @@
|
||||||
render: list.render,
|
render: list.render,
|
||||||
validate: list.validate,
|
validate: list.validate,
|
||||||
save: list.save,
|
save: list.save,
|
||||||
|
destroy: list.destroy,
|
||||||
displayInToolbox: true,
|
displayInToolbox: true,
|
||||||
showInlineToolbar: true,
|
showInlineToolbar: true,
|
||||||
enableLineBreaks: true,
|
enableLineBreaks: true,
|
||||||
|
@ -122,6 +127,7 @@
|
||||||
render: quote.render,
|
render: quote.render,
|
||||||
validate: quote.validate,
|
validate: quote.validate,
|
||||||
save: quote.save,
|
save: quote.save,
|
||||||
|
destroy: quote.destroy,
|
||||||
displayInToolbox: true,
|
displayInToolbox: true,
|
||||||
enableLineBreaks: true,
|
enableLineBreaks: true,
|
||||||
showInlineToolbar: true,
|
showInlineToolbar: true,
|
||||||
|
@ -138,6 +144,7 @@
|
||||||
makeSettings: image.makeSettings,
|
makeSettings: image.makeSettings,
|
||||||
render: image.render,
|
render: image.render,
|
||||||
save: image.save,
|
save: image.save,
|
||||||
|
destroy: image.destroy,
|
||||||
isStretched: true,
|
isStretched: true,
|
||||||
showInlineToolbar: true,
|
showInlineToolbar: true,
|
||||||
displayInToolbox: true,
|
displayInToolbox: true,
|
||||||
|
@ -153,6 +160,7 @@
|
||||||
render: instagram.reneder,
|
render: instagram.reneder,
|
||||||
validate: instagram.validate,
|
validate: instagram.validate,
|
||||||
save: instagram.save,
|
save: instagram.save,
|
||||||
|
destroy: instagram.destroy,
|
||||||
renderOnPastePatterns: instagram.pastePatterns,
|
renderOnPastePatterns: instagram.pastePatterns,
|
||||||
},
|
},
|
||||||
tweet: {
|
tweet: {
|
||||||
|
@ -162,6 +170,7 @@
|
||||||
render: twitter.render,
|
render: twitter.render,
|
||||||
validate: twitter.validate,
|
validate: twitter.validate,
|
||||||
save: twitter.save,
|
save: twitter.save,
|
||||||
|
destroy: twitter.destroy,
|
||||||
showInlineToolbar : true,
|
showInlineToolbar : true,
|
||||||
renderOnPastePatterns: twitter.pastePatterns,
|
renderOnPastePatterns: twitter.pastePatterns,
|
||||||
config : {
|
config : {
|
||||||
|
@ -173,6 +182,7 @@
|
||||||
make: embed.make,
|
make: embed.make,
|
||||||
render: embed.render,
|
render: embed.render,
|
||||||
save: embed.save,
|
save: embed.save,
|
||||||
|
destroy: embed.destroy,
|
||||||
validate: embed.validate,
|
validate: embed.validate,
|
||||||
renderOnPastePatterns: embed.pastePatterns,
|
renderOnPastePatterns: embed.pastePatterns,
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
* @author Codex Team
|
* @author Codex Team
|
||||||
* @version 1.3.7
|
* @version 1.3.7
|
||||||
*/
|
*/
|
||||||
let editor = codex.editor;
|
|
||||||
|
|
||||||
module.exports = (function (callbacks) {
|
module.exports = (function (callbacks) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
callbacks.globalKeydown = function (event) {
|
callbacks.globalKeydown = function (event) {
|
||||||
|
|
||||||
switch (event.keyCode) {
|
switch (event.keyCode) {
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
* @author Codex Team
|
* @author Codex Team
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
let editor = codex.editor;
|
|
||||||
|
|
||||||
module.exports = (function (caret) {
|
module.exports = (function (caret) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var {int} InputIndex - editable element in DOM
|
* @var {int} InputIndex - editable element in DOM
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
* @author Codex Team
|
* @author Codex Team
|
||||||
* @version 1.3.11
|
* @version 1.3.11
|
||||||
*/
|
*/
|
||||||
let editor = codex.editor;
|
|
||||||
|
|
||||||
module.exports = (function (content) {
|
module.exports = (function (content) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Links to current active block
|
* Links to current active block
|
||||||
* @type {null | Element}
|
* @type {null | Element}
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
* @version 1.1.2
|
* @version 1.1.2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let editor = codex.editor;
|
|
||||||
|
|
||||||
module.exports = (function (core) {
|
module.exports = (function (core) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*
|
*
|
||||||
|
@ -215,8 +215,6 @@ module.exports = (function (core) {
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
|
||||||
const instancePrefix = 'cdx-script-';
|
|
||||||
|
|
||||||
let script;
|
let script;
|
||||||
|
|
||||||
/** Script is already loaded */
|
/** Script is already loaded */
|
||||||
|
@ -224,7 +222,7 @@ module.exports = (function (core) {
|
||||||
|
|
||||||
reject('Instance name is missed');
|
reject('Instance name is missed');
|
||||||
|
|
||||||
} else if ( document.getElementById(instancePrefix + instanceName) ) {
|
} else if ( document.getElementById(editor.scriptPrefix + instanceName) ) {
|
||||||
|
|
||||||
resolve(scriptPath);
|
resolve(scriptPath);
|
||||||
|
|
||||||
|
@ -233,7 +231,7 @@ module.exports = (function (core) {
|
||||||
script = document.createElement('SCRIPT');
|
script = document.createElement('SCRIPT');
|
||||||
script.async = true;
|
script.async = true;
|
||||||
script.defer = true;
|
script.defer = true;
|
||||||
script.id = instancePrefix + instanceName;
|
script.id = editor.scriptPrefix + instanceName;
|
||||||
|
|
||||||
script.onload = function () {
|
script.onload = function () {
|
||||||
|
|
||||||
|
|
98
modules/destroyer.js
Normal file
98
modules/destroyer.js
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
/**
|
||||||
|
* Codex Editor Destroyer module
|
||||||
|
*
|
||||||
|
* @auhor Codex Team
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = function (destroyer) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
|
destroyer.removeNodes = function () {
|
||||||
|
|
||||||
|
editor.nodes.wrapper.remove();
|
||||||
|
editor.nodes.notifications.remove();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
destroyer.destroyPlugins = function () {
|
||||||
|
|
||||||
|
for (var tool in editor.tools) {
|
||||||
|
|
||||||
|
if (typeof editor.tools[tool].destroy === 'function') {
|
||||||
|
|
||||||
|
editor.tools[tool].destroy();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
destroyer.destroyScripts = function () {
|
||||||
|
|
||||||
|
var scripts = document.getElementsByTagName('SCRIPT');
|
||||||
|
|
||||||
|
for (var i = 0; i < scripts.length; i++) {
|
||||||
|
|
||||||
|
if (scripts[i].id.indexOf(editor.scriptPrefix) + 1) {
|
||||||
|
|
||||||
|
scripts[i].remove();
|
||||||
|
i--;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete editor data from webpage.
|
||||||
|
* You should send settings argument with boolean flags:
|
||||||
|
* @param settings.ui- remove redactor event listeners and DOM nodes
|
||||||
|
* @param settings.scripts - remove redactor scripts from DOM
|
||||||
|
* @param settings.plugins - remove plugin's objects
|
||||||
|
* @param settings.core - remove editor core. You can remove core only if UI and scripts flags is true
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
destroyer.destroy = function (settings) {
|
||||||
|
|
||||||
|
if (!settings || typeof settings !== 'object') {
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.ui) {
|
||||||
|
|
||||||
|
destroyer.removeNodes();
|
||||||
|
editor.listeners.removeAll();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.scripts) {
|
||||||
|
|
||||||
|
destroyer.destroyScripts();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.plugins) {
|
||||||
|
|
||||||
|
destroyer.destroyPlugins();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.ui && settings.scripts && settings.core) {
|
||||||
|
|
||||||
|
delete codex.editor;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return destroyer;
|
||||||
|
|
||||||
|
}({});
|
192
modules/listeners.js
Normal file
192
modules/listeners.js
Normal file
|
@ -0,0 +1,192 @@
|
||||||
|
/**
|
||||||
|
* Codex Editor Listeners module
|
||||||
|
*
|
||||||
|
* @author Codex Team
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module-decorator for event listeners assignment
|
||||||
|
*/
|
||||||
|
module.exports = function (listeners) {
|
||||||
|
|
||||||
|
var allListeners = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search methods
|
||||||
|
*
|
||||||
|
* byElement, byType and byHandler returns array of suitable listeners
|
||||||
|
* one and all takes element, eventType, and handler and returns first (all) suitable listener
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
listeners.search = function () {
|
||||||
|
|
||||||
|
var byElement = function (element, context) {
|
||||||
|
|
||||||
|
var listenersOnElement = [];
|
||||||
|
|
||||||
|
context = context || allListeners;
|
||||||
|
|
||||||
|
for (var i = 0; i < context.length; i++) {
|
||||||
|
|
||||||
|
var listener = context[i];
|
||||||
|
|
||||||
|
if (listener.element === element) {
|
||||||
|
|
||||||
|
listenersOnElement.push(listener);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return listenersOnElement;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var byType = function (eventType, context) {
|
||||||
|
|
||||||
|
var listenersWithType = [];
|
||||||
|
|
||||||
|
context = context || allListeners;
|
||||||
|
|
||||||
|
for (var i = 0; i < context.length; i++) {
|
||||||
|
|
||||||
|
var listener = context[i];
|
||||||
|
|
||||||
|
if (listener.type === eventType) {
|
||||||
|
|
||||||
|
listenersWithType.push(listener);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return listenersWithType;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var byHandler = function (handler, context) {
|
||||||
|
|
||||||
|
var listenersWithHandler = [];
|
||||||
|
|
||||||
|
context = context || allListeners;
|
||||||
|
|
||||||
|
for (var i = 0; i < context.length; i++) {
|
||||||
|
|
||||||
|
var listener = context[i];
|
||||||
|
|
||||||
|
if (listener.handler === handler) {
|
||||||
|
|
||||||
|
listenersWithHandler.push(listener);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return listenersWithHandler;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var one = function (element, eventType, handler) {
|
||||||
|
|
||||||
|
var result = allListeners;
|
||||||
|
|
||||||
|
if (element)
|
||||||
|
result = byElement(element, result);
|
||||||
|
|
||||||
|
if (eventType)
|
||||||
|
result = byType(eventType, result);
|
||||||
|
|
||||||
|
if (handler)
|
||||||
|
result = byHandler(handler, result);
|
||||||
|
|
||||||
|
return result[0];
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var all = function (element, eventType, handler) {
|
||||||
|
|
||||||
|
var result = allListeners;
|
||||||
|
|
||||||
|
if (element)
|
||||||
|
result = byElement(element, result);
|
||||||
|
|
||||||
|
if (eventType)
|
||||||
|
result = byType(eventType, result);
|
||||||
|
|
||||||
|
if (handler)
|
||||||
|
result = byHandler(handler, result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
byElement : byElement,
|
||||||
|
byType : byType,
|
||||||
|
byHandler : byHandler,
|
||||||
|
one : one,
|
||||||
|
all : all
|
||||||
|
};
|
||||||
|
|
||||||
|
}();
|
||||||
|
|
||||||
|
listeners.add = function (element, eventType, handler, isCapture) {
|
||||||
|
|
||||||
|
element.addEventListener(eventType, handler, isCapture);
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
element: element,
|
||||||
|
type: eventType,
|
||||||
|
handler: handler
|
||||||
|
};
|
||||||
|
|
||||||
|
var alreadyAddedListener = listeners.search.one(element, eventType, handler);
|
||||||
|
|
||||||
|
if (!alreadyAddedListener) {
|
||||||
|
|
||||||
|
allListeners.push(data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
listeners.remove = function (element, eventType, handler) {
|
||||||
|
|
||||||
|
element.removeEventListener(eventType, handler);
|
||||||
|
|
||||||
|
var existingListeners = listeners.search.all(element, eventType, handler);
|
||||||
|
|
||||||
|
for (var i = 0; i < existingListeners.length; i++) {
|
||||||
|
|
||||||
|
var index = allListeners.indexOf(existingListeners[i]);
|
||||||
|
|
||||||
|
if (index > 0) {
|
||||||
|
|
||||||
|
allListeners.splice(index, 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
listeners.removeAll = function () {
|
||||||
|
|
||||||
|
allListeners.map(function (current) {
|
||||||
|
|
||||||
|
listeners.remove(current.element, current.type, current.handler);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
listeners.get = function (element, eventType, handler) {
|
||||||
|
|
||||||
|
return listeners.search.all(element, eventType, handler);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return listeners;
|
||||||
|
|
||||||
|
}({});
|
|
@ -138,8 +138,8 @@ module.exports = (function (notifications) {
|
||||||
okBtn.textContent = settings.okMsg || 'ОК';
|
okBtn.textContent = settings.okMsg || 'ОК';
|
||||||
cancelBtn.textContent = settings.cancelMsg || 'Отмена';
|
cancelBtn.textContent = settings.cancelMsg || 'Отмена';
|
||||||
|
|
||||||
okBtn.addEventListener('click', confirmHandler);
|
editor.listeners.add(okBtn, 'click', confirmHandler);
|
||||||
cancelBtn.addEventListener('click', cancelHandler);
|
editor.listeners.add(cancelBtn, 'click', cancelHandler);
|
||||||
|
|
||||||
wrapper.appendChild(message);
|
wrapper.appendChild(message);
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
* @author Codex Team
|
* @author Codex Team
|
||||||
* @version 1.1
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
let editor = codex.editor;
|
|
||||||
|
|
||||||
module.exports = (function (parser) {
|
module.exports = (function (parser) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
/** inserting text */
|
/** inserting text */
|
||||||
parser.insertPastedContent = function (blockType, tag) {
|
parser.insertPastedContent = function (blockType, tag) {
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,6 @@ module.exports = function (paste) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return paste;
|
return paste;
|
||||||
|
|
||||||
}({});
|
}({});
|
|
@ -5,10 +5,10 @@
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let editor = codex.editor;
|
|
||||||
|
|
||||||
module.exports = (function (renderer) {
|
module.exports = (function (renderer) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asyncronously parses input JSON to redactor blocks
|
* Asyncronously parses input JSON to redactor blocks
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
* Codex Sanitizer
|
* Codex Sanitizer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var janitor = require('html-janitor');
|
|
||||||
|
|
||||||
module.exports = (function (sanitizer) {
|
module.exports = (function (sanitizer) {
|
||||||
|
|
||||||
|
var janitor = require('html-janitor');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic config
|
* Basic config
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
* @version 1.0.2
|
* @version 1.0.2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let editor = codex.editor;
|
|
||||||
|
|
||||||
module.exports = (function (saver) {
|
module.exports = (function (saver) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves blocks
|
* Saves blocks
|
||||||
* @private
|
* @private
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let editor = codex.editor;
|
|
||||||
|
|
||||||
module.exports = (function (inline) {
|
module.exports = (function (inline) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
inline.buttonsOpened = null;
|
inline.buttonsOpened = null;
|
||||||
inline.actionsOpened = null;
|
inline.actionsOpened = null;
|
||||||
inline.wrappersOffset = null;
|
inline.wrappersOffset = null;
|
||||||
|
@ -363,7 +363,7 @@ module.exports = (function (inline) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
/** Callback to link action */
|
/** Callback to link action */
|
||||||
action.addEventListener('keydown', inlineToolbarAnchorInputKeydown_, false);
|
editor.listeners.add(action, 'keydown', inlineToolbarAnchorInputKeydown_, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
* @version 1.0.4
|
* @version 1.0.4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let editor = codex.editor;
|
|
||||||
|
|
||||||
module.exports = (function (settings) {
|
module.exports = (function (settings) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
settings.opened = false;
|
settings.opened = false;
|
||||||
|
|
||||||
settings.setting = null;
|
settings.setting = null;
|
||||||
|
@ -141,7 +141,7 @@ module.exports = (function (settings) {
|
||||||
}
|
}
|
||||||
|
|
||||||
setting = editor.draw.node('DIV', editor.ui.className.SETTINGS_ITEM, data);
|
setting = editor.draw.node('DIV', editor.ui.className.SETTINGS_ITEM, data);
|
||||||
setting.addEventListener('click', editor.toolbar.settings.updateFeedMode, false);
|
editor.listeners.add(setting, 'click', editor.toolbar.settings.updateFeedMode, false);
|
||||||
|
|
||||||
return setting;
|
return setting;
|
||||||
|
|
||||||
|
@ -182,10 +182,10 @@ module.exports = (function (settings) {
|
||||||
hash = editor.draw.node('i', 'ce-settings__anchor-hash', {}),
|
hash = editor.draw.node('i', 'ce-settings__anchor-hash', {}),
|
||||||
anchor = editor.draw.node('input', 'ce-settings__anchor-input', { placeholder: 'Якорь' });
|
anchor = editor.draw.node('input', 'ce-settings__anchor-input', { placeholder: 'Якорь' });
|
||||||
|
|
||||||
anchor.addEventListener('keydown', editor.anchors.keyDownOnAnchorInput );
|
editor.listeners.add(anchor, 'keydown', editor.anchors.keyDownOnAnchorInput );
|
||||||
anchor.addEventListener('keyup', editor.anchors.keyUpOnAnchorInput );
|
editor.listeners.add(anchor, 'keyup', editor.anchors.keyUpOnAnchorInput );
|
||||||
anchor.addEventListener('input', editor.anchors.anchorChanged );
|
editor.listeners.add(anchor, 'input', editor.anchors.anchorChanged );
|
||||||
anchor.addEventListener('blur', editor.anchors.anchorChanged );
|
editor.listeners.add(anchor, 'blur', editor.anchors.anchorChanged );
|
||||||
|
|
||||||
anchorWrapper.appendChild(hash);
|
anchorWrapper.appendChild(hash);
|
||||||
anchorWrapper.appendChild(anchor);
|
anchorWrapper.appendChild(anchor);
|
||||||
|
@ -207,11 +207,11 @@ module.exports = (function (settings) {
|
||||||
confirmAction = editor.draw.node('DIV', 'ce-toolbar__remove-confirm', { textContent : 'Удалить блок' }),
|
confirmAction = editor.draw.node('DIV', 'ce-toolbar__remove-confirm', { textContent : 'Удалить блок' }),
|
||||||
cancelAction = editor.draw.node('DIV', 'ce-toolbar__remove-cancel', { textContent : 'Отмена' });
|
cancelAction = editor.draw.node('DIV', 'ce-toolbar__remove-cancel', { textContent : 'Отмена' });
|
||||||
|
|
||||||
settingButton.addEventListener('click', editor.toolbar.settings.removeButtonClicked, false);
|
editor.listeners.add(settingButton, 'click', editor.toolbar.settings.removeButtonClicked, false);
|
||||||
|
|
||||||
confirmAction.addEventListener('click', editor.toolbar.settings.confirmRemovingRequest, false);
|
editor.listeners.add(confirmAction, 'click', editor.toolbar.settings.confirmRemovingRequest, false);
|
||||||
|
|
||||||
cancelAction.addEventListener('click', editor.toolbar.settings.cancelRemovingRequest, false);
|
editor.listeners.add(cancelAction, 'click', editor.toolbar.settings.cancelRemovingRequest, false);
|
||||||
|
|
||||||
actionWrapper.appendChild(confirmAction);
|
actionWrapper.appendChild(confirmAction);
|
||||||
actionWrapper.appendChild(cancelAction);
|
actionWrapper.appendChild(cancelAction);
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let editor = codex.editor;
|
|
||||||
|
|
||||||
module.exports = (function (toolbar) {
|
module.exports = (function (toolbar) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
toolbar.settings = require('./settings');
|
toolbar.settings = require('./settings');
|
||||||
toolbar.inline = require('./inline');
|
toolbar.inline = require('./inline');
|
||||||
toolbar.toolbox = require('./toolbox');
|
toolbar.toolbox = require('./toolbox');
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let editor = codex.editor;
|
|
||||||
|
|
||||||
module.exports = (function (toolbox) {
|
module.exports = (function (toolbox) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
toolbox.opened = false;
|
toolbox.opened = false;
|
||||||
|
|
||||||
/** Shows toolbox */
|
/** Shows toolbox */
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
* @author Codex Team
|
* @author Codex Team
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
let editor = codex.editor;
|
|
||||||
|
|
||||||
module.exports = (function (transport) {
|
module.exports = (function (transport) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
transport.input = null;
|
transport.input = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +22,7 @@ module.exports = (function (transport) {
|
||||||
var input = document.createElement('INPUT');
|
var input = document.createElement('INPUT');
|
||||||
|
|
||||||
input.type = 'file';
|
input.type = 'file';
|
||||||
input.addEventListener('change', editor.transport.fileSelected);
|
editor.listeners.add(input, 'change', editor.transport.fileSelected);
|
||||||
|
|
||||||
editor.transport.input = input;
|
editor.transport.input = input;
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
* @version 1.1
|
* @version 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let editor = codex.editor;
|
|
||||||
|
|
||||||
module.exports = (function (ui) {
|
module.exports = (function (ui) {
|
||||||
|
|
||||||
|
let editor = codex.editor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic editor classnames
|
* Basic editor classnames
|
||||||
*/
|
*/
|
||||||
|
@ -274,28 +274,28 @@ module.exports = (function (ui) {
|
||||||
// }, false );
|
// }, false );
|
||||||
|
|
||||||
/** All keydowns on Document */
|
/** All keydowns on Document */
|
||||||
document.addEventListener('keydown', editor.callback.globalKeydown, false );
|
editor.listeners.add(document, 'keydown', editor.callback.globalKeydown, false);
|
||||||
|
|
||||||
/** All keydowns on Redactor zone */
|
/** All keydowns on Redactor zone */
|
||||||
editor.nodes.redactor.addEventListener('keydown', editor.callback.redactorKeyDown, false);
|
editor.listeners.add(editor.nodes.redactor, 'keydown', editor.callback.redactorKeyDown, false);
|
||||||
|
|
||||||
/** All keydowns on Document */
|
/** All keydowns on Document */
|
||||||
document.addEventListener('keyup', editor.callback.globalKeyup, false );
|
editor.listeners.add(document, 'keyup', editor.callback.globalKeyup, false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mouse click to radactor
|
* Mouse click to radactor
|
||||||
*/
|
*/
|
||||||
editor.nodes.redactor.addEventListener('click', editor.callback.redactorClicked, false );
|
editor.listeners.add(editor.nodes.redactor, 'click', editor.callback.redactorClicked, false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clicks to the Plus button
|
* Clicks to the Plus button
|
||||||
*/
|
*/
|
||||||
editor.nodes.plusButton.addEventListener('click', editor.callback.plusButtonClicked, false);
|
editor.listeners.add(editor.nodes.plusButton, 'click', editor.callback.plusButtonClicked, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clicks to SETTINGS button in toolbar
|
* Clicks to SETTINGS button in toolbar
|
||||||
*/
|
*/
|
||||||
editor.nodes.showSettingsButton.addEventListener('click', editor.callback.showSettingsButtonClicked, false );
|
editor.listeners.add(editor.nodes.showSettingsButton, 'click', editor.callback.showSettingsButtonClicked, false );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated ( but now in use for syncronization );
|
* @deprecated ( but now in use for syncronization );
|
||||||
|
@ -306,7 +306,7 @@ module.exports = (function (ui) {
|
||||||
/** Bind click listeners on toolbar buttons */
|
/** Bind click listeners on toolbar buttons */
|
||||||
for (var button in editor.nodes.toolbarButtons) {
|
for (var button in editor.nodes.toolbarButtons) {
|
||||||
|
|
||||||
editor.nodes.toolbarButtons[button].addEventListener('click', editor.callback.toolbarButtonClicked, false);
|
editor.listeners.add(editor.nodes.toolbarButtons[button], 'click', editor.callback.toolbarButtonClicked, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ module.exports = (function (ui) {
|
||||||
/**
|
/**
|
||||||
* Block keydowns
|
* Block keydowns
|
||||||
*/
|
*/
|
||||||
block.addEventListener('keydown', editor.callback.blockKeydown, false);
|
editor.listeners.add(block, 'keydown', editor.callback.blockKeydown, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pasting content from another source
|
* Pasting content from another source
|
||||||
|
@ -340,9 +340,9 @@ module.exports = (function (ui) {
|
||||||
* @example editor.callback.blockPasteViaSanitize(event), the second method.
|
* @example editor.callback.blockPasteViaSanitize(event), the second method.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
block.addEventListener('paste', editor.callback.blockPasteCallback, false);
|
editor.listeners.add(block, 'paste', editor.callback.blockPasteCallback, false);
|
||||||
|
|
||||||
block.addEventListener('mouseup', editor.toolbar.inline.show, false);
|
editor.listeners.add(block, 'mouseup', editor.toolbar.inline.show, false);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ module.exports = (function (ui) {
|
||||||
|
|
||||||
ui.setInlineToolbarButtonBehaviour = function (button, type) {
|
ui.setInlineToolbarButtonBehaviour = function (button, type) {
|
||||||
|
|
||||||
button.addEventListener('mousedown', function (event) {
|
editor.listeners.add(button, 'mousedown', function (event) {
|
||||||
|
|
||||||
editor.toolbar.inline.toolClicked(event, type);
|
editor.toolbar.inline.toolClicked(event, type);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "codex.editor",
|
"name": "codex.editor",
|
||||||
"version": "1.4.10",
|
"version": "1.5.0",
|
||||||
"description": "Codex Editor. Native JS, based on API and Open Source",
|
"description": "Codex Editor. Native JS, based on API and Open Source",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* Creates code tag and adds content to this tag
|
* Creates code tag and adds content to this tag
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var code = (function(code) {
|
var code = (function(code_plugin) {
|
||||||
|
|
||||||
var baseClass = "ce-code";
|
var baseClass = "ce-code";
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ var code = (function(code) {
|
||||||
/**
|
/**
|
||||||
* Method to render HTML block from JSON
|
* Method to render HTML block from JSON
|
||||||
*/
|
*/
|
||||||
code.render = function (data) {
|
code_plugin.render = function (data) {
|
||||||
|
|
||||||
return make_(data);
|
return make_(data);
|
||||||
};
|
};
|
||||||
|
@ -36,7 +36,7 @@ var code = (function(code) {
|
||||||
/**
|
/**
|
||||||
* Method to extract JSON data from HTML block
|
* Method to extract JSON data from HTML block
|
||||||
*/
|
*/
|
||||||
code.save = function (blockContent){
|
code_plugin.save = function (blockContent) {
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
text : blockContent.innerHTML
|
text : blockContent.innerHTML
|
||||||
|
@ -45,7 +45,7 @@ var code = (function(code) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
code.validate = function(data) {
|
code_plugin.validate = function (data) {
|
||||||
|
|
||||||
if (data.text.trim() == '')
|
if (data.text.trim() == '')
|
||||||
return;
|
return;
|
||||||
|
@ -53,6 +53,12 @@ var code = (function(code) {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
return code;
|
code_plugin.destroy = function () {
|
||||||
|
|
||||||
|
code = null;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return code_plugin;
|
||||||
|
|
||||||
})({});
|
})({});
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Embed plugin by gohabereg
|
* Embed plugin by gohabereg
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
*/
|
*/
|
||||||
var embed = function(embed){
|
var embed = function(embed_plugin){
|
||||||
|
|
||||||
var methods = {
|
var methods = {
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ var embed = function(embed){
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
embed.make = function(data, isInternal) {
|
embed_plugin.make = function(data, isInternal) {
|
||||||
|
|
||||||
if (!data.remote_id)
|
if (!data.remote_id)
|
||||||
return;
|
return;
|
||||||
|
@ -152,7 +152,7 @@ var embed = function(embed){
|
||||||
* Saving JSON output.
|
* Saving JSON output.
|
||||||
* Upload data via ajax
|
* Upload data via ajax
|
||||||
*/
|
*/
|
||||||
embed.save = function(blockContent) {
|
embed_plugin.save = function(blockContent) {
|
||||||
|
|
||||||
if (!blockContent)
|
if (!blockContent)
|
||||||
return;
|
return;
|
||||||
|
@ -175,11 +175,11 @@ var embed = function(embed){
|
||||||
/**
|
/**
|
||||||
* Render data
|
* Render data
|
||||||
*/
|
*/
|
||||||
embed.render = function(data) {
|
embed_plugin.render = function(data) {
|
||||||
return embed.make(data);
|
return embed_plugin.make(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
embed.urlPastedCallback = function(url, pattern) {
|
embed_plugin.urlPastedCallback = function(url, pattern) {
|
||||||
|
|
||||||
var execArray = pattern.regex.exec(url),
|
var execArray = pattern.regex.exec(url),
|
||||||
id = methods.getRemoteId(pattern.type, execArray);
|
id = methods.getRemoteId(pattern.type, execArray);
|
||||||
|
@ -190,10 +190,10 @@ var embed = function(embed){
|
||||||
thumbnailUrl: url
|
thumbnailUrl: url
|
||||||
};
|
};
|
||||||
|
|
||||||
embed.make(data, true);
|
embed_plugin.make(data, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
embed.validate = function(savedData) {
|
embed_plugin.validate = function(savedData) {
|
||||||
|
|
||||||
var source = savedData.source,
|
var source = savedData.source,
|
||||||
execArray = services[source].regex.exec(savedData.thumbnailUrl),
|
execArray = services[source].regex.exec(savedData.thumbnailUrl),
|
||||||
|
@ -203,69 +203,74 @@ var embed = function(embed){
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
embed.pastePatterns = [
|
embed_plugin.pastePatterns = [
|
||||||
{
|
{
|
||||||
type: 'vk',
|
type: 'vk',
|
||||||
regex: /https?:\/\/vk\.com\/.*(?:video)([-0-9]+_[0-9]+)/, ///https?.+vk?.com\/feed\?w=wall\d+_\d+/,
|
regex: /https?:\/\/vk\.com\/.*(?:video)([-0-9]+_[0-9]+)/, ///https?.+vk?.com\/feed\?w=wall\d+_\d+/,
|
||||||
callback: embed.urlPastedCallback
|
callback: embed_plugin.urlPastedCallback
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'youtube',
|
type: 'youtube',
|
||||||
regex: /(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/,
|
regex: /(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/,
|
||||||
callback: embed.urlPastedCallback
|
callback: embed_plugin.urlPastedCallback
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'vimeo',
|
type: 'vimeo',
|
||||||
regex: /(?:http[s]?:\/\/)?(?:www.)?vimeo\.co(?:.+\/([^\/]\d+)(?:#t=[\d]+)?s?$)/,
|
regex: /(?:http[s]?:\/\/)?(?:www.)?vimeo\.co(?:.+\/([^\/]\d+)(?:#t=[\d]+)?s?$)/,
|
||||||
callback: embed.urlPastedCallback
|
callback: embed_plugin.urlPastedCallback
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'coub',
|
type: 'coub',
|
||||||
regex: /https?:\/\/coub\.com\/view\/([^\/\?\&]+)/,
|
regex: /https?:\/\/coub\.com\/view\/([^\/\?\&]+)/,
|
||||||
callback: embed.urlPastedCallback
|
callback: embed_plugin.urlPastedCallback
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'vine',
|
type: 'vine',
|
||||||
regex: /https?:\/\/vine\.co\/v\/([^\/\?\&]+)/,
|
regex: /https?:\/\/vine\.co\/v\/([^\/\?\&]+)/,
|
||||||
callback: embed.urlPastedCallback
|
callback: embed_plugin.urlPastedCallback
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'imgur',
|
type: 'imgur',
|
||||||
regex: /https?:\/\/(?:i\.)?imgur\.com.*\/([a-zA-Z0-9]+)(?:\.gifv)?/,
|
regex: /https?:\/\/(?:i\.)?imgur\.com.*\/([a-zA-Z0-9]+)(?:\.gifv)?/,
|
||||||
callback: embed.urlPastedCallback
|
callback: embed_plugin.urlPastedCallback
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'gfycat',
|
type: 'gfycat',
|
||||||
regex: /https?:\/\/gfycat\.com(?:\/detail)?\/([a-zA-Z]+)/,
|
regex: /https?:\/\/gfycat\.com(?:\/detail)?\/([a-zA-Z]+)/,
|
||||||
callback: embed.urlPastedCallback
|
callback: embed_plugin.urlPastedCallback
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'twitch-channel',
|
type: 'twitch-channel',
|
||||||
regex: /https?:\/\/www.twitch.tv\/([^\/\?\&]*)/,
|
regex: /https?:\/\/www.twitch.tv\/([^\/\?\&]*)/,
|
||||||
callback: embed.urlPastedCallback
|
callback: embed_plugin.urlPastedCallback
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'twitch-video',
|
type: 'twitch-video',
|
||||||
regex: /https?:\/\/www.twitch.tv\/(?:[^\/\?\&]*\/v|videos)\/([0-9]*)/,
|
regex: /https?:\/\/www.twitch.tv\/(?:[^\/\?\&]*\/v|videos)\/([0-9]*)/,
|
||||||
callback: embed.urlPastedCallback
|
callback: embed_plugin.urlPastedCallback
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'yandex-music-album',
|
type: 'yandex-music-album',
|
||||||
regex: /https?:\/\/music.yandex.ru\/album\/([0-9]*)/,
|
regex: /https?:\/\/music.yandex.ru\/album\/([0-9]*)/,
|
||||||
callback: embed.urlPastedCallback
|
callback: embed_plugin.urlPastedCallback
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'yandex-music-track',
|
type: 'yandex-music-track',
|
||||||
regex: /https?:\/\/music.yandex.ru\/album\/([0-9]*)\/track\/([0-9]*)/,
|
regex: /https?:\/\/music.yandex.ru\/album\/([0-9]*)\/track\/([0-9]*)/,
|
||||||
callback: embed.urlPastedCallback
|
callback: embed_plugin.urlPastedCallback
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'yandex-music-playlist',
|
type: 'yandex-music-playlist',
|
||||||
regex: /https?:\/\/music.yandex.ru\/users\/([^\/\?\&]*)\/playlists\/([0-9]*)/,
|
regex: /https?:\/\/music.yandex.ru\/users\/([^\/\?\&]*)\/playlists\/([0-9]*)/,
|
||||||
callback: embed.urlPastedCallback
|
callback: embed_plugin.urlPastedCallback
|
||||||
} ];
|
} ];
|
||||||
|
|
||||||
|
embed_plugin.destroy = function () {
|
||||||
|
|
||||||
return embed;
|
embed = null;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return embed_plugin;
|
||||||
|
|
||||||
}({});
|
}({});
|
|
@ -3,7 +3,7 @@
|
||||||
* H e a d e r
|
* H e a d e r
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var header = (function(header) {
|
var header = (function(header_plugin) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
|
@ -92,14 +92,14 @@ var header = (function(header) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
header.prepareDataForSave = function(data) {
|
header_plugin.prepareDataForSave = function(data) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to render HTML block from JSON
|
* Method to render HTML block from JSON
|
||||||
*/
|
*/
|
||||||
header.render = function (data) {
|
header_plugin.render = function (data) {
|
||||||
|
|
||||||
return make_(data);
|
return make_(data);
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ var header = (function(header) {
|
||||||
/**
|
/**
|
||||||
* Method to extract JSON data from HTML block
|
* Method to extract JSON data from HTML block
|
||||||
*/
|
*/
|
||||||
header.save = function (blockContent) {
|
header_plugin.save = function (blockContent) {
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
"heading-styles": blockContent.dataset.headerData,
|
"heading-styles": blockContent.dataset.headerData,
|
||||||
|
@ -126,7 +126,7 @@ var header = (function(header) {
|
||||||
* - - - - - - - - - - - - -
|
* - - - - - - - - - - - - -
|
||||||
* @return {Element} element contains all settings
|
* @return {Element} element contains all settings
|
||||||
*/
|
*/
|
||||||
header.makeSettings = function () {
|
header_plugin.makeSettings = function () {
|
||||||
|
|
||||||
var holder = codex.editor.draw.node('DIV', ['cdx-plugin-settings--horisontal'], {} ),
|
var holder = codex.editor.draw.node('DIV', ['cdx-plugin-settings--horisontal'], {} ),
|
||||||
types = {
|
types = {
|
||||||
|
@ -148,7 +148,7 @@ var header = (function(header) {
|
||||||
return holder;
|
return holder;
|
||||||
};
|
};
|
||||||
|
|
||||||
header.validate = function(data) {
|
header_plugin.validate = function(data) {
|
||||||
|
|
||||||
if (data.text.trim() === '' || data['heading-styles'].trim() === ''){
|
if (data.text.trim() === '' || data['heading-styles'].trim() === ''){
|
||||||
return false;
|
return false;
|
||||||
|
@ -157,7 +157,13 @@ var header = (function(header) {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
return header;
|
header_plugin.destroy = function () {
|
||||||
|
|
||||||
|
header = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return header_plugin;
|
||||||
|
|
||||||
})({});
|
})({});
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @version 1.2.0
|
* @version 1.2.0
|
||||||
*/
|
*/
|
||||||
var image = (function(image) {
|
var image = (function(image_plugin) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
|
@ -428,9 +428,9 @@ var image = (function(image) {
|
||||||
*/
|
*/
|
||||||
uploadImageFromUrl : function(path) {
|
uploadImageFromUrl : function(path) {
|
||||||
|
|
||||||
var ajaxUrl = image.config.uploadUrl,
|
var ajaxUrl = image_plugin.config.uploadUrl,
|
||||||
file,
|
file,
|
||||||
image_plugin,
|
image,
|
||||||
current = codex.editor.content.currentNode,
|
current = codex.editor.content.currentNode,
|
||||||
beforeSend,
|
beforeSend,
|
||||||
success_callback;
|
success_callback;
|
||||||
|
@ -440,7 +440,7 @@ var image = (function(image) {
|
||||||
|
|
||||||
var imageInfo = JSON.parse(data);
|
var imageInfo = JSON.parse(data);
|
||||||
|
|
||||||
var newImage = image_plugin.getElementsByTagName('IMG')[0];
|
var newImage = image.getElementsByTagName('IMG')[0];
|
||||||
|
|
||||||
newImage.dataset.stretched = false;
|
newImage.dataset.stretched = false;
|
||||||
newImage.dataset.src = imageInfo.file.url;
|
newImage.dataset.src = imageInfo.file.url;
|
||||||
|
@ -449,7 +449,7 @@ var image = (function(image) {
|
||||||
newImage.dataset.height = imageInfo.file.height;
|
newImage.dataset.height = imageInfo.file.height;
|
||||||
newImage.dataset.additionalData = imageInfo.file.additionalData;
|
newImage.dataset.additionalData = imageInfo.file.additionalData;
|
||||||
|
|
||||||
image_plugin.classList.remove(elementClasses_.imagePreview);
|
image.classList.remove(elementClasses_.imagePreview);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -473,19 +473,19 @@ var image = (function(image) {
|
||||||
cover: null
|
cover: null
|
||||||
};
|
};
|
||||||
|
|
||||||
image_plugin = codex.editor.tools.image_extended.render(data);
|
image = codex.editor.tools.image_extended.render(data);
|
||||||
|
|
||||||
image_plugin.classList.add(elementClasses_.imagePreview);
|
image.classList.add(elementClasses_.imagePreview);
|
||||||
|
|
||||||
var img = image_plugin.querySelector('img');
|
var img = image.querySelector('img');
|
||||||
|
|
||||||
codex.editor.content.switchBlock(codex.editor.content.currentNode, image_plugin, 'image_extended');
|
codex.editor.content.switchBlock(codex.editor.content.currentNode, image, 'image_extended');
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Preparing data for XMLHTTP */
|
/** Preparing data for XMLHTTP */
|
||||||
var data = {
|
var data = {
|
||||||
url: image.config.uploadUrl,
|
url: image_plugin.config.uploadUrl,
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data : {
|
data : {
|
||||||
url: path
|
url: path
|
||||||
|
@ -504,12 +504,12 @@ var image = (function(image) {
|
||||||
* Image path
|
* Image path
|
||||||
* @type {null}
|
* @type {null}
|
||||||
*/
|
*/
|
||||||
image.path = null;
|
image_plugin.path = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin configuration
|
* Plugin configuration
|
||||||
*/
|
*/
|
||||||
image.config = null;
|
image_plugin.config = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -567,9 +567,9 @@ var image = (function(image) {
|
||||||
* @public
|
* @public
|
||||||
* @param config
|
* @param config
|
||||||
*/
|
*/
|
||||||
image.prepare = function(config) {
|
image_plugin.prepare = function(config) {
|
||||||
|
|
||||||
image.config = config;
|
image_plugin.config = config;
|
||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
@ -579,7 +579,7 @@ var image = (function(image) {
|
||||||
*
|
*
|
||||||
* this tool works when tool is clicked in toolbox
|
* this tool works when tool is clicked in toolbox
|
||||||
*/
|
*/
|
||||||
image.appendCallback = function(event) {
|
image_plugin.appendCallback = function(event) {
|
||||||
|
|
||||||
/** Upload image and call success callback*/
|
/** Upload image and call success callback*/
|
||||||
uploadButtonClicked_(event);
|
uploadButtonClicked_(event);
|
||||||
|
@ -592,7 +592,7 @@ var image = (function(image) {
|
||||||
* @param data
|
* @param data
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
image.render = function( data ) {
|
image_plugin.render = function( data ) {
|
||||||
|
|
||||||
return make_(data);
|
return make_(data);
|
||||||
};
|
};
|
||||||
|
@ -603,7 +603,7 @@ var image = (function(image) {
|
||||||
* @param block
|
* @param block
|
||||||
* @return {{background: boolean, border: boolean, isstretch: boolean, file: {url: (*|string|Object), bigUrl: (null|*), width: *, height: *, additionalData: null}, caption: (string|*|string), cover: null}}
|
* @return {{background: boolean, border: boolean, isstretch: boolean, file: {url: (*|string|Object), bigUrl: (null|*), width: *, height: *, additionalData: null}, caption: (string|*|string), cover: null}}
|
||||||
*/
|
*/
|
||||||
image.save = function ( block ) {
|
image_plugin.save = function ( block ) {
|
||||||
|
|
||||||
var content = block,
|
var content = block,
|
||||||
image = ui_.getImage(content),
|
image = ui_.getImage(content),
|
||||||
|
@ -633,7 +633,7 @@ var image = (function(image) {
|
||||||
* Settings panel content
|
* Settings panel content
|
||||||
* @return {Element} element contains all settings
|
* @return {Element} element contains all settings
|
||||||
*/
|
*/
|
||||||
image.makeSettings = function () {
|
image_plugin.makeSettings = function () {
|
||||||
|
|
||||||
var currentNode = codex.editor.content.currentNode,
|
var currentNode = codex.editor.content.currentNode,
|
||||||
wrapper = currentNode.querySelector('.' + elementClasses_.imageWrapper),
|
wrapper = currentNode.querySelector('.' + elementClasses_.imageWrapper),
|
||||||
|
@ -688,20 +688,26 @@ var image = (function(image) {
|
||||||
/**
|
/**
|
||||||
* Share as API
|
* Share as API
|
||||||
*/
|
*/
|
||||||
image.uploadImageFromUri = uploadingCallbacks_.ByPaste.uploadImageFromUrl;
|
image_plugin.uploadImageFromUri = uploadingCallbacks_.ByPaste.uploadImageFromUrl;
|
||||||
|
|
||||||
image.pastePatterns = [
|
image_plugin.pastePatterns = [
|
||||||
{
|
{
|
||||||
type: 'image',
|
type: 'image',
|
||||||
regex: /(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*\.(?:jpe?g|gif|png))(?:\?([^#]*))?(?:#(.*))?/i,
|
regex: /(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*\.(?:jpe?g|gif|png))(?:\?([^#]*))?(?:#(.*))?/i,
|
||||||
callback: image.uploadImageFromUri
|
callback: image_plugin.uploadImageFromUri
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'uploadCare',
|
type: 'uploadCare',
|
||||||
regex: /^https:\/\/(uploadcare\.cmtt\.ru|ucarecdn\.com|static[0-9]+\.siliconrus\.cmtt\.ru|static[0-9]+\.cmtt\.ru)/i,
|
regex: /^https:\/\/(uploadcare\.cmtt\.ru|ucarecdn\.com|static[0-9]+\.siliconrus\.cmtt\.ru|static[0-9]+\.cmtt\.ru)/i,
|
||||||
callback: image.uploadImageFromUri
|
callback: image_plugin.uploadImageFromUri
|
||||||
} ];
|
} ];
|
||||||
|
|
||||||
return image;
|
image_plugin.destroy = function () {
|
||||||
|
|
||||||
|
image = null;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return image_plugin;
|
||||||
|
|
||||||
})({});
|
})({});
|
|
@ -2,7 +2,7 @@
|
||||||
* Instagram plugin
|
* Instagram plugin
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
*/
|
*/
|
||||||
var instagram = (function(instagram) {
|
var instagram = (function(instagram_plugin) {
|
||||||
|
|
||||||
var methods = {
|
var methods = {
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ var instagram = (function(instagram) {
|
||||||
* Prepare before usage
|
* Prepare before usage
|
||||||
* Load important scripts to render embed
|
* Load important scripts to render embed
|
||||||
*/
|
*/
|
||||||
instagram.prepare = function() {
|
instagram_plugin.prepare = function() {
|
||||||
|
|
||||||
return new Promise(function(resolve, reject){
|
return new Promise(function(resolve, reject){
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ var instagram = (function(instagram) {
|
||||||
return block;
|
return block;
|
||||||
};
|
};
|
||||||
|
|
||||||
instagram.validate = function(data) {
|
instagram_plugin.validate = function(data) {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ var instagram = (function(instagram) {
|
||||||
* Saving JSON output.
|
* Saving JSON output.
|
||||||
* Upload data via ajax
|
* Upload data via ajax
|
||||||
*/
|
*/
|
||||||
instagram.save = function(blockContent) {
|
instagram_plugin.save = function(blockContent) {
|
||||||
|
|
||||||
var data;
|
var data;
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ var instagram = (function(instagram) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
instagram.validate = function(data) {
|
instagram_plugin.validate = function(data) {
|
||||||
|
|
||||||
var checkUrl = new RegExp("http?.+instagram.com\/p?.");
|
var checkUrl = new RegExp("http?.+instagram.com\/p?.");
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ var instagram = (function(instagram) {
|
||||||
/**
|
/**
|
||||||
* Render data
|
* Render data
|
||||||
*/
|
*/
|
||||||
instagram.render = function(data) {
|
instagram_plugin.render = function(data) {
|
||||||
return make_(data);
|
return make_(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ var instagram = (function(instagram) {
|
||||||
* Using instagram Embed Widgete to render
|
* Using instagram Embed Widgete to render
|
||||||
* @param url
|
* @param url
|
||||||
*/
|
*/
|
||||||
instagram.urlPastedCallback = function(url) {
|
instagram_plugin.urlPastedCallback = function(url) {
|
||||||
var data = {
|
var data = {
|
||||||
instagram_url: url
|
instagram_url: url
|
||||||
};
|
};
|
||||||
|
@ -141,15 +141,22 @@ var instagram = (function(instagram) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
instagram.pastePatterns = [
|
instagram_plugin.pastePatterns = [
|
||||||
{
|
{
|
||||||
type: 'instagram',
|
type: 'instagram',
|
||||||
regex: /http?.+instagram.com\/p\/([a-zA-Z0-9]*)/,
|
regex: /http?.+instagram.com\/p\/([a-zA-Z0-9]*)/,
|
||||||
callback: instagram.urlPastedCallback
|
callback: instagram_plugin.urlPastedCallback
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
return instagram;
|
instagram_plugin.destroy = function () {
|
||||||
|
|
||||||
|
instagram = null;
|
||||||
|
delete window.instgrm
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return instagram_plugin;
|
||||||
|
|
||||||
})({});
|
})({});
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* Link tool plugin
|
* Link tool plugin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var link = (function(link) {
|
var link = (function(link_plugin) {
|
||||||
|
|
||||||
var settings = {
|
var settings = {
|
||||||
defaultText : 'Вставьте ссылку ...',
|
defaultText : 'Вставьте ссылку ...',
|
||||||
|
@ -178,7 +178,7 @@ var link = (function(link) {
|
||||||
/* Show loader gif **/
|
/* Show loader gif **/
|
||||||
block.classList.add(settings.elementClasses.loader);
|
block.classList.add(settings.elementClasses.loader);
|
||||||
|
|
||||||
return fetch( link.config.fetchUrl + '?url=' + encodeURI(url) );
|
return fetch( link_plugin.config.fetchUrl + '?url=' + encodeURI(url) );
|
||||||
})
|
})
|
||||||
|
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
|
@ -242,9 +242,9 @@ var link = (function(link) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
link.prepare = function (config) {
|
link_plugin.prepare = function (config) {
|
||||||
|
|
||||||
link.config = config;
|
link_plugin.config = config;
|
||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ var link = (function(link) {
|
||||||
* @param {object} JSON with block data
|
* @param {object} JSON with block data
|
||||||
* @return {Element} element to append
|
* @return {Element} element to append
|
||||||
*/
|
*/
|
||||||
link.makeNewBlock = function (data) {
|
link_plugin.makeNewBlock = function (data) {
|
||||||
|
|
||||||
var wrapper = ui.mainBlock(),
|
var wrapper = ui.mainBlock(),
|
||||||
tag = ui.input();
|
tag = ui.input();
|
||||||
|
@ -278,7 +278,7 @@ var link = (function(link) {
|
||||||
/**
|
/**
|
||||||
* Method to render HTML block from JSON
|
* Method to render HTML block from JSON
|
||||||
*/
|
*/
|
||||||
link.render = function (json) {
|
link_plugin.render = function (json) {
|
||||||
|
|
||||||
if ( json ) {
|
if ( json ) {
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ var link = (function(link) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
link.validate = function (data) {
|
link_plugin.validate = function (data) {
|
||||||
|
|
||||||
if (data.url.trim() == '' || data.title.trim() == '' || data.description.trim() == '')
|
if (data.url.trim() == '' || data.title.trim() == '' || data.description.trim() == '')
|
||||||
return;
|
return;
|
||||||
|
@ -323,7 +323,7 @@ var link = (function(link) {
|
||||||
/**
|
/**
|
||||||
* Method to extract JSON data from HTML block
|
* Method to extract JSON data from HTML block
|
||||||
*/
|
*/
|
||||||
link.save = function (blockContent){
|
link_plugin.save = function (blockContent){
|
||||||
|
|
||||||
var linkElement = settings.elementClasses.link;
|
var linkElement = settings.elementClasses.link;
|
||||||
|
|
||||||
|
@ -339,6 +339,12 @@ var link = (function(link) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return link;
|
link_plugin.destroy = function () {
|
||||||
|
|
||||||
|
link = null;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return link_plugin;
|
||||||
|
|
||||||
})({});
|
})({});
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Code Plugin\
|
* Code Plugin\
|
||||||
* Creates code tag and adds content to this tag
|
* Creates code tag and adds content to this tag
|
||||||
*/
|
*/
|
||||||
var list = (function(list) {
|
var list = (function(list_plugin) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CSS class names
|
* CSS class names
|
||||||
|
@ -76,7 +76,6 @@ var list = (function(list) {
|
||||||
|
|
||||||
codex.editor.content.switchBlock(currentBlock, newEditable, 'list');
|
codex.editor.content.switchBlock(currentBlock, newEditable, 'list');
|
||||||
},
|
},
|
||||||
|
|
||||||
keyDown: function (e) {
|
keyDown: function (e) {
|
||||||
|
|
||||||
var controlKeyPressed = e.ctrlKey || e.metaKey,
|
var controlKeyPressed = e.ctrlKey || e.metaKey,
|
||||||
|
@ -117,7 +116,7 @@ var list = (function(list) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
range.selectNode(currentSelectedNode);
|
range.selectNodeContents(currentSelectedNode);
|
||||||
|
|
||||||
selection.removeAllRanges();
|
selection.removeAllRanges();
|
||||||
selection.addRange(range);
|
selection.addRange(range);
|
||||||
|
@ -128,7 +127,7 @@ var list = (function(list) {
|
||||||
/**
|
/**
|
||||||
* Method to render HTML block from JSON
|
* Method to render HTML block from JSON
|
||||||
*/
|
*/
|
||||||
list.render = function (data) {
|
list_plugin.render = function (data) {
|
||||||
|
|
||||||
var type = data && data.type == 'ordered' ? 'OL' : 'UL',
|
var type = data && data.type == 'ordered' ? 'OL' : 'UL',
|
||||||
tag = ui.make(type),
|
tag = ui.make(type),
|
||||||
|
@ -158,7 +157,7 @@ var list = (function(list) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
list.validate = function(data) {
|
list_plugin.validate = function(data) {
|
||||||
|
|
||||||
var items = data.items.every(function(item){
|
var items = data.items.every(function(item){
|
||||||
return item.trim() !== '';
|
return item.trim() !== '';
|
||||||
|
@ -176,7 +175,7 @@ var list = (function(list) {
|
||||||
/**
|
/**
|
||||||
* Method to extract JSON data from HTML block
|
* Method to extract JSON data from HTML block
|
||||||
*/
|
*/
|
||||||
list.save = function (blockContent){
|
list_plugin.save = function (blockContent){
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
type : null,
|
type : null,
|
||||||
|
@ -192,7 +191,7 @@ var list = (function(list) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
list.makeSettings = function () {
|
list_plugin.makeSettings = function () {
|
||||||
|
|
||||||
var holder = document.createElement('DIV');
|
var holder = document.createElement('DIV');
|
||||||
|
|
||||||
|
@ -219,6 +218,12 @@ var list = (function(list) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return list;
|
list_plugin.destroy = function () {
|
||||||
|
|
||||||
|
list = null;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return list_plugin;
|
||||||
|
|
||||||
})({});
|
})({});
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
* Creates DIV tag and adds content to this tag
|
* Creates DIV tag and adds content to this tag
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var paragraph = (function(paragraph) {
|
var paragraph = (function(paragraph_plugin) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*
|
*
|
||||||
* Make initial header block
|
* Make initial paragraph block
|
||||||
* @param {object} JSON with block data
|
* @param {object} JSON with block data
|
||||||
* @return {Element} element to append
|
* @return {Element} element to append
|
||||||
*/
|
*/
|
||||||
|
@ -44,7 +44,7 @@ var paragraph = (function(paragraph) {
|
||||||
* Plugins should have prepare method
|
* Plugins should have prepare method
|
||||||
* @param config
|
* @param config
|
||||||
*/
|
*/
|
||||||
paragraph.prepare = function(config) {
|
paragraph_plugin.prepare = function(config) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ var paragraph = (function(paragraph) {
|
||||||
*
|
*
|
||||||
* Method to render HTML block from JSON
|
* Method to render HTML block from JSON
|
||||||
*/
|
*/
|
||||||
paragraph.render = function (data) {
|
paragraph_plugin.render = function (data) {
|
||||||
|
|
||||||
return make_(data);
|
return make_(data);
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ var paragraph = (function(paragraph) {
|
||||||
* Check output data for validity.
|
* Check output data for validity.
|
||||||
* Should be defined by developer
|
* Should be defined by developer
|
||||||
*/
|
*/
|
||||||
paragraph.validate = function(output) {
|
paragraph_plugin.validate = function(output) {
|
||||||
|
|
||||||
if (output.text === '')
|
if (output.text === '')
|
||||||
return;
|
return;
|
||||||
|
@ -78,7 +78,7 @@ var paragraph = (function(paragraph) {
|
||||||
*
|
*
|
||||||
* Method to extract JSON data from HTML block
|
* Method to extract JSON data from HTML block
|
||||||
*/
|
*/
|
||||||
paragraph.save = function (blockContent){
|
paragraph_plugin.save = function (blockContent){
|
||||||
|
|
||||||
var wrappedText = codex.editor.content.wrapTextWithParagraphs(blockContent.innerHTML);
|
var wrappedText = codex.editor.content.wrapTextWithParagraphs(blockContent.innerHTML);
|
||||||
|
|
||||||
|
@ -92,6 +92,12 @@ var paragraph = (function(paragraph) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return paragraph;
|
paragraph_plugin.destroy = function () {
|
||||||
|
|
||||||
|
paragraph = null;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return paragraph_plugin;
|
||||||
|
|
||||||
})({});
|
})({});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* Quote plugin
|
* Quote plugin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var quote = (function(quote) {
|
var quote = (function(quote_plugin) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
|
@ -401,7 +401,7 @@ var quote = (function(quote) {
|
||||||
|
|
||||||
if (data && data.size) {
|
if (data && data.size) {
|
||||||
|
|
||||||
data.style = quote.config.defaultStyle;
|
data.style = quote_plugin.config.defaultStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supported types
|
* Supported types
|
||||||
|
@ -457,11 +457,11 @@ var quote = (function(quote) {
|
||||||
*
|
*
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
quote.render = function(data) {
|
quote_plugin.render = function(data) {
|
||||||
return make_(data);
|
return make_(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
quote.validate = function(output) {
|
quote_plugin.validate = function(output) {
|
||||||
|
|
||||||
if (typeof output.text != "string") {
|
if (typeof output.text != "string") {
|
||||||
return;
|
return;
|
||||||
|
@ -470,7 +470,7 @@ var quote = (function(quote) {
|
||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
quote.save = function(blockContent) {
|
quote_plugin.save = function(blockContent) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts JSON quote data from HTML block
|
* Extracts JSON quote data from HTML block
|
||||||
|
@ -495,7 +495,7 @@ var quote = (function(quote) {
|
||||||
*
|
*
|
||||||
* Draws settings
|
* Draws settings
|
||||||
*/
|
*/
|
||||||
quote.makeSettings = function(data) {
|
quote_plugin.makeSettings = function(data) {
|
||||||
|
|
||||||
var holder = document.createElement('DIV'),
|
var holder = document.createElement('DIV'),
|
||||||
types = {
|
types = {
|
||||||
|
@ -517,7 +517,7 @@ var quote = (function(quote) {
|
||||||
|
|
||||||
selectTypeButton.dataset.style = type;
|
selectTypeButton.dataset.style = type;
|
||||||
|
|
||||||
if ( type == quote.config.defaultStyle ){
|
if ( type == quote_plugin.config.defaultStyle ){
|
||||||
selectTypeButton.classList.add(quoteTools.styles.settings.selectedType);
|
selectTypeButton.classList.add(quoteTools.styles.settings.selectedType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,27 +539,33 @@ var quote = (function(quote) {
|
||||||
* Default path to redactors images
|
* Default path to redactors images
|
||||||
* @type {null}
|
* @type {null}
|
||||||
*/
|
*/
|
||||||
quote.path = null;
|
quote_plugin.path = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*
|
*
|
||||||
* @type {null}
|
* @type {null}
|
||||||
*/
|
*/
|
||||||
quote.config = null;
|
quote_plugin.config = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*
|
*
|
||||||
* @param config
|
* @param config
|
||||||
*/
|
*/
|
||||||
quote.prepare = function(config) {
|
quote_plugin.prepare = function(config) {
|
||||||
|
|
||||||
quote.config = config;
|
quote_plugin.config = config;
|
||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
return quote;
|
quote_plugin.destroy = function () {
|
||||||
|
|
||||||
|
quote = null;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return quote_plugin;
|
||||||
|
|
||||||
})({});
|
})({});
|
|
@ -3,7 +3,7 @@
|
||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var twitter = (function(twitter) {
|
var twitter = (function(twitter_plugin) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User's configuration object
|
* User's configuration object
|
||||||
|
@ -158,7 +158,7 @@ var twitter = (function(twitter) {
|
||||||
* Prepare twitter scripts
|
* Prepare twitter scripts
|
||||||
* @param {object} config
|
* @param {object} config
|
||||||
*/
|
*/
|
||||||
twitter.prepare = function(config) {
|
twitter_plugin.prepare = function(config) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save configs
|
* Save configs
|
||||||
|
@ -199,11 +199,11 @@ var twitter = (function(twitter) {
|
||||||
return tweet;
|
return tweet;
|
||||||
};
|
};
|
||||||
|
|
||||||
twitter.validate = function(data) {
|
twitter_plugin.validate = function(data) {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
twitter.save = function(blockContent) {
|
twitter_plugin.save = function(blockContent) {
|
||||||
|
|
||||||
var data,
|
var data,
|
||||||
caption = blockContent.querySelector('.ce-twitter__caption');
|
caption = blockContent.querySelector('.ce-twitter__caption');
|
||||||
|
@ -228,11 +228,11 @@ var twitter = (function(twitter) {
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
twitter.render = function(data) {
|
twitter_plugin.render = function(data) {
|
||||||
return make_(data);
|
return make_(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
twitter.urlPastedCallback = function(url) {
|
twitter_plugin.urlPastedCallback = function(url) {
|
||||||
|
|
||||||
var tweetId,
|
var tweetId,
|
||||||
arr,
|
arr,
|
||||||
|
@ -256,15 +256,22 @@ var twitter = (function(twitter) {
|
||||||
make_(data);
|
make_(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
twitter.pastePatterns = [
|
twitter_plugin.pastePatterns = [
|
||||||
{
|
{
|
||||||
type: 'twitter',
|
type: 'twitter',
|
||||||
regex: /http?.+twitter.com?.+\//,
|
regex: /http?.+twitter.com?.+\//,
|
||||||
callback: twitter.urlPastedCallback
|
callback: twitter_plugin.urlPastedCallback
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
return twitter;
|
twitter_plugin.destroy = function () {
|
||||||
|
|
||||||
|
twitter = null;
|
||||||
|
delete window.twttr;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return twitter_plugin;
|
||||||
|
|
||||||
})({});
|
})({});
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue