Document editing method and device, storage medium and terminal

By updating and synchronizing shared data structures, conflict problems during multiple editing are solved, real-time consistency and efficient collaborative editing of documents are achieved.

CN119227641APending Publication Date: 2024-12-31BEIJING QIHOOD TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310785926.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-29
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

Existing document editors are prone to conflicts when multiple people edit the same document at the same time, and cannot achieve efficient collaborative editing.

Method used

By obtaining the editor data generated by the document editor, updating the shared data structure, and sending it to the server, synchronous update of documents between multiple clients, ensuring that all users can see and edit the latest content in real time.

Benefits of technology

It realizes the function of multiple clients to edit the same document at the same time, improves the efficiency of editing the same document by multiple people and ensures real-time consistency of the document.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119227641A_ABST
    Figure CN119227641A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a document editing method and device, a storage medium and a terminal, and the method comprises the steps: obtaining first editor data, generated by a first document editor, for a shared document in response to a first document sharing editing operation for the shared document, obtaining a first shared data structure corresponding to the shared document, the first shared data structure is updated based on the first editor data to obtain a target shared data structure, the target shared data structure is sent to a server, and the target shared data structure is used for the server to send the target shared data structure to at least one second client side. The target shared data structure is used for determining second editor data for the shared document by the second client and controlling a second document editor to update the shared document based on the second editor data. According to the embodiment of the invention, the function that multiple clients edit the same shared document at the same time is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of collaborative editing technology, and in particular to a document editing method, device, storage medium and terminal. Background Art

[0002] With the development of computer technology, documents such as Word, Excel and PPT have been integrated into all aspects of people's daily office work. In daily office scenarios, different users using different terminals may edit the same document.

[0003] For this scenario, the existing technology can use online document collaboration technology to enable different users to edit the same document. For example, in some document editors, when one user edits a document, the edited content can be instantly synchronized to other users who have co-editing permissions on the document, and other users can also see the user's complete editing process of the document. Summary of the invention

[0004] The embodiment of the present application provides a document editing method, device, computer storage medium and terminal, which realizes the function of multiple clients editing the same shared document at the same time. The technical solution is as follows:

[0005] In a first aspect, an embodiment of the present application provides a document editing method, which is applied to a first client, and the method includes:

[0006] In response to a first document sharing and editing operation on a shared document, obtaining first editor data for the shared document generated by a first document editor;

[0007] Acquire a first shared data structure corresponding to the shared document, and update the first shared data structure based on the first editor data to obtain a target shared data structure;

[0008] The target shared data structure is sent to a server, and the target shared data structure is used by the server to send the target shared data structure to at least one second client, and the target shared data structure is used by the second client to determine second editor data for the shared document and control the second document editor to update the shared document based on the second editor data.

[0009] In a feasible implementation manner, before obtaining first editor data for the shared document generated by a first document editor in response to a first document shared editing operation for the shared document, the method further includes:

[0010] Generating a shared document display interface for the shared document based on the first document editor;

[0011] A first document sharing and editing operation for a shared document is received in the shared document display interface.

[0012] In a feasible implementation manner, the updating the first shared data structure based on the first editor data to obtain a target shared data structure includes:

[0013] Performing data conversion on the first editor data to obtain reference editing data of a data sharing type;

[0014] The first shared data structure is updated based on the reference edit data to obtain a target shared data structure.

[0015] In a feasible implementation manner, performing data conversion on the first editor data to obtain reference editing data of a data sharing type includes:

[0016] Obtaining a preset data conversion container, where the data conversion container is a container component that performs data conversion on the first document editor and the first shared data structure;

[0017] The first editor data is converted into a data sharing type based on the data conversion container to obtain reference editing data of the data sharing type.

[0018] In a feasible implementation manner, the updating the first shared data structure based on the reference edit data to obtain a target shared data structure includes:

[0019] Determining, based on the reference editing data, a data modification time, a data modification location, and a data modification content for the shared document;

[0020] Based on the data modification time, the data modification location, and the data modification content, the first shared data structure is updated to obtain a target shared data structure.

[0021] In a feasible implementation manner, the method further includes:

[0022] receiving a reference shared data structure for the shared document sent by the server, wherein the reference shared data structure is generated when the second client responds to a second document shared editing operation for the shared document and is sent by the second client to the server;

[0023] determining third editor data for the shared document based on the reference shared data structure;

[0024] The first document editor is controlled to update the shared document based on the third editor data.

[0025] In a feasible implementation manner, the determining the third editor data for the shared document based on the reference shared data structure includes:

[0026] Acquire the target shared data structure corresponding to the shared document, and update the target shared data structure based on the reference shared data structure to obtain the updated target shared data structure;

[0027] The target shared data structure is converted into third editor data for the shared document.

[0028] In a feasible implementation manner, controlling the first document editor to update the shared document based on the third editor data includes:

[0029] Determining data editing time, data editing location, and data editing content for the shared document based on the third editing data;

[0030] The first document editor is controlled to update the shared document at the data editing location according to the data editing time and the data editing content.

[0031] In a second aspect, an embodiment of the present application provides a document editing device, applied to a first client, the device comprising:

[0032] A data acquisition module, configured to acquire, in response to a first document sharing and editing operation on a shared document, first editor data for the shared document generated by a first document editor;

[0033] A data updating module, configured to obtain a first shared data structure corresponding to the shared document, and update the first shared data structure based on the first editor data to obtain a target shared data structure;

[0034] A data sending module is used to send the target shared data structure to a server, and the target shared data structure is used by the server to send the target shared data structure to at least one second client, and the target shared data structure is used by the second client to determine the second editor data for the shared document and control the second document editor to update the shared document based on the second editor data.

[0035] In a feasible implementation manner, before obtaining first editor data for the shared document generated by a first document editor in response to a first document shared editing operation for the shared document, the method further includes:

[0036] Generating a shared document display interface for the shared document based on the first document editor;

[0037] A first document sharing and editing operation for a shared document is received in the shared document display interface.

[0038] In a feasible implementation manner, the updating the first shared data structure based on the first editor data to obtain a target shared data structure includes:

[0039] Performing data conversion on the first editor data to obtain reference editing data of a data sharing type;

[0040] The first shared data structure is updated based on the reference edit data to obtain a target shared data structure.

[0041] In a feasible implementation manner, performing data conversion on the first editor data to obtain reference editing data of a data sharing type includes:

[0042] Obtaining a preset data conversion container, where the data conversion container is a container component that performs data conversion on the first document editor and the first shared data structure;

[0043] The first editor data is converted into a data sharing type based on the data conversion container to obtain reference editing data of the data sharing type.

[0044] In a feasible implementation manner, the updating the first shared data structure based on the reference edit data to obtain a target shared data structure includes:

[0045] Determining a data modification time, a data modification location, and a data modification content for the shared document based on the reference editing data;

[0046] Based on the data modification time, the data modification position and the data modification content, the first shared data structure is updated to obtain a target shared data structure.

[0047] In a feasible implementation manner, the method further includes:

[0048] receiving a reference shared data structure for the shared document sent by the server, wherein the reference shared data structure is generated when the second client responds to a second document shared editing operation for the shared document and is sent by the second client to the server;

[0049] determining third editor data for the shared document based on the reference shared data structure;

[0050] The first document editor is controlled to update the shared document based on the third editor data.

[0051] In a feasible implementation manner, the determining the third editor data for the shared document based on the reference shared data structure includes:

[0052] Acquire the target shared data structure corresponding to the shared document, and update the target shared data structure based on the reference shared data structure to obtain the updated target shared data structure;

[0053] The target shared data structure is converted into third editor data for the shared document.

[0054] In a feasible implementation manner, controlling the first document editor to update the shared document based on the third editor data includes:

[0055] Determining data editing time, data editing location, and data editing content for the shared document based on the third editing data;

[0056] The first document editor is controlled to update the shared document at the data editing location according to the data editing time and the data editing content.

[0057] In a third aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium has a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.

[0058] In a fourth aspect, an embodiment of the present application provides a terminal, which may include: a memory and a processor; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the memory and executing the above-mentioned method steps.

[0059] The beneficial effects brought by the technical solution provided by the embodiment of the present application include at least:

[0060] In an embodiment of the present application, in response to a first document sharing and editing operation on a shared document, a first client obtains first editor data for the shared document generated by a first document editor, obtains a first shared data structure corresponding to the shared document, updates the first shared data structure based on the first editor data, obtains a target shared data structure, and sends the target shared data structure to a server, wherein the target shared data structure is used by the server to send the target shared data structure to at least one second client, and the target shared data structure is used by the second client to determine the second editor data for the shared document and control the second document editor to update the shared document based on the second editor data. In an embodiment of the present application, an editor and a shared data structure of a shared document are combined to update the shared data structure using the editor data generated by the editor, and the updated shared data structure is sent to the server, so that the server can forward the updated shared data structure to the second client that participates in editing the shared document with the first client, and the second client can update the shared document on the local side according to the updated shared data structure, so as to realize the function of multiple clients editing the same shared document at the same time, thereby improving the efficiency of multiple people editing the same document. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.

[0062] Figure 1 It is a schematic diagram of the system architecture of a document editing method provided in an embodiment of the present application;

[0063] Figure 2 It is a flowchart of a document editing method provided in an embodiment of the present application;

[0064] Figure 3 It is a flowchart of another document editing method provided in an embodiment of the present application;

[0065] Figure 4 It is a structural schematic diagram of a document editing device provided in an embodiment of the present application;

[0066] Figure 5 It is a structural diagram of a terminal provided in an embodiment of the present application. DETAILED DESCRIPTION

[0067] In order to make the purpose, features, and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0068] In the description of the present application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In the description of the present application, it should be noted that, unless otherwise clearly specified and limited, "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood in specific circumstances. In addition, in the description of the present application, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are an "or" relationship.

[0069] In the related art, many document editors can enable different users to edit the same document.

[0070] In order to avoid conflicts caused by multiple people editing at the same time, some document editors choose to lock the document. That is, when one user modifies the document, the entire document is locked, and other users can only view but not edit the document. The document will be unlocked only when the editing user quits editing. In this document editor, only one user is allowed to edit the document at the same time, and it is impossible to realize the function of multiple people editing the same document at the same time.

[0071] See also Figure 1 , which is a system architecture diagram of a document editing method provided in an embodiment of the present application.

