Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
CN115543142B - Real-time text editing methods, devices, computer equipment, and storage media - Google Patents
[go: Go Back, main page]

CN115543142B - Real-time text editing methods, devices, computer equipment, and storage media - Google Patents

Real-time text editing methods, devices, computer equipment, and storage media

Info

Publication number
CN115543142B
CN115543142B CN202211364021.2A CN202211364021A CN115543142B CN 115543142 B CN115543142 B CN 115543142B CN 202211364021 A CN202211364021 A CN 202211364021A CN 115543142 B CN115543142 B CN 115543142B
Authority
CN
China
Prior art keywords
paragraph
text
input
remote
editing operation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211364021.2A
Other languages
Chinese (zh)
Other versions
CN115543142A (en
Inventor
王颖奇
冯斌
张其纲
魏拾俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Fulin Technology Co Ltd
Original Assignee
Shenzhen Fulin Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Fulin Technology Co Ltd filed Critical Shenzhen Fulin Technology Co Ltd
Priority to CN202211364021.2A priority Critical patent/CN115543142B/en
Publication of CN115543142A publication Critical patent/CN115543142A/en
Application granted granted Critical
Publication of CN115543142B publication Critical patent/CN115543142B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0481Interaction techniques based on graphical user interfaces [GUI] based on specific properties of the displayed interaction object or a metaphor-based environment, e.g. interaction with desktop elements like windows or icons, or assisted by a cursor's changing behaviour or appearance
    • G06F3/04812Interaction techniques based on cursor appearance or behaviour, e.g. being affected by the presence of displayed objects
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/197Version control

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Human Computer Interaction (AREA)
  • Document Processing Apparatus (AREA)

Abstract

本发明属于数据处理技术领域,公开了文本实时编辑方法、装置、计算机设备及存储介质。该方法包括当监听到文本输入开始的事件触发时,定位当前文本输入的光标位置,并确定当前输入段落;在所述当前文本输入的光标位置插入标签,并将所述光标设置于标签内;通过标签接收输入的文本,且在文本输入过程中使光标保持在所述标签内;当监测到当前输入段落的远程编辑操作时,根据远程编辑操作的内容对标签前后的元素进行替换。该方法可以快速更新远程用户最新修改的内容,实现更新远程编辑操作的内容时不影响本地文本的正常输入。

This invention belongs to the field of data processing technology and discloses a method, apparatus, computer device, and storage medium for real-time text editing. The method 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 and setting the cursor within the label; receiving the input text through the label and keeping the cursor within the label during text input; and when a remote editing operation is detected in the current input paragraph, replacing elements before and after the label according to the content of the remote editing operation. This method can quickly update the latest modifications made by a remote user, ensuring that updating the content of a remote editing operation does not affect normal local text input.

Description

Text real-time editing method, device, computer equipment and storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method and apparatus for editing text in real time, a computer device, and a storage medium.
Background
In the current stage, in order to quickly display editing operations of other people in the multi-person real-time collaborative editor, the content of a current document can be quickly updated, if a user in the current local area is in the text input process, a remote user also edits the document, and the cursor position can be possibly changed when the content of the local document is updated, so that the Chinese input in the current area is forcedly terminated, and the result of input errors can be easily generated.
Therefore, in the Chinese input process, the multi-user real-time collaboration editor can prohibit updating of the change operation of the remote user, so that the interface can not update the modification results of other people in time.
Disclosure of Invention
The embodiment of the invention provides a method, a device, computer equipment and a storage medium for editing text in real time, which aim to solve the problem that input errors are easy to generate if remote editing exists in local editing in multi-person collaborative editing in the prior art.
In a first aspect, an embodiment of the present invention provides a method for editing text in real time, including:
When the event trigger of starting text input is monitored, positioning the cursor position of the current text input, and determining the current input paragraph;
Inserting a label in the cursor position of the current text input, and setting the cursor in the label;
receiving input text through the tag, and keeping the cursor in the tag during text input;
when the remote editing operation of the current input paragraph is monitored, replacing elements before and after the label according to the content of the remote editing operation.
In a second aspect, an embodiment of the present invention provides a text real-time editing apparatus, including:
The positioning module is used for positioning the cursor position of the current text input and determining the current input paragraph when the event trigger of starting the text input is monitored;
the inserting module is used for inserting a label in the cursor position of the current text input and setting the cursor in the label;
the receiving module is used for receiving input text through the tag and keeping the cursor in the tag in the text input process;
And the replacing module is used for replacing the elements before and after the label according to the content of the remote editing operation when the remote editing operation of the current input paragraph is monitored.
In a third aspect, an embodiment of the present invention further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor executes the computer program to implement the method for editing text in real time according to the first aspect.
In a fourth aspect, an embodiment of the present invention further provides a computer readable storage medium, where the computer readable storage medium stores a computer program, where the computer program when executed by a processor causes the processor to perform the method for editing text in real time according to the first aspect.
The embodiment of the invention provides a method and a device for editing text in real time, computer equipment and a storage medium. The method comprises the steps of locating a cursor position of a current text input when an event trigger of starting text input is monitored, determining a current input paragraph, inserting a tag at the cursor position of the current text input, setting the cursor in the tag, receiving the input text through the tag, enabling the cursor to be kept in the tag in the text input process, and replacing elements before and after the tag according to the content of the remote editing operation when the remote editing operation of the current input paragraph is monitored. According to the method, the cursor position is positioned, the inserted label is utilized to lock the cursor position, the input text is received through the label, the cursor position is fixed in the text input process, the cursor is prevented from changing due to the fact that the position is changed when the remote editing operation content is updated, errors caused by updating the remote editing operation content in the text input process are avoided, when the remote editing operation is received, elements before and after the label are replaced according to the remote operation content, the latest modified content of a remote user can be updated rapidly, and normal input of the local text is not affected when the remote editing operation content is updated.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of a text real-time editing method according to an embodiment of the present invention;
FIG. 2 is a detailed flowchart of the step S140 in FIG. 1;
FIG. 3 is a detailed flowchart of the step S220 in FIG. 2;
Fig. 4 is a schematic block diagram of a text real-time editing apparatus according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of 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 as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
Referring to fig. 1, a flow chart of a text real-time editing method according to an embodiment of the invention includes steps S110 to S140.
Step S110, when the event trigger of starting text input is monitored, the cursor position of the current text input is positioned, and the current input paragraph is determined;
step S120, inserting a label in the cursor position of the current text input, and setting the cursor in the label;
step S130, receiving input text through the tag, and keeping the cursor in the tag during text input;
and step 140, when the remote editing operation of the current input paragraph is monitored, replacing elements before and after the label according to the content of the remote editing operation.
In this embodiment, the editing terminal monitors whether an event triggering the start of text input is currently triggered through compositionstart command, if yes, obtains the current cursor position through document. Getselection () method, locates the cursor position of the current text input and determines the current input paragraph, in order to prevent cursor movement, inserts a tag at the cursor position of the current text input, sets the cursor in the tag, then receives the input text through the tag, keeps the cursor in the tag during text input, monitors whether there is a remote editing operation on the current input paragraph in real time, and when the remote editing operation on the current input paragraph is monitored, replaces elements before and after the tag according to the content of the remote editing operation, so as to realize text update on the current input paragraph. Where the tags may be span tags, which are in-line tags of the hypertext markup language (HTML), are used to combine in-line elements in the document. span tags do not appear in a fixed format. When a pattern is applied to it, it produces a visual change. By using compositionstart and compositionend events to monitor the events of the text input start and the text input end, whether the input method input is currently performed or not can be effectively judged.
In an embodiment, the text real-time editing method provided by the embodiment of the invention further includes:
when the event trigger of ending the text input is monitored, extracting the text input in the label, inserting the input text into the current input paragraph and deleting the label.
In this embodiment, when the event trigger of ending the text input is detected, the user is indicated to end the text input, and when the user ends the text input, the text input in the span tag is extracted, inserted into the current input paragraph, and the tag is deleted. In practical applications, compositionstart events are triggered when a user starts to input Chinese characters using the pinyin input method. The compositionend event will be triggered when the composition of a text passage is completed or cancelled. That is, the text input is started, the compositionstart events are triggered once, the compositionstart events are not started in the Chinese input process, and finally the text input is completed, and the compositionend events are triggered.
In an embodiment, the text real-time editing method provided by the embodiment of the invention further includes:
When the event trigger of starting text input is monitored, updating the text input state of the current input paragraph to be true;
When the event trigger of ending the text input is monitored, the text input state of the current input paragraph is updated to be false.
In this embodiment, in order to facilitate the user to distinguish the text input states, the text input state of the editor is set, when the event trigger of the beginning of text input is monitored, the text input state of the current input paragraph is updated to true (true), which indicates that the text input state of the current input paragraph is being input by the user, and when the event trigger of the ending of text input is monitored, the text input state of the current input paragraph is updated to false (false), which indicates that the text input state of the current input paragraph is being input by the user.
For example, when the user inputs text into the current input paragraph, the text input state of the current input paragraph is updated to true (true) by the event trigger that the text input starts, and when the user finishes inputting text into the current input paragraph, the text input state of the current input paragraph is updated to false (false) by the event trigger that the text input ends.
As shown in fig. 2, in an embodiment, step S140 includes:
Step S210, when a remote editing operation pushed by a server is received, acquiring a text input state of a paragraph corresponding to the remote editing operation;
Step S220, if the text input state is true, confirming that the paragraph corresponding to the remote editing operation is the current input paragraph, and replacing elements before and after the label according to the content of the remote editing operation;
Step S230, if the text input status is false, updating the corresponding paragraph directly according to the content of the remote editing operation.
In this embodiment, when it is monitored that a remote editing operation exists in a current input paragraph, in order to avoid affecting text input and conflicting, it is necessary to confirm a text input state of the current input paragraph, if the text input state is true, confirm that a paragraph corresponding to the remote editing operation is the current input paragraph, replace elements before and after a label according to contents of the remote editing operation, so as to prevent the remote editing operation and the current input state from conflicting and causing text modification errors, and if the text input state is false, update the corresponding paragraph directly according to contents of the remote editing operation.
For example, when a remote editing operation pushed by the server is received, confirming the text input state of a paragraph corresponding to the remote editing operation, if the currently corresponding paragraph is paragraph 5, and if the text input state of paragraph 5 is true, then the text input state of paragraph 5 indicates that paragraph 5 is being edited, then the elements before and after the current span label are replaced according to the content of the remote editing operation, and if the text input state of paragraph 5 is false, then the text input of current paragraph 5 is completed or the user does not currently input text to paragraph 5, then the content of the remote editing operation can be directly updated to paragraph 5.
As shown in fig. 3, in an embodiment, step S220 includes:
step S310, obtaining remote paragraph information of a current input paragraph according to the remote editing operation, and obtaining local paragraph information of the current input paragraph;
and step 320, comparing the remote paragraph information with the local paragraph information, and replacing elements before and after the label according to the comparison result.
In this embodiment, when it is monitored that a remote editing operation exists in a current input paragraph and the text input state of the current input paragraph is true, it indicates that the current input paragraph is being edited locally, and then the remote editing operation and the text in the span tag need to be compared, so that modification information (i.e., remote paragraph information) of the current input paragraph and local paragraph information of the current input paragraph are obtained remotely according to the remote editing operation, the remote paragraph information and the local paragraph information are compared, and elements before and after the tag are replaced according to the comparison result.
In one embodiment, in the editor, the remote paragraph information is remote html of the current input paragraph generated based on the remote editing operation, and the local paragraph information is local html of the current input paragraph generated locally.
Step S320 includes performing diff analysis on virtual Dom corresponding to remote html and local html through virtual-Dom components, screening out elements needing to be replaced according to diff analysis results, and replacing elements before and after labels in a current input paragraph.
The diff analysis is a comparison algorithm, the diff analysis can find the difference between new and old virtual doms of the current input paragraph, screen out the element to be replaced, and update the element to be replaced to the real doms corresponding to the current input paragraph according to the compared result after comparing the virtual doms of the current input paragraph.
In an embodiment, the setting the cursor in the tag includes:
Filling a preset character in the cursor, enabling the cursor to be positioned in the label, and enabling the label to be non-empty.
In this embodiment, taking the span tag as an example, in order to set the cursor in the span tag, the span tag is filled with the '\u200b' character, so that the cursor is located in the tag, wherein the '\u200b' character is a special character, and the use of the '\u200b' character can not only ensure non-empty in the span tag, but also not affect the visual effect.
According to the method, the cursor position is positioned, the inserted label is utilized to lock the cursor position, the input text is received through the label, the cursor position is fixed in the text input process, the cursor cannot change due to the fact that the position is changed when the remote editing operation content is updated, when the remote editing operation is received, elements before and after the label are replaced according to the remote operation content, the latest modified content of a remote user can be updated rapidly, and normal input of the local text is not affected when the remote editing operation content is updated.
The embodiment of the invention also provides a text real-time editing device which is used for executing any embodiment of the text real-time editing method. Specifically, referring to fig. 4, fig. 4 is a schematic block diagram of a text real-time editing apparatus according to an embodiment of the present invention. The text real-time editing apparatus 100 may be configured in a server.
As shown in fig. 4, the text real-time editing apparatus 100 includes a positioning module 110, an inserting module 120, a receiving module 130, and a replacing module 140.
A positioning module 110, configured to, when an event trigger from the start of text input is detected, position a cursor of a current text input, and determine a current input paragraph;
the inserting module 120 is configured to insert a tag in a cursor position of the current text input, and set the cursor in the tag;
A receiving module 130, configured to receive an input text through the tag, and maintain the cursor within the tag during a text input process;
And the replacing module 140 is used for replacing elements before and after the label according to the content of the remote editing operation when the remote editing operation of the current input paragraph is monitored.
In this embodiment, the editing terminal monitors whether to trigger the event of starting text input currently through compositionstart command, if so, obtains the current cursor position through document. Getselection () method, locates the cursor position of current text input and determines the current input paragraph, in order to prevent cursor movement, inserts a span tag at the cursor position of current text input, and sets the cursor in the span tag, then receives the input text through the tag, keeps the cursor in the tag during text input, and when the remote editing operation of the current input paragraph is monitored, real-time detection is performed, the elements before and after the tag are replaced according to the content of the remote editing operation. Wherein the span tags are in-line tags of the hypertext markup language (HTML) that are used to combine in-line elements in the document. Span tags do not appear in a fixed format. When a pattern is applied to it, it produces a visual change. And in the text input process, monitoring whether a remote editing operation exists in real time. When the remote editing operation of the current input paragraph is monitored, replacing elements before and after the label according to the content of the remote editing operation, and updating the text of the current input paragraph.
In one embodiment, the text real-time editing apparatus 100 further includes:
And the extraction module is used for extracting the text input in the tag when the event trigger of ending the text input is monitored, inserting the input text into the current input paragraph and deleting the tag.
In this embodiment, when the event trigger of ending the text insertion is detected, the user is indicated to end the text input, and when the user ends the text input, the text input in 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 to input Chinese characters by using the pinyin input method, and the compositionend event is triggered when the input of a text paragraph is completed or canceled. That is, the text input is started, the compositionstart events are triggered once, the compositionstart events are not started in the Chinese input process, and the compositionend events are triggered when the text input is completed.
For example, in the editor, when the user starts text entry, it is monitored compositionstart that an event is triggered, and when the user ends text entry, it is monitored compositionend that an event is triggered.
In one embodiment, the text real-time editing apparatus 100 includes:
the first updating module is used for updating the text input state of the current input paragraph to be true when the event trigger of starting text input is monitored;
And the second updating module is used for updating the text input state of the current input paragraph to be false when the event triggering of ending the text input is monitored.
In this embodiment, in order to facilitate the user to distinguish the text input states, the text input state of the editor is set, when the event trigger of the beginning of text input is monitored, the text input state of the current input paragraph is updated to true (true), which indicates that the text input state of the current input paragraph is being input by the user, and when the event trigger of the ending of text input is monitored, the text input state of the current input paragraph is updated to false (false), which indicates that the text input state of the current input paragraph is being input by the user.
For example, when the user inputs text into the current input paragraph, the text input state of the current input paragraph is updated to true (true) by the event trigger that the text input starts, and when the user finishes inputting text into the current input paragraph, the text input state of the current input paragraph is updated to false (false) by the event trigger that the text input ends.
In one embodiment, the replacement module 140 includes:
The device comprises an acquisition unit, a server and a storage unit, wherein the acquisition unit is used for acquiring the text input state of a paragraph corresponding to a remote editing operation when the remote editing operation pushed by the server is received;
A replacing unit, configured to confirm that a paragraph corresponding to the remote editing operation is a current input paragraph if the text input state is true, and replace elements before and after the tag according to the content of the remote editing operation;
and the updating unit is used for updating the corresponding paragraph directly according to the content of the remote editing operation if the text input state is false.
In this embodiment, when it is monitored that a remote editing operation exists in a current input paragraph, in order to avoid affecting text input and conflicting, it is necessary to confirm a text input state of the current input paragraph, if the text input state is true (true), confirm that a paragraph corresponding to the remote editing operation is the current input paragraph, replace elements before and after a label according to contents of the remote editing operation, so as to prevent the remote editing operation and the current input state from conflicting and causing a text modification error, and if the text input state is false, update the corresponding paragraph directly according to contents of the remote editing operation.
For example, when a remote editing operation pushed by the server is received, confirming the text input state of a paragraph corresponding to the remote editing operation, if the currently corresponding paragraph is paragraph 5, and if the text input state of paragraph 5 is true, then the text input state of paragraph 5 indicates that paragraph 5 is being edited, then the elements before and after the current span label are replaced according to the content of the remote editing operation, and if the text input state of paragraph 5 is false, then the text input of current paragraph 5 is completed or the user does not currently input text to paragraph 5, then the content of the remote editing operation can be directly updated to paragraph 5.
In an embodiment, the replacement unit comprises:
the acquisition subunit is used for acquiring remote paragraph information of the current input paragraph according to the remote editing operation and acquiring local paragraph information of the current input paragraph;
And the replacing subunit is used for comparing the remote paragraph information with the local paragraph information and replacing elements before and after the label according to the comparison result.
In this embodiment, when it is monitored that a remote editing operation exists in a current input paragraph and the text input state of the current input paragraph is true, it indicates that the current input paragraph is being edited locally, and then the remote editing operation and the text in the span tag need to be compared, so that modification information (i.e., remote paragraph information) of the current input paragraph and local paragraph information of the current input paragraph are obtained remotely according to the remote editing operation, the remote paragraph information and the local paragraph information are compared, and elements before and after the tag are replaced according to the comparison result.
In one embodiment, the replacement subunit comprises:
and the analysis subunit is used for performing diff analysis on the remote html and the local html through the virtual-dom component, screening out elements needing to be replaced according to diff analysis results, and replacing the elements before and after the tag in the current input paragraph.
In this embodiment, in the editor, the remote paragraph information is remote html of a current input paragraph generated based on a remote editing operation, and the local paragraph information is local html of the current input paragraph generated locally. The diff analysis is a comparison algorithm, the diff analysis can find the difference between new and old virtual doms of the current input paragraph, screen out the element to be replaced, and update the element to be replaced to the real doms corresponding to the current input paragraph according to the compared result after comparing the virtual doms of the current input paragraph.
In one embodiment, the insertion module 120 includes:
And the filling unit is used for filling preset characters in the cursor, enabling the cursor to be positioned in the label and enabling the label to be non-empty.
In this embodiment, in order to set the cursor in the span tag, the span tag is filled with the '\u200b' character, so that the cursor is located in the tag, wherein the '\u200b' character is a special character, and the use of the '\u200b' character can ensure that the span tag is not empty, and can not affect the visual effect.
The embodiment of the invention also provides computer equipment, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor realizes the text real-time editing method when executing the computer program.
In the embodiment, the processor is used for executing a text real-time editing method, and the method comprises the steps of positioning a cursor position of a current text input and determining a current input paragraph when an event trigger of starting text input is monitored, inserting a tag into the cursor position of the current text input and setting a cursor in the tag, receiving the input text through the tag, enabling the cursor to be kept in the tag in the text input process, and replacing elements before and after the tag according to the content of the remote editing operation when the remote editing operation of the current input paragraph is monitored.
In another embodiment of the invention, a computer-readable storage medium is provided. The computer readable storage medium may be a nonvolatile computer readable storage medium or a volatile computer readable storage medium. The computer readable storage medium stores a computer program which, when executed by a processor, causes the processor to perform the text real-time editing method as described above.
In the embodiment, the computer program is used for executing a text real-time editing method, and the method comprises the steps of positioning a cursor position of a current text input and determining a current input paragraph when an event trigger of starting text input is monitored, inserting a tag into the cursor position of the current text input and setting a cursor in the tag, receiving the input text through the tag, enabling the cursor to be kept in the tag in the text input process, and replacing elements before and after the tag according to the content of the remote editing operation when the remote editing operation of the current input paragraph is monitored.
It will be clearly understood by those skilled in the art that, for convenience and brevity of description, specific working procedures of the apparatus, device and unit described above may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein. Those of ordinary skill in the art will appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein may be embodied in electronic hardware, in computer software, or in a combination of the two, and that the elements and steps of the examples have been generally described in terms of function in the foregoing description to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus, device and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, and for example, the division of the units is merely a logical function division, there may be another division manner in actual implementation, or units having the same function may be integrated into one unit, for example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed. In addition, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices, or elements, or may be an electrical, mechanical, or other form of connection.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiment of the present invention.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units may be stored in a storage medium if implemented in the form of software functional units and sold or used as stand-alone products. Based on such understanding, the technical solution of the present invention is essentially or a part contributing to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. The storage medium includes various media capable of storing program codes, such as a usb (universal serial bus), a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk.
While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.

Claims (9)

1.一种文本实时编辑方法,其特征在于,包括:1. A real-time text editing method, characterized in that it includes: 当监听到文本输入开始的事件触发时,定位当前文本输入的光标位置,并确定当前输入段落;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 for the current input paragraph, the elements before and after the tag are replaced according to the content of the remote editing operation. This includes: when a remote editing operation is received from the server, obtaining the text input status of the paragraph corresponding to the remote editing operation; if the text input status is true, confirming that the paragraph corresponding to the remote editing operation is the current input paragraph, and replacing the elements before and after the tag according to the content of the remote editing operation; if the text input status is false, directly updating the corresponding paragraph according to the content of the remote editing operation. 2.根据权利要求1所述的文本实时编辑方法,其特征在于,还包括:2. The real-time text editing method according to claim 1, characterized in that it further 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.根据权利要求2所述的文本实时编辑方法,其特征在于,还包括:3. The real-time text editing method according to claim 2, characterized in that it further 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.根据权利要求1所述的文本实时编辑方法,其特征在于,所述根据所述远程编辑操作的内容对所述标签前后的元素进行替换,包括: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.根据权利要求4所述的文本实时编辑方法,其特征在于,所述远程段落信息为基于所述远程编辑操作生成的当前输入段落的远程html,所述本地段落信息为本地生成的当前输入段落的本地html;5. The real-time text editing method according to claim 4, wherein 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: 通过virtual-dom组件对所述远程html和本地html进行diff分析,根据diff分析结果筛选出需要替换的元素,并将当前输入段落中所述标签前后的元素进行替换。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.根据权利要求1所述的文本实时编辑方法,其特征在于,所述将光标设置于所述标签内,包括: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.一种文本实时编辑装置,其特征在于,包括:7. A real-time text editing device, characterized in that it comprises: 定位模块,用于当监听到文本输入开始的事件触发时,定位当前文本输入的光标位置,并确定当前输入段落;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.一种计算机设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1至6中任一项所述的文本实时编辑方法。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 the processor, when executing the computer program, implements the real-time text editing method as described in any one of claims 1 to 6. 9.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,所述计算机程序当被处理器执行时使所述处理器执行如权利要求1至6任一项所述的文本实时编辑方法。9. A computer-readable storage medium, characterized in that 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 as described in any one of claims 1 to 6.
CN202211364021.2A 2022-11-02 2022-11-02 Real-time text editing methods, devices, computer equipment, and storage media Active CN115543142B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211364021.2A CN115543142B (en) 2022-11-02 2022-11-02 Real-time text editing methods, devices, computer equipment, and storage media

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211364021.2A CN115543142B (en) 2022-11-02 2022-11-02 Real-time text editing methods, devices, computer equipment, and storage media

Publications (2)

Publication Number Publication Date
CN115543142A CN115543142A (en) 2022-12-30
CN115543142B true CN115543142B (en) 2026-02-10

Family

ID=84721023

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211364021.2A Active CN115543142B (en) 2022-11-02 2022-11-02 Real-time text editing methods, devices, computer equipment, and storage media

Country Status (1)

Country Link
CN (1) CN115543142B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116108814B (en) * 2023-04-13 2023-06-06 深圳复临科技有限公司 Gantt chart processing method and device, computer equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1074300A (en) * 1991-12-31 1993-07-14 国际商业机器公司 Cursor lock region
CN101952821A (en) * 2008-02-25 2011-01-19 微软公司 Editing a document using a transitory editing surface

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110795910B (en) * 2019-10-10 2023-10-17 北京字节跳动网络技术有限公司 Text information processing method, device, server and storage medium
CN112667585B (en) * 2019-11-19 2022-06-07 腾讯科技(深圳)有限公司 Synchronous management method, device and equipment for online documents
CN111913979B (en) * 2020-09-29 2021-01-12 大汉软件股份有限公司 Multi-terminal data updating conflict solution method based on block authority lock
CN113521754B (en) * 2021-08-04 2024-02-27 广州四三九九信息科技有限公司 Method for preventing conflict of configuration of multiple persons in data processing of map editor

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1074300A (en) * 1991-12-31 1993-07-14 国际商业机器公司 Cursor lock region
CN101952821A (en) * 2008-02-25 2011-01-19 微软公司 Editing a document using a transitory editing surface

Also Published As

Publication number Publication date
CN115543142A (en) 2022-12-30

Similar Documents

Publication Publication Date Title
CN106844635B (en) Method and device for editing elements in webpage
JP4344693B2 (en) System and method for browser document editing
EP1376391A2 (en) Word processor for freestyle editing of well-formed xml documents
US9043695B2 (en) Visualizing total order relation of nodes in a structured document
CN102016834A (en) Conflict resolution
CN108366058B (en) Method, device, equipment and storage medium for preventing traffic hijacking of advertisement operator
CN110633390A (en) Method and device for acquiring user behavior path
CN115543142B (en) Real-time text editing methods, devices, computer equipment, and storage media
CN107391933A (en) A kind of electronic health record quality control management device and method
CN113206869B (en) Data acquisition method and device, storage medium and electronic equipment
CN111026485B (en) Data processing method and device
CN113361525A (en) Page generation method and device based on OCR, computer equipment and storage medium
JP5961430B2 (en) CONTENT DISPLAY PROGRAM USING BIOLOGICAL INFORMATION, CONTENT DISTRIBUTION DEVICE, METHOD, AND PROGRAM
CN111291533B (en) Sentence segment to be displayed display method and device, computer equipment and storage medium
US20150234793A1 (en) Font resource management
US20110035433A1 (en) Webpage display method, computer system, and program
KR101712592B1 (en) program
JP2004086851A (en) Apparatus, method, and program for detecting significant updating of electronic document, and record medium storing the program
CN108494728B (en) Method, device, equipment and medium for creating blacklist library for preventing traffic hijacking
EP1959354A2 (en) Method and system for converting hypertext markup language web page to plain text
CN105824606B (en) Rolling input method and terminal
JP2009230258A (en) Restoration support system and program for the same
CN113722001B (en) A display theme switching method, device, wearable device and storage medium
JP5479285B2 (en) Intellectual property management system
JP4971935B2 (en) Information processing apparatus, information processing method, and program

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant