Address LaySite 1.4.5 editor and release review suggestions
This commit is contained in:
@@ -753,8 +753,13 @@ jQuery(function ($) {
|
||||
const target = doc && formatTarget();
|
||||
$format.add($fontSize).add($fontPreset).prop('disabled', !target);
|
||||
const sample = target && (selectedText()[0]?.node || target);
|
||||
const computed = sample ? doc.defaultView.getComputedStyle(sample.nodeType === 1 ? sample : sample.parentElement) : null;
|
||||
if (!$fontSize.is(':focus')) $fontSize.val(computed ? Math.round(parseFloat(computed.fontSize)) : '');
|
||||
const element = sample?.nodeType === 1 ? sample : sample?.parentElement;
|
||||
const computed = element ? doc.defaultView.getComputedStyle(element) : null;
|
||||
const sizeClass = element && classesOf(element).size;
|
||||
const size = sizeClass ? sizeClass.slice('studio-style-size-'.length)
|
||||
: (computed ? String(Math.round(parseFloat(computed.fontSize))) : '');
|
||||
if (!$fontSize.is(':focus')) $fontSize.val(size);
|
||||
$fontPreset.val($fontPreset.find('option').toArray().some((option) => option.value === size) ? size : '');
|
||||
$color.add($clearColor).prop('disabled', !target);
|
||||
const rgb = computed?.color.match(/^rgba?\((\d+), (\d+), (\d+)(?:, [\d.]+)?\)$/);
|
||||
if (rgb && !$color.is(':focus')) $color.val('#' + rgb.slice(1).map((channel) => Number(channel).toString(16).padStart(2, '0')).join(''));
|
||||
@@ -815,7 +820,6 @@ jQuery(function ($) {
|
||||
$format.on('click', function () { applyTextStyle(this.dataset.canvasFormat); });
|
||||
$fontPreset.on('change', function () {
|
||||
applyTextStyle('size', this.value);
|
||||
this.value = '';
|
||||
});
|
||||
$fontSize.on('change', function () {
|
||||
if (this.validity.valid) applyTextStyle('size', this.value === '' ? '' : String(this.valueAsNumber));
|
||||
@@ -833,7 +837,7 @@ jQuery(function ($) {
|
||||
const presets = $preset.data('spacingPreset');
|
||||
const index = same && values[0] !== '' ? presets.indexOf(Number(values[0])) : -1;
|
||||
const label = !same ? '自定义' : (values[0] === '' ? '默认' : values[0] + ' px');
|
||||
$preset.val(index === -1 ? $preset.prop('defaultValue') : index).attr('aria-valuetext', label);
|
||||
$preset.val(index).attr('aria-valuetext', label);
|
||||
$fields.find('[data-spacing-readout]').text(label);
|
||||
}
|
||||
|
||||
@@ -850,7 +854,7 @@ jQuery(function ($) {
|
||||
$spacingForm.on('input', '[data-spacing-preset]', function () {
|
||||
const $preset = $(this);
|
||||
const $fields = $preset.closest('fieldset');
|
||||
$fields.find('[data-spacing-side]').val($preset.data('spacingPreset')[this.valueAsNumber]);
|
||||
$fields.find('[data-spacing-side]').val($preset.data('spacingPreset')[this.valueAsNumber] ?? '');
|
||||
syncSpacingPreset($fields);
|
||||
}).on('input', '[data-spacing-side]', function () {
|
||||
syncSpacingPreset($(this).closest('fieldset'));
|
||||
|
||||
Reference in New Issue
Block a user