[0072] like Figure 1 As shown, the figure includes a first terminal 101, a second terminal 102 and a server 103. Figure 1 The number of second terminals shown is only exemplary, and the embodiment of the present application does not limit the number of second terminals to one.

[0073] The first terminal 101 may be a first client in the embodiment of the present application, and the first terminal 101 may include a desktop computer, a notebook, a mobile phone, a tablet, etc. The second terminal may be a second client in the embodiment of the present application, and the second terminal 102 may also include a desktop computer, a notebook, a mobile phone, a tablet, etc.

[0074] The first terminal and the second terminal are two different devices.

[0075] The server 103 may be an electronic device with a data forwarding function, or a separate server device, such as a rack-mounted, blade, tower, or cabinet-mounted server device, or a workstation, mainframe computer, or other hardware device with strong computing power; it may also be a server cluster composed of multiple servers, wherein each server in the service cluster may be composed in a symmetrical manner, wherein each server has equivalent functions and status in the business link, and each server may provide services to the outside independently, and the independent service may be understood as requiring no assistance from another server.

[0076] The first terminal 101 and the server 103, and the second terminal 102 and the server 103 can communicate interactively via a wired network or a wireless network. The wireless network includes but is not limited to a cellular network, a wireless local area network, an infrared network, or a Bluetooth network. The wired network includes but is not limited to an Ethernet, a universal serial bus (USB), or a controller area network.

[0077] In some embodiments, technologies and / or formats including Hyper Text Mark-up Language (HTML), Extensible Markup Language (XML), etc. are used to represent data (such as target compressed packages) exchanged through the network. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec), etc. can also be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technologies can also be used to replace or supplement the above data communication technologies.

[0078] In an embodiment of the present application, in response to a first document sharing and editing operation on a shared document, a first client obtains first editor data for the shared document generated by a first document editor, obtains a first shared data structure corresponding to the shared document, updates the first shared data structure based on the first editor data, obtains a target shared data structure, and sends the target shared data structure to a server, wherein the target shared data structure is used by the server to send the target shared data structure to at least one second client, and the target shared data structure is used by the second client to determine the second editor data for the shared document and control the second document editor to update the shared document based on the second editor data. In an embodiment of the present application, a document sharing editor and a shared data structure are combined to update the shared data structure using the editor data generated by the document sharing editor, and the updated shared data structure is sent to the server, so that the server can forward the updated shared data structure to the second client that participates in editing the shared document with the first client, and the second client can update the shared document on the local side according to the updated shared data structure, so as to realize the function of multiple clients editing the same shared document at the same time, thereby improving the efficiency of multiple people editing the same document.

[0079] In the following method embodiments, for the sake of convenience, only the execution subject of each step is introduced and described as the terminal.

[0080] See also Figure 2 , is a flowchart of a document editing method provided in an embodiment of the present application. Figure 2 As shown, the method of the embodiment of the present application may include the following steps:

[0081] S201 : In response to a first document sharing and editing operation on a shared document, obtaining first editor data for a shared document generated by a first document editor.

[0082] It is easy to understand that a shared document may refer to a document that supports collaborative editing by multiple users.

[0083] The first document sharing and editing operation may refer to a document editing operation input in the shared document. For example, the first document sharing and editing operation may be an adding operation, a deleting operation, etc. When a user performs the first document sharing and editing operation on a shared document, other users who collaborate with the user may view the first document sharing and editing operation on their respective terminals.

[0084] The first document editor may refer to a document editor installed on the first client, which may support the creation of a shared document and support collaborative editing of the shared document with other clients. The client here may refer to a terminal. Specifically, the first document editor in the embodiment of the present application may refer to a document editor installed in a browser, that is, a user can use the document editor in a browser.

[0085] In some embodiments, when a first document sharing and editing operation for a shared document is received, in response to the first document sharing and editing operation, first editor data for the shared document generated by the first document editor according to the first document sharing and editing operation can be obtained from the first document editor. Specifically, the first editor data may include the operation position and operation content of the first document sharing and editing operation in the shared document. For example, the operation position may be the position indicated by the row and column in the shared document; the operation content may be adding a certain word or a certain character at the operation position, or deleting a certain word or a certain character at the operation position.

[0086] S202, obtaining a first shared data structure corresponding to the shared document, and updating the first shared data structure based on the first editor data to obtain a target shared data structure.

[0087] It is easy to understand that the first shared data structure refers to a shared type of data structure provided by a collaborative library implemented based on a conflict-free replicated data type (CRDT). For example, the collaborative library may refer to Yjs. The first shared data structure, as the name implies, can be disclosed as a shared type. For different terminals using this data structure, the data corresponding to each of the different terminals can be merged without conflict through this data structure.

[0088] In some embodiments, for different terminals that collaborate to edit the same shared document, each terminal can locally store a first shared data structure corresponding to the shared document edited by each terminal. After acquiring the first editor data, the first shared data structure corresponding to the shared document can be acquired locally first, and then the local first shared data structure can be updated according to the first editor data acquired above to obtain the target shared data structure. Specifically, the first editor data and the first shared data structure respectively store data of two different data types, so when updating the first shared data structure, the first editor data can be first converted into editing data of the data type corresponding to the first shared data structure, and then the first shared data structure can be updated according to the editing data of the data type.

