medium-draft-studio
Advanced tools
Comparing version 0.1.5 to 0.1.6
/*! | ||
* medium-draft-studio | ||
* Version - 0.1.5 | ||
* Version - 0.1.6 | ||
* Author - Brijesh Bittu <brijeshb42@gmail.com> (http://bitwiser.in/) | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("draft-convert"),require("react")):"function"==typeof define&&define.amd?define(["draft-convert","react"],t):"object"==typeof exports?exports.MediumDraftExporter=t(require("draft-convert"),require("react")):e.MediumDraftExporter=t(e.DraftConvert,e.React)}(this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var l=n[r]={i:r,l:!1,exports:{}};return e[r].call(l.exports,l,l.exports,t),l.l=!0,l.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/static/",t(t.s=3)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=t.Block={UNSTYLED:"unstyled",PARAGRAPH:"unstyled",OL:"ordered-list-item",UL:"unordered-list-item",H1:"header-one",H2:"header-two",H3:"header-three",H4:"header-four",H5:"header-five",H6:"header-six",CODE:"code-block",BLOCKQUOTE:"blockquote",PULLQUOTE:"pullquote",ATOMIC:"atomic",BLOCKQUOTE_CAPTION:"block-quote-caption",CAPTION:"caption",TODO:"todo",IMAGE:"atomic:image",BREAK:"atomic:break",ALIGN_LEFT:"align-left",ALIGN_CENTER:"align-center",ALIGN_RIGHT:"align-right"},l=t.Inline={BOLD:"BOLD",CODE:"CODE",ITALIC:"ITALIC",STRIKETHROUGH:"STRIKETHROUGH",UNDERLINE:"UNDERLINE",HIGHLIGHT:"HIGHLIGHT",FONT_SMALL:"FONT_SMALL",FONT_LARGE:"FONT_LARGE",SUPERSCRIPT:"SUPERSCRIPT",SUBSCRIPT:"SUBSCRIPT"},a=t.Entity={LINK:"LINK",COVER_REQUEST:"COVER_REQUEST",PLACEHOLDER:"PLACEHOLDER",QUOTATION:"QUOTATION"};t.HYPERLINK="hyperlink",t.HANDLED="handled",t.NOT_HANDLED="not_handled",t.KEY_COMMANDS={addNewBlock:function(){return"add-new-block"},changeType:function(){return"changetype:"+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")},showLinkInput:function(){return"showlinkinput"},unlink:function(){return"unlink"},toggleInline:function(){return"toggleinline:"+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")},deleteBlock:function(){return"delete-block"}};t.default={Block:r,Inline:l,Entity:a}},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setRenderOptions=t.options=t.entityToHTML=t.blockToHTML=t.styleToHTML=void 0;var r=n(2),l=function(e){return e&&e.__esModule?e:{default:e}}(r),a=n(1),c=n(0),u=t.styleToHTML=function(e){switch(e){case c.Inline.ITALIC:return l.default.createElement("em",null);case c.Inline.BOLD:return l.default.createElement("strong",null);case c.Inline.STRIKETHROUGH:return l.default.createElement("strike",null);case c.Inline.UNDERLINE:return l.default.createElement("u",null);case c.Inline.HIGHLIGHT:return l.default.createElement("mark",null);case c.Inline.CODE:return l.default.createElement("code",null);case c.Inline.SUPERSCRIPT:return l.default.createElement("sup",null);case c.Inline.SUBSCRIPT:return l.default.createElement("sub",null);case"FONT_SMALL":return{start:'<span style="font-size: 0.8em">',end:"</span>"};case"FONT_MEDIUM":return{start:'<span style="font-size: 1em">',end:"</span>"};case"FONT_LARGE":return{start:'<span style="font-size: 1.2em">',end:"</span>"};case"QUOTATION":return l.default.createElement("q",null);default:return null}},o=t.blockToHTML=function(e){var t=e.type;switch(t){case c.Block.H1:return l.default.createElement("h1",null);case c.Block.H2:return l.default.createElement("h2",null);case c.Block.H3:return l.default.createElement("h3",null);case c.Block.H4:return l.default.createElement("h4",null);case c.Block.H5:return l.default.createElement("h5",null);case c.Block.H6:return l.default.createElement("h6",null);case c.Block.BLOCKQUOTE_CAPTION:case c.Block.CAPTION:return{start:"<p><caption>",end:"</caption></p>"};case c.Block.IMAGE:return{start:'<figure><img src="'+e.data.src+'" alt="'+e.text+'" /><figcaption className="md-block-image-caption">',end:"</figcaption></figure>"};case c.Block.ATOMIC:return l.default.createElement("figure",null);case c.Block.TODO:var n=e.data.checked||!1,r="",a="";return n?(r='<input type=checkbox disabled checked="checked" />',a="md-block-todo-checked"):(r="<input type=checkbox disabled />",a="md-block-todo-unchecked"),{start:'<div class="md-block-'+t.toLowerCase()+" "+a+'">'+r+"<p>",end:"</p></div>"};case c.Block.BREAK:return l.default.createElement("hr",null);case c.Block.BLOCKQUOTE:return l.default.createElement("blockquote",null);case c.Block.OL:return{element:l.default.createElement("li",null),nest:l.default.createElement("ol",null)};case c.Block.UL:return{element:l.default.createElement("li",null),nest:l.default.createElement("ul",null)};case c.Block.UNSTYLED:return e.text.length<1?l.default.createElement("p",null,l.default.createElement("br",null)):l.default.createElement("p",null);case c.Block.ALIGN_CENTER:return{start:'<div style="text-align: center;">',end:"</div>"};case c.Block.ALIGN_RIGHT:return{start:'<div style="text-align: right;">',end:"</div>"};case c.Block.ALIGN_LEFT:return{start:'<div style="text-align: left;">',end:"</div>"};case c.Block.CODE:return l.default.createElement("code",null);default:return null}},i=t.entityToHTML=function(e,t){return e.type===c.Entity.LINK?l.default.createElement("a",{href:e.data.url,target:"_blank",rel:"noopener noreferrer"},t):e.type===c.Entity.COVER_REQUEST?'<a9-self-request data-covername="'+e.data.cover+'">'+t+"</a9-self-request>":e.type===c.Entity.QUOTATION?"<q>"+t+"</q>":t},d=t.options={styleToHTML:u,blockToHTML:o,entityToHTML:i};t.setRenderOptions=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d;return(0,a.convertToHTML)(e)};t.default=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d;return(0,a.convertToHTML)(t)(e)}}])}); |
/*! | ||
* medium-draft-studio | ||
* Version - 0.1.5 | ||
* Version - 0.1.6 | ||
* Author - Brijesh Bittu <brijeshb42@gmail.com> (http://bitwiser.in/) | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("draft-convert")):"function"==typeof define&&define.amd?define(["draft-convert"],t):"object"==typeof exports?exports.MediumDraftImporter=t(require("draft-convert")):e.MediumDraftImporter=t(e.DraftConvert)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/static/",t(t.s=2)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=t.Block={UNSTYLED:"unstyled",PARAGRAPH:"unstyled",OL:"ordered-list-item",UL:"unordered-list-item",H1:"header-one",H2:"header-two",H3:"header-three",H4:"header-four",H5:"header-five",H6:"header-six",CODE:"code-block",BLOCKQUOTE:"blockquote",PULLQUOTE:"pullquote",ATOMIC:"atomic",BLOCKQUOTE_CAPTION:"block-quote-caption",CAPTION:"caption",TODO:"todo",IMAGE:"atomic:image",BREAK:"atomic:break",ALIGN_LEFT:"align-left",ALIGN_CENTER:"align-center",ALIGN_RIGHT:"align-right"},o=t.Inline={BOLD:"BOLD",CODE:"CODE",ITALIC:"ITALIC",STRIKETHROUGH:"STRIKETHROUGH",UNDERLINE:"UNDERLINE",HIGHLIGHT:"HIGHLIGHT",FONT_SMALL:"FONT_SMALL",FONT_LARGE:"FONT_LARGE",SUPERSCRIPT:"SUPERSCRIPT",SUBSCRIPT:"SUBSCRIPT"},i=t.Entity={LINK:"LINK",COVER_REQUEST:"COVER_REQUEST",PLACEHOLDER:"PLACEHOLDER",QUOTATION:"QUOTATION"};t.HYPERLINK="hyperlink",t.HANDLED="handled",t.NOT_HANDLED="not_handled",t.KEY_COMMANDS={addNewBlock:function(){return"add-new-block"},changeType:function(){return"changetype:"+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")},showLinkInput:function(){return"showlinkinput"},unlink:function(){return"unlink"},toggleInline:function(){return"toggleinline:"+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")},deleteBlock:function(){return"delete-block"}};t.default={Block:r,Inline:o,Entity:i}},function(t,n){t.exports=e},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setImportOptions=t.options=t.htmlToBlock=t.htmlToEntity=t.htmlToStyle=void 0;var r=n(1),o=n(0),i=t.htmlToStyle=function(e,t,n){switch(e){case"em":return n.add(o.Inline.ITALIC);case"strong":return n.add(o.Inline.BOLD);case"strike":return n.add(o.Inline.STRIKETHROUGH);case"u":return n.add(o.Inline.UNDERLINE);case"span":if(t.className==="md-inline-"+o.Inline.HIGHLIGHT.toLowerCase())return n.add(o.Inline.HIGHLIGHT);break;case"code":return n.add(o.Inline.CODE);case"sup":return n.add(o.Inline.SUPERSCRIPT);case"sub":return n.add(o.Inline.SUBSCRIPT)}return n},a=t.htmlToEntity=function(e,t,n){if("a"===e)return n(o.Entity.LINK,"MUTABLE",{url:t.href})},c=t.htmlToBlock=function(e,t){if("h1"===e)return{type:o.Block.H1,data:{}};if("h2"===e)return{type:o.Block.H2,data:{}};if("h3"===e)return{type:o.Block.H3,data:{}};if("h4"===e)return{type:o.Block.H4,data:{}};if("h5"===e)return{type:o.Block.H5,data:{}};if("h6"===e)return{type:o.Block.H6,data:{}};if("p"===e&&(t.className==="md-block-"+o.Block.CAPTION.toLowerCase()||t.className==="md-block-"+o.Block.BLOCKQUOTE_CAPTION.toLowerCase()))return{type:o.Block.BLOCKQUOTE_CAPTION,data:{}};{if("figure"!==e){if("div"===e&&t.className&&t.className.match(/^md-block-todo/)){var n=t.querySelector("input");return{type:o.Block.TODO,data:{checked:n&&n.checked}}}return"hr"===e?{type:o.Block.BREAK,data:{}}:"blockquote"===e?{type:o.Block.BLOCKQUOTE,data:{}}:"p"===e?{type:o.Block.UNSTYLED,data:{}}:void 0}if(t.className.match(/^md-block-image/)){var r=t.querySelector("img");return{type:o.Block.IMAGE,data:{src:r&&r.src}}}if(t.className==="md-block-"+o.Block.ATOMIC.toLowerCase())return{type:o.Block.ATOMIC,data:{}}}},l=t.options={htmlToStyle:i,htmlToEntity:a,htmlToBlock:c};t.setImportOptions=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l;return(0,r.convertFromHTML)(e)};t.default=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l;return(0,r.convertFromHTML)(t)(e)}}])}); |
@@ -182,3 +182,3 @@ 'use strict'; | ||
if (isCoverRequest) { | ||
_this.props.onRemoveCoverRequest(entityData.cover); | ||
_this.props.onRemoveCoverRequest(entityData.cover, newEditorState); | ||
} | ||
@@ -325,9 +325,12 @@ _this.onChange(newEditorState, _this.focus); | ||
if (cover !== '') { | ||
this.props.onAutocompleteSelect(cover, _id, preexisting); | ||
var contentWithEntity = content.createEntity(_constants.Entity.COVER_REQUEST, 'MUTABLE', { cover: cover, _id: _id }); | ||
editorState = _draftJs.EditorState.push(editorState, contentWithEntity, 'create-entity'); | ||
entityKey = contentWithEntity.getLastCreatedEntityKey(); | ||
var updatedState = _draftJs.RichUtils.toggleLink(editorState, selection, entityKey); | ||
if (previousCover) this.props.onRemoveCoverRequest(previousCover); | ||
this.props.onAutocompleteSelect(cover, _id, preexisting, updatedState); | ||
if (previousCover) this.props.onRemoveCoverRequest(previousCover, updatedState); | ||
} | ||
this.onChange(_draftJs.RichUtils.toggleLink(editorState, selection, entityKey), this.focus); | ||
@@ -334,0 +337,0 @@ } |
{ | ||
"name": "medium-draft-studio", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "A medium like rich text editor built upon draft-js with an emphasis on eliminating mouse usage by adding relevant keyboard shortcuts", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
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
698171
14829