editorjs-style
Advanced tools
Comparing version 2.2.0 to 3.0.0
declare class EditorJSStyleElement extends HTMLElement { | ||
constructor(); | ||
} | ||
export default EditorJSStyleElement; | ||
export { EditorJSStyleElement }; |
declare class EditorJSStyleError extends Error { | ||
constructor(...args: any[]); | ||
} | ||
export default EditorJSStyleError; | ||
export { EditorJSStyleError }; |
@@ -1,2 +0,1 @@ | ||
import EditorJSStyle from './EditorJSStyle'; | ||
export default EditorJSStyle; | ||
export { StyleInlineTool } from './StyleInlineTool'; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.EditorJSStyle=t():e.EditorJSStyle=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var s=t[r]={i:r,l:!1,exports:{}};return e[r].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)n.d(r,s,function(t){return e[t]}.bind(null,s));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);class r extends HTMLElement{constructor(){super(),this.addEventListener("keydown",e=>e.stopPropagation())}}var s=r;class i extends Error{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,i),this.name="EditorJSStyleError"}}var o,l,a=i,c=function(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n},u=function(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)};o=new WeakMap,l=new WeakMap;var d=class{constructor({api:e}){o.set(this,void 0),l.set(this,void 0),c(this,o,document.createElement("div")),c(this,l,e),customElements.get("editorjs-style")||customElements.define("editorjs-style",s)}static get isInline(){return!0}static get sanitize(){return{"editorjs-style":{class:!0,id:!0,style:!0}}}static get title(){return"Style"}get shortcut(){return"CMD+S"}checkState(){var e;u(this,o).innerHTML="";const t=u(this,l).selection.findParentTag("EDITORJS-STYLE");if(!t)return!1;u(this,o).innerHTML=`\n <div style="margin-left: 0.5rem; ">\n <div style="display: flex; align-items: center; justify-content: space-between; ">\n <div>Style settings</div>\n\n <button class="delete-button ${u(this,l).styles.settingsButton}" type="button">\n <svg class="icon" height="24" viewBox="0 0 24 24" width="24">\n <path d="M0 0h24v24H0z" fill="none"/>\n <path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/>\n </svg>\n </button>\n </div>\n\n <label style="display: flex; align-items: center; justify-content: space-between; ">\n <span>ID</span>\n\n <input class="id-input ${u(this,l).styles.input}" placeholder="exciting" style="width: 80%; ">\n </label>\n\n <label style="display: flex; align-items: center; justify-content: space-between; ">\n <span>Class</span>\n\n <input class="class-input ${u(this,l).styles.input}" placeholder="note editorial" style="width: 80%; ">\n </label>\n\n <label style="display: flex; align-items: center; justify-content: space-between; ">\n <span>Style</span>\n\n <textarea\n class="style-textarea ${u(this,l).styles.input}"\n placeholder="background: #ffe7e8;"\n style="resize: none; width: 80%; ">\n </textarea>\n </label>\n </div>\n `;const n=u(this,o).querySelector(".delete-button"),r=u(this,o).querySelector(".class-input"),s=u(this,o).querySelector(".id-input"),i=u(this,o).querySelector(".style-textarea");if(!(n&&r&&s&&i))throw new a;return n.addEventListener("click",()=>{const e=Array.from(t.childNodes).map(e=>e.cloneNode(!0));if(e.forEach(e=>{var n;return null===(n=t.parentNode)||void 0===n?void 0:n.insertBefore(e,t)}),t.remove(),0===e.length)return;const n=window.getSelection();if(!n)throw new a;n.removeAllRanges();const r=new Range;r.setStartBefore(e[0]),r.setEndAfter(e[e.length-1]),n.addRange(r)}),u(this,l).tooltip.onHover(n,"Delete style",{placement:"top"}),r.value=t.className,r.addEventListener("input",()=>t.setAttribute("class",r.value)),s.value=t.id,s.addEventListener("input",()=>t.id=s.value),i.value=null!==(e=t.getAttribute("style"))&&void 0!==e?e:"",i.addEventListener("keydown",e=>e.stopPropagation()),i.addEventListener("input",()=>t.setAttribute("style",i.value)),!0}clear(){u(this,o).innerHTML=""}render(){const e=document.createElement("button");return e.classList.add(u(this,l).styles.inlineToolButton),e.type="button",e.innerHTML='\n <svg class="icon" height="24" viewBox="0 0 24 24" width="24">\n <path d="M0 0h24v24H0z" fill="none"/>\n <path d="M2.53 19.65l1.34.56v-9.03l-2.43 5.86c-.41 1.02.08 2.19 1.09 2.61zm19.5-3.7L17.07 3.98c-.31-.75-1.04-1.21-1.81-1.23-.26 0-.53.04-.79.15L7.1 5.95c-.75.31-1.21 1.03-1.23 1.8-.01.27.04.54.15.8l4.96 11.97c.31.76 1.05 1.22 1.83 1.23.26 0 .52-.05.77-.15l7.36-3.05c1.02-.42 1.51-1.59 1.09-2.6zM7.88 8.75c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-2 11c0 1.1.9 2 2 2h1.45l-3.45-8.34v6.34z"/>\n </svg>\n ',e}renderActions(){return u(this,o)}surround(e){const t=new s;t.append(e.collapsed?"new style":e.extractContents()),setTimeout(()=>{e.insertNode(t),u(this,l).selection.expandToTag(t)})}};t.default=d}]).default})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.EditorJSStyle=t():e.EditorJSStyle=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t),n.d(t,"StyleInlineTool",(function(){return c}));class r extends HTMLElement{}class i extends Error{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,i),this.name="EditorJSStyleError"}}var s,o,l=function(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n},a=function(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)};class c{constructor({api:e}){s.set(this,void 0),o.set(this,void 0),l(this,s,document.createElement("div")),l(this,o,e)}static get isInline(){return!0}static get sanitize(){return{"editorjs-style":{class:!0,id:!0,style:!0}}}static get title(){return"Style"}static prepare(){customElements.get("editorjs-style")||customElements.define("editorjs-style",r)}get shortcut(){return"CMD+S"}checkState(){var e;a(this,s).innerHTML="";const t=a(this,o).selection.findParentTag("EDITORJS-STYLE");if(!t)return!1;a(this,s).innerHTML=`\n <div style="margin-bottom: 16px; margin-left: 16px; margin-right: 16px; ">\n <div style="display: flex; align-items: center; justify-content: space-between; ">\n <div>Style settings</div>\n\n <button class="delete-button ${a(this,o).styles.settingsButton}" type="button">\n <svg class="icon" height="24" viewBox="0 0 24 24" width="24">\n <path d="M0 0h24v24H0z" fill="none"/>\n <path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/>\n </svg>\n </button>\n </div>\n\n <label style="display: flex; align-items: center; justify-content: space-between; ">\n <span>ID</span>\n\n <input class="id-input ${a(this,o).styles.input}" style="width: 80%; ">\n </label>\n\n <label style="display: flex; align-items: center; justify-content: space-between; ">\n <span>Class</span>\n\n <input class="class-input ${a(this,o).styles.input}" style="width: 80%; ">\n </label>\n\n <label style="display: flex; align-items: center; justify-content: space-between; ">\n <span>Style</span>\n\n <textarea\n class="style-textarea ${a(this,o).styles.input}"\n placeholder="background: #ffe7e8;"\n style="resize: none; width: 80%; ">\n </textarea>\n </label>\n </div>\n `;const n=a(this,s).querySelector(".delete-button"),r=a(this,s).querySelector(".class-input"),l=a(this,s).querySelector(".id-input"),c=a(this,s).querySelector(".style-textarea");if(!(n&&r&&l&&c))throw new i;return n.addEventListener("click",()=>{const e=Array.from(t.childNodes).map(e=>e.cloneNode(!0));if(e.forEach(e=>{var n;return null===(n=t.parentNode)||void 0===n?void 0:n.insertBefore(e,t)}),t.remove(),0===e.length)return;const n=window.getSelection();if(!n)throw new i;n.removeAllRanges();const r=new Range;r.setStartBefore(e[0]),r.setEndAfter(e[e.length-1]),n.addRange(r),a(this,s).innerHTML="",a(this,o).tooltip.hide()}),a(this,o).tooltip.onHover(n,"Delete style",{placement:"top"}),r.value=t.className,r.addEventListener("input",()=>t.setAttribute("class",r.value)),l.value=t.id,l.addEventListener("input",()=>t.id=l.value),c.value=null!==(e=t.getAttribute("style"))&&void 0!==e?e:"",c.addEventListener("keydown",e=>e.stopPropagation()),c.addEventListener("input",()=>t.setAttribute("style",c.value)),!0}clear(){a(this,s).innerHTML=""}render(){const e=document.createElement("button");return e.classList.add(a(this,o).styles.inlineToolButton),e.type="button",e.innerHTML='\n <svg class="icon" height="24" viewBox="0 0 24 24" width="24">\n <path d="M0 0h24v24H0z" fill="none"/>\n <path d="M2.53 19.65l1.34.56v-9.03l-2.43 5.86c-.41 1.02.08 2.19 1.09 2.61zm19.5-3.7L17.07 3.98c-.31-.75-1.04-1.21-1.81-1.23-.26 0-.53.04-.79.15L7.1 5.95c-.75.31-1.21 1.03-1.23 1.8-.01.27.04.54.15.8l4.96 11.97c.31.76 1.05 1.22 1.83 1.23.26 0 .52-.05.77-.15l7.36-3.05c1.02-.42 1.51-1.59 1.09-2.6zM7.88 8.75c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-2 11c0 1.1.9 2 2 2h1.45l-3.45-8.34v6.34z"/>\n </svg>\n ',e}renderActions(){return a(this,s)}surround(e){const t=new r;t.append(e.extractContents()),e.insertNode(t),a(this,o).selection.expandToTag(t)}}s=new WeakMap,o=new WeakMap}])})); |
{ | ||
"name": "editorjs-style", | ||
"version": "2.2.0", | ||
"version": "3.0.0", | ||
"description": "Inline-style Tool for Editor.js", | ||
@@ -15,3 +15,3 @@ "keywords": [ | ||
"license": "MIT", | ||
"author": "hata6502", | ||
"author": "Tomoyuki Hata <hato6502@gmail.com>", | ||
"main": "dist/index.js", | ||
@@ -27,3 +27,3 @@ "scripts": { | ||
"devDependencies": { | ||
"@editorjs/editorjs": "^2.18.0", | ||
"@editorjs/editorjs": "^2.19.1", | ||
"license-checker": "^25.0.1", | ||
@@ -30,0 +30,0 @@ "material-design-icons": "^3.0.1", |
@@ -0,1 +1,2 @@ | ||
<!-- markdownlint-disable first-line-h1 --> | ||
<h1 align="center">Welcome to editorjs-style 👋</h1> | ||
@@ -9,8 +10,2 @@ <p> | ||
</a> | ||
<a href="https://lgtm.com/projects/g/hata6502/editorjs-style/alerts/"> | ||
<img alt="Total alerts" src="https://img.shields.io/lgtm/alerts/g/hata6502/editorjs-style.svg?logo=lgtm&logoWidth=18"/> | ||
</a> | ||
<a href="https://lgtm.com/projects/g/hata6502/editorjs-style/context:javascript"> | ||
<img alt="Language grade: JavaScript" src="https://img.shields.io/lgtm/grade/javascript/g/hata6502/editorjs-style.svg?logo=lgtm&logoWidth=18"/> | ||
</a> | ||
<a href="https://twitter.com/hata6502" target="_blank"> | ||
@@ -28,5 +23,2 @@ <img alt="Twitter: hata6502" src="https://img.shields.io/twitter/follow/hata6502.svg?style=social" /> | ||
By using with [editorjs-inspector](https://github.com/hata6502/editorjs-inspector), | ||
Editor.js can be used like a HTML editor. | ||
### ✨ [Demo](https://hata6502.github.io/editorjs-style/) | ||
@@ -76,8 +68,4 @@ | ||
<img alt="hata6502" src="https://avatars.githubusercontent.com/hata6502" width="48" /> **hata6502** | ||
<img alt="hata6502" src="https://avatars.githubusercontent.com/hata6502" width="48" /> **Tomoyuki Hata <hato6502@gmail.com>** | ||
- Website: https://b-hood.site/ | ||
- Twitter: [@hata6502](https://twitter.com/hata6502) | ||
- Github: [@hata6502](https://github.com/hata6502) | ||
## 🤝 Contributing | ||
@@ -95,3 +83,3 @@ | ||
Copyright © 2020 [hata6502](https://github.com/hata6502). | ||
Copyright © 2020 [Tomoyuki Hata](https://github.com/hata6502). | ||
@@ -98,0 +86,0 @@ This project is [MIT](https://github.com/hata6502/editorjs-style/blob/master/LICENSE) licensed. |
@@ -1,10 +0,3 @@ | ||
class EditorJSStyleElement extends HTMLElement { | ||
constructor() { | ||
super(); | ||
class EditorJSStyleElement extends HTMLElement {} | ||
// To prevent Editor.js keydown event | ||
this.addEventListener('keydown', (event) => event.stopPropagation()); | ||
} | ||
} | ||
export default EditorJSStyleElement; | ||
export { EditorJSStyleElement }; |
@@ -13,2 +13,2 @@ class EditorJSStyleError extends Error { | ||
export default EditorJSStyleError; | ||
export { EditorJSStyleError }; |
@@ -1,3 +0,1 @@ | ||
import EditorJSStyle from './EditorJSStyle'; | ||
export default EditorJSStyle; | ||
export { StyleInlineTool } from './StyleInlineTool'; |
@@ -17,5 +17,4 @@ module.exports = { | ||
library: 'EditorJSStyle', | ||
libraryExport: 'default', | ||
libraryTarget: 'umd', | ||
}, | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24
719590
251
91
1