[0089] It should be noted that the first shared data structure stored locally has corresponding data for the data stored at the location in the shared document. For example, each location in the shared document can be represented by a specific serial number. Location 12 and location 13 store two characters "Logic", and the corresponding data stored in the first shared data structure can be represented by data of a data type unique to the shared data structure.

[0090] S203: Send the target shared data structure to the server.

[0091] In some embodiments, after a shared document is created and the terminals for collaborative editing have not yet performed an editing operation on the shared document, the first shared data structure corresponding to the shared document stored locally by each terminal may be the same data structure. When one of the terminals performs an editing operation on the shared document, the first shared data structure corresponding to the local shared data structure will change and may become the above-mentioned target shared data structure. During the short period of time when the editing operation of the shared document by the terminal has not yet been synchronized to other terminals, the first shared data structures corresponding to the local shared data of the other terminals have not changed and are still the original data structures. At this time, in order to synchronize the editing operation of the shared document by the terminal to other terminals, the target shared data structure in the terminal may be sent to the server, and the server may send the target shared data structure to other terminals. If the terminal is represented by the first client and the other terminals are represented by the second client, then the server sends the target shared data structure from the first client to at least one second client, and the target shared data structure may be used by the second client to determine the second editor data for the above-mentioned shared document, and the target shared data structure may be used by the second client to control the second document editor to update the shared document based on the second editor data. This allows one client to edit a shared document while a second client can simultaneously update the shared document, thereby making the shared document consistent.

[0092] The second document editor may refer to an editor on the second client for editing the shared document. The second editor data refers to data transmitted by the second client to the second document editor for updating the shared document.

[0093] Since the first client first obtains the first editor data generated by the first document editor for the shared document in the process of generating the target shared data structure, and then updates the first shared data structure according to the editor data to obtain the target shared data structure, the second client needs to first determine the second editor data according to the target shared data, and then control the second document editor to update the shared document according to the second editor data, in the process of restoring the editing operation on the shared document from the target shared data structure.

[0094] In an embodiment of the present application, in response to a first document sharing and editing operation on a shared document, a first client obtains first editor data for the shared document generated by a first document editor, obtains a first shared data structure corresponding to the shared document, updates the first shared data structure based on the first editor data, obtains a target shared data structure, and sends the target shared data structure to a server, wherein the target shared data structure is used by the server to send the target shared data structure to at least one second client, and the target shared data structure is used by the second client to determine the second editor data for the shared document and control the second document editor to update the shared document based on the second editor data. In an embodiment of the present application, an editor and a shared data structure of a shared document are combined to update the shared data structure using the editor data generated by the editor, and the updated shared data structure is sent to the server, so that the server can forward the updated shared data structure to the second client that participates in editing the shared document with the first client, and the second client can update the shared document on the local side according to the updated shared data structure, so as to realize the function of multiple clients editing the same shared document at the same time, thereby improving the efficiency of multiple people editing the same document.

[0095] See also Figure 3 , is a flowchart of a document editing method provided in an embodiment of the present application. Figure 3 As shown, the method of the embodiment of the present application may include the following steps:

[0096] S301: Generate a shared document display interface for a shared document based on a first document editor.

[0097] In the embodiment of the present application, the first document editor may be prosemirror. prosemirror may be a toolkit for developing a rich text editor. A rich text editor refers to a text editor that can be embedded in a browser and is WYSIWYG.

[0098] The shared document display interface refers to the user interface of a text editor used to edit shared documents.

[0099] In the embodiment of the present application, the vue framework can be used to generate a shared document display interface for shared documents according to the prosemirror. The vue framework is a progressive JavaScript framework. The goal of vue is to implement responsive data binding and combined view components through the simplest application programming interface (API) possible. The core of vue mainly includes three aspects: first, data-driven pages, vue modifies the bound data, and can update the page accordingly, which greatly liberates the work of operating dom and improves development efficiency; second, vue adopts the MVVM mode, the first M in the MVVM mode represents the data model model, the first V represents the view (i.e., the view or page), and the latter two VMs represent the controller viewmodel of the data model and the view, realizing two-way binding of data; third, vue can split the page according to the page function, such as navigation, sidebar, drop-down box, etc., and each component can correspond to an independent function, ensuring the maintainability and reusability of the code.

[0100] S302: receiving a first document sharing and editing operation on a shared document in a shared document display interface.

[0101] It is easy to understand that the first document sharing and editing operation may refer to a document editing operation input in the shared document. For example, the first document sharing and editing operation may be an adding operation, a deleting operation, and the like.

[0102] In some embodiments, a user may input a first document sharing and editing operation for a shared document on the shared document display interface, and at the same time, the terminal may receive the first document sharing and editing operation in the shared document display interface. The first document sharing and editing operation may include an operation position and an operation content. The operation position may refer to the document position operated in the shared document; the operation content may refer to the modified content input at the operation position.

[0103] S303: In response to a first document sharing and editing operation on a shared document, first editor data generated by a first document editor and for the shared document is obtained.

[0104] Specifically, see Figure 2 S201 in the illustrated embodiment will not be described in detail here.

