mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 07:10:41 +00:00
Allow newlines in strings by special casing "\n"
This commit is contained in:
@@ -135,7 +135,7 @@ const SPECIAL_UNSET = '__unset__'
|
||||
function StringHead({ type, optional, node, ctx }: Props<StringType>) {
|
||||
const { locale } = useLocale()
|
||||
|
||||
const value = JsonStringNode.is(node) ? node.value : undefined
|
||||
const value = (JsonStringNode.is(node) ? node.value : undefined)?.replaceAll('\n', '\\n')
|
||||
|
||||
const idAttribute = type.attributes?.find(a => a.name === 'id')?.value
|
||||
const idRegistry = idAttribute?.kind === 'literal' && idAttribute.value.kind === 'string'
|
||||
@@ -149,6 +149,7 @@ function StringHead({ type, optional, node, ctx }: Props<StringType>) {
|
||||
const isSelect = idRegistry && isSelectRegistry(idRegistry)
|
||||
|
||||
const onChangeValue = useCallback((newValue: string) => {
|
||||
newValue = newValue.replaceAll('\\n', '\n')
|
||||
if (value === newValue) {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user