@lexical/react
Version:
This package provides Lexical components and hooks for React applications.
10 lines (8 loc) • 1.33 kB
JavaScript
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import{DecoratorNode as t,$getDocument as r,nodeSchema as e,withField as o,enumValue as n}from"lexical";function a(t,r){t.__format=r.__format}const f=()=>({exportJSON:function(t){return{format:t.__format,type:t.__type,version:1}},exportCompactJSON:function(t){const r={type:t.__type},e=t.__format;return void 0!==e&&""!==e&&(r.format=e),r},updateFromJSON:function(t,r){const e=r.format;return t.__format=""===e||"left"===e||"start"===e||"center"===e||"right"===e||"end"===e||"justify"===e?e:"",t},afterCloneFrom:a}),i=/* @__PURE__ */e()({format:/* @__PURE__ */o(/* @__PURE__ */n(["","left","start","center","right","end","justify"]),{field:"__format"})});class c extends t{__format;constructor(t,r){super(r),this.__format=t||""}$config(){return this.config(Symbol.for("DecoratorBlockNode"),{extends:t,generated:f,json:i})}canIndent(){return!1}createDOM(){return r().createElement("div")}updateDOM(){return!1}setFormat(t){const r=this.getWritable();return r.__format=t,r}getFormat(){return this.getLatest().__format}isInline(){return!1}}function s(t){return t instanceof c}export{s as $isDecoratorBlockNode,c as DecoratorBlockNode};