Skip to content

Commit

Permalink
fix: html deserializer error
Browse files Browse the repository at this point in the history
  • Loading branch information
big-camel committed Jul 4, 2023
1 parent 54e5dd1 commit f5a4018
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/unlucky-cars-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@editablejs/plugin-alignment': patch
'@editablejs/plugin-leading': patch
---

fix html deserializer error
8 changes: 4 additions & 4 deletions packages/plugins/alignment/src/deserializer/html.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { isDOMHTMLElement } from '@editablejs/models'
import { isDOMHTMLElement, Element } from '@editablejs/models'
import { HTMLDeserializerWithTransform } from '@editablejs/deserializer/html'
import { Align, AlignKeys, AlignValue } from '../interfaces/align'
export const withAlignHTMLDeserializerTransform: HTMLDeserializerWithTransform = next => {
return (node, options = {}) => {
const { element } = options
if (isDOMHTMLElement(node)) {
if (isDOMHTMLElement(node) && options.element) {
let { textAlign, justifyContent } = node.style
if (node.nodeName === 'CENTER') {
textAlign = 'center'
}
const align: Align = element as Align

const align: Align = options.element as Align
if (
textAlign &&
textAlign.toLowerCase() !== AlignValue.Left &&
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/leading/src/deserializer/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Leading } from '../interfaces/leading'
export const withLeadingHTMLDeserializerTransform: HTMLDeserializerWithTransform = next => {
return (node, options = {}) => {
const { element } = options
if (isDOMHTMLElement(node)) {
if (isDOMHTMLElement(node) && element) {
const { lineHeight } = node.style
let leading: Partial<Leading> = element as Partial<Leading>
if (lineHeight) {
Expand Down

0 comments on commit f5a4018

Please sign in to comment.