ユーザーがテキストをサーバーに送信するアプリを開発しています。次に、サーバーはテキストを変更し、元のテキストと変更されたテキストで応答します。
JSON で削除されたテキストを表現する方法。(取り消し線)
たとえば、次のようにします。
私はそのようなことを考えました:
ストロークを含む場所とそうでない場所に分割されたすべてのテキストを含む配列:
data={
textBefore:'this is the first world. this is the second world',
textAfter:'this is first world. this is second world,
changes:[
{'nostroke':'this is th'},
{'stroe':'efirst world'},
{'nostroke':'in the third world'}
]
}
もっと良いアイデアはありますか?
またはこのように:
data={
textBefore:'this is the first world. this is the second world',
textAfter:'this is first world. this is second world,
changes:[
{from:2,to:22,text:'repace from char 2 to char 22 with this text'},
{from:2,to:4} // This will only delete 2 chars
{from:2,to:2,text:'This will only append this text without replae},
]