mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-26 02:05:31 +00:00
Copy react-native-enriched-markdown@1.2.0-nightly-20261014-766fc0e67 (upstream software-mansion/enriched-markdown 766fc0e67) into packages/react-native-enriched-markdown, with patches/react-native-enriched-markdown+1.2.0-nightly-20261014-766fc0e67.patch applied. Nothing else changes in this commit; the package is not a workspace yet. Reproduce: npm pack react-native-enriched-markdown@1.2.0-nightly-20261014-766fc0e67 tar xzf react-native-enriched-markdown-*.tgz mkdir -p t/node_modules && mv package t/node_modules/react-native-enriched-markdown (cd t && git init -q && git apply ../patches/react-native-enriched-markdown+*.patch) diff -r t/node_modules/react-native-enriched-markdown packages/react-native-enriched-markdown The diff is empty.
106 lines
3.5 KiB
JavaScript
106 lines
3.5 KiB
JavaScript
"use strict";
|
|
|
|
import { processColor } from 'react-native';
|
|
import { normalizeLinkVariantEntries } from "./linkVariantUtils.js";
|
|
import { normalizeColor } from "./styleUtils.js";
|
|
import { DEFAULT_HEADING_FONT_WEIGHT, HEADING_DEFAULTS } from "./headingDefaults.js";
|
|
const DEFAULT_LINK_COLOR = '#2563EB';
|
|
const DEFAULT_LINK_BG_COLOR = 'transparent';
|
|
const DEFAULT_SPOILER_COLOR = '#374151';
|
|
const DEFAULT_SPOILER_BG_COLOR = '#E5E7EB';
|
|
|
|
// Defaults shared with the read-only renderer via headingDefaults; consumers
|
|
// override per level via markdownStyle h1..h6.
|
|
const defaultHeadingInternal = key => {
|
|
const d = HEADING_DEFAULTS[key];
|
|
return {
|
|
fontSize: d.fontSize,
|
|
fontWeight: DEFAULT_HEADING_FONT_WEIGHT,
|
|
color: processColor(d.color)
|
|
};
|
|
};
|
|
const defaultInternal = Object.freeze({
|
|
strong: {
|
|
color: undefined
|
|
},
|
|
em: {
|
|
color: undefined
|
|
},
|
|
link: {
|
|
color: processColor(DEFAULT_LINK_COLOR),
|
|
underline: true,
|
|
backgroundColor: processColor(DEFAULT_LINK_BG_COLOR)
|
|
},
|
|
linkVariants: [],
|
|
spoiler: {
|
|
color: processColor(DEFAULT_SPOILER_COLOR),
|
|
backgroundColor: processColor(DEFAULT_SPOILER_BG_COLOR)
|
|
},
|
|
h1: defaultHeadingInternal('h1'),
|
|
h2: defaultHeadingInternal('h2'),
|
|
h3: defaultHeadingInternal('h3'),
|
|
h4: defaultHeadingInternal('h4'),
|
|
h5: defaultHeadingInternal('h5'),
|
|
h6: defaultHeadingInternal('h6'),
|
|
list: {
|
|
itemSpacing: 0
|
|
}
|
|
});
|
|
const normalizeHeadingStyle = (key, style) => {
|
|
const fallback = defaultInternal[key];
|
|
return {
|
|
fontSize: style?.fontSize ?? fallback.fontSize,
|
|
fontWeight: style?.fontWeight ?? fallback.fontWeight,
|
|
color: normalizeColor(style?.color) ?? fallback.color
|
|
};
|
|
};
|
|
let cachedInput;
|
|
let cachedResult;
|
|
function normalizeInputLinkStyle(style, fallback) {
|
|
return {
|
|
color: normalizeColor(style?.color) ?? fallback.color,
|
|
underline: style?.underline ?? fallback.underline,
|
|
backgroundColor: normalizeColor(style?.backgroundColor) ?? fallback.backgroundColor
|
|
};
|
|
}
|
|
export const normalizeMarkdownTextInputStyle = style => {
|
|
if (!style || Object.keys(style).length === 0) {
|
|
return defaultInternal;
|
|
}
|
|
if (style === cachedInput && cachedResult) {
|
|
return cachedResult;
|
|
}
|
|
const linkBase = normalizeInputLinkStyle(style.link, defaultInternal.link);
|
|
const result = {
|
|
strong: {
|
|
color: normalizeColor(style.strong?.color)
|
|
},
|
|
em: {
|
|
color: normalizeColor(style.em?.color)
|
|
},
|
|
link: linkBase,
|
|
linkVariants: normalizeLinkVariantEntries(style.linkVariants).map(([pattern, override]) => ({
|
|
pattern,
|
|
color: normalizeColor(override.color) ?? linkBase.color,
|
|
underline: override.underline ?? linkBase.underline,
|
|
backgroundColor: normalizeColor(override.backgroundColor) ?? defaultInternal.link.backgroundColor
|
|
})),
|
|
spoiler: {
|
|
color: normalizeColor(style.spoiler?.color) ?? defaultInternal.spoiler.color,
|
|
backgroundColor: normalizeColor(style.spoiler?.backgroundColor) ?? defaultInternal.spoiler.backgroundColor
|
|
},
|
|
h1: normalizeHeadingStyle('h1', style.h1),
|
|
h2: normalizeHeadingStyle('h2', style.h2),
|
|
h3: normalizeHeadingStyle('h3', style.h3),
|
|
h4: normalizeHeadingStyle('h4', style.h4),
|
|
h5: normalizeHeadingStyle('h5', style.h5),
|
|
h6: normalizeHeadingStyle('h6', style.h6),
|
|
list: {
|
|
itemSpacing: style.list?.itemSpacing ?? defaultInternal.list.itemSpacing
|
|
}
|
|
};
|
|
cachedInput = style;
|
|
cachedResult = result;
|
|
return result;
|
|
};
|
|
//# sourceMappingURL=normalizeMarkdownTextInputStyle.js.map
|