[0105] S304: Acquire a first shared data structure corresponding to the shared document.

[0106] The first shared data structure may be a shared data structure provided by Yjs based on CRDT implementation.

[0107] For example, the first shared data structure can be a doubly linked list. In Yjs, data in these shared types, such as YText, YArray, and YMap, are all stored in a doubly linked list. Each item in the doubly linked list uniquely records the data modified by a first document shared editing operation. Each item needs to carry an identifier that can be used to uniquely determine its position on the logical timeline. It can be considered that operations on YText, YArray, or YMap will eventually be converted into transformations of structures such as append, insert, split, merge, etc. in the doubly linked list.

[0108] In some embodiments, when creating each shared document, the terminal may locally generate a first shared data structure corresponding to the shared document. Therefore, the first shared data structure corresponding to the shared document may be locally acquired from the terminal.

[0109] S305, performing data conversion on the first editor data to obtain reference editing data of a data sharing type.

[0110] The data sharing type may be a data type corresponding to the first shared data structure, that is, the data sharing type may refer to a sharing type provided by Yjs, and the reference editing data is the editing data of the sharing type.

[0111] Data sharing types may include but are not limited to YText, YArray, and YMap.

[0112] Specifically, a preset data conversion container may be obtained, and data sharing type conversion may be performed on the first editor data based on the data conversion container to obtain reference editing data of the data sharing type.

[0113] Among them, the data conversion container can be a container component for performing data conversion on the first document editor and the first shared data structure. When the first document editor is a prosemirror and the first shared data structure is a shared type of data structure provided by Yjs, the data conversion container can refer to the y-prosemirror library. In the y-prosemirror library, document editing operations in the prosemirror editor can be mapped to changes in the shared type of data provided by Yjs. Therefore, the y-prosemirror library can be used to convert the first editor data into reference editing data of the data sharing type provided by Yjs.

[0114] S306: Update the first shared data structure based on the reference edit data to obtain a target shared data structure.

[0115] Specifically, based on the reference editing data, the data modification time, data modification location and data modification content for the shared document can be determined, and based on the data modification time, the data modification location and the data modification content, the first shared data structure is updated to obtain the target shared data.

[0116] Among them, the data modification time may refer to the time when the shared document is edited, that is, the operation time of the first document sharing editing operation on the shared document. The data modification position may refer to the document position where the editing operation is performed in the shared document. In the prosemirror editor, each position in the shared document can be represented by the number corresponding to the position. The data modification position in the embodiment of the present application may refer to the position data represented after the number of a certain position in the shared document is converted into a data sharing type. The data modification content may refer to the document content added or deleted in the shared document.

[0117] The first shared data structure is a bidirectional linked list, and the target shared data structure is the updated first shared data structure, which is also a bidirectional chain. The chain stores items. Each item consists of a unique identifier, content, and position. The unique identifier consists of the terminal's unique ID (clientId) and the Lamport timestamp (clock), ensuring that the unique identifier generated by each terminal is unique. Content refers to the data stored in the item (for example, an inserted string). Position includes attributes such as left and right. Each item is connected to the left and right items through left and right to form a bidirectional linked list tree.

[0118] For example: the reference editing data may include inserted characters. For example, the inserted characters can be determined as "Y AT A" based on the reference editing data, and each of these characters corresponds to an item. When these characters are inserted into the first shared data structure (i.e., a bidirectional linked list), they are connected together through the left and right fields. When inserting a new character "T" into the first shared data structure (i.e., a bidirectional linked list), the insertion position of the item corresponding to the character can be found in the first shared data structure (i.e., a bidirectional linked list) according to the ID of the item corresponding to the character, and the item corresponding to the new character "T" is connected to the first shared data structure (i.e., a bidirectional linked list) at the insertion position. Similarly, the insertion process of other characters can refer to the insertion process of the new character "T", and finally all the above characters "Y AT A" are inserted into the first shared data structure to obtain the target shared data structure.

[0119] S307, sending the target shared data structure to the server.

[0120] Specifically, see Figure 2 The description of S202 in the illustrated embodiment will not be repeated here.

[0121] S308: Receive a reference shared data structure for the shared document sent by the server.

[0122] It is easy to understand that the reference shared data structure is generated and sent to the server by the second client when the second client responds to the second document shared editing operation on the shared document. The second client may refer to other terminals that write and edit the shared document with the current terminal. Specifically, the process of the second client generating the reference reference data structure can refer to the operation process described in S301-S306 in the embodiment of the present application.

[0123] The reference shared data structure may also be a shared data structure provided by Yjs based on CRDT implementation. For example, the reference shared data structure may be a bidirectional linked list.

[0124] The terminal in the embodiment of the present application can update the first shared data structure corresponding to the shared document to obtain the target shared data structure, and then send the target shared data structure to the server, and can also receive the reference shared data structure for the shared document sent by the server. In the embodiment of the present application, the target shared data structure is sent to the server, and its purpose is to send the target shared data structure to other terminals, that is, one or more second clients, through the server, so that the second client can synchronously update the shared document in the second client according to the target shared data structure. Similarly, the embodiment of the present application can also receive the reference shared data structure from the second client sent by the server, also in order to synchronously update the shared document of this terminal by referring to the shared data structure.

