Text real-time editing method and device, computer device and storage medium
By inserting tags in a multi-user collaborative editor to lock the cursor position and replacing the elements before and after the tags, the problem of cursor position changes caused by remote editing is solved, ensuring the accuracy of text input and the synchronization of remote editing.
Patent Information
- Application Number
- CN202211364021.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-02
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2042-11-02
AI Technical Summary
In a multi-user real-time collaborative editor, there is a problem where the cursor position changes due to remote editing during Chinese input, leading to input errors.
By inserting tags to lock the cursor position and keeping the cursor within the tags during text input, the system monitors the replacement of elements before and after the tags during remote editing operations.
It avoids cursor position changes caused by remote editing, ensures the accuracy of text input, and enables rapid updates of remotely edited content without affecting local text input.
Smart Images

Figure CN115543142B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a method, apparatus, computer device, and storage medium for real-time text editing. Background Technology
[0002] Currently, in multi-user real-time collaborative editors, the content of the current document is updated quickly to display the editing operations of others. If a local user is currently inputting text while a remote user is also editing the document, updating the local document content may cause the cursor position to change, thereby forcibly terminating the local input of Chinese characters and easily resulting in input errors.
[0003] Therefore, during Chinese input, multi-user real-time collaborative editors will prevent updates to remote users' changes, causing the interface to fail to update others' modification results in a timely manner. Summary of the Invention
[0004] This invention provides a method, apparatus, computer device, and storage medium for real-time text editing, aiming to solve the problem in existing technologies where input errors are easily generated when remote editing occurs during local editing in multi-person collaborative editing.
[0005] In a first aspect, embodiments of the present invention provide a real-time text editing method, comprising:
[0006] When the event indicating the start of text input is triggered, locate the cursor position for the current text input and determine the current input paragraph;
[0007] Insert a label at the cursor position of the current text input, and set the cursor inside the label;
[0008] The input text is received through the label, and the cursor is kept within the label during the text input process;
[0009] When a remote editing operation is detected in the current input paragraph, the elements before and after the tag are replaced according to the content of the remote editing operation.
[0010] Secondly, embodiments of the present invention provide a real-time text editing device, comprising:
[0011] The positioning module is used to locate the cursor position of the current text input and determine the current input paragraph when the event of the start of text input is triggered.
[0012] An insertion module is used to insert a label at the cursor position of the current text input and to set the cursor within the label;
[0013] A receiving module is used to receive input text through the label and keep the cursor within the label during text input.
[0014] The replacement module is used to replace the elements before and after the tag according to the content of the remote editing operation when a remote editing operation is detected in the current input paragraph.
[0015] Thirdly, embodiments of the present invention provide a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the real-time text editing method described in the first aspect.
[0016] Fourthly, embodiments of the present invention also provide a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, which, when executed by a processor, causes the processor to perform the real-time text editing method described in the first aspect.
[0017] This invention provides a method, apparatus, computer device, and storage medium for real-time text editing. The method includes locating the cursor position and determining the current input paragraph when a text input start event is detected; inserting a label at the cursor position and placing the cursor within the label; receiving the input text through the label and keeping the cursor within the label during text input; and replacing elements before and after the label according to the content of the remote editing operation when a remote editing operation is detected. This method ensures a fixed cursor position during text input by locating the cursor, locking the cursor position with the inserted label, and receiving the input text through the label. This prevents the cursor from changing its position due to updates to the remote editing operation, thus avoiding errors caused by updates to the remote editing operation. Furthermore, by replacing elements before and after the label according to the remote editing operation, the method can quickly update the latest modifications made by the remote user, ensuring that updating the remote editing operation does not affect the normal input of the local text. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 A flowchart illustrating the real-time text editing method provided in an embodiment of the present invention;
[0020] Figure 2 for Figure 1 A detailed flowchart of an embodiment of step S140;
[0021] Figure 3 for Figure 2 A detailed flowchart of an embodiment of step S220;
[0022] Figure 4 This is a schematic block diagram of a real-time text editing device provided in an embodiment of the present invention. Detailed Implementation
[0023] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0024] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0025] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0026] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0027] Please see Figure 1 This is a flowchart illustrating a real-time text editing method provided in an embodiment of the present invention, which includes steps S110 to S140.
[0028] Step S110: When the event of the start of text input is detected, locate the cursor position of the current text input and determine the current input paragraph;
[0029] Step S120: Insert a label at the cursor position of the current text input, and set the cursor inside the label;
[0030] Step S130: Receive the input text through the label, and keep the cursor within the label during the text input process;
[0031] Step S140: When a remote editing operation of the current input paragraph is detected, replace the elements before and after the tag according to the content of the remote editing operation.
[0032] In this embodiment, the editing terminal uses the `compositionstart` command to listen for the occurrence of a text input start event. If triggered, it obtains the current cursor position using the `document.getSelection()` method, locates the current text input cursor position, and determines the current input paragraph. To prevent cursor movement, a tag is inserted at the current text input cursor position, and the cursor is set within the tag. The input text is then received through the tag, keeping the cursor within the tag during text input. Real-time monitoring is conducted to detect any remote editing operations on the current input paragraph. When such operations are detected, the elements before and after the tag are replaced according to the content of the remote editing operation, thus updating the text of the current input paragraph. The tag can be a `span` tag, an inline tag in Hypertext Markup Language (HTML) used to group inline elements in a document. The `span` tag has no fixed format. Applying styles to it produces visual changes. Using the `compositionstart` and `compositionend` events to listen for the start and end of text input effectively determines whether the current input is being processed by an input method.
[0033] In one embodiment, the real-time text editing method provided by this invention further includes:
[0034] When the event indicating the end of text input is triggered, extract the text entered within the label, insert the entered text into the current input paragraph, and delete the label.
[0035] In this embodiment, when the event indicating the end of text input is triggered, it means the user has finished inputting text. When the user finishes inputting text, the text entered within the `span` tag is extracted, inserted into the current input paragraph, and the tag is deleted. In practical applications, the `compositionstart` event is triggered when the user starts inputting Chinese characters using Pinyin input method. The `compositionend` event is triggered when the composition of the text paragraph is completed or canceled. That is, the `compositionstart` event is triggered once when text input begins, it is not triggered again during Chinese input, and the `compositionend` event is triggered when the text input is completed.
[0036] In one embodiment, the real-time text editing method provided by this invention further includes:
[0037] When the event indicating the start of text input is triggered, update the text input state of the current input paragraph to true;
[0038] When the event indicating the end of text input is triggered, update the text input state of the current input paragraph to false.
[0039] In this embodiment, to facilitate users in distinguishing text input states, the text input states of the editor are set. When the event of the start of text input is detected, the text input state of the current input paragraph is updated to true, indicating to the user that the text input state of the current input paragraph is in progress. When the event of the end of text input is detected, the text input state of the current input paragraph is updated to false, indicating to the user that the text input state of the current input paragraph is finished.
[0040] For example, when a user enters text into the current input paragraph, the text input start event is triggered, updating the text input state of the current input paragraph to true; when the user finishes entering text into the current input paragraph, the text input end event is triggered, updating the text input state of the current input paragraph to false.
[0041] like Figure 2 As shown, in one embodiment, step S140 includes:
[0042] Step S210: When a remote editing operation is received from the server, the text input status of the paragraph corresponding to the remote editing operation is obtained;
[0043] Step S220: If the text input status is true, then confirm that the paragraph corresponding to the remote editing operation is the current input paragraph, and replace the elements before and after the tag according to the content of the remote editing operation;
[0044] Step S230: If the text input status is false, then the corresponding paragraph is updated directly according to the content of the remote editing operation.
[0045] In this embodiment, when a remote editing operation is detected in the current input paragraph, in order to avoid conflicts that may affect text input, it is necessary to confirm the text input status of the current input paragraph. If the text input status is true, the paragraph corresponding to the remote editing operation is confirmed as the current input paragraph, and the elements before and after the tag are replaced according to the content of the remote editing operation to prevent conflicts between the remote editing operation and the current input status, which could lead to text modification errors. If the text input status is false, the corresponding paragraph is updated directly according to the content of the remote editing operation.
[0046] For example, when a remote editing operation is received from the server, the text input status of the paragraph corresponding to the remote editing operation is checked. If the current corresponding paragraph is paragraph 5 and the text input status of paragraph 5 is true, it means that paragraph 5 is being edited. Then, the elements before and after the current span tag are replaced according to the content of the remote editing operation. If the text input status of paragraph 5 is false, it means that the current paragraph 5 has completed text input or the user is not currently inputting text into paragraph 5. Then, the content of the remote editing operation can be directly updated into paragraph 5.
[0047] like Figure 3 As shown, in one embodiment, step S220 includes:
[0048] Step S310: Obtain the remote paragraph information of the current input paragraph and the local paragraph information of the current input paragraph according to the remote editing operation;
[0049] Step S320: Compare the remote paragraph information with the local paragraph information, and replace the elements before and after the tag according to the comparison result.
[0050] In this embodiment, when a remote editing operation is detected in the current input paragraph and the text input status of the current input paragraph is true, it indicates that the current input paragraph is being edited locally. Therefore, it is necessary to compare the remote editing operation with the text within the span tag. Thus, the remote modification information of the current input paragraph (i.e., remote paragraph information) and the local paragraph information of the current input paragraph are obtained based on the remote editing operation. The remote paragraph information and the local paragraph information are compared, and the elements before and after the tag are replaced based on the comparison result.
[0051] In one embodiment, in the editor, remote paragraph information is the remote HTML of the current input paragraph generated based on remote editing operations, and local paragraph information is the local HTML of the current input paragraph generated locally.
[0052] Step S320 includes: performing a diff analysis on the virtual DOM corresponding to the remote html and the local html using the virtual-dom component, filtering out the elements that need to be replaced based on the diff analysis results, and replacing the elements before and after the tags in the current input paragraph.
[0053] Among them, diff analysis is a comparison algorithm that can find the differences between the new and old virtual DOM of the current input paragraph, filter out the elements that need to be replaced, and update the elements that need to be replaced to the real DOM of the current input paragraph based on the comparison results after comparing the virtual DOM of the current input paragraph.
[0054] In one embodiment, setting the cursor within the label includes:
[0055] Fill the cursor with a predetermined character so that the cursor is positioned inside the label and the label is not empty.
[0056] In this embodiment, taking the span tag as an example, in order to place the cursor inside the span tag, the character '\u200B' is filled inside the span tag, so that the cursor is located inside the tag. The character '\u200B' is a special character. Using the character '\u200B' can ensure that the span tag is not empty, and will not affect the visual effect.
[0057] This method locates the cursor position and locks it using an inserted label. The input text is received through the label, ensuring that the cursor position remains fixed during text input. This prevents the local text input position from changing due to updates to remote editing operations. When a remote editing operation is received, the elements before and after the label are replaced according to the content of the remote operation. This allows for quick updates to the latest modifications made by the remote user, ensuring that updating the content of remote editing operations does not affect the normal input of local text.
[0058] This invention also provides a real-time text editing device for executing any of the aforementioned real-time text editing methods. Specifically, please refer to... Figure 4 , Figure 4 This is a schematic block diagram of a real-time text editing device provided in an embodiment of the present invention. The real-time text editing device 100 can be configured in a server.
[0059] like Figure 4 As shown, the real-time text editing device 100 includes a positioning module 110, an insertion module 120, a receiving module 130, and a replacement module 140.
[0060] The positioning module 110 is used to locate the cursor position of the current text input and determine the current input paragraph when the event of the start of text input is detected.
[0061] The insertion module 120 is used to insert a label at the cursor position of the current text input and set the cursor inside the label;
[0062] The receiving module 130 is used to receive input text through the label and keep the cursor within the label during text input.
[0063] The replacement module 140 is used to replace the elements before and after the label according to the content of the remote editing operation when a remote editing operation of the current input paragraph is detected.
[0064] In this embodiment, the editing terminal listens for the text input start event via the `compositionstart` command. If triggered, it obtains the current cursor position using the `document.getSelection()` method, locates the current text input cursor position, and determines the current input paragraph. To prevent cursor movement, a `span` tag is inserted at the current text input cursor position, and the cursor is set within the `span` tag. The input text is then received through the tag, keeping the cursor within the tag during text input. Real-time detection is performed; when a remote editing operation is detected in the current input paragraph, the elements before and after the `span` tag are replaced according to the content of the remote editing operation. The `span` tag is an inline tag in Hypertext Markup Language (HTML) used to group inline elements in a document. The `span` tag has no fixed format. Applying styles to it produces visual changes. During text input, the system monitors for remote editing operations in real time. When a remote editing operation is detected in the current input paragraph, the elements before and after the `span` tag are replaced according to the content of the remote editing operation, thus updating the text of the current input paragraph.
[0065] In one embodiment, the real-time text editing device 100 further includes:
[0066] The extraction module is used to extract the text entered within the label when the event of the end of text input is triggered, insert the entered text into the current input paragraph, and delete the label.
[0067] In this embodiment, when the event indicating the end of text insertion is detected, it signifies that the user has finished text input. When the user finishes text input, the text entered within the `span` tag is extracted, inserted into the current input paragraph, and the tag is deleted. In practical applications, the `compositionstart` event is triggered when the user begins inputting Chinese characters using Pinyin input; the `compositionend` event is triggered when the text paragraph is completed or canceled. That is, the `compositionstart` event is triggered once when text input begins, and it is not triggered again during Chinese input; the `compositionend` event is triggered when text input is completed.
[0068] For example, in an editor, the `compositionstart` event is listened to when the user starts typing text, and the `compositionend` event is listened to when the user finishes typing text.
[0069] In one embodiment, the real-time text editing device 100 includes:
[0070] The first update module is used to update the text input state of the current input paragraph to true when the event of the start of text input is triggered.
[0071] The second update module is used to update the text input status of the current input paragraph to false when the event of the end of text input is detected.
[0072] In this embodiment, to facilitate users in distinguishing text input states, the text input states of the editor are set. When the event of the start of text input is detected, the text input state of the current input paragraph is updated to true, indicating to the user that the text input state of the current input paragraph is in progress. When the event of the end of text input is detected, the text input state of the current input paragraph is updated to false, indicating to the user that the text input state of the current input paragraph is finished.
[0073] For example, when a user enters text into the current input paragraph, the text input start event is triggered, updating the text input state of the current input paragraph to true; when the user finishes entering text into the current input paragraph, the text input end event is triggered, updating the text input state of the current input paragraph to false.
[0074] In one embodiment, the replacement module 140 includes:
[0075] The acquisition unit is used to acquire the text input status of the paragraph corresponding to the remote editing operation when a remote editing operation pushed by the server is received;
[0076] The replacement unit is used to confirm that the paragraph corresponding to the remote editing operation is the current input paragraph if the text input state is true, and to replace the elements before and after the tag according to the content of the remote editing operation;
[0077] The update unit is used to update the corresponding paragraph directly based on the content of the remote editing operation if the text input status is false.
[0078] In this embodiment, when a remote editing operation is detected in the current input paragraph, in order to avoid conflicts that may affect text input, it is necessary to confirm the text input status of the current input paragraph. If the text input status is true, the paragraph corresponding to the remote editing operation is confirmed as the current input paragraph, and the elements before and after the tag are replaced according to the content of the remote editing operation to prevent conflicts between the remote editing operation and the current input status, which could lead to text modification errors. If the text input status is false, the corresponding paragraph is updated directly according to the content of the remote editing operation.
[0079] For example, when a remote editing operation is received from the server, the text input status of the paragraph corresponding to the remote editing operation is checked. If the current corresponding paragraph is paragraph 5 and the text input status of paragraph 5 is true, it means that paragraph 5 is being edited. Then, the elements before and after the current span tag are replaced according to the content of the remote editing operation. If the text input status of paragraph 5 is false, it means that the current paragraph 5 has completed text input or the user is not currently inputting text into paragraph 5. Then, the content of the remote editing operation can be directly updated into paragraph 5.
[0080] In one embodiment, the replacement unit includes:
[0081] The acquisition subunit is used to acquire remote paragraph information of the current input paragraph and local paragraph information of the current input paragraph according to the remote editing operation.
[0082] The replacement subunit is used to compare the remote paragraph information with the local paragraph information, and replace the elements before and after the tag according to the comparison result.
[0083] In this embodiment, when a remote editing operation is detected in the current input paragraph and the text input status of the current input paragraph is true, it indicates that the current input paragraph is being edited locally. Therefore, it is necessary to compare the remote editing operation with the text within the span tag. Thus, the remote modification information of the current input paragraph (i.e., remote paragraph information) and the local paragraph information of the current input paragraph are obtained based on the remote editing operation. The remote paragraph information and the local paragraph information are compared, and the elements before and after the tag are replaced based on the comparison result.
[0084] In one embodiment, the replacement subunit includes:
[0085] The analysis subunit is used to perform diff analysis on the remote HTML and local HTML using the virtual-dom component, filter out the elements that need to be replaced based on the diff analysis results, and replace the elements before and after the tags in the current input paragraph.
[0086] In this embodiment, within the editor, remote paragraph information refers to the remote HTML of the current input paragraph generated based on remote editing operations, while local paragraph information refers to the locally generated local HTML of the current input paragraph. The diff analysis is a comparison algorithm that identifies differences between the old and new virtual DOMs of the current input paragraph, filters out elements that need to be replaced, and updates the corresponding real DOM of the current input paragraph with the elements that need to be replaced based on the comparison results after comparing the virtual DOMs of the current input paragraph.
[0087] In one embodiment, the insertion module 120 includes:
[0088] A fill unit is used to fill the cursor with a predetermined character so that the cursor is located inside the label and the label is not empty.
[0089] In this embodiment, to place the cursor inside the span tag, the span tag is filled with the character '\u200B', so that the cursor is located inside the tag. The character '\u200B' is a special character. Using the character '\u200B' can ensure that the span tag is not empty, and will not affect the visual effect.
[0090] This invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the real-time text editing method described above.
[0091] In this embodiment, the processor is used to execute a real-time text editing method, which includes: when an event triggering the start of text input is detected, locating the cursor position of the current text input and determining the current input paragraph; inserting a label at the cursor position of the current text input and setting the cursor within the label; receiving the input text through the label and keeping the cursor within the label during the text input process; and when a remote editing operation of the current input paragraph is detected, replacing the elements before and after the label according to the content of the remote editing operation.
[0092] In another embodiment of the invention, a computer-readable storage medium is provided. This computer-readable storage medium may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to perform the real-time text editing method as described above.
[0093] In this embodiment, the computer program is used to execute a real-time text editing method, which includes: when an event triggering the start of text input is detected, locating the cursor position of the current text input and determining the current input paragraph; inserting a label at the cursor position of the current text input and setting the cursor within the label; receiving the input text through the label and keeping the cursor within the label during the text input process; and when a remote editing operation of the current input paragraph is detected, replacing the elements before and after the label according to the content of the remote editing operation.
[0094] Those skilled in the art will readily understand that, for the sake of convenience and brevity, the specific working processes of the devices, apparatuses, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this invention.
[0095] In the embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Units with the same function may be grouped into one unit. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. In addition, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, or it may be an electrical, mechanical, or other form of connection.
[0096] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the embodiments of the present invention, depending on actual needs.
[0097] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0098] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks.
[0099] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A real-time text editing method, characterized in that, include: When the event indicating the start of text input is triggered, locate the cursor position for the current text input and determine the current input paragraph; Insert a label at the cursor position of the current text input, and set the cursor inside the label; The input text is received through the label, and the cursor is kept within the label during the text input process; When a remote editing operation is detected in the current input paragraph, the elements before and after the tag are replaced according to the content of the remote editing operation, including: when a remote editing operation is received from the server, the text input status of the paragraph corresponding to the remote editing operation is obtained; If the text input status is true, the paragraph corresponding to the remote editing operation is confirmed as the current input paragraph, and the elements before and after the tag are replaced according to the content of the remote editing operation; if the text input status is false, the corresponding paragraph is updated directly according to the content of the remote editing operation.
2. The real-time text editing method according to claim 1, characterized in that, Also includes: When the event indicating the end of text input is triggered, extract the text entered within the tag, insert the entered text into the current input paragraph, and delete the tag.
3. The real-time text editing method according to claim 2, characterized in that, Also includes: When the event indicating the start of text input is triggered, update the text input state of the current input paragraph to true; When the event indicating the end of text input is triggered, update the text input state of the current input paragraph to false.
4. The real-time text editing method according to claim 1, characterized in that, The step of replacing the elements before and after the tag according to the content of the remote editing operation includes: According to the remote editing operation, obtain the remote paragraph information of the current input paragraph and the local paragraph information of the current input paragraph; The remote paragraph information is compared with the local paragraph information, and the elements before and after the tag are replaced according to the comparison result.
5. The real-time text editing method according to claim 4, characterized in that, The remote paragraph information is the remote HTML of the current input paragraph generated based on the remote editing operation, and the local paragraph information is the local HTML of the current input paragraph generated locally; The step of comparing the remote paragraph information with the local paragraph information and replacing the elements before and after the tag based on the comparison result includes: The remote HTML and local HTML are analyzed by using the virtual-dom component. Based on the results of the analysis, the elements that need to be replaced are selected, and the elements before and after the tags in the current input paragraph are replaced.
6. The real-time text editing method according to claim 1, characterized in that, Setting the cursor within the label includes: Fill the cursor with a predetermined character so that the cursor is positioned inside the label and the label is not empty.
7. A real-time text editing device, characterized in that, include: The positioning module is used to locate the cursor position of the current text input and determine the current input paragraph when the event of the start of text input is triggered. An insertion module is used to insert a label at the cursor position of the current text input and to set the cursor within the label; A receiving module is used to receive input text through the label and keep the cursor within the label during text input. The replacement module is used to replace the elements before and after the tag according to the content of the remote editing operation when a remote editing operation is detected in the current input paragraph; The replacement module is specifically used to obtain the text input status of the paragraph corresponding to the remote editing operation when a remote editing operation is received from the server. If the text input status is true, the paragraph corresponding to the remote editing operation is confirmed as the current input paragraph, and the elements before and after the tag are replaced according to the content of the remote editing operation; if the text input status is false, the corresponding paragraph is updated directly according to the content of the remote editing operation.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the real-time text editing method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to perform the real-time text editing method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Editing a document using a transitory editing surface
CN101952821A
Cursor lock region
CN1074300A