independant elements from p + delete p from li
This commit is contained in:
parent
048a1b67e6
commit
c321a17f3e
8 changed files with 36 additions and 19 deletions
|
|
@ -306,9 +306,11 @@ export function useElementSettings({ margin, padding, basePopup }) {
|
|||
getValue: () => bold.value ? 'bold' : (INLINE_DEFAULTS[currentTag.value]?.fontWeight || null),
|
||||
skip: () => !bold.value && !INLINE_DEFAULTS[currentTag.value]?.fontWeight && !hasInCss('font-weight') },
|
||||
{ css: 'font-size', group: 'fontSize', special: true,
|
||||
getValue: () => `${fontSize.value}${fontSize.unit}` },
|
||||
getValue: () => `${fontSize.value}${fontSize.unit}`,
|
||||
skip: () => isIndependentElement.value && !settingEnabled.fontSize && !hasInCss('font-size') },
|
||||
{ css: 'line-height', group: 'lineHeight', special: true,
|
||||
getValue: () => `${lineHeight.value}${lineHeight.unit}` },
|
||||
getValue: () => `${lineHeight.value}${lineHeight.unit}`,
|
||||
skip: () => isIndependentElement.value && !settingEnabled.lineHeight && !hasInCss('line-height') },
|
||||
{ css: 'text-align', group: 'textAlign',
|
||||
getValue: () => textAlign.value,
|
||||
skip: () => !settingEnabled.textAlign && !hasInCss('text-align') },
|
||||
|
|
@ -345,6 +347,10 @@ export function useElementSettings({ margin, padding, basePopup }) {
|
|||
|
||||
const isInlineElement = computed(() => !!INLINE_DEFAULTS[currentTag.value]);
|
||||
|
||||
// Elements that don't inherit font-size/line-height from <p> — fully independent of TextSettings p-level
|
||||
const INDEPENDENT_TAGS = new Set(['li', 'ul', 'ol', 'dt', 'dd', 'dl', 'table', 'tr', 'td', 'th', 'caption', 'figure', 'figcaption', 'pre', 'blockquote']);
|
||||
const isIndependentElement = computed(() => INDEPENDENT_TAGS.has(currentTag.value));
|
||||
|
||||
// Check if the current selector has a CSS property in the store
|
||||
const hasInCss = (cssProp) => {
|
||||
if (!selector.value) return false;
|
||||
|
|
@ -642,28 +648,33 @@ export function useElementSettings({ margin, padding, basePopup }) {
|
|||
}
|
||||
}
|
||||
|
||||
// Fallback to TextSettings defaults only if the selector doesn't already have the value
|
||||
// Fallback to TextSettings defaults only if the selector doesn't already have the value.
|
||||
// Independent elements (li, ul, ol, table...) don't inherit from <p> — only body-level fallbacks apply.
|
||||
const independent = isIndependentElement.value;
|
||||
|
||||
if (!settingEnabled.font && !settingCache.font) {
|
||||
if (!stylesheetStore.extractValue(selector.value, 'font-family')) {
|
||||
const ff = stylesheetStore.extractValue('body', 'font-family');
|
||||
if (ff) fontFamily.value = (typeof ff === 'string' ? ff : ff.value).replace(/['"]/g, '');
|
||||
}
|
||||
if (!stylesheetStore.extractValue(selector.value, 'font-style')) {
|
||||
const fs = stylesheetStore.extractValue('p', 'font-style');
|
||||
if (fs) italic.value = (typeof fs === 'string' ? fs : fs.value) === 'italic';
|
||||
}
|
||||
if (!stylesheetStore.extractValue(selector.value, 'font-weight')) {
|
||||
const fw = stylesheetStore.extractValue('p', 'font-weight');
|
||||
if (fw) { const v = typeof fw === 'string' ? fw : fw.value; bold.value = v === 'bold' || parseInt(v) >= 700; }
|
||||
if (!independent) {
|
||||
if (!stylesheetStore.extractValue(selector.value, 'font-style')) {
|
||||
const fs = stylesheetStore.extractValue('p', 'font-style');
|
||||
if (fs) italic.value = (typeof fs === 'string' ? fs : fs.value) === 'italic';
|
||||
}
|
||||
if (!stylesheetStore.extractValue(selector.value, 'font-weight')) {
|
||||
const fw = stylesheetStore.extractValue('p', 'font-weight');
|
||||
if (fw) { const v = typeof fw === 'string' ? fw : fw.value; bold.value = v === 'bold' || parseInt(v) >= 700; }
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!settingEnabled.fontSize && !settingCache.fontSize) {
|
||||
if (!independent && !settingEnabled.fontSize && !settingCache.fontSize) {
|
||||
if (!stylesheetStore.extractValue(selector.value, 'font-size')) {
|
||||
const data = stylesheetStore.extractValue('p', 'font-size');
|
||||
if (data && data.value !== undefined) { fontSize.value = data.value; fontSize.unit = data.unit; }
|
||||
}
|
||||
}
|
||||
if (!settingEnabled.lineHeight && !settingCache.lineHeight) {
|
||||
if (!independent && !settingEnabled.lineHeight && !settingCache.lineHeight) {
|
||||
if (!stylesheetStore.extractValue(selector.value, 'line-height')) {
|
||||
const data = stylesheetStore.extractValue('p', 'line-height');
|
||||
if (data && data.value !== undefined) { lineHeight.value = data.value; lineHeight.unit = data.unit; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue