Remove tool type from switchBlock -> by default it will saved from previous (#166)

* small fixes

regex match must not be similar to pasted string. Ex:
```https://www.instagram.com/p/BQ3wxmlA5GN/?taken-by=thenotoriousmma``
and match is ```https://www.instagram.com/p/BQ3wxmlA5GN/```.

```SwitchBlock``` have 3 parameter that is not important

* new instagram embed regex
This commit is contained in:
khaydarov 2017-02-26 13:22:21 +03:00 committed by Peter Savchenko
parent 7f737774bb
commit 3cbe8faaa6
14 changed files with 25 additions and 23 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -68,8 +68,8 @@
showInlineToolbar: true,
allowRenderOnPaste: true
},
heading_styled: {
type: 'heading_styled',
header: {
type: 'header',
iconClassname: 'ce-icon-header',
appendCallback: header.appendCallback,
makeSettings: header.makeSettings,
@ -120,8 +120,8 @@
enableLineBreaks: true,
allowedToPaste: true,
},
quote_styled: {
type: 'quote_styled',
quote: {
type: 'quote',
iconClassname: 'ce-icon-quote',
makeSettings: quote.makeSettings,
prepare: quote.prepare,
@ -158,7 +158,7 @@
type: 'instagram',
iconClassname: 'ce-icon-instagram',
prepare: instagram.prepare,
render: instagram.reneder,
render: instagram.render,
validate: instagram.validate,
save: instagram.save,
destroy: instagram.destroy,

View file

@ -3,7 +3,7 @@
* Works with DOM
*
* @author Codex Team
* @version 1.3.11
* @version 1.3.12
*/
module.exports = (function (content) {
@ -347,6 +347,7 @@ module.exports = (function (content) {
*/
content.switchBlock = function (blockToReplace, newBlock, tool) {
tool = tool || editor.content.currentNode.dataset.tool;
var newBlockComposed = editor.content.composeNewBlock(newBlock, tool);
/** Replacing */

View file

@ -2,7 +2,7 @@
* Codex Editor Paste module
*
* @author Codex Team
* @version 1.0
* @version 1.1.1
*/
module.exports = function (paste) {
@ -25,6 +25,7 @@ module.exports = function (paste) {
tools[tool].renderOnPastePatterns.map(function (pattern) {
patterns.push(pattern);
});

View file

@ -2,7 +2,7 @@
* Codex Editor UI module
*
* @author Codex Team
* @version 1.1
* @version 1.1.3
*/
module.exports = (function (ui) {
@ -178,7 +178,7 @@ module.exports = (function (ui) {
editor.tools[toolName] = tool;
if (!tool.iconClassname) {
if (!tool.iconClassname && tool.displayInToolbox) {
editor.core.log('Toolbar icon classname missed. Tool %o skipped', 'warn', toolName);
continue;

View file

@ -1,6 +1,6 @@
{
"name": "codex.editor",
"version": "1.5.2",
"version": "1.5.3",
"description": "Codex Editor. Native JS, based on API and Open Source",
"main": "index.js",
"scripts": {

View file

@ -7,7 +7,7 @@ var embed = function(embed_plugin){
var methods = {
addInternal: function (content) {
codex.editor.content.switchBlock(codex.editor.content.currentNode, content, 'video_extended');
codex.editor.content.switchBlock(codex.editor.content.currentNode, content);
var blockContent = codex.editor.content.currentNode.childNodes[0];
blockContent.classList.add('embed__loader');

View file

@ -39,7 +39,7 @@ var header = (function(header_plugin) {
new_header.setAttribute('data-placeholder', 'Заголовок');
new_header.dataset.headerData = type;
codex.editor.content.switchBlock(old_header, new_header, 'heading_styled');
codex.editor.content.switchBlock(old_header, new_header);
/** Close settings after replacing */
codex.editor.toolbar.settings.close();

View file

@ -369,7 +369,7 @@ var image = (function(image_plugin) {
var newImage = make_(data);
codex.editor.content.switchBlock(image.holder, newImage, 'image_extended');
codex.editor.content.switchBlock(image.holder, newImage);
newImage.classList.add(elementClasses_.imagePreview);
/**
@ -414,7 +414,7 @@ var image = (function(image_plugin) {
var oldHolder = image.holder;
var form = ui_.makeForm();
codex.editor.content.switchBlock(oldHolder, form, 'image_extended');
codex.editor.content.switchBlock(oldHolder, form);
}
},
@ -479,7 +479,7 @@ var image = (function(image_plugin) {
var img = image.querySelector('img');
codex.editor.content.switchBlock(codex.editor.content.currentNode, image, 'image_extended');
codex.editor.content.switchBlock(codex.editor.content.currentNode, image);
};

View file

@ -8,7 +8,7 @@ var instagram = (function(instagram_plugin) {
render : function(content) {
codex.editor.content.switchBlock(codex.editor.content.currentNode, content, 'instagram');
codex.editor.content.switchBlock(codex.editor.content.currentNode, content);
setTimeout(function() {
window.instgrm.Embeds.process();
@ -144,7 +144,7 @@ var instagram = (function(instagram_plugin) {
instagram_plugin.pastePatterns = [
{
type: 'instagram',
regex: /http?.+instagram.com\/p\/([a-zA-Z0-9]*)/,
regex: /http?.+instagram.com\/p\/([a-zA-Z0-9]*)\S*/,
callback: instagram_plugin.urlPastedCallback
}
];

View file

@ -74,7 +74,7 @@ var list = (function(list_plugin) {
newEditable.innerHTML = oldEditable.innerHTML;
newEditable.classList.add(elementClasses_.pluginWrapper);
codex.editor.content.switchBlock(currentBlock, newEditable, 'list');
codex.editor.content.switchBlock(currentBlock, newEditable);
},
keyDown: function (e) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long