(raw: string)
| 154 | } |
| 155 | |
| 156 | function parseLegacyEditmodeObject(raw: string): EditmodeTokens | null { |
| 157 | const text = raw.trim(); |
| 158 | if (!text.startsWith('{') || !text.endsWith('}')) return null; |
| 159 | const body = text.slice(1, -1).trim(); |
| 160 | if (body.length === 0) return {}; |
| 161 | |
| 162 | const tokens: EditmodeTokens = {}; |
| 163 | for (const rawLine of body.split('\n')) { |
| 164 | const line = rawLine.trim(); |
| 165 | if (line.length === 0) continue; |
| 166 | const entry = line.endsWith(',') ? line.slice(0, -1).trimEnd() : line; |
| 167 | const colon = entry.indexOf(':'); |
| 168 | if (colon <= 0) return null; |
| 169 | const key = parseLegacyKey(entry.slice(0, colon)); |
| 170 | if (key === null) return null; |
| 171 | const value = parseLegacyPrimitive(entry.slice(colon + 1)); |
| 172 | if (value === null) return null; |
| 173 | tokens[key] = value; |
| 174 | } |
| 175 | return tokens; |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Upgrades the old built-in-template EDITMODE form: |
no test coverage detected