mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-21 08:17:10 +08:00
fix #13459 fix #13707 fix #13924 #### PR Dependency Tree * **PR #14394** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Improved URL paste: text is split into segments, inserted correctly, and single-URL pastes create linked-page references. * **UI Improvements** * Redesigned layout selector with compact dynamic options. * Number-format options are always available in table headers and mobile menus. * **Bug Fixes** * More consistent paste behavior for mixed text+URL content. * Prevented recursive selection updates when exiting edit mode. * **Tests** * Added tests for URL splitting, paste insertion, number formatting, and selection behavior. * **Chores** * Removed number-formatting feature flag; formatting now applied by default. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import zod from 'zod';
|
|
|
|
import { t } from '../../core/logical/type-presets.js';
|
|
import { propertyType } from '../../core/property/property-config.js';
|
|
import { NumberPropertySchema } from './types.js';
|
|
import { parseNumber } from './utils/formatter.js';
|
|
export const numberPropertyType = propertyType('number');
|
|
|
|
export const numberPropertyModelConfig = numberPropertyType.modelConfig({
|
|
name: 'Number',
|
|
propertyData: {
|
|
schema: NumberPropertySchema,
|
|
default: () => ({ decimal: 0, format: 'number' }) as const,
|
|
},
|
|
jsonValue: {
|
|
schema: zod.number().nullable(),
|
|
isEmpty: ({ value }) => value == null,
|
|
type: () => t.number.instance(),
|
|
},
|
|
rawValue: {
|
|
schema: zod.number().nullable(),
|
|
default: () => null,
|
|
toString: ({ value }) => value?.toString() ?? '',
|
|
fromString: ({ value }) => {
|
|
const num = value ? parseNumber(value) : NaN;
|
|
return { value: isNaN(num) ? null : num };
|
|
},
|
|
toJson: ({ value }) => value ?? null,
|
|
fromJson: ({ value }) => (typeof value !== 'number' ? null : value),
|
|
},
|
|
});
|