Skip to content

Commit

Permalink
fix(prosemirror-resizable-view): set initial size CSS styles (remirro…
Browse files Browse the repository at this point in the history
  • Loading branch information
ocavue authored Oct 24, 2021
1 parent 2cfbca2 commit a469345
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-glasses-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'prosemirror-resizable-view': patch
---

Fix a bug that causes initial size CSS in resizable view not be set.
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ export abstract class ResizableNodeView implements NodeView {

if (initialSize) {
setStyle(outer, {
width: `${initialSize.width}px`,
height: `${initialSize.height}px`,
width: normalizeSize(initialSize.width),
height: normalizeSize(initialSize.height),
});
} else {
setStyle(outer, {
width: node.attrs.width,
height: node.attrs.height,
width: normalizeSize(node.attrs.width),
height: normalizeSize(node.attrs.height),
});
}

Expand Down Expand Up @@ -326,3 +326,13 @@ function sameMarkup(node1: ProsemirrorNode, node2: ProsemirrorNode, ignoreAttrs:

return same;
}

function normalizeSize(size: string | number | null | undefined): string | undefined {
if (typeof size === 'number') {
return `${size}px`;
} else if (size) {
return size;
} else {
return undefined;
}
}
1 change: 0 additions & 1 deletion support/root/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ let config = {
// Built in eslint rules
'no-constant-condition': 'off', // To many false positives
'no-empty': 'warn',
'no-else-return': 'warn',
'no-useless-escape': 'warn',
'default-case': 'off',
'default-case-last': 'error',
Expand Down

0 comments on commit a469345

Please sign in to comment.