[0125] S309: Determine third editor data for the shared document based on the reference shared data structure.

[0126] It is easy to understand that the third editor data refers to data used to instruct the first document editor to update the document.

[0127] In some embodiments, the reference shared data structure may be a data structure sent by the server and received only after the target shared data structure is obtained. Specifically, the target shared data structure corresponding to the shared document may be obtained, the target shared data structure may be updated based on the reference shared data structure to obtain an updated target shared data structure, and the updated target shared data structure may be converted into the third editor data for the shared document.

[0128] According to the description in the above operation, the target shared data structure is the data structure of the shared document in the latest state of the local terminal. Therefore, based on the target shared data structure, the target shared data structure can be updated according to the reference shared data structure to obtain an updated target shared data structure, that is, the target shared data structure of the local terminal is updated according to the operation of the second client on the shared document. The target shared data structure and the reference shared data structure are two different bidirectional linked lists. The two linked lists can be compared to determine the difference between the reference shared data structure and the target shared data structure, and the target shared data structure can be updated according to the difference to obtain an updated target shared data structure.

[0129] Furthermore, a data conversion container may be obtained, through which the updated target shared data structure is converted into the third editor data for the shared document. The data conversion container is a component for performing data conversion on the first document editor and the target shared data structure. The data conversion container may be a y-prosemirror library. In the y-prosemirror library, changes in the shared type data provided by Yjs can be mapped to document editing operations in the prosemirror editor.

[0130] In another embodiment, the reference shared data structure may be a data structure sent by the server and received before the target shared data structure is obtained. That is, when the reference shared data structure is received, the local first shared data structure is still the data structure corresponding to the shared document when the local end has not edited it. Specifically, the first shared data structure corresponding to the shared document may be obtained, and the first shared data structure may be updated based on the reference shared data structure. The updated first shared data structure may convert the updated first shared data structure into the third editor data for the shared document. The first shared data structure and the reference shared data structure may be two different bidirectional chains, and the two chains may be compared to determine the difference between the reference shared data structure and the first shared data structure, and then the first shared data structure may be updated according to the difference to obtain the updated first shared data structure. Furthermore, a data conversion container may be obtained, and the updated first shared data structure may be converted into the third editor data for the shared document through the conversion container. The data conversion container here may also be a y-prosemirror library.

[0131] S310: Control the first document editor to update the shared document based on the third editor data.

[0132] Specifically, the data editing time, data editing location, and data editing content for the shared document can be determined based on the third editing data, and the first document editor can be controlled to update the shared document at the data editing location according to the data editing time and the data editing content. Among them, for multiple editing operations on the shared document, the data editing time corresponding to each editing operation has a time sequence.

[0133] Data editing time may refer to the operation time corresponding to an editing operation on a shared document. Data editing location may refer to the document location corresponding to an editing operation on a shared document. Data editing content may refer to the document modification content corresponding to an editing operation on a shared document.

[0134] When the third editing data includes editing data of multiple operations performed by the second client on the shared document, the first document editor can be controlled to update the shared document according to the data editing content at the data editing position corresponding to the operation in the time sequence of the data editing time of each operation.

[0135] In an embodiment of the present application, a first document sharing and editing operation for a shared document is received in a shared document display interface, and in response to the first document sharing and editing operation, first editor data for the shared document generated by a first document editor is obtained, and the first shared data structure is updated by the first editor data to obtain a target shared data structure, and then the target shared data structure is sent to a server, so that the server sends the target shared data to at least one second client, so that the second client can determine the second editor data for the above-mentioned shared document based on the target shared data structure, and then the second client controls the second document editor to update the shared document according to the second editor data. In addition, the embodiment of the present application can also receive a reference shared data structure for a shared document sent by a server, and then determine the third editor data for the shared document based on the reference shared data structure, and then control the first document editor to update the shared document according to the third editor data. Therefore, the embodiment of the present application can not only update the local shared data structure according to the editor data generated by the document editor of the local end, but also send the updated shared data structure to other terminals of collaborative editing through the server, so that other terminals can also synchronously update the shared document. At the same time, the embodiment of the present application can also receive the reference shared data structure for the shared document sent by other collaboratively edited terminals through the server to achieve synchronous update of the shared document on the local end. In the above implementation process, the shared data structure provided by Yjs based on CRDT is mainly adopted, which can ensure that the document status of each collaboratively edited terminal can be synchronized to the same status even if concurrency occurs.

[0136] See also Figure 4 , is a schematic diagram of the structure of a document editing device provided in an embodiment of the present application. The document editing device 400 can be implemented as all or part of a terminal through software, hardware, or a combination of both. The device 400 includes:

[0137] A data acquisition module 410 is used to acquire first editor data for a shared document generated by a first document editor in response to a first document shared editing operation for the shared document;

[0138] A data updating module 420 is used to obtain a first shared data structure corresponding to the shared document, and update the first shared data structure based on the first editor data to obtain a target shared data structure;

[0139] The data sending module 430 is used to send the target shared data structure to the server, and the target shared data structure is used by the server to send the target shared data structure to at least one second client, and the target shared data structure is used by the second client to determine the second editor data for the shared document and control the second document editor to update the shared document based on the second editor data.

[0140] Optionally, the document editing device includes:

