"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/typeof"),t=require("lodash"),r=require("slate");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=a(e),i=function(e){if(!e)return!1;try{var t=JSON.parse(e);return{isValid:"object"===n.default(t)&&null!==t,parsedJSON:t}}catch(e){return{isValid:!1,parsedJSON:null}}},l=function(e){return[{type:"paragraph",children:[{text:e}]}]},u={getValidJSON:i,getValidSlateJSON:function(e){var r=i(e),a=r.isValid,n=r.parsedJSON;return a?{isTextValidSlateJSON:a&&t.get(n,"0.children"),parsedJSON:n}:{isTextValidSlateJSON:!1,parsedSlateJSON:null}},getDefaultParagraphObjectEmpty:function(){return[{type:"paragraph",children:[]}]},isSlateTextEmpty:function(e){return!e||1===e.length&&!t.get(e,"0.children.0.text")&&!t.get(e,"0.children.0.type")},getFormattedText:function(e){var t=e.isValid,r=e.isEmpty,a=e.text,n=e.parsedText,i=e.defaultText;return t?r?i:n:a||i},getFormattedTextToEdit:function(e){var t=e.isValid,r=e.isEmpty,a=e.text,n=e.parsedText;return t?r?l(""):n:a&&l(a)||l("")},getPlainTextFromSlateJSON:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",a=i(e);return(null==a?void 0:a.parsedJSON)&&a.parsedJSON.map((function(e){return r.Node.string(e)})).join("\n")||t}};exports.slateFormattingTextUtils=u;
//# sourceMappingURL=utils.js.map
