{"record":{"id":"fdb10f3a5403af78","repo":"toeverything/AFFiNE","slug":"inlineeditorerror-fdb10f","errorCode":"InlineEditorError","errorMessage":"yText must not contain \"\\r\" because it will break the range synchronization","messagePattern":"yText must not contain \"\\\\r\" because it will break the range synchronization","errorType":"exception","errorClass":"BlockSuiteError","httpStatus":null,"severity":"error","filePath":"blocksuite/framework/std/src/inline/services/render.ts","lineNumber":66,"sourceCode":"    };\n    if (!this.editor.isValidInlineRange(newInlineRange)) return;\n\n    this.editor.setInlineRange(newInlineRange);\n  };\n\n  private readonly _onYTextChange = (\n    _: Y.YTextEvent,\n    transaction: Y.Transaction\n  ) => {\n    this.editor.slots.textChange.next();\n\n    const yText = this.editor.yText;\n\n    if (\n      (this._carriageReturnValidationCounter++ & 0x3f) === 0 &&\n      yText.toString().includes('\\r')\n    ) {\n      throw new BlockSuiteError(\n        ErrorCode.InlineEditorError,\n        'yText must not contain \"\\\\r\" because it will break the range synchronization'\n      );\n    }\n\n    if (!transaction.local) {\n      this._pendingRemoteInlineRangeSync = true;\n    }\n\n    this.render();\n  };\n\n  mount = () => {\n    const editor = this.editor;\n    const yText = editor.yText;\n\n    yText.observe(this._onYTextChange);\n    editor.disposables.add({","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/blocksuite/framework/std/src/inline/services/render.ts#L48-L84","documentation":"RenderService periodically validates (every 64th yText change) that the inline editor's Y.Text contains no carriage returns, because \\r corrupts DOM/range synchronization; throwing turns a silent rendering bug into an explicit data error from upstream content.","triggerScenarios":"Thrown at blocksuite/framework/std/src/inline/services/render.ts:66 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Strip carriage returns from text before inserting into yText: text.replace(/\\r\\n?/g, '\\n').","Normalize pasted or imported content to use only \\n line endings before applying it to the inline editor.","If the text comes from a file or clipboard, normalize line endings at the import boundary, not inside the editor."],"exampleFix":"function normalizeForYText(text: string): string {\n  return text.replace(/\\r\\n?/g, '\\n');\n}\nyText.insert(0, normalizeForYText(rawText));","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}