-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: paragraphNode should apply configured indent value from theme on exportDOM #6082
Labels
enhancement
Improvement over existing feature
Comments
What i understand:
Personally, I lean towards (B) since it ensures the same result for the same editor state source but (A) is for outside sources. |
For someone who needs this, you can utilize HTML config as a workaround. for example: const htmlConfig: HTMLConfig = {
export: new Map([
[
ParagraphNode,
(editor, node) => {
const targetNode = node as ParagraphNode;
const element = document.createElement('p');
if (element && isHTMLElement(element)) {
if (targetNode.isEmpty()) {
element.append(document.createElement('br'));
}
const formatType = targetNode.getFormatType();
element.style.textAlign = formatType;
const direction = targetNode.getDirection();
if (direction) {
element.dir = direction;
}
const indent = targetNode.getIndent();
setElementIndent(element, indent, editor._config.theme.indent);
}
return {
element,
};
},
],
]),
};
const DEFAULT_INDENT_VALUE = '40px';
function setElementIndent(dom: HTMLElement, indent: number, indentClassName?: string): void {
if (indent < 1) {
return;
}
if (typeof indentClassName === 'string') {
dom.classList.add(indentClassName);
}
const indentationBaseValue =
window.getComputedStyle(dom).getPropertyValue('--lexical-indent-base-value') ||
DEFAULT_INDENT_VALUE;
dom.style.setProperty(
// padding-inline-start is not widely supported in email HTML, but
// Lexical Reconciler uses padding-inline-start. Using text-indent instead.
'text-indent',
`${indent * parseInt(indentationBaseValue, 10)}px`
);
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from exportDOM
from reconciler
element returned from
exportDOM
ofparagraphNode
doesn't have indent class from theme and doesn't apply configured indentation base value as well.instead, it always has 20px as indentation value which makes difference between generated html and contenteditable.
Should this exported element have indent class from theme and also same indent value as configured in indent class ?
The text was updated successfully, but these errors were encountered: