Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

editore

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

editore - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

.npmignore

7

package.json
{
"name": "editore",
"version": "1.0.0",
"version": "1.1.0",
"author": "Evandro Eisinger <evandroeisinger@gmail.com>",

@@ -28,6 +28,3 @@ "license": "MIT",

],
"main": "src/editore.js",
"files": [
"src/editore.js"
]
"main": "src/editore.js"
}

@@ -1,2 +0,2 @@

# editore.js [![Build Status](https://travis-ci.org/evandroeisinger/editor.js.svg?branch=master)](https://travis-ci.org/evandroeisinger/editor.js)
# editore.js [![Build Status](https://travis-ci.org/evandroeisinger/editore.js.svg?branch=master)](https://travis-ci.org/evandroeisinger/editore.js) [![npm version](https://badge.fury.io/js/editore.svg)](http://badge.fury.io/js/editore)

@@ -3,0 +3,0 @@ > It's a magnific javascript editor! It's easy to create and valitade fields and get data from them, even better is that you don't need to handle contenteditable yourself :8ball:

@@ -37,3 +37,4 @@ (function (global, editore) {

plugins: [],
status: false
status: false,
checkPluginsState: self.setEditionComponentPluginsState.bind(self)
}

@@ -44,6 +45,6 @@ };

self.components.insert.element.setAttribute('contenteditable', 'false');
self.components.insert.element.setAttribute('id', 'insertComponent');
self.components.insert.element.setAttribute('id', 'insert-component');
// set edition element
self.components.edition.element.setAttribute('contenteditable', 'false');
self.components.edition.element.setAttribute('id', 'editionComponent');
self.components.edition.element.setAttribute('id', 'edition-component');
self.components.edition.element.style.position = 'absolute';

@@ -113,4 +114,5 @@ self.components.edition.element.style.zIndex = 9999;

return new Error('invalid component type or plugin');
var plugin = new Plugin(self.components[component]);
Plugin.prototype.component = self.components[component];
// instance a new plugin
var plugin = new Plugin();
self.components[component].plugins[plugin.name] = plugin;

@@ -142,3 +144,3 @@ self.components[component].element.appendChild(plugin.button);

plugin = component.plugins[plugin];
plugin.beforeDestroy(component);
plugin.destroy();
// unset components listeners

@@ -253,2 +255,4 @@ if (plugin._action)

selection = window.getSelection(),
selectionSupport = ['p', 'b', 'a', 'i'],
selectionTag = e.target.tagName.toLowerCase(),
range,

@@ -259,3 +263,6 @@ position,

if (selection.type == 'Range' && !self.components.edition.status) {
if (selectionSupport.indexOf(selectionTag) < 0)
return;
if (selection.type == 'Range') {
self.setComponent('edition', field);

@@ -266,13 +273,14 @@ range = selection.getRangeAt(0);

left = ((position.left + position.right) / 2) - (self.components.edition.element.offsetWidth / 2);
// set component position and props
self.components.edition.element.style.top = top + 'px';
self.components.edition.element.style.left = left + 'px';
self.components.edition.status = true;
self.components.edition.selection = selection;
// set edition plugins state
self.setEditionComponentPluginsState();
return;
}
if(self.components.edition.status) {
if (self.components.edition.selection) {
document.body.removeChild(self.components.edition.element);
self.components.edition.status = false;
self.components.edition.selection = false;
self.components.edition.selection = null;
}

@@ -461,5 +469,8 @@ },

// set new action
plugin._action = self.setListener([plugin.action], field, plugin);
if (component == 'edition')
plugin._action = self.setListener([plugin.action, self.setEditionComponentPluginsState], field, plugin);
else
plugin._action = self.setListener([plugin.action], field, plugin);
// set action handler
plugin.button.addEventListener('click', plugin._action);
plugin.beforeShow(self.components[component], field);
}

@@ -474,2 +485,7 @@

case 'edition':
self.components.edition.element.innerHTML = "";
for (plugin in self.components.edition.plugins) {
plugin = self.components.edition.plugins[plugin];
self.components.edition.element.appendChild(plugin.button);
}
// set edition component

@@ -484,2 +500,34 @@ document.body.appendChild(self.components.edition.element);

setEditionComponentPluginsState: function() {
var self = this,
edition = self.component || self.components.edition,
currentSelectionNode,
plugin,
range;
// set plugins state
for (plugin in edition.plugins) {
plugin = edition.plugins[plugin];
range = edition.selection.getRangeAt(0);
if (range.startContainer.nodeType === 3)
currentSelectionNode = range.startContainer.parentNode;
else
currentSelectionNode = range.startContainer;
plugin.button.classList.remove('active');
while (currentSelectionNode.parentNode.tagName !== undefined) {
if (currentSelectionNode.tagName.toLowerCase() == plugin.tag.toLowerCase()) {
plugin.button.classList.add('active');
break;
}
// keep find
currentSelectionNode = currentSelectionNode.parentNode;
}
}
return self;
},
setListener: function(methods, data, context) {

@@ -486,0 +534,0 @@ var method;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc