为什么 Google Docs 的运营转型会偏向删除?

2024-01-03

今天尝试了这个实验:为 Google 文档打开两个离线编辑器。其中,我将第一个词加粗。第二次,我把它删除了。无论我首先打开哪个客户端,该单词最终都会被删除。

首先,为什么会出现这种情况——我对运营转型的理解是排序很重要?在两个人分别输入“a”和“b”的简单示例中,如果服务器首先收到“a”,它将通过将第二个人的“b”事件转换为“传递一个空格”来强制输出“ab” ,然后添加 b" 事件,反之亦然。

其次,如果顺序无关紧要,是否存在技术原因导致 Google Docs 选择在删除方面犯错误?或者对于用户来说原因很简单?


这是(5年后我知道的)一个关于为什么会发生这种情况的图形解释。事实上,这就是 @osma 所描述的,但以图形方式解释:

当您在 GDocs 中加粗字符串时,您正在将字符串包装到容器中,大概是这样<strong></strong>但他们可以使用任何其他语法。为了简单起见,我们假设将字符串加粗只需要在单词开头加一个“+”。因此,为了简单起见,文本“lorem ipsum”将变为lorem +ipsum并不是lorem <strong>ipsum<strong>

1

Both Alice and Bob start with the text "Lorem ipsum" enter image description here

2

Bob then deletes "ipsum". Notice that he sends the changeset retain(6), delete(5) to the server. A changeset is essentially a patch, Google probably used this library https://github.com/GerHobbelt/google-diff-match-patch. enter image description here

3

Now Alice bolds "ipsum" (adding "+"). She sends is the changeset retain(6), insert(+), retain(5) enter image description here

4

Both changesets are traveling to the server. The server knows nothing about these sets yet. enter image description here

5

Assuming the worst scenario: Bob's package arrives first and then the word will be deleted. The other scenario is obvious. enter image description here

6

When Alice's package arrives, it will only add a "+" to the text because what she sent is only a single changeset. enter image description here

7

Both texts are then broadcasted to the clients. This is the first one. enter image description here

8

And this is the second one. enter image description here

9

将这些变更集修补到原始文本中后,您最终会得到“Lorem +”。服务器和所有客户端现在具有相同的文本。这+符号稍后将被常见的 HTML 清理过程删除,该过程消除了空标签,例如<tag></tag>,

要测试此演示,请访问:http://operational-transformation.github.io/visualization.html http://operational-transformation.github.io/visualization.html。在那里,您可以在发送/接收文本和包裹时进行操作。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么 Google Docs 的运营转型会偏向删除? 的相关文章

随机推荐