[0141] A page generation module, used to generate a shared document display interface for the shared document based on the first document editor;

[0142] The operation receiving module is used to receive a first document sharing and editing operation on a shared document in the shared document display interface.

[0143] Optionally, the data updating module includes:

[0144] A data conversion unit, used for performing data conversion on the first editor data to obtain reference editing data of a data sharing type;

[0145] A data updating unit is used to update the first shared data structure based on the reference editing data to obtain a target shared data structure.

[0146] Optionally, the data conversion unit includes:

[0147] A first conversion unit, configured to obtain a preset data conversion container, where the data conversion container is a container component for performing data conversion on the first document editor and the first shared data structure;

[0148] The second conversion unit is used to perform data sharing type conversion on the first editor data based on the data conversion container to obtain reference editing data of the data sharing type.

[0149] Optionally, the data updating unit includes:

[0150] A first updating unit, configured to determine a data modification time, a data modification location, and a data modification content for the shared document based on the reference editing data;

[0151] The second updating unit is used to update the first shared data structure based on the data modification time, the data modification position and the data modification content to obtain a target shared data structure.

[0152] Optionally, the document editing device further includes:

[0153] a data receiving module, configured to receive a reference shared data structure for the shared document sent by the server, wherein the reference shared data structure is generated when the second client responds to a second document shared editing operation for the shared document and is sent by the second client to the server;

[0154] A data generation module, configured to determine third editor data for the shared document based on the reference shared data structure;

[0155] A document updating module is used to control the first document editor to update the shared document based on the third editor data.

[0156] Optionally, the data generation module includes:

[0157] A first generating unit, configured to obtain the target shared data structure corresponding to the shared document, and update the target shared data structure based on the reference shared data structure to obtain the updated target shared data structure;

[0158] The second generating unit is used to convert the target shared data structure into third editor data for the shared document.

[0159] Optionally, the document update module includes:

[0160] A first updating unit, configured to determine a data editing time, a data editing position, and a data editing content for the shared document based on the third editing data;

[0161] The second updating unit is used to control the first document editor to update the shared document at the data editing position according to the data editing time and the data editing content.

[0162] Please refer to Figure 5 , Figure 5 A schematic diagram of the structure of a terminal provided in an embodiment of the present application. Figure 5 As shown, the terminal 500 may include: at least one processor 501 , at least one network interface 504 , a user interface 503 , a memory 505 , a display screen component 506 , and at least one communication bus 502 .

[0163] The communication bus 502 is used to realize the connection and communication between these components.

[0164] The user interface 503 may include a display screen (Display) and a camera (Camera), and the optional user interface 503 may also include a standard wired interface and a wireless interface.

