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