Skip to content

Commit 9e16c0e

Browse files
authored
Merge pull request #1874 from merico-dev/fix-line-height
fix(rich-text-editor): Fix line-height mark parsing and rendering
2 parents 070b197 + 8b708b8 commit 9e16c0e

File tree

5 files changed

+10
-23
lines changed

5 files changed

+10
-23
lines changed

api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtable/api",
3-
"version": "14.60.2",
3+
"version": "14.60.3",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

dashboard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtable/dashboard",
3-
"version": "14.60.2",
3+
"version": "14.60.3",
44
"license": "Apache-2.0",
55
"repository": {
66
"url": "https://github.com/merico-dev/table"

dashboard/src/components/widgets/rich-text-editor/line-height-mark/line-height-mark.tsx

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,17 @@ export const LineHeightMark = Mark.create({
3838
return [
3939
{
4040
tag: 'line-height',
41-
getAttrs: (node: string | HTMLElement) => {
42-
if (typeof node === 'string') {
43-
console.debug(node);
44-
return false;
45-
}
46-
47-
return [node.getAttribute(AttrKey)];
41+
getAttrs: (element) => {
42+
const lineHeight = element.getAttribute(AttrKey);
43+
console.log('parse html', lineHeight);
44+
return lineHeight ? { [AttrKey]: lineHeight } : false;
4845
},
4946
},
5047
];
5148
},
5249

5350
renderHTML({ HTMLAttributes }) {
54-
const lineHeight = HTMLAttributes[AttrKey];
55-
if (lineHeight) {
56-
// Apply line-height as inline style
57-
return [
58-
'span',
59-
{
60-
...HTMLAttributes,
61-
style: `line-height: ${lineHeight}`,
62-
},
63-
0,
64-
];
65-
}
66-
return ['span', HTMLAttributes, 0];
51+
return ['line-height', { ...HTMLAttributes, style: `line-height: ${HTMLAttributes[AttrKey]}` }, 0];
6752
},
6853

6954
addCommands() {

dashboard/src/components/widgets/rich-text-editor/readonly-rich-text-editor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { ColorMappingMark, getColorMappingStyle } from './color-mapping-mark';
2424
import { DynamicColorMark, getDynamicColorStyles } from './dynamic-color-mark';
2525
import { FontSize } from './font-size-extension';
2626
import { InteractionBlock } from './interaction-block-node';
27+
import { LineHeightMark } from './line-height-mark';
2728

2829
interface IReadonlyRichText {
2930
value: string;
@@ -61,6 +62,7 @@ export const ReadonlyRichText = forwardRef<HTMLDivElement, IReadonlyRichText>(
6162
TextStyle,
6263
Color,
6364
FontSize,
65+
LineHeightMark,
6466
DynamicColorMark,
6567
InteractionBlock,
6668
];

settings-form/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtable/settings-form",
3-
"version": "14.60.2",
3+
"version": "14.60.3",
44
"license": "Apache-2.0",
55
"repository": {
66
"url": "https://github.com/merico-dev/table"

0 commit comments

Comments
 (0)