[0165] The network interface 504 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0166] Among them, the processor 501 may include one or more processing cores. The processor 501 uses various interfaces and lines to connect various parts in the entire terminal 500, and executes various functions and processes data of the terminal 500 by running or executing instructions, programs, code sets or instruction sets stored in the memory 505, and calling data stored in the memory 505. Optionally, the processor 501 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 501 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a search engine library builder (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor 501, and it can be implemented separately through a chip.

[0167] Among them, the memory 505 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 505 includes a non-transitory computer-readable storage medium. The memory 505 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 505 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 505 may also be optionally at least one storage device located away from the aforementioned processor 501. As Figure 5 As shown, the memory 505 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a program of a document editing method.

[0168] exist Figure 5 In the terminal shown, the processor 501 can be used to call the program of the document editing method stored in the memory 505, and specifically perform the following operations:

[0169] In response to a first document sharing and editing operation on a shared document, obtaining first editor data for the shared document generated by a first document editor;

[0170] Acquire a first shared data structure corresponding to the shared document, and update the first shared data structure based on the first editor data to obtain a target shared data structure;

[0171] The target shared data structure is sent to a server, and the target shared data structure is used by the server to send the target shared data structure to at least one second client, and the target shared data structure is used by the second client to determine second editor data for the shared document and control the second document editor to update the shared document based on the second editor data.

[0172] In one embodiment, before executing the acquisition of first editor data for the shared document generated by the first document editor in response to the first document shared editing operation for the shared document, the processor 501 further performs the following operations:

[0173] Generating a shared document display interface for the shared document based on the first document editor;

[0174] A first document sharing and editing operation for a shared document is received in the shared document display interface.

[0175] In one embodiment, when the processor 501 executes the updating of the first shared data structure based on the first editor data to obtain the target shared data structure, the processor 501 specifically performs the following operations:

[0176] Performing data conversion on the first editor data to obtain reference editing data of a data sharing type;

[0177] The first shared data structure is updated based on the reference edit data to obtain a target shared data structure.

[0178] In one embodiment, when the processor 501 performs the data conversion on the first editor data to obtain the reference editing data of the data sharing type, the processor 501 specifically performs the following operations:

[0179] Obtaining a preset data conversion container, where the data conversion container is a container component that performs data conversion on the first document editor and the first shared data structure;

[0180] The first editor data is converted into a data sharing type based on the data conversion container to obtain reference editing data of the data sharing type.

[0181] In one embodiment, when the processor 501 updates the first shared data structure based on the reference edit data to obtain the target shared data structure, the processor 501 specifically performs the following operations:

[0182] Determining a data modification time, a data modification location, and a data modification content for the shared document based on the reference editing data;

[0183] Based on the data modification time, the data modification position and the data modification content, the first shared data structure is updated to obtain a target shared data structure.

[0184] In one embodiment, the processor 501 further performs the following operations:

[0185] receiving a reference shared data structure for the shared document sent by the server, wherein the reference shared data structure is generated when the second client responds to a second document shared editing operation for the shared document and is sent by the second client to the server;

[0186] determining third editor data for the shared document based on the reference shared data structure;

[0187] The first document editor is controlled to update the shared document based on the third editor data.

[0188] In one embodiment, when the processor 501 determines the third editor data for the shared document based on the reference shared data structure, the processor 501 specifically performs the following operations:

[0189] Acquire the target shared data structure corresponding to the shared document, and update the target shared data structure based on the reference shared data structure to obtain the updated target shared data structure;

[0190] The target shared data structure is converted into third editor data for the shared document.

[0191] In one embodiment, when the processor 501 executes the step of controlling the first document editor to update the shared document based on the third editor data, the processor 501 specifically performs the following operations:

[0192] Determining data editing time, data editing location, and data editing content for the shared document based on the third editing data;

[0193] The first document editor is controlled to update the shared document at the data editing location according to the data editing time and the data editing content.

[0194] In addition, those skilled in the art will appreciate that the structure of the terminal 500 shown in the above figures does not limit the terminal 500, and the user terminal may include more or fewer components than shown, or combine certain components, or arrange the components differently. For example, the terminal 500 also includes components such as a radio frequency circuit, an audio circuit, a WiFi component, a power supply, and a Bluetooth component, which will not be described in detail here.

[0195] An embodiment of the present application further provides a computer-readable storage medium, which stores at least one instruction, and the at least one instruction is used to be executed by a processor to implement the document editing method as described in the above embodiments.

[0196] An embodiment of the present application further provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the document editing method described in the above embodiments.

[0197] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented with hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein the communication media include any media that facilitates the transmission of a computer program from one place to another. The storage medium can be any available medium that a general or special-purpose computer can access.

[0198] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A document editing method, applied to a first client, characterized in that: The method comprises: In response to a first document sharing and editing operation on a shared document, obtaining first editor data for the shared document generated by a first document editor; Acquire a first shared data structure corresponding to the shared document, and update the first shared data structure based on the first editor data to obtain a target shared data structure; The target shared data structure is sent to a server, and the target shared data structure is used by the server to send the target shared data structure to at least one second client, and the target shared data structure is used by the second client to determine second editor data for the shared document and control the second document editor to update the shared document based on the second editor data.

2. The method according to claim 1, characterized in that: Before the step of obtaining first editor data for the shared document generated by a first document editor in response to a first document shared editing operation for the shared document, the step further includes: Generating a shared document display interface for the shared document based on the first document editor; A first document sharing and editing operation for a shared document is received in the shared document display interface.

3. The method according to claim 1, characterized in that: The updating of the first shared data structure based on the first editor data to obtain a target shared data structure includes: Performing data conversion on the first editor data to obtain reference editing data of a data sharing type; The first shared data structure is updated based on the reference edit data to obtain a target shared data structure.

4. The method according to claim 3, characterized in that The step of converting the first editor data to obtain reference editing data of a data sharing type includes: Obtaining a preset data conversion container, where the data conversion container is a container component that performs data conversion on the first document editor and the first shared data structure; The first editor data is converted into a data sharing type based on the data conversion container to obtain reference editing data of the data sharing type.

5. The method according to claim 3, characterized in that: The updating of the first shared data structure based on the reference edit data to obtain a target shared data structure includes: Determining, based on the reference editing data, a data modification time, a data modification location, and a data modification content for the shared document; Based on the data modification time, the data modification location, and the data modification content, the first shared data structure is updated to obtain a target shared data structure.

6. The method according to claim 1, characterized in that The method further comprises: receiving a reference shared data structure for the shared document sent by the server, wherein the reference shared data structure is generated when the second client responds to a second document shared editing operation for the shared document and is sent by the second client to the server; determining third editor data for the shared document based on the reference shared data structure; The first document editor is controlled to update the shared document based on the third editor data.

7. The method according to claim 6, characterized in that The determining, based on the reference shared data structure, third editor data for the shared document comprises: Acquire the target shared data structure corresponding to the shared document, and update the target shared data structure based on the reference shared data structure to obtain the updated target shared data structure; The target shared data structure is converted into third editor data for the shared document.

8. A document editing device, applied to a first client, characterized in that: The device comprises: A data acquisition module, configured to acquire, in response to a first document sharing and editing operation on a shared document, first editor data for the shared document generated by a first document editor; A data updating module, configured to obtain a first shared data structure corresponding to the shared document, and update the first shared data structure based on the first editor data to obtain a target shared data structure; A data sending module is used to send the target shared data structure to a server, and the target shared data structure is used by the server to send the target shared data structure to at least one second client, and the target shared data structure is used by the second client to determine the second editor data for the shared document and control the second document editor to update the shared document based on the second editor data.

9. A computer storage medium, characterized in that: The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 7.

10. A terminal, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps as claimed in any one of claims 1 to 7.