Document collaborative editing method, electronic equipment and program product
By establishing local channels for specific areas of a document, operations and updates are performed only in those local areas, solving the problems of network latency and congestion in online document collaborative editing, and achieving more efficient network transmission and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-26
- Publication Date
- 2026-04-10
AI Technical Summary
Existing online document collaborative editing technologies suffer from network latency and congestion when editing large-scale documents and multi-user collaboratively. In particular, when synchronizing globally in real time, broadcast messages need to be sent to all clients, resulting in large amounts of network data transmission, high latency, and excessive consumption of computing resources.
By establishing local channels for specific areas of a document, updates are performed only in those local areas, reducing network data transmission. Local channels are used to synchronize the content of local sub-regions, avoiding global synchronization.
It effectively reduces network data transmission volume, lowers synchronization latency and network congestion, improves network transmission smoothness and user experience, and reduces client computing overhead.
Smart Images

Figure CN121835616A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of online editing technology, specifically relating to a collaborative document editing method, electronic device, and program product. Background Technology
[0002] Online collaborative document editing technology allows multiple users to edit the same document simultaneously over a network and see each other's changes in real time. However, this technology faces challenges such as resolving operational conflicts, ensuring eventual data consistency, and achieving efficient real-time synchronization.
[0003] In related technologies, Operational Transformation (OT) and Conflict-free Replicated Data Types (CRDT) are used to ensure that the document state is eventually consistent across all clients.
[0004] However, as the volume of documents increases and the number of collaborating users grows, the above solution, when handling global real-time synchronization, requires sending broadcast messages to all document clients that have established global links for state synchronization, even if only one character is modified. This results in a large amount of network data transmission, causing severe delays and congestion. Summary of the Invention
[0005] This application aims to provide a document collaborative editing method, electronic device, and computer program product that at least solves the network latency and congestion problems that occur when using global real-time synchronization in related technologies when the document size is large or the number of collaborative users is large.
[0006] In a first aspect, embodiments of this application propose a document collaborative editing method, applied to a server, the method comprising: In response to the request to establish a channel in the first sub-region, a first sub-channel is established between the first client and the first sub-client based on the first sub-region of the document, and the first sub-region is marked as the first sub-active region. The first sub-activated region is synchronized to the operation client of the document, wherein the operation client does not include the first client; Based on the first operation request corresponding to the first sub-activation area and the first sub-channel, the first operation corresponding to the first operation request is updated to the document, and the first operation is synchronized to the operation client.
[0007] Secondly, embodiments of this application provide a document collaborative editing method, applied to a first client, the method comprising: Monitor the editing focus of the document, and based on the first sub-region corresponding to the editing focus, send a first sub-region channel establishment request to the server; Receive the first sub-channel and the first sub-activation area sent by the server; Based on the first operation corresponding to the first sub-activation region, a first operation request is sent to the server through the first sub-channel; The system receives a first operation confirmation notification sent by the server through the first sub-channel and displays the first operation in the document.
[0008] Thirdly, embodiments of this application provide a document collaborative editing method applied to a second client, the method comprising: Receive the first sub-activation region sent by the server; Receive the first operation corresponding to the first sub-activated region sent by the server; Based on the first operation, differential calculation is performed on the first sub-activation region corresponding to the first operation to determine the changed region of the document, and the changed region is updated.
[0009] Fourthly, embodiments of this application provide an electronic device including a processor, a memory, and a program or instructions stored in the memory and executable on the processor. When the program or instructions are executed by the processor, they implement the steps of the method described in the first aspect, or the steps of the method described in the second aspect, or the steps of the method described in the third aspect.
[0010] Fifthly, embodiments of this application provide a program product stored in a storage medium, which is executed by at least one processor to implement the steps of the method described in the first aspect, or the steps of the method described in the second aspect, or the steps of the method described in the third aspect.
[0011] In the embodiments of this application, the server first responds to the first sub-region channel establishment request, establishes a first sub-channel with the first client based on the first sub-region of the document, and marks the first sub-region as the first sub-active region. Then, the first sub-active region is synchronized to the document's operation client (excluding the first client). Finally, based on the first operation request corresponding to the first sub-active region and the first sub-channel, the first operation corresponding to the first operation request is updated to the document, and the first operation is synchronized to the operation client. This embodiment of the application creates local channels for local sub-regions of the document. When an operation exists in that local sub-region, the document is updated through the local channel. Since global synchronization is not required, and only the content corresponding to the operation within the local sub-region is updated through the local channel, the amount of network data transmission is smaller, and network transmission is smoother. Attached Figure Description
[0012] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1 This is a flowchart of a document collaborative editing method provided in one embodiment of this application; Figure 2 This is a schematic diagram of a conflict resolution process for multiple users editing the same sub-region, provided in one embodiment of this application. Figure 3 This is a flowchart of another document collaborative editing method provided in one embodiment of this application; Figure 4 This is a flowchart of yet another document collaborative editing method provided in one embodiment of this application; Figure 5 This is a schematic diagram of a system architecture for collaborative document editing provided in one embodiment of this application; Figure 6 This is a schematic diagram of a multi-party collaborative workflow for collaborative document editing provided in one embodiment of this application; Figure 7 This is a schematic diagram of a document collaborative editing device provided in one embodiment of this application; Figure 8 This is a schematic diagram of another document collaborative editing device provided in one embodiment of this application; Figure 9 This is another schematic diagram of collaborative document editing provided in one embodiment of this application; Figure 10 This is a schematic diagram of an electronic device provided in one embodiment of this application. Detailed Implementation
[0013] The embodiments of this application will now be described in detail. Examples of these embodiments are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0014] The terms "first" and "second" in the specification and claims of this application may explicitly or implicitly include one or more of the features. In the description of this application, unless otherwise stated, "multiple" means two or more. Furthermore, "and / or" in the specification and claims indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0015] In the description of this application, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", "clockwise", "counterclockwise", "axial", "radial", "circumferential", etc., indicating the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application.
[0016] In the description of this application, it should be noted that, unless otherwise expressly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection between two components. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.
[0017] Among related technologies, online document collaborative editing technology is the core of modern collaborative office work, allowing multiple users to edit the same document simultaneously over a network and see each other's changes in real time. This technology mainly faces three core challenges: resolving operational conflicts, ensuring eventual data consistency, and achieving efficient real-time synchronization. Current mainstream technologies, such as OT (On-Time) and CRDT (Continuous Data Transmission Technology), use rigorously defined algorithms to ensure eventual consistency of document states across all clients. However, as document size and the number of collaborating users increase, these solutions often involve huge amounts of network data transmission and client-side computational overhead when handling global real-time synchronization, becoming a technical bottleneck restricting system performance and user experience improvement.
[0018] The core idea of globally synchronous collaborative editing such as OT and CRDT is that any user's operation, such as insertion or deletion, will be broadcast to all other online clients via a server or peer-to-peer (P2P) network. After receiving the remote operation, each client needs to handle conflicts according to algorithm rules, such as the transformation function of OT or the merging logic of CRDT, and recalculate and render the entire document or the affected document structure to maintain consistency.
[0019] However, using the above method, even if only one character is modified, a broadcast message needs to be sent to all document clients that have established global links in order to synchronize the state. This will cause serious delays and congestion when editing large documents or when network bandwidth is limited. Moreover, frequent global document rendering or large-scale data structure merging will consume a lot of client computing resources, resulting in interface lag and slow response, which will seriously affect the smoothness of editing.
[0020] Therefore, the document collaborative editing method, electronic device and computer program product provided in this application establishes local links for local areas of the document. Based on changes in the document, the changed local areas are updated through the local links without global synchronization, which greatly reduces the amount of network data transmission and can avoid network congestion.
[0021] The following is combined with Figures 1-10 This application provides a detailed description of a document collaborative editing method, electronic device, and computer program product through specific embodiments and application scenarios.
[0022] Figure 1 A flowchart illustrating a collaborative document editing method provided in an embodiment of this application. Figure 1 As shown, the document collaborative editing method is applied to a server, and the document collaborative editing method may include the content shown in steps 101 to 103.
[0023] In S101, in response to the request to establish a first sub-region channel, a first sub-channel is established between the first client and the first sub-region based on the first sub-region of the document, and the first sub-region is marked as the first sub-active region.
[0024] The document can be divided into multiple sub-regions based on its content, such as chapters, images, tables, macros, and content blocks. In response to the first sub-region channel establishment request of the first sub-region, a first sub-channel is established between the client and the server to transmit only the data of the first sub-region.
[0025] The first sub-region can be the currently active editing area, i.e. the area where the user's editing focus is, or it can be an area in the user's historical editing area where the activity level is greater than a threshold, or it can be an area determined based on the user's historical operations. This embodiment does not limit it to the actual application.
[0026] The first sub-region is marked as the first active sub-region to identify it as the current editing area and distinguish it from other sub-regions.
[0027] In other embodiments, a single channel can be established, and communication flows from different regions can be logically distinguished using different messages or region identifiers (IDs) to save connection resources. For example, instead of establishing a separate physical WebSocket connection between the server and the client, communication flows from different regions can be logically distinguished over a single WebSocket connection using different messages or region IDs.
[0028] In S102, the first sub-activated region is synchronized to the document's operation client, which does not include the first client.
[0029] In this context, the "operation client" refers to the client whose interface displays the first sub-active area; that is, the operation client's interface also displays this first sub-active area. Synchronizing the first sub-active area to the operation client, rather than to all clients of the document, allows system resources, such as network bandwidth, to be allocated on demand, prioritizing document synchronization of the first sub-active area on the operation client, thereby reducing data transmission volume and lowering the information synchronization latency.
[0030] In S103, based on the first operation request and the first sub-channel corresponding to the first sub-activation area, the first operation corresponding to the first operation request is updated to the document, and the first operation is synchronized to the operation client.
[0031] The first operation may include insertion, deletion, text modification, format modification, and other operations, depending on the actual application. This embodiment does not limit the scope of the operation.
[0032] This embodiment updates the first operation corresponding to the first sub-activated area to the first client through the first sub-channel and synchronizes it to the operation client. There is no need to synchronize the document globally, which reduces the amount of network data transmission and the number of synchronization clients. Under the condition of limited network bandwidth, it can prioritize the synchronization of data by the operation client. Moreover, only the data of the sub-activated area is synchronized, which greatly avoids the occurrence of synchronization delay and network congestion.
[0033] In the embodiments of this application, the server first responds to the first sub-region channel establishment request, establishes a first sub-channel with the first client based on the first sub-region of the document, and marks the first sub-region as the first sub-active region. Then, the first sub-active region is synchronized to the document's operation client (excluding the first client). Finally, based on the first operation request corresponding to the first sub-active region and the first sub-channel, the first operation corresponding to the first operation request is updated to the document, and the first operation is synchronized to the operation client. This embodiment of the application creates local channels for local sub-regions of the document. When an operation exists in that local sub-region, the document is updated through the local channel. Since global synchronization is not required, and only the content corresponding to the operation within the local sub-region is updated through the local channel, the amount of network data transmission is smaller, and network transmission is smoother.
[0034] In one example, the server can divide a document, either based on its content (elements). When dividing regions, it's crucial to maintain a balance: the regions shouldn't be too large to fully leverage the performance advantages of local linking and differential refresh, nor too small to avoid frequent region switching during user operations, which could lead to additional performance overhead. Therefore, in addition to dividing based on document elements, the document can also be dynamically divided based on the editing activity of those elements.
[0035] In one possible implementation of this application, before responding to the request to establish a first sub-region channel, the document collaborative editing method may further include: dividing the document into multiple sub-regions based on the elements of the document and the editing activity of the elements, wherein the elements include at least one of the following: chapters, tables, images, macros, and content blocks.
[0036] Among them, editing activity refers to the frequency of operation of each element, which can be calculated by the user's past operation records of the document, or it can be determined based on the content of the element. The actual application shall prevail, and this application does not limit it.
[0037] In this embodiment, the server can divide the document. In addition to the division based on the document's content (elements) as described in the previous embodiment, it can also divide the document based on its elements and the editing activity of those elements. That is, the document can be divided into multiple independent sub-regions, such as R1, R2, ..., Rn, based on its elements, such as chapters, tables, images, macros, content blocks, etc., and the editing activity of those elements.
[0038] For example, if an element is too large, it can be split into multiple sub-regions; if two adjacent elements have similar editing activity, they can be divided into the same sub-region; if an element, such as a chapter, has very low editing activity in the upper part (below the minimum threshold) while the lower part has high editing activity (above the maximum threshold), the chapter can be divided into two or more sub-regions.
[0039] In one example, dividing a document into multiple sub-regions based on its elements and their editing activity can include: obtaining the editing activity of elements, where editing activity is the frequency of operations performed on each element; and, based on the editing activity of adjacent elements, grouping adjacent elements whose editing activity difference is less than a first difference threshold into the same sub-region, and grouping adjacent elements whose editing activity difference is greater than a second difference threshold into different sub-regions, wherein the first difference threshold is less than the second difference threshold.
[0040] The first and second difference thresholds can be determined based on historical data or experience, depending on the actual application. This embodiment does not impose any limitations on them.
[0041] In this embodiment, the document can be divided into multiple sub-regions based on the editing activity of the elements. Elements with similar editing activity are grouped into the same region as much as possible, while elements with significantly different editing activity are grouped into different regions as much as possible. By dividing the document, the size of the sub-regions can be reduced as much as possible, and users can avoid frequently switching regions during the editing process, which would require the creation of multiple sub-channels, thereby avoiding resource waste.
[0042] In one example, regions can be dynamically merged or split based on editing activity and document structure. For instance, adjacent small regions that have not been edited for a long time can be automatically merged into a larger region to reduce management overhead.
[0043] After dividing the document into multiple sub-regions using the above embodiments, if a new element is added to the document, it can be determined whether to assign the new element to the current sub-region based on the weight of the new element and the weight of the current sub-region.
[0044] In one possible implementation of this application, the document collaborative editing method may further include: determining whether to assign the element to be assigned to the current sub-region based on the difference in editing activity between the elements in the current sub-region and the previous sub-region, the weight of the current sub-region, and the weight of the element to be assigned, wherein the current sub-region and the previous sub-region are two adjacent sub-regions, the elements are assigned weights, different elements have different weights, and the weight of the sub-region is the sum of the weights of the elements within the sub-region; if the difference, the weight of the current sub-region, and the sum of the weights of the element to be assigned are less than or equal to a maximum weight threshold, assign the element to be assigned to the current sub-region; if the difference, the weight of the current sub-region, and the sum of the weights of the element to be assigned are greater than the maximum weight threshold, determine whether the weight of the element to be assigned is less than a minimum weight threshold; if the weight of the element to be assigned is less than or equal to the minimum weight threshold, assign the element to be assigned to the current sub-region; if the weight of the element to be assigned is greater than the minimum weight threshold, create a target sub-region and assign the element to be assigned to the target sub-region.
[0045] The server can assign a basic weight, complexity factor, and size factor to each element in the document, and divide the document based on the above to avoid sub-regions being too large or too small, as shown in Table 1 below.
[0046] Table 1
[0047] In this embodiment, the difference in editing activity between two adjacent elements is normalized into element weights. Editing activity can be transformed into a factor for region division and processed uniformly. That is, based on the difference in editing activity between the elements in the current sub-region and the previous sub-region, the weight of the current sub-region, and the weight of the element to be assigned, it is determined whether to assign the element to be assigned to the current sub-region, so as to avoid the current sub-region having too large a weight.
[0048] In one example, the weighted adjustment values for the difference in editing activity between the current sub-region and the previous sub-region are as follows: W_a = | A_current - A_previous | * N (1) Where A_previous represents the editing activity of the previous sub-region; A_current represents the editing activity of the current sub-region; W_a represents the weighted adjustment value of the difference in editing activity between the current sub-region and the previous sub-region; and N represents the weighting coefficient for the difference in editing frequency.
[0049] The following formula is used to determine whether to add the element to be assigned to the current sub-region: W_a+W_current+W_elemen≤W_max(2) Where W_current is the cumulative weight already assigned to the current sub-region; W_element is the weight of the element to be assigned; and W_max is the maximum weight threshold.
[0050] If the above formula (2) is satisfied, add W_element to the current sub-region; otherwise, perform the judgment shown in the following formula: W_current<W_min(3) Where W_min is the minimum weight threshold.
[0051] If the above formula (3) is satisfied, then W_element is added to the current sub-region; otherwise, a new sub-region is created, namely the target sub-region, and W_element is added to the target sub-region.
[0052] The formula for calculating the dynamic threshold is as follows: W_min = W_basemin × log 10 (W_total / 1000 +1) (4) W_max = W_basemax × log 10 (W_total / 1000 +1)(5) Where W_basemin and W_basemax are the minimum and maximum values of the base threshold, respectively, for example, 20 and 100, depending on the actual application, and are not limited in this embodiment; W_total is the sum of the weights of all sub-regions of the document.
[0053] Through the above embodiments, it is possible to dynamically adjust the document division according to the content and structure of the document, determine the relatively balanced load of each region, and avoid a certain sub-region being too large or too small, or having too large or too small a weight.
[0054] For any active sub-region, if only one user operates on that sub-region at the same time, the corresponding operation can be displayed in the corresponding region and synchronized to the display interface of other operating clients. If two or more users operate on that sub-region at the same time, or with a time difference less than a time threshold (i.e., a close time difference), a conflict will occur. To avoid conflicts, in one possible implementation of this application, the document collaborative editing method may further include: based on the first operation request and the second operation request corresponding to the first sub-active region, using an operation conversion algorithm to convert the first operation and the second operation corresponding to the first sub-active region, wherein the time difference between the first operation request and the second operation request is less than a time threshold, and the operation conversion algorithm is used to adjust the execution order of the received multiple operation requests so that the display content of different clients is consistent; updating the converted first operation and the second operation to the document, and synchronizing the converted first operation and the second operation to a third client, wherein the third client does not include the first client corresponding to the first operation request and the second client corresponding to the second operation request.
[0055] If the time difference between the first operation request and the second operation request is less than the time threshold, it indicates that the time interval between the two operation requests is small. If no action is taken, neither request may be completed.
[0056] In this embodiment, the Operation Transformation (OT) algorithm can be used for conflict merging. That is, when at least two operations are received, the OT algorithm is used to decompose the user operation into atomic operation units, such as insertion, deletion, and format modification. The execution order of the operations is adjusted by the transformation function, thereby ensuring that the data replicas of each terminal in the distributed environment are eventually consistent.
[0057] Figure 2 A schematic diagram illustrating the conflict resolution process for multiple users editing the same sub-region.
[0058] like Figure 2As shown, user A focuses on region Rx and establishes a link, i.e., a first sub-channel is established between client A and the server. User B focuses on region Rx and establishes a link, i.e., a second sub-channel is established between client B and the server. User A inserts the text "Hello" at position P, and user B deletes the text "World" at position P. Client A generates operation OpA, and client B generates operation OpB. The server receives the two operations, OpA and OpB, almost simultaneously. At this time, the server inputs OpA, OpB, and the operation sequence into the conflict resolution engine for operation transformation (OT) processing, generating transformed operations OpA' and OpB'. The conflict resolution engine returns a consistent operation sequence to the server, and the server updates OpA' and OpB' to the document. The content displayed by client A and client B is consistent, i.e., the text "Hello" is inserted and the text "World" is deleted.
[0059] In one possible implementation of this application, the document collaborative editing method may further include: releasing the first sub-channel according to the first sub-channel release request, deleting the marker of the first sub-activated region to obtain the first sub-region; and synchronizing the first sub-region to the operating client.
[0060] In this embodiment, after the user's focus leaves the first sub-active area, the client can send a first sub-channel release request to the server. Upon receiving the request, the server can release the first sub-channel and remove the marker from the first sub-active area, at which point the first sub-active area reverts to the first sub-area. Releasing the first sub-channel ensures resource reclamation, enables dynamic on-demand resource allocation, and avoids areas that have been occupied for extended periods without any activity.
[0061] Figure 3 A flowchart illustrating a collaborative document editing method provided in an embodiment of this application. Figure 3 As shown, the document collaborative editing method is applied to the first client, and the document collaborative editing method may include the content shown in steps 301 to 304.
[0062] In S301, the document's editing focus is monitored, and a first sub-region channel establishment request is sent to the server based on the first sub-region corresponding to the editing focus.
[0063] The editing focus can be the current cursor position, the position displayed on the interface, or other methods to determine the editing focus. This embodiment does not limit the specific method used in the actual application.
[0064] In other embodiments, response speed can be further improved by pre-establishing channels to predict the area that the user may edit next by analyzing user behavior.
[0065] In S302, the first sub-channel and the first sub-activated area are sent by the receiving server.
[0066] The first sub-channel is the channel established by the server based on the first sub-region between the server and the first client. The first sub-activated region is obtained by the server after marking the first sub-region.
[0067] In S303, based on the first operation corresponding to the first sub-activated region, a first operation request is sent to the server through the first sub-channel.
[0068] The first operation can be an insertion, deletion, or modification operation, or other operations, depending on the actual application; this embodiment does not impose any limitations. After detecting the corresponding operation, the first client sends the corresponding operation request to the server through the first sub-channel.
[0069] In S304, a first operation confirmation notification sent by the server is received through the first sub-channel, and the first operation is displayed in the document.
[0070] In this embodiment, the document's editing focus is first monitored, and a first sub-region channel establishment request is sent to the server based on the first sub-region corresponding to the editing focus. Next, the first sub-channel and first sub-activated region are received from the server. Then, based on the first operation corresponding to the first sub-activated region, a first operation request is sent to the server through the first sub-channel. Finally, a first operation confirmation notification is received from the server through the first sub-channel, and the first operation is displayed in the document. This embodiment establishes a first sub-channel with the server based on the first sub-region corresponding to the editing focus and sends the first operation corresponding to the first sub-activated region to the server through the first sub-channel. This eliminates the need to send the entire document content to the server, reducing data transmission volume. Furthermore, since the operation corresponds to the first sub-activated region, only the first sub-activated region is differentially refreshed, significantly reducing client computational overhead and graphics rendering pressure by minimizing the rendering area.
[0071] In one possible implementation of this application, the document collaborative editing method may further include: sending a global channel establishment request to the server; receiving the global channel, the document, and various sub-regions of the document sent by the server.
[0072] In this embodiment, based on the user's request to open a document, the first client sends a global channel establishment request to the server to obtain the global channel, the complete document, and the various sub-regions divided by the server. That is, before monitoring the editing focus of the document, an initialization phase can be performed to complete the connection with the server and obtain the completed document data.
[0073] In one possible implementation of this application, the document collaborative editing method may further include: sending a first sub-channel release request to the server based on the editing focus leaving the first sub-active area; and receiving a notification from the server to release the first sub-channel.
[0074] In this embodiment, after the user's editing focus leaves the first sub-active area, the first client can send a first sub-channel release request to the server. Upon receiving the request, the server can release the first sub-channel and remove the marker from the first sub-active area. At this point, the first sub-active area reverts to the first sub-area, and the first client then receives a notification from the server confirming the release of the first sub-channel. Releasing the first sub-channel ensures resource reclamation, enables dynamic on-demand resource allocation, and prevents areas from being occupied by inactive regions for extended periods.
[0075] Figure 4 A flowchart illustrating a collaborative document editing method provided in an embodiment of this application. Figure 4 As shown, the document collaborative editing method is applied to the second client, and the document collaborative editing method may include the content shown in steps 401 to 403.
[0076] In S401, the first sub-activation region is sent by the receiving server.
[0077] The second client can receive the first sub-active area synchronized by the server. This first sub-active area is the editing active area marked by the server, that is, the area where other clients are the focus of editing.
[0078] In S402, the first operation corresponding to the first sub-activated region sent by the receiving server is performed.
[0079] The first operation may include insertion, deletion, text modification, format modification, and other operations, depending on the actual application. This embodiment does not limit the scope of the operation.
[0080] In this embodiment, when there is a corresponding first operation in the first sub-activation area, the second client can receive the first operation synchronized by the server. Since only the first operation corresponding to the first sub-activation area is received, rather than the entire document, the amount of network data transmission can be reduced, and synchronization delay can be avoided. That is, after the server receives the first operation request, it can synchronize the first operation to each operation client.
[0081] In S403, based on the first operation, differential calculation is performed on the first sub-activation region corresponding to the first operation to determine the changed region of the document, and the changed region is updated.
[0082] In this process, after receiving the first operation, the second client calculates the difference between the Virtual Document Object Model (Virtual DOM) before and after receiving the first operation. Since the first operation corresponds to the first sub-activated region, it is only necessary to calculate the difference (Diff) of the Virtual DOM in the first sub-activated region, without having to calculate the difference of the Virtual DOM of the entire document, which effectively reduces computational complexity and resource consumption.
[0083] In one example, different refresh granularities can be set. For example, for high-frequency, low-impact operations such as cursor movement, a very fine-grained differential refresh can be used; for operations such as pasting large blocks of text, a slightly larger area (such as paragraph level) refresh can be used to achieve a balance between performance and effect.
[0084] In this embodiment, the system first receives a first sub-activation region sent by the server, then receives a first operation corresponding to the first sub-activation region sent by the server, and finally performs differential calculation on the first sub-activation region corresponding to the first operation based on the first operation to determine the changed region of the document and update the changed region. This embodiment only requires differential calculation on the changed sub-region when the document is changed, instead of calculating the entire document, which reduces computational complexity, computational load, and resource consumption.
[0085] In one possible implementation of this application, the document collaborative editing method may further include: monitoring the first sub-activation area entering the display interface and the duration exceeding a first preset duration, sending a first sub-activation area channel establishment request to the server; and receiving a second sub-channel sent by the server.
[0086] In this embodiment, upon detecting that the first sub-activated area enters the display interface (window), a channel establishment request is not immediately sent to the server. Since this may be during the user's browsing process, meaning the first sub-activated area is merely passing through the window and the user is not paying attention to its content, there is no need to establish a channel with the server at this time. However, if the duration of the first sub-activated area on the display interface exceeds a first preset duration, it indicates that the first sub-activated area may be attracting user attention. At this point, a channel establishment request for the first sub-activated area can be sent to the server, and the server will establish and send a second sub-channel. When an operation is performed corresponding to the first sub-activated area, the second client can receive a corresponding operation synchronized from the server, which is then displayed on the second client's display interface. This embodiment employs a delayed channel establishment strategy to avoid resource waste caused by misjudgments.
[0087] In one possible implementation of this application, the document collaborative editing method may further include: sending a second sub-channel release request to the server based on the detection that the duration of the first sub-activation area leaving the display interface exceeds a second preset duration; and receiving a notification from the server to release the second sub-channel.
[0088] In this embodiment, upon detecting that the first sub-active area has left the display interface, a channel release request is not immediately sent to the server. This is to prevent the user from viewing the preceding and following sub-areas and then returning to the first sub-active area. If a channel release request were sent to the server immediately, but the user then returns the first sub-active area to the display interface, a channel would be re-established after release, resulting in resource waste. This embodiment employs a delayed channel release strategy to avoid frequent channel creation and release, thus reducing resource waste.
[0089] To further improve performance, reduce resource consumption, and enhance user experience, a dynamic channel management time parameter adjustment strategy can be adopted in one instance. This strategy dynamically adjusts the time window for channel establishment and release based on factors such as user behavior and system environment.
[0090] The factors that affect the establishment and release of channels are shown in Table 2 below.
[0091] Table 2
[0092] Where T1 is the waiting time from when the first sub-activated region enters the window to when the channel is established; T2 is the waiting time from when the first sub-activated region leaves the window to when the channel is released. In one example, the baseline value of T1 can be 200-500ms, and the baseline value of T2 can be 1000-2000ms. Other values can also be used in other embodiments, depending on the actual application. This embodiment does not limit the values.
[0093] In one example, adaptive adjustments can be made based on scrolling behavior. First, the page scrolling speed is detected, i.e., the frequency and magnitude of changes in the viewport area are calculated to identify whether the user is quickly browsing or carefully reading. Then, T1 and T2 are adjusted based on the scrolling speed. Specifically, when the scrolling speed is greater than a first speed, T1 is increased to reduce frequent channel establishment, and T2 is decreased to quickly release channels. When the scrolling speed is less than a second speed, T1 is decreased to quickly respond to requests to establish channels, and T2 is increased to maintain channel connectivity. Here, the first speed is greater than the second speed.
[0094] In one example, intelligent recognition is based on editing patterns. First, editing activity is assessed, which involves monitoring the frequency of user operations within a region, analyzing dwell time and operation density. Then, T1 and T2 are adjusted based on the active editing region. Specifically, when the editing activity of a region is greater than the first activity level, T1 is made to approach the minimum value to quickly establish a channel, and T2 is made to approach the maximum value to maintain channel connectivity. When the editing activity of a region is less than the second activity level, both T1 and T2 are made to approach the baseline value to respond to various situations, where the first activity level is greater than the second activity level.
[0095] In one example, optimization is performed based on network conditions. First, network quality is assessed by measuring round-trip time (RTT) and packet loss rate. Bandwidth utilization is evaluated based on RTT and packet loss rate. Then, T1 and T2 are adjusted based on network quality. Specifically, a small T1 and large T2 strategy is used for high-quality networks, while a large T1 and small T2 strategy is used for low-quality networks to ensure data transmission efficiency.
[0096] By adopting the above-described dynamic parameter adjustment strategy, improvements can be achieved in the indicators shown in Table 3 below compared to the fixed parameter strategy.
[0097] Table 3
[0098] In one possible implementation of this application, based on the first operation, differential calculation is performed on the first sub-activated region corresponding to the first operation to determine the changed region of the document, and the changed region is updated. This may include: based on the first operation, determining the first sub-activated region corresponding to the first operation; based on the first operation, calculating the differences between virtual document object model nodes within the first sub-activated region; rendering the virtual document object model nodes with differences and displaying them on the display interface.
[0099] In this embodiment, a first sub-activated region is first determined based on a first operation. Then, according to the first operation, the differences between the virtual DOM nodes within the first sub-activated region are calculated, and the nodes with differences are rendered and displayed on the display interface. In this embodiment, when the document is modified, only the differences between the virtual DOM nodes involved in the modified sub-region need to be calculated, without needing to calculate the virtual DOM tree of the entire document. This reduces computational complexity, computational load, and resource consumption.
[0100] In one example, all clients corresponding to the document perform differential calculations only on the virtual DOM nodes involved in the changed sub-regions. Since there is no need to calculate the virtual DOM tree of the entire document, the computational complexity and workload on the client side are reduced, thus lowering resource consumption. Furthermore, because only a portion needs to be updated, the update speed is faster, effectively avoiding interface lag and scrolling jumps, providing users with a more stable and faster editing experience.
[0101] The correctness of the differential refresh results will be explained below through examples.
[0102] The following is an explanation of the correctness of the local refresh result based on the principle of local difference: Suppose that the set of all virtual DOM nodes in a document is S, and the document is divided into n regions, with each region having a set of nodes S1, S2, ..., Sn, then we have: S = S1 + S2 + ... + Sn.
[0103] Assuming d is the difference calculated when using global refresh, S_new is the set of nodes after global document update, and apply is the update function of the virtual DOM, then: S_new = apply(S, d).
[0104] Meanwhile, if the global difference d is decomposed into a difference list [d1, d2, ..., dn] according to the region, then: apply(S, d) = apply(S1, d1) + apply(S2, d2) + ... + apply(Sn, dn).
[0105] For any set of nodes in region m, assuming that d is represented by 0 when there is no difference, then apply(Sm,0) = Sm.
[0106] Therefore, assuming the set of document nodes updated using the local update method is S_local_new, the locally updated region is x, and its local difference is dx, then according to the differential refresh scheme, only region x will be updated, while other regions remain unchanged. Thus, we have: S_local_new = S1 + S2 + ... + apply(Sx, dx) + ... + Sn.
[0107] Finally, we can get: S_new = apply(S, d) = apply(S1, 0) + apply(S2, 0) + ... + apply(Sx, dx) + ... + apply(Sn, 0) = S1 + S2 + ... + apply(Sx, dx) + ... + Sn = S_local_new.
[0108] The above analysis shows that the results obtained by using differential refresh are consistent with those obtained by using global refresh.
[0109] Table 4 below compares global refresh and differential refresh.
[0110] Table 4
[0111] Where O(.) represents the time complexity; n is the total number of nodes in the document; and k is the number of nodes in the modified sub-region. n; m is the total number of DOM elements affected; p is the number of DOM elements actually changed. m.
[0112] Based on the time complexity above, we can obtain the performance improvement ratio of differential refresh compared to global refresh.
[0113] The global refresh cost is:
[0114] The cost of differential refresh is:
[0115] The performance improvement rate is:
[0116] in, Cost of global refresh; This is the refresh time for all document nodes; The refresh time of the affected DOM elements; For full document rendering time; Cost of differential refresh; The refresh time for the nodes in the modified sub-region; the refresh time for the actual modified DOM elements. To change the rendering time of the region; For the performance improvement rate.
[0117] Based on the above analysis, the performance improvement effect over time can be estimated as shown in Table 5 below: Table 5
[0118] This embodiment uses differential refresh, which significantly improves performance by changing detection and local rendering while ensuring consistent results. It is suitable for real-time collaborative editing scenarios of documents of various sizes.
[0119] Figure 5 This is a schematic diagram of the system architecture for collaborative document editing provided in an embodiment of this application.
[0120] like Figure 5 As shown, the client includes a user interface layer, a local link building manager, a differential refresh engine, and an OT client.
[0121] The user interface layer uses Canvas technology to render document content and provides an interactive editing interface. The virtual DOM is used to efficiently calculate changes in the user interface (UI).
[0122] The document collaborative editing method proposed in this application can improve the user interface experience in the following ways: Due to the use of differential refresh, flickering of the entire page or sudden rearrangement of content areas is avoided, making the editing experience indistinguishable from single-user document editing. Combined with local link information, the UI can display the collaborative status more precisely. For example, only the user's avatar and cursor are highlighted on the border of the paragraph they are actively editing, instead of being displayed at the top of the entire document or in the sidebar, making the information presentation more intuitive and less disruptive. When the network fluctuates, the system can prioritize the synchronization of the sub-area the user is currently editing, with a slight delay in the synchronization of other areas. The UI can use subtle visual cues (such as a slight graying of the area's background color) to indicate that the information in that area may be outdated, rather than the entire interface freezing, improving usability in weak network environments.
[0123] The local link manager is responsible for monitoring the user's editing focus, dynamically negotiating with the server, and establishing an independent data synchronization channel between the client and the server for active editing areas.
[0124] The local link manager will establish a link for a sub-region when it meets one of the following conditions: 1. When the area contains an element that the user has turned off their focus on (i.e., it has been designated as the focus of editing); 2. When the region appears within the viewport and the corresponding region has already been activated on another client.
[0125] When the above conditions are no longer met, the local link manager will release the link, that is, send a channel release request to the server.
[0126] The management process of the local link manager is as follows: First, it retrieves and loads the document from the server, as well as the region division information, such as R1, R2, ..., Rn; then, it performs editing focus monitoring, that is, continuously monitors the user's editing behavior, such as whether the cursor position changes. If it changes, it focuses on the current focus region Rx and determines whether Rx is the current sub-active region. If it is, it maintains the current link; if not, it disconnects the previous sub-active region link and requests the server to establish the link for Rx. The server records the client's request and the region Rx, and marks Rx as a sub-active region. If the cursor position does not change, it maintains the current state; secondly, it performs window region monitoring, holding... Continue monitoring the window area. When area Ri enters the window, determine whether a link has been established for area Ri. If not, start timer T1 and continue to determine whether the duration of area Ri in the window is greater than T1. If so, request the server to establish a link for area Ri. The server records the client's request and marks Ri as a sub-active area. If area Ri establishes a link, maintain the link for area Ri. When area Ri leaves the window, determine whether a link has been established for area Ri. If so, start timer T2 and calculate the time area Ri has been out of the window. If the time area Ri has been out of the window exceeds T2, request the server to disconnect the link. The server releases the link and marks area Ri as disconnected.
[0127] The differential refresh engine is used to calculate the differences in the virtual DOM before and after receiving an operation update from the server via WebSocket, and only updates the changed parts to the screen through the Canvas Application Programming Interface (API).
[0128] The differential refresh engine features precise positioning and minimal updates. It can quickly locate the update target through the mapping relationship between links and regions, and ensure that only the changed pixel areas are redrawn through the virtual DOM Diff algorithm.
[0129] The OT client is responsible for generating local operations and sending them to the OT engine on the server via WebSocket; it also receives remote operations from the server.
[0130] The server (i.e., the collaborative editing server) includes a session manager, an operation transformation engine (OT algorithm), and a document state store.
[0131] The session manager is responsible for tasks such as document area partitioning, user connection management, and document session information management. It handles local connection requests from clients and maintains routing information for both global and local logical channels.
[0132] The Operation Transformation Engine (OT algorithm) is the core algorithm layer, used to resolve operation conflicts from different clients, ensure document consistency, and distribute the processed operations to the relevant clients by the server.
[0133] Document state storage is used to persistently store document data and operation history.
[0134] In this implementation, all clients establish a WebSocket connection only with the collaborative editing server. The architecture of this embodiment is a browser / server (B / S) model, which is easy to deploy, expand, and manage, and avoids complex problems such as NAT traversal that may arise with P2P.
[0135] Figure 6 This is a schematic diagram of a multi-party collaborative workflow for document collaborative editing provided in an embodiment of this application.
[0136] like Figure 6 As shown, the entire process includes the initialization and global connection establishment phase, the local link establishment phase, the editing and differential synchronization phase, and the link lifecycle management phase.
[0137] In the initialization and global connection establishment phase, clients A and B respectively establish basic WebSocket connections (global control links) with the server, obtain complete document data, and render it.
[0138] Local link establishment phase: When user A edits a document through client A, based on the current focus of the user's cursor, client A calculates the active region as Rx, establishes link S1 with the server, and the server records the currently active region as Rx; the server records the currently active region as Rx and notifies client B, which has already opened the document, that region Rx is active through the control link; when user B operates the document through client B, if region Rx enters the client's viewport and the duration exceeds T1, then client B establishes link S2 between Rx and the server.
[0139] Editing and Differential Synchronization Phase: User A's editing operation (Op1) is sent to the server via the S1 local channel, ensuring low latency. The server-side OT engine handles operation conflicts and obtains the transformed operation (Op1'). The server-side session manager looks up the clients subscribed to Rx according to the region subscription table, obtains the local link S2, and sends Op1' to client B through S2. After receiving Op1', client B's differential refresh engine starts working, i.e., performing region positioning. The differential refresh engine locates the region Rx through link S2, calculates the affected range, calculates the range of affected virtual DOM nodes, calculates the difference, applies Op1' to the affected virtual DOM, compares the state of the virtual DOM before and after the update, accurately calculates the minimum screen area that needs to be updated, performs local redraw, calls the Canvas API, and only redraws the changed rectangular area, rather than refreshing the entire document or the entire Rx region. This ensures that the update seen by user B is smooth and flicker-free.
[0140] During the link lifecycle management phase, the release of a local link will be triggered under the following circumstances: When user A leaves region Rx, client A will actively request the release of that local link S1; the server will notify client B to release the link S2 corresponding to Rx. When region Rx on client B leaves the client's viewport for a period exceeding T2, client B will request the release of link S2 between Rx and the server. When a user closes a document, the server, based on a keep-alive detection strategy, will release all links between the closed document and the closed document after a period of time T3.
[0141] These link management mechanisms ensure that servers can reclaim resources in a timely manner, enabling dynamic on-demand allocation of resources.
[0142] The document collaborative editing method provided in this application can be applied to B / S architecture products that require real-time collaboration among multiple users to process structured content. For example, it can be applied to scenarios such as online office, low-code / no-code development platforms, online design tools, and collaborative code editors. It can also be applied to scenarios such as collaborative editing with artificial intelligence (AI) or intelligent agents. The specific application shall prevail, and this embodiment does not impose any limitations.
[0143] For example, while a user is writing a report, the AI assistant analyzes the content in the background and provides writing suggestions, continuation suggestions, or grammar corrections in real time in the sidebar or between paragraphs. The user can choose to accept or ignore these suggestions. Local linking: When the user's cursor is focused on a paragraph, the system can establish an efficient link between that paragraph and the AI service, enabling low-latency push of AI suggestions. Differential refresh: The AI-generated suggestions can be inserted and rendered as an independent, non-intrusive AI area. When the user accepts the suggestions, the content of that area is simply differentially merged into the main document, providing a seamless and smooth experience without interrupting the user's writing flow.
[0144] In one instance, this can be applied to AI-driven collaborative content review and formatting scenarios. For example, multiple people can simultaneously edit a marketing copy. The AI agent runs synchronously, checking the content entered by everyone in real time to ensure it conforms to brand guidelines (such as colors, fonts, and wording), and automatically making formatting adjustments. AI's formatting operation can be seen as a special kind of remote editing operation. Through differential refresh, the subtle adjustments made by AI (such as changing the color of a title) can be silently applied to the screens of all collaborators, avoiding interface flickering caused by frequent AI operations and ensuring that user focus is not disturbed.
[0145] In one application, this can be used in intelligent grading and interactive scenarios in education. For example, students collaborate on assignments using a shared document, and an AI teacher assistant reviews each student's contribution in real time, providing annotations, hints, and even generating personalized practice questions. A local chaining mechanism ensures that AI annotations and feedback are accurately and with low latency sent to the vicinity of the relevant student's edited paragraph, while differential refresh makes the appearance and updating of AI annotations very smooth, without suddenly overwriting or disrupting the student's existing content.
[0146] In one instance, this can be applied to complex task decomposition and collaboration scenarios for intelligent agents. For example, a user proposes a complex requirement (such as "create a PPT about quantum computing"), and the system decomposes it into sub-tasks such as outline, pagination content, and chart generation, and assigns them to multiple corresponding AI agents (such as text generation AI and chart generation AI) to work in parallel. This application is suitable for dividing a document into task areas managed by different agents. Local linking establishes an independent communication channel between each AI agent and its managed area, ensuring the independence of its workflow. Differential refresh allows each AI agent to fill its work results (a piece of text, an image) into the corresponding areas of the document in parallel and incrementally, ultimately efficiently synthesizing a complete result.
[0147] In one embodiment, it can be applied to the metaverse / VR collaborative space, in a 3D virtual environment, the concept of region is expanded to objects or regions in 3D space, enabling efficient collaborative editing of virtual assets by humans and AI agents.
[0148] In the context of the growing trend of human-computer collaboration, the embodiments of this application can provide crucial underlying technical support for achieving a smooth, natural, and interference-free human-computer interaction experience through its efficient local communication capabilities and refined interface update capabilities, enabling AI agents to collaborate efficiently with users.
[0149] Figure 7 This is a schematic diagram of a document collaborative editing device provided in an embodiment of this application. Figure 7As shown, the document collaborative editing device is applied to a server, and the document collaborative editing device may include a creation module 701, a synchronization module 702, and a first update module 703.
[0150] The module 701 is used to respond to the first sub-region channel establishment request, establish a first sub-channel with the first client based on the first sub-region of the document, and mark the first sub-region as the first sub-active region; the synchronization module 702 is used to synchronize the first sub-active region to the document's operation client, which does not include the first client; the first update module 703 is used to update the first operation corresponding to the first operation request to the document based on the first operation request and the first sub-channel corresponding to the first sub-active region, and synchronize the first operation to the operation client.
[0151] In the embodiments of this application, the establishment module 701 first responds to the first sub-region channel establishment request, establishes a first sub-channel with the first client based on the first sub-region of the document, and marks the first sub-region as the first sub-active region. Then, the synchronization module 702 synchronizes the first sub-active region to the document's operation client (excluding the first client). Finally, the first update module 703 updates the document with the first operation corresponding to the first operation request based on the first sub-active region and the first sub-channel, and synchronizes the first operation to the operation client. This embodiment of the application creates local channels for local sub-regions of the document. When an operation exists in the local sub-region, the document is updated through the local channel. Since global synchronization is not required, and only the content corresponding to the operation within the local sub-region is updated through the local channel, the amount of network data transmission is small, and network transmission is smoother.
[0152] In one possible embodiment of this application, the document collaborative editing device may further include a partitioning module.
[0153] The partitioning module is used to divide the document into multiple sub-regions based on the document's elements and the editing activity of those elements. The elements include at least one of the following: chapters, tables, images, macros, and content blocks.
[0154] In one possible implementation of this application, the partitioning module is used to: obtain the editing activity of elements, where editing activity is the operation frequency of each element; based on the editing activity of adjacent elements, partition adjacent elements whose editing activity difference is less than a first difference threshold into the same sub-region, and partition adjacent elements whose editing activity difference is greater than a second difference threshold into different sub-regions, wherein the first difference threshold is less than the second difference threshold.
[0155] In one possible implementation of this application, the partitioning module is configured to: determine whether to partition the element to be partitioned into the current sub-region based on the difference in editing activity between the elements in the current sub-region and the previous sub-region, the weight of the current sub-region, and the weight of the element to be partitioned, wherein the current sub-region and the previous sub-region are two adjacent sub-regions, the elements are assigned weights, different elements have different weights, and the weight of the sub-region is the sum of the weights of the elements within the sub-region; if the sum of the difference, the weight of the current sub-region, and the weight of the element to be partitioned is less than or equal to the maximum weight threshold, the element to be partitioned into the current sub-region; if the sum of the difference, the weight of the current sub-region, and the weight of the element to be partitioned is greater than the maximum weight threshold, determine whether the weight of the element to be partitioned is less than the minimum weight threshold; if the weight of the element to be partitioned is less than or equal to the minimum weight threshold, the element to be partitioned into the current sub-region; if the weight of the element to be partitioned is greater than the minimum weight threshold, create a target sub-region and partition the element to be partitioned into the target sub-region.
[0156] In one possible embodiment of this application, the document collaborative editing device may further include a conversion module.
[0157] The conversion module is used to convert the first operation and the second operation corresponding to the first sub-activation region using an operation conversion algorithm. The time difference between the first operation request and the second operation request is less than a time threshold. The operation conversion algorithm is used to adjust the execution order of multiple received operation requests so that the display content of different clients is consistent. The converted first and second operations are updated to the document and synchronized to a third client. The third client does not include the first client corresponding to the first operation request and the second client corresponding to the second operation request.
[0158] In one possible embodiment of this application, the document collaborative editing device may further include a release module.
[0159] The release module is used to release the first sub-channel according to the release request of the first sub-channel, delete the mark of the first sub-activated area to obtain the first sub-area, and synchronize the first sub-area to the operation client.
[0160] The document collaborative editing device provided in this application embodiment can achieve... Figures 1 to 2 The various processes implemented in the method embodiments achieve the same technical effect, and will not be described again here to avoid repetition.
[0161] Figure 8 This is a schematic diagram of a document collaborative editing device provided in an embodiment of this application. Figure 8As shown, the document collaborative editing device is applied to a first client. The document collaborative editing device may include a monitoring module 801, a first receiving module 802, a first sending module 803, and a display module 804.
[0162] The monitoring module 801 is used to monitor the editing focus of the document and send a first sub-region channel establishment request to the server based on the first sub-region corresponding to the editing focus; the first receiving module 802 is used to receive the first sub-channel and the first sub-active region sent by the server; the first sending module 803 is used to send a first operation request to the server through the first sub-channel based on the first operation corresponding to the first sub-active region; and the display module 804 is used to receive the first operation confirmation notification sent by the server through the first sub-channel and display the first operation on the document.
[0163] In this embodiment, the monitoring module 801 first monitors the editing focus of the document and sends a first sub-region channel establishment request to the server based on the first sub-region corresponding to the editing focus. Next, the first receiving module 802 receives the first sub-channel and the first sub-active region sent by the server. Then, the first sending module 803 sends a first operation request to the server through the first sub-channel based on the first operation corresponding to the first sub-active region. Finally, the display module 804 receives the first operation confirmation notification sent by the server through the first sub-channel and displays the first operation in the document. This embodiment establishes a first sub-channel with the server based on the first sub-region corresponding to the editing focus and sends the first operation corresponding to the first sub-active region to the server through the first sub-channel. This eliminates the need to send the entire document content to the server, reducing data transmission volume. Furthermore, since the operation corresponds to the first sub-active region, only the first sub-active region is differentially refreshed, significantly reducing client computational overhead and graphics rendering pressure by minimizing the rendering area.
[0164] In one possible embodiment of this application, the document collaborative editing device may further include: a second sending module and a second receiving module.
[0165] The second sending module is used to send a global channel establishment request to the server; the second receiving module is used to receive the global channel, document, and various sub-regions of the document sent by the server.
[0166] In one possible embodiment of this application, the document collaborative editing device may further include: a third sending module and a third receiving module.
[0167] The third sending module is used to send a first sub-channel release request to the server based on the editing focus leaving the first sub-active area; the third receiving module is used to receive the notification from the server to release the first sub-channel.
[0168] The document collaborative editing device provided in this application embodiment can achieve... Figure 3 The various processes implemented in the method embodiments achieve the same technical effect, and will not be described again here to avoid repetition.
[0169] Figure 9 This is a schematic diagram of a document collaborative editing device provided in an embodiment of this application. Figure 9 As shown, the document collaborative editing device is applied to a server, and the document collaborative editing device may include a fourth receiving module 901, a fifth receiving module 902, and a second updating module 903.
[0170] The fourth receiving module 901 is used to receive the first sub-activation region sent by the server; the fifth receiving module 902 is used to receive the first operation corresponding to the first sub-activation region sent by the server; and the second updating module 903 is used to perform differential calculation on the first sub-activation region corresponding to the first operation based on the first operation, determine the changed region of the document, and update the changed region.
[0171] In this embodiment, the fourth receiving module 901 first receives the first sub-activation region sent by the server, then the fifth receiving module 902 receives the first operation corresponding to the first sub-activation region sent by the server, and finally the second updating module 903 performs differential calculation on the first sub-activation region corresponding to the first operation based on the first operation to determine the changed area of the document and updates the changed area. In this embodiment, when the document is changed, only the changed sub-region needs to be calculated, without calculating the entire document, which reduces computational complexity and the amount of computation, thus reducing resource consumption.
[0172] In one possible embodiment of this application, the document collaborative editing device may further include: a fourth sending module and a sixth receiving module.
[0173] The fourth sending module is used to monitor when the first sub-activation area enters the display interface and the duration exceeds the first preset duration, and then sends a request to the server to establish a channel for the first sub-activation area; the sixth receiving module is used to receive the second sub-channel sent by the server.
[0174] In one possible embodiment of this application, the document collaborative editing device may further include a fifth sending module and a seventh receiving module.
[0175] The fifth sending module is used to send a second sub-channel release request to the server based on the fact that the duration of the first sub-activation area leaving the display interface exceeds the second preset duration; the seventh receiving module is used to receive the notification of the release of the second sub-channel sent by the server.
[0176] In one possible implementation of this application, the second update module 903 is used to determine the first sub-activation region corresponding to the first operation based on the first operation; calculate the differences of virtual document object model nodes within the first sub-activation region based on the first operation; and render and display the virtual document object model nodes with differences on the display interface.
[0177] The document collaborative editing device provided in this application embodiment can achieve... Figure 4 The various processes implemented in the method embodiments achieve the same technical effect, and will not be described again here to avoid repetition.
[0178] like Figure 10 As shown, this application embodiment also provides an electronic device 1000, including a processor 1001, a memory 1002, and a program or instructions stored in the memory 1002 and executable on the processor 1001. When the program or instructions are executed by the processor 1001, they implement the various processes of the above-described document collaborative editing method embodiment and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0179] This application also provides a storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the document collaborative editing method embodiments provided in any of the above embodiments. Furthermore, they achieve the same technical effects, and to avoid repetition, will not be described again here.
[0180] The processor is the processor in the electronic device described in the above embodiments. The storage medium includes computer storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0181] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described document collaborative editing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0182] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0183] This application also provides a computer program / program product, which is stored in a storage medium and executed by at least one processor to implement the various processes of the above-described document collaborative editing method embodiments, and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0184] This application embodiment also provides a processing device, which is configured to execute the various processes of the above-described document collaborative editing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0185] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0186] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0187] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A method for collaborative document editing, characterized in that, Applied to a server, the method includes: In response to the request to establish a channel in the first sub-region, a first sub-channel is established between the first client and the first sub-client based on the first sub-region of the document, and the first sub-region is marked as the first sub-active region. The first sub-activated region is synchronized to the operation client of the document, wherein the operation client does not include the first client; Based on the first operation request corresponding to the first sub-activation area and the first sub-channel, the first operation corresponding to the first operation request is updated to the document, and the first operation is synchronized to the operation client.
2. The method according to claim 1, characterized in that, Before responding to the first sub-region channel establishment request, the following is also included: Based on the elements of the document and the editing activity of the elements, the document is divided into multiple sub-regions, wherein the elements include at least one of the following: chapters, tables, images, macros, and content blocks.
3. The method according to claim 2, characterized in that, The document is divided into multiple sub-regions based on its elements and the editing activity of those elements, including: Get the editing activity of the elements, where the editing activity is the operation frequency of each element; Based on the editing activity of adjacent elements, adjacent elements whose difference in editing activity is less than a first difference threshold are divided into the same sub-region, and adjacent elements whose difference in editing activity is greater than a second difference threshold are divided into different sub-regions, wherein the first difference threshold is less than the second difference threshold.
4. The method according to claim 2, characterized in that, The method further includes: Based on the difference in editing activity between the elements in the current sub-region and the previous sub-region, the weight of the current sub-region, and the weight of the element to be assigned, it is determined whether to assign the element to be assigned to the current sub-region. The current sub-region and the previous sub-region are two adjacent sub-regions, and the elements are assigned weights. Different elements have different weights, and the weight of the sub-region is the sum of the weights of the elements in the sub-region. If the sum of the difference, the weight of the current sub-region, and the weight of the element to be assigned is less than or equal to the maximum weight threshold, the element to be assigned is assigned to the current sub-region. If the sum of the difference, the weight of the current sub-region, and the weight of the element to be assigned is greater than the maximum weight threshold, determine whether the weight of the element to be assigned is less than the minimum weight threshold. If the weight of the element to be assigned is less than or equal to the minimum weight threshold, the element to be assigned is assigned to the current sub-region. If the weight of the element to be assigned is greater than the minimum weight threshold, a target sub-region is created, and the element to be assigned is assigned to the target sub-region.
5. The method according to claim 1, characterized in that, The method further includes: Based on the first operation request and the second operation request corresponding to the first sub-activated region, the first operation and the second operation corresponding to the first sub-activated region are converted using an operation conversion algorithm. The time difference between the first operation request and the second operation request is less than a time threshold. The operation conversion algorithm is used to adjust the execution order of multiple received operation requests so that the display content of different clients is consistent. The first and second operations after conversion are updated to the document, and the first and second operations after conversion are synchronized to the third client, wherein the third client does not include the first client corresponding to the first operation request and the second client corresponding to the second operation request.
6. The method according to claim 1, characterized in that, The method further includes: Based on the first sub-channel release request, the first sub-channel is released, and the marker of the first sub-activated region is deleted to obtain the first sub-region; The first sub-region is synchronized to the operation client.
7. A method for collaborative document editing, characterized in that, Applied to a first client, the method includes: Monitor the editing focus of the document, and based on the first sub-region corresponding to the editing focus, send a first sub-region channel establishment request to the server; Receive the first sub-channel and the first sub-activation area sent by the server; Based on the first operation corresponding to the first sub-activation region, a first operation request is sent to the server through the first sub-channel; The system receives a first operation confirmation notification sent by the server through the first sub-channel and displays the first operation in the document.
8. The method according to claim 7, characterized in that, The method further includes: Send a global channel establishment request to the server; Receive the global channel, the document, and the various sub-regions of the document sent by the server.
9. The method according to claim 7, characterized in that, The method further includes: Based on the fact that the editing focus leaves the first sub-activation area, a first sub-channel release request is sent to the server; Receive a notification from the server to release the first sub-channel.
10. A method for collaborative document editing, characterized in that, Applied to a second client, the method includes: Receive the first sub-activation region sent by the server; Receive the first operation corresponding to the first sub-activated region sent by the server; Based on the first operation, differential calculation is performed on the first sub-activation region corresponding to the first operation to determine the changed region of the document, and the changed region is updated.
11. The method according to claim 10, characterized in that, The method further includes: If the first sub-activated area enters the display interface and the duration exceeds the first preset duration, a first sub-activated area channel establishment request is sent to the server. Receive the second sub-channel sent by the server.
12. The method according to claim 10, characterized in that, The method further includes: Based on the fact that the duration of time the first sub-activated area leaves the display interface exceeds the second preset duration, a second sub-channel release request is sent to the server; Receive a notification from the server to release the second sub-channel.
13. The method according to claim 10, characterized in that, The step of performing differential calculations on the first sub-activation region corresponding to the first operation based on the first operation, determining the changed region of the document, and updating the changed region includes: Based on the first operation, the first sub-activation region corresponding to the first operation is determined; Based on the first operation, calculate the differences between virtual document object model nodes within the first sub-activated region; After rendering the virtual document object model nodes that have differences, they are displayed on the display interface.
14. An electronic device, characterized in that, It includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the method as described in any one of claims 1 to 13.
15. A program product, characterized in that, The program product is stored in a storage medium, and the program product is executed by at least one processor to implement the steps of the method as described in any one of claims 1 to 13.