CN113836875B - Text processing method, system, device and storage medium - Google Patents

Text processing method, system, device and storage medium Download PDF

Info

Publication number
CN113836875B
CN113836875B CN202111089345.5A CN202111089345A CN113836875B CN 113836875 B CN113836875 B CN 113836875B CN 202111089345 A CN202111089345 A CN 202111089345A CN 113836875 B CN113836875 B CN 113836875B
Authority
CN
China
Prior art keywords
operation result
client
text
stack
editing
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
CN202111089345.5A
Other languages
Chinese (zh)
Other versions
CN113836875A (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.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network 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 Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202111089345.5A priority Critical patent/CN113836875B/en
Publication of CN113836875A publication Critical patent/CN113836875A/en
Application granted granted Critical
Publication of CN113836875B publication Critical patent/CN113836875B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces
    • G06F9/452Remote windowing, e.g. X-Window System, desktop virtualisation

Landscapes

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

Abstract

The present disclosure relates to a text processing method, system, apparatus, storage medium. Wherein the method comprises the following steps: executing a first editing operation on the target text on the first client through a text editor to obtain a first operation result, and distributing the first operation result to the second client; executing a second editing operation on the target text through a text editor on a second client, and acquiring a second operation result from the first stack; removing, on the second client, the second operation result from the first stack and adding the second operation result to the second stack; and executing conversion operation on the first operation result by using the association relation between the second operation result added in the second stack and the first operation result obtained through the first editing operation on the second client to obtain a third operation result.

Description

Text processing method, system, device and storage medium
Technical Field
The present disclosure relates to the field of text processing, and in particular, to a text processing method, system, apparatus, and storage medium.
Background
Currently, each time a user's input is recorded in the local history of the editor, the editor is typically employed to restore the previous input record by itself redoing and undoing the operations ctrl+z/ctrl+shift+z. Since the rich text editor Draft-js opens the local history by default, the specific operation flow is shown in fig. 1, the update of the current data must be realized through the application editing interface every time through the local or remote input, and the representation content of the latest editor is recorded every time the push operation is executed, and when the current editor needs to be withdrawn, the current editor can be taken out through the last stack and restored back.
In addition, fig. 2a, 2b, and 2c show flowcharts of steps of a local input record and remote input record generating a cancel stack process, performing a cancel process, and performing a redo process in the prior art, respectively, and it can be seen from fig. 2a to 2c that, due to the OT and built-in stack, built-in cancel stack process implemented by adopting the Json structure, when a remote user submits input data, the remote input data also enters the local cancel stack, and whether the local input data or the remote input data cannot be distinguished, so that the local cancel operation may cancel the content input by the remote user.
In view of the above problems, no effective solution has been proposed at present.
Disclosure of Invention
The embodiment of the disclosure provides a text processing method, a system, a device and a storage medium, which at least solve the technical problems that in the existing text processing method, a remote client and a local client cannot realize online editing at the same time and one party does not influence the editing of the other party when performing the redo undo.
According to an aspect of the embodiments of the present disclosure, there is provided a text processing method, including: executing a first editing operation on the target text on the first client through a text editor to obtain a first operation result, and distributing the first operation result to the second client; executing a second editing operation on the target text on the second client through the text editor, and acquiring a second operation result from the first stack, wherein the second editing operation comprises one of the following steps: undoing and redoing, wherein the second operation result is used for indicating the latest change data content of the target text corresponding to the second client; removing the second operation result from the first stack and adding the second operation result to the second stack on the second client, wherein the first stack and the second stack respectively correspond to a undo operation and a redo operation based on the operation type of the second editing operation; and executing conversion operation on the first operation result by using the association relation between the second operation result added in the second stack and the first operation result obtained through the first editing operation on the second client to obtain a third operation result.
According to another aspect of the embodiments of the present disclosure, there is also provided a text processing system including: a first client and a second client; the first client is used for executing a first editing operation on the target text through the text editor to obtain a first operation result, and distributing the first operation result to the second client; the second client is configured to perform, by using the text editor, a second editing operation on the target text, and obtain a second operation result from the first stack, where the second editing operation includes one of: undoing and redoing, wherein the second operation result is the latest change data content of the target text on the second client; removing the second operation result from the first stack and adding the second operation result to the second stack, wherein the first stack and the second stack respectively correspond to a undo operation and a redo operation based on the operation type of the second editing operation; and executing conversion operation on the first operation result by utilizing the association relation between the second operation result added in the second stack and the first operation result obtained through the first editing operation to obtain a third operation result.
According to another aspect of the embodiments of the present disclosure, there is also provided a text processing apparatus including: executing a first editing operation on the target text on the first client through a text editor to obtain a first operation result, and distributing the first operation result to the second client; executing a second editing operation on the target text on the second client through the text editor, and acquiring a second operation result from the first stack, wherein the second editing operation comprises one of the following steps: undoing and redoing, wherein the second operation result is used for indicating the latest change data content of the target text corresponding to the second client; removing the second operation result from the first stack and adding the second operation result to the second stack on the second client, wherein the first stack and the second stack respectively correspond to a undo operation and a redo operation based on the operation type of the second editing operation; and executing conversion operation on the first operation result by using the association relation between the second operation result added in the second stack and the first operation result obtained through the first editing operation on the second client to obtain a third operation result.
According to another aspect of the embodiments of the present disclosure, there is further provided a computer readable storage medium, where the computer readable storage medium includes a stored program, and when the program runs, the device on which the computer readable storage medium is located is controlled to execute any one of the text processing methods described above.
According to another aspect of the embodiments of the present disclosure, there is further provided a processor, where the processor is configured to execute a program stored in a memory, where the program executes any one of the text processing methods described above.
In the embodiment of the disclosure, a first editing operation is performed on a target text on a first client through a text editor, a first operation result is obtained, and the first operation result is distributed to a second client; executing a second editing operation on the target text on the second client through the text editor, and acquiring a second operation result from the first stack, wherein the second editing operation comprises one of the following steps: undoing and redoing, wherein the second operation result is used for indicating the latest change data content of the target text corresponding to the second client; removing the second operation result from the first stack and adding the second operation result to the second stack on the second client, wherein the first stack and the second stack respectively correspond to a undo operation and a redo operation based on the operation type of the second editing operation; and executing conversion operation on the first operation result by using the association relation between the second operation result added in the second stack and the first operation result obtained through the first editing operation on the second client to obtain a third operation result.
It is to be noted that, in the embodiment of the present disclosure, a first operation result of performing a first editing operation on a target text by a remote client (i.e., a first client) is distributed to a local client (i.e., a second client), and a second editing operation is performed on the target text at the local client, the second operation result is obtained from a first stack, and the second operation result is removed from the first stack and added to a second stack by the local client, so that the first stack and the second stack respectively correspond to a undo operation and a redo operation based on an operation type of the second editing operation; therefore, the conversion operation can be performed on the first operation result by using the association relationship between the second operation result added in the second stack and the first operation result obtained by the first editing operation on the local client, so as to obtain a third operation result.
Therefore, the technical effects that the remote client and the local client cannot simultaneously realize online editing and the other party editing is not influenced when one party executes the redo undo are achieved, so that the mutually noninterfere undo operation or the redo operation can be carried out on the target text through a text editor under the condition of the cooperation of multiple clients, and the technical problems that the existing text processing method cannot simultaneously realize online editing and the other party editing is not influenced when one party executes the redo undo are solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure, illustrate and explain the present disclosure, and together with the description serve to explain the present disclosure. In the drawings:
FIG. 1 is a flow chart of a undo and redo operation that implements multi-client collaboration in accordance with the prior art;
FIG. 2a is a flow chart of the steps of a local client and remote client revocation procedure according to the prior art;
FIG. 2b is a flow chart of steps for performing a revocation procedure with a local client and a remote client input according to the prior art;
FIG. 2c is a flow chart of steps in a prior art process for performing a redo process with local client and remote client inputs;
FIG. 3 is a flow chart of a text processing method according to an embodiment of the present disclosure;
FIG. 4 is a flowchart of steps of an alternative local and remote input record generation revocation process, in accordance with an embodiment of the present disclosure;
FIG. 5 is a flowchart of steps for an alternative local client to perform a revocation procedure with a remote client, in accordance with an embodiment of the present disclosure;
FIG. 6 is a flowchart of steps for an alternative local client to perform a redo process with a remote client in accordance with an embodiment of the present disclosure;
Fig. 7 is a schematic structural view of a text processing apparatus according to an embodiment of the present disclosure.
Detailed Description
In order that those skilled in the art will better understand the present disclosure, a technical solution in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present disclosure, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without inventive effort, based on the embodiments in this disclosure, shall fall within the scope of the present disclosure.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the foregoing figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the disclosure described herein may be capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
First, to facilitate understanding of the embodiments of the present disclosure, some terms or nouns referred to in the present disclosure will be explained below:
draft-js: is a JavaScript (JS, a programming language) framework for building a rich text editor Draft, which is a Facebook open source;
the data structure of the Draft-js is as follows: data such as currentContent, selection and the like are packaged in a data object editor state of the Draft-js, wherein currentContent describes storage of all rich texts, and selection describes data of a cursor; the currentContent data structure comprises blocks and an entitmap, wherein the blocks are data for describing each block, and each block comprises a unique key, text content, text type (customizable), data information and the like, and the key is a field corresponding to the entitmap; the eneitypap data structure is a hash structure, and keys in the eneitypap represent keys in the block.
OT (Operational Transformation): an algorithm for automatically merging multiple modifications in collaborative editing was published in 1989 at the earliest and was subsequently popular due to the large use of Google in its online collaborative product Google Wave.
Ws communication: webSocket is a protocol that HTML5 begins to provide for full duplex communication over a single transmission control protocol connection.
Json: a data exchange format, like a group, is used to store data.
In accordance with the disclosed embodiments, a method embodiment of text processing is provided, it being noted that the steps shown in the flowcharts of the figures may be performed in a computer system, such as a set of computer executable instructions, and, although a logical order is shown in the flowcharts, in some cases, the steps shown or described may be performed in an order other than that shown or described herein.
The technical scheme of the method embodiment can be executed in a mobile terminal, a computer terminal or similar computing devices. Taking the mobile terminal as an example, the mobile terminal can be a terminal device such as a smart phone (such as an Android mobile phone, an iOS mobile phone, etc.), a tablet computer, a palm computer, a mobile internet device (Mobile Internet Devices, abbreviated as MID), a PAD, etc. A mobile terminal may include one or more processors (which may include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processor (GPU), a Digital Signal Processing (DSP) chip, a Microprocessor (MCU), a programmable logic device (FPGA), a neural Network Processor (NPU), a Tensor Processor (TPU), an Artificial Intelligence (AI) type processor, etc.) and a memory for storing data. Optionally, the mobile terminal may further include a transmission device, an input/output device, and a display device for a communication function. It will be appreciated by those of ordinary skill in the art that the foregoing structural descriptions are merely illustrative and are not intended to limit the structure of the mobile terminal. For example, the mobile terminal may also include more or fewer components than the above structural description, or have a different configuration than the above structural description.
The memory may be used to store a computer program, for example, a software program of application software and a module, such as a computer program corresponding to a text processing method in an embodiment of the present disclosure, and the processor executes the computer program stored in the memory, thereby performing various functional applications and data processing, that is, implementing the above-mentioned text processing method. The memory may include high-speed random access memory, and may also include computer-readable memory, such as one or more magnetic storage devices, flash memory, or other computer-readable solid state memory. In some examples, the memory may further include memory remotely located with respect to the processor, the remote memory being connectable to the mobile terminal through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device includes a network adapter (Network Interface Controller, simply referred to as NIC) that can connect to other network devices through the base station to communicate with the internet. In one example, the transmission device may be a Radio Frequency (RF) module, which is used to communicate with the internet wirelessly. The technical scheme of the method embodiment can be applied to various communication systems, such as: global system for mobile communications (Global System of Mobile communication, abbreviated GSM), code division multiple access (Code Division Multiple Access, abbreviated CDMA) system, wideband code division multiple access (Wideband Code Division Multiple Access, abbreviated WCDMA) system, general packet radio service (General Packet Radio Service, abbreviated GPRS), long term evolution (Long Term Evolution, abbreviated LTE) system, LTE frequency division duplex (Frequency Division Duplex, abbreviated FDD) system, LTE time division duplex (Time Division Duplex, abbreviated TDD), universal mobile communication system (Universal Mobile Telecommunication System, abbreviated UMTS), worldwide interoperability for microwave access (Worldwide Interoperability for Microwave Access, abbreviated WiMAX) communication system, or 5G system, etc. Alternatively, device-to-Device (D2D) communication may be performed between a plurality of mobile terminals. Alternatively, the 5G system or 5G network is also referred to as a New Radio (NR) system or NR network.
Display devices may be, for example, touch screen type Liquid Crystal Displays (LCDs) and touch displays (also referred to as "touch screens" or "touch display screens"). The liquid crystal display may enable a user to interact with a user interface of the mobile terminal. In some embodiments, the mobile terminal has a Graphical User Interface (GUI), and the user may interact with the GUI by touching finger contacts and/or gestures on the touch-sensitive surface, where the man-machine interaction functions optionally include the following interactions: executable instructions for performing the above-described human-machine interaction functions, such as creating web pages, drawing, word processing, making electronic documents, games, video conferencing, instant messaging, sending and receiving electronic mail, talking interfaces, playing digital video, playing digital music, and/or web browsing, are configured/stored in one or more processor-executable computer program products or readable computer-readable storage media.
Fig. 3 is a flowchart of a text processing method according to an embodiment of the present disclosure, as shown in fig. 3, including the steps of:
step S102, a first editing operation is carried out on a target text on a first client through a text editor, a first operation result is obtained, and the first operation result is distributed to a second client;
Step S104, executing a second editing operation on the target text through the text editor on the second client, and acquiring a second operation result from the first stack, wherein the second editing operation comprises one of the following steps: undoing and redoing, wherein the second operation result is used for indicating the latest change data content of the target text corresponding to the second client;
step S106, on the second client, removing the second operation result from the first stack and adding the second operation result to the second stack, wherein the first stack and the second stack respectively correspond to a undo operation and a redo operation based on the operation type of the second editing operation;
and step S108, on the second client, performing conversion operation on the first operation result by using the association relation between the second operation result added in the second stack and the first operation result obtained through the first editing operation, so as to obtain a third operation result.
In the embodiment of the disclosure, a first operation result of performing a first editing operation on a target text by a remote client (i.e., a first client) is distributed to a local client (i.e., a second client), and a second editing operation is performed on the target text at the local client, the second operation result is obtained from a first stack, and the first stack and the second stack respectively correspond to a undo operation and a redo operation due to the operation types of the first and second editing operations by removing the second operation result from the first stack and adding the second operation result to the second stack at the local client; therefore, the conversion operation can be performed on the first operation result by using the association relationship between the second operation result added in the second stack and the first operation result obtained by the first editing operation on the local client, so as to obtain a third operation result.
Therefore, the purpose that the remote client and the local client cannot simultaneously realize online editing and cancel each other without interference is achieved, the technical effect that the target text can be subjected to cancel operation or redo operation without interference through a text editor under the condition of cooperation of multiple clients is achieved, and the technical problem that the existing text processing method cannot simultaneously realize online editing and one party does not influence editing of the other party when the remote client and the local client execute redo cancel is solved.
Optionally, the first client is a remote client, the second client is a local client, the text editor is a rich text editor Draft-js, and for the same target text, different user clients can perform editing operations, such as undoing operations and redoing operations, on the target text by connecting the text editors.
As an alternative embodiment, the rich text editor is a text editor that can be embedded in a browser, and the text editor obtained by seeing is different from a general text editor, and can be conveniently edited by a user by embedding the rich text editor downloaded on a network in a local website or program, for example, an article text or an information text, etc.
Optionally, the first editing operation includes one of: and (3) cancelling operation and redoing operation, wherein the first operation result is used for indicating the latest change data content of the target text corresponding to the remote client.
In an optional embodiment, taking the first client as a remote client and the second client as a local client as an example, performing a first editing operation on the target text on the remote client through a text editor to obtain a first operation result, and distributing the first operation result to the local client; and executing a second editing operation on the target text on the local client through the text editor, and acquiring a second operation result from the first stack, wherein the second operation result is used for indicating the latest change data content of the target text corresponding to the second client.
As an optional embodiment, the first stack and the second stack respectively correspond to a undo operation and a redo operation based on an operation type of the second editing operation; for example, when the second editing operation is a undo operation, the first stack corresponds to the undo operation, and the second stack corresponds to a redo operation; when the second editing operation is a redo operation, the first stack corresponds to the redo operation, and the second stack corresponds to a undo operation.
As an optional embodiment, the first stack is a redo stack, configured to store the first operation result and the second operation result, and may properly perform the conversion operation to restore to the correct local operation during the redo operation; the second stack is a undo stack, and the stored contents of the undo stack are the same as those of the redo stack, except that the operation types based on the second editing operation are transferred to each other in the two stacks.
As an optional embodiment, the association between the second operation result and the first operation result is determined using a remote operation identifier of the first operation result and a conversion operation identifier of the first stack.
Alternatively, the association relationship between the first operation result and the second operation result may be determined by marking the first operation result with a remote operation identifier and marking the first stack with a conversion operation identifier, where the second operation result is obtained from the first stack.
As an optional embodiment, by monitoring a first operation result of the local client on the target text through the text editor, or by monitoring whether a second operation result pushed to the local client by the remote client is received, determining whether the current operation on the target text is an operation of the remote client or an operation of the local client, for example, when the second operation result of the local client is removed from the undo stack and added to the redo stack, performing a conversion operation on the first operation result by the local client using an association relationship between the second operation result added in the redo stack and the first operation result of the remote client, to obtain a third operation result, it may be ensured that the current editing operation of the remote client is not revoked by the local undo operation, and similarly, when the second operation result of the local client is removed from the redo stack and added to the undo stack, the second operation result is added to the local client, and performing a conversion operation on the first operation result of the remote client by using the second operation result added in the redo stack, and performing a conversion operation on the first operation result of the remote client may not be guaranteed.
For example, multiple user clients edit at the same time, and both the remote user terminal a and the local user terminal B edit the target text at the same time, but the remote user terminal a can only redo and undo the text content input by itself, distribute the first operation result to the local client terminal B through the shared database, and cannot redo or undo the second operation result of the local client terminal B.
As an alternative embodiment, the method further comprises: and the second client sends the third operation result to the first client.
As an optional embodiment, performing a conversion operation on the first operation result by using an association relationship between the second operation result and the first operation result, to obtain the third operation result includes:
step S202, acquiring a first identifier, a second identifier, a third identifier and data to be edited in the second operation result on the second client, and acquiring text content corresponding to the first operation result;
step S204, determining, on the second client, the first identifier, the third identifier and the data to be edited in the third operation result by using the first identifier, the third identifier and the data to be edited in the second operation result, and determining, based on the second identifier in the second operation result and the text content corresponding to the first operation result, the second identifier in the third operation result.
As an alternative embodiment, the data storage structure of the text editor may include, but is not limited to: setting the maximum local storage stack length to prevent excessive memory overflow of the stack; distinguishing editing operation of a local client from editing operation of a remote client by recording the identification number of the current history record and the identification number of the next stacked history record; and, an operation conversion key required for conversion operation can be set, wherein each undo stack and redo stack corresponds to a unique conversion operation key.
As an optional embodiment, determining the second identifier in the third operation result based on the second identifier in the second operation result and the text content corresponding to the first operation result includes:
step S302, determining the display position of the data to be edited in the text content corresponding to the first operation result;
step S304, performing shift operation on the second identifier in the second operation result based on the display position, and obtaining the second identifier in the third operation result.
As an alternative embodiment, for example, the description information of the first operation result remoteOp and the second operation result localOp may be: https:// github.com/ottypes/json0 describing a set of operations such as [ { p: [ 'a',0], ld:100} ], delete 100 this element on index 0 on path a; the third operation result newop=transform (localOp, remoteOp, 'left'), and the third operation result newOp is obtained by indexing the second identifier of the second operation result through the display position in the text content corresponding to the first operation result remoteOp, for example, the current character on a is abcd, the second operation result localop= [ { p [ 'a',2], li:100} ], the converted third operation result is ab100cd, the first operation result remoteop= [ { p [ 'a',2], b } ], a100 ld, and by rolling back the local operation, there may be a problem in directly adopting the second operation result localOp, and the third operation result newop= [ { p [ 'a',1], li:100} ] may be obtained after the conversion processing.
As an alternative embodiment, the method further comprises:
step S402, a first text state and a second text state are obtained on the second client, wherein the first text state is used for describing the data content which is input by the text editor last time, and the second text state is used for describing the data content which is input by the text editor last time;
and step S404, determining the latest change data content on the second client based on the first text state and the second text state, and obtaining the second operation result.
In the embodiment of the disclosure, based on the collaborative text editing logic of the rich text editor Draft-js, each time the granularity of a single operation on the rich text editor may be obtained by calculating a text state difference value according to the latest input data content of the text editor and the data content input last time, for example, the text state difference value between text states determined by the data content of any two input operations may be determined.
As an alternative embodiment, in order to calculate the text state difference value between the latest input data content and the last input data content of the rich text editor more accurately, after waiting for the preset time period, calculating the latest input data content and the last input data content may be restarted, and the latest change data content is determined, so as to obtain the second operation result.
As an alternative embodiment, as shown in fig. 4, when receiving the input content of the remote client, a remote callback event is triggered, and the first operation result is distributed to the local client; and triggering a local callback event to execute a push operation when receiving input content of a local client, namely executing a second editing operation on the target text through the text editor on the second client, acquiring a second operation result from a first stack, removing the second operation result from the first stack on the second client, and adding the second operation result to the second stack.
As an alternative embodiment, the method further comprises:
step S502, judging whether an anti-shake function is started on the second client when the second editing operation is a cancel operation, wherein the anti-shake function is used for controlling the processing times of the cancel operation within a preset duration;
step S504, when the anti-shake function is not started on the second client, determining to remove the second operation result from the first stack, adding the second operation result to the second stack, and performing a conversion operation on the first operation result by using an association relationship between the second operation result and the first operation result to obtain the third operation result;
Step S506, when the anti-shake function is turned on the second client, the second editing operation is ignored and the anti-shake function is turned off.
As shown in fig. 4, by turning on the anti-shake function, the local computation consumption of the rich text editor can be reduced based on the anti-shake logic by controlling the number of times the undo operation is processed within a preset period of time. When the anti-shake function is not started on the second client, determining to remove the second operation result from the first stack, adding the second operation result to the second stack, and performing conversion operation on the first operation result by using the association relation between the second operation result and the first operation result to obtain the third operation result.
When the anti-shake function is started on the second client, ignoring the second editing operation, closing the anti-shake function, detecting whether the time limit of text to be submitted is reached, if so, calculating a text state difference value between the latest input data content and the last input data content of the rich text editor, and submitting the state difference value to a server.
In the embodiment of the disclosure, since the calculation operation result needs to consume a great deal of local calculation capacity, anti-shake logic is added for, for example, not inputting any more within 1 second after inputting, i.e. closing and submitting, and if inputting is still performed in the process, neglecting.
As an optional embodiment, the description information of the first operation result and the second operation result includes: a first component for determining a target position to be edited in the target text, and a second component for determining text data to be edited at the target position;
the first component includes: the first identifier is used for determining the initial position of a character string to be edited in the target text, and the second identifier is used for indexing the target position in the character string to be edited according to the initial position;
the second component comprises: the device comprises a third identifier and data to be edited, wherein the third identifier is used for determining the type of editing operation to be executed on the target position, and the data to be edited is operation data corresponding to the type of editing operation.
The above description information is schematically explained in an alternative embodiment, for example, the current character is abcd, and the input is ab1cd, and if the description information of the first operation result and the second operation result includes: the first mark 'a' in the first component part is used for determining the initial position of a character string to be edited in the target text, the second mark 2 is used for indexing the target position in the character string to be edited according to the initial position, the third mark li in the second component part is used for determining the type of editing operation to be performed at the target position, and the data 1 to be edited is operation data corresponding to the type of editing operation, namely, one data 1 to be edited is inserted at the position of index 2.
Optionally, since the input content of the local client is not immediately submitted to the server, in the embodiment of the present disclosure, there are two cases in which the revocation operation is performed: when no input content needs to be submitted, i.e. the anti-shake function is not started, the stack-pulling operation of the cancel stack needs to be executed, and the conversion operation key corresponding to the cancel stack is converted, so that the cancelled content can be obtained; the content is currently input and is not submitted to the server, at the moment, the input content does not enter the revocation stack and is not submitted to the server, and the revocation is completed only by discarding the current operation and restoring the last input content to the current state.
Optionally, as shown in fig. 5, the performing the revocation procedure specifically includes: the local client executes the revocation operation; the rich text editor responds to the withdrawal operation request, detects whether the anti-shake function is started, discards current input data and disables the anti-shake function if the anti-shake function is detected to be started, adds the withdrawal operation to the second stack, and returns a processing result to the local client; if the anti-shake function is detected not to be started, executing an interception operation, and acquiring the last stack in the first stack, wherein the anti-shake function is used for reducing the local calculation consumption of the rich text editor based on anti-shake logic; removing the last stack from the first stack, adding the last stack into the second stack, and obtaining a second operation result corresponding to the last stack; converting the second operation result corresponding to the last stack with the associated remote operation description information to obtain new operation description information; and obtaining a stack to be revoked by applying the current stack, namely determining the state information of the operation to be redone by adopting the new operation description information, and executing a state restoration operation to restore the operation to be redone to the last operation to obtain the local revocation result.
As another alternative embodiment, as shown in FIG. 6, the local client performs a redo operation; after detecting the request of the redo operation, executing the interception operation and acquiring the last stack in the second stack; removing the last stack from the second stack, adding the last stack into the first stack, and obtaining a second operation result corresponding to the last stack; converting the second operation result corresponding to the last stack with the associated remote operation description information to obtain new operation description information, wherein the second operation result can be, but is not limited to, a state difference value between the last text content of the rich text editor and the current text content; updating the new operation description information to a current stack, applying the current stack to obtain a stack to be revoked, namely determining the state information of the operation to be redone by adopting the new operation description information, and executing a state restoration operation to restore the operation to be redone to the last operation to obtain the local redone result; and after rendering the local redo result, returning a rendering result to the local client.
There is also provided, in accordance with an embodiment of the present disclosure, a text processing system including: a first client and a second client;
the first client is used for executing a first editing operation on the target text through the text editor to obtain a first operation result, and distributing the first operation result to the second client; the second client is configured to perform, by using the text editor, a second editing operation on the target text, and obtain a second operation result from the first stack, where the second editing operation includes one of: undoing and redoing, wherein the second operation result is the latest change data content of the target text on the second client; removing the second operation result from the first stack and adding the second operation result to the second stack, wherein the first stack and the second stack respectively correspond to a undo operation and a redo operation based on the operation type of the second editing operation; and executing conversion operation on the first operation result by utilizing the association relation between the second operation result added in the second stack and the first operation result obtained through the first editing operation to obtain a third operation result.
According to an embodiment of the present disclosure, there is further provided an embodiment of an apparatus for implementing the above text processing method, and fig. 7 is a schematic structural diagram of a text processing apparatus according to an embodiment of the present disclosure, as shown in fig. 7, where the above text processing apparatus includes: a first editing module 80, a second editing module 82, an operation processing module 84, a conversion processing module 86, wherein:
the first editing module 80 is configured to perform a first editing operation on the target text through the text editor on the first client, obtain a first operation result, and distribute the first operation result to the second client; a second editing module 82, configured to perform a second editing operation on the target text by using the text editor on the second client, and obtain a second operation result from the first stack, where the second editing operation includes one of: undoing and redoing, wherein the second operation result is used for indicating the latest change data content of the target text corresponding to the second client; an operation processing module 84, configured to remove the second operation result from the first stack and add the second operation result to the second stack on the second client, where the first stack and the second stack respectively correspond to a undo operation and a redo operation based on an operation type of the second editing operation; an operation processing module 86, configured to execute a conversion operation on the first operation result by using an association relationship between the second operation result added in the second stack and the first operation result obtained by the first editing operation on the second client, so as to obtain a third operation result.
It should be noted that each of the above modules may be implemented by software or hardware, for example, in the latter case, it may be implemented by: the above modules may be located in the same processor; alternatively, the various modules described above may be located in different processors in any combination.
It should be noted that, the first editing module 80, the second editing module 82, the operation processing module 84, and the conversion processing module 86 correspond to steps S102 to S108 in the method embodiment, and the foregoing modules are the same as the examples and application scenarios implemented by the corresponding steps, but are not limited to the disclosure of the foregoing method embodiment. It should be noted that the above modules may be run in a computer terminal as part of the apparatus.
It should be noted that, the optional or preferred implementation manner of this embodiment may refer to the related description in the method embodiment, which is not repeated herein.
The above-mentioned text processing device may further include a processor and a memory, where the above-mentioned first editing module 80, second editing module 82, operation processing module 84, conversion processing module 86, etc. are stored as program units, and the processor executes the above-mentioned program units stored in the memory to realize the corresponding functions.
The processor comprises a kernel, the kernel fetches corresponding program units from the memory, and one or more of the kernels can be arranged. The memory may include non-volatile memory in a computer-readable medium, random Access Memory (RAM) and/or computer-readable memory, such as read-only memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
According to an embodiment of the present application, there is also provided a computer-readable storage medium embodiment. Optionally, in this embodiment, the computer readable storage medium includes a stored program, where the program is executed to control a device in which the computer readable storage medium is located to execute any one of the text processing methods.
Alternatively, in this embodiment, the computer readable storage medium may be located in any one of the computer terminals in the computer terminal group in the computer network, or in any one of the mobile terminals in the mobile terminal group, where the computer readable storage medium includes a stored program.
Optionally, the computer readable storage medium is controlled to perform the following functions when the program is run: executing a first editing operation on the target text on the first client through a text editor to obtain a first operation result, and distributing the first operation result to the second client; executing a second editing operation on the target text on the second client through the text editor, and acquiring a second operation result from the first stack, wherein the second editing operation comprises one of the following steps: undoing and redoing, wherein the second operation result is used for indicating the latest change data content of the target text corresponding to the second client; removing the second operation result from the first stack and adding the second operation result to the second stack on the second client, wherein the first stack and the second stack respectively correspond to a undo operation and a redo operation based on the operation type of the second editing operation; and executing conversion operation on the first operation result by using the association relation between the second operation result added in the second stack and the first operation result obtained through the first editing operation on the second client to obtain a third operation result.
Optionally, the computer readable storage medium is controlled to perform the following functions when the program is run: when the second editing operation is a undo operation, the first stack corresponds to the undo operation, and the second stack corresponds to a redo operation; when the second editing operation is a redo operation, the first stack corresponds to the redo operation, and the second stack corresponds to a undo operation.
Optionally, the computer readable storage medium is controlled to perform the following functions when the program is run: and the second client sends the third operation result to the first client.
Optionally, the computer readable storage medium is controlled to perform the following functions when the program is run: acquiring a first identifier, a second identifier, a third identifier and data to be edited in the second operation result on the second client, and acquiring text content corresponding to the first operation result; and determining the first identifier, the third identifier and the data to be edited in the third operation result by using the first identifier, the third identifier and the data to be edited in the second operation result on the second client, and determining the second identifier in the third operation result based on the second identifier in the second operation result and the text content corresponding to the first operation result.
Optionally, the computer readable storage medium is controlled to perform the following functions when the program is run: determining a display position of the data to be edited in the text content corresponding to the first operation result; and performing shift operation on the second identifier in the second operation result based on the display position to obtain the second identifier in the third operation result.
Optionally, the computer readable storage medium is controlled to perform the following functions when the program is run: acquiring a first text state and a second text state on the second client, wherein the first text state is used for describing the data content which is input by the text editor last time, and the second text state is used for describing the data content which is input by the text editor last time; and determining the latest change data content on the second client based on the first text state and the second text state to obtain the second operation result.
Optionally, the computer readable storage medium is controlled to perform the following functions when the program is run: when the second editing operation is a cancel operation, judging whether an anti-shake function is started on the second client, wherein the anti-shake function is used for controlling the processing times of the cancel operation within a preset duration; when the anti-shake function is not started on the second client, determining to remove the second operation result from the first stack, adding the second operation result to the second stack, and performing conversion operation on the first operation result by using the association relation between the second operation result and the first operation result to obtain the third operation result; and when the anti-shake function is started on the second client, ignoring the second editing operation and closing the anti-shake function.
According to an embodiment of the present application, there is also provided a processor embodiment. Optionally, in this embodiment, the processor is configured to run a program, where any one of the text processing methods is executed when the program runs.
The application also provides a computer program product adapted to perform, when executed on a data processing device, a program initialized with the method steps of: executing a first editing operation on the target text on the first client through a text editor to obtain a first operation result, and distributing the first operation result to the second client; executing a second editing operation on the target text on the second client through the text editor, and acquiring a second operation result from the first stack, wherein the second editing operation comprises one of the following steps: undoing and redoing, wherein the second operation result is used for indicating the latest change data content of the target text corresponding to the second client; removing the second operation result from the first stack and adding the second operation result to the second stack on the second client, wherein the first stack and the second stack respectively correspond to a undo operation and a redo operation based on the operation type of the second editing operation; and executing conversion operation on the first operation result by using the association relation between the second operation result added in the second stack and the first operation result obtained through the first editing operation on the second client to obtain a third operation result.
The foregoing embodiment numbers of the present disclosure are merely for description and do not represent advantages or disadvantages of the embodiments.
In the foregoing embodiments of the present disclosure, the descriptions of the various embodiments are emphasized, and for a portion of this disclosure that is not described in detail in this embodiment, reference is made to the related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed technology may be implemented in other manners. The above-described embodiments of the apparatus are merely exemplary, and the division of the units may be a logic function division, and there may be another division manner when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interfaces, units or modules, or may be in electrical or other forms.
The units described above as separate components may or may not be physically separate, and components shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present disclosure 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 described above, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present disclosure may be embodied in essence or a part contributing to the prior art or all or part of the technical solution in the form of a software product stored in a computer readable storage medium, including several instructions to cause 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 above-described method of the various embodiments of the present disclosure. And the aforementioned computer-readable storage medium includes: a U-disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely a preferred embodiment of the present disclosure, and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present disclosure, which are intended to be comprehended within the scope of the present disclosure.

Claims (10)

1. A text processing method, comprising:
executing a first editing operation on a target text on a first client through a text editor to obtain a first operation result, and distributing the first operation result to a second client, wherein the first client is a remote client;
performing a second editing operation on the target text on the second client through the text editor, and acquiring a second operation result from the first stack, wherein the second editing operation comprises one of the following steps: undoing and redoing operations, wherein the second operation result is used for indicating the latest change data content of the target text corresponding to the second client;
removing, on the second client, the second operation result from the first stack and adding the second operation result to a second stack, wherein when the second editing operation is a undo operation, the first stack corresponds to a undo operation and the second stack corresponds to a redo operation; when the second editing operation is a redo operation, the first stack corresponds to a redo operation, and the second stack corresponds to a undo operation;
And on the second client, performing a conversion operation on the first operation result and the second operation result by using the association relation between the second operation result added in the second stack and the first operation result obtained through the first editing operation to obtain a third operation result, wherein the association relation between the second operation result and the first operation result is determined by using a remote operation identifier of the first operation result and a conversion operation identifier of the first stack, and the conversion operation is used for determining a target position to be edited in the target text and text data to be edited in the target position.
2. The method according to claim 1, wherein the method further comprises:
and the second client sends the third operation result to the first client.
3. The method of claim 1, wherein the description information of the first operation result and the second operation result includes: a first component for determining a target position to be edited in the target text and a second component for determining text data to be edited at the target position;
The first component comprises: the first identifier is used for determining the starting position of a character string to be edited in the target text, and the second identifier is used for indexing the target position in the character string to be edited according to the starting position;
the second component comprises: the system comprises a third identifier and data to be edited, wherein the third identifier is used for determining the type of editing operation to be executed on the target position, and the data to be edited is operation data corresponding to the type of editing operation.
4. The method of claim 3, wherein performing a conversion operation on the first operation result using an association between the second operation result and the first operation result, the obtaining the third operation result comprises:
acquiring a first identifier, a second identifier, a third identifier and data to be edited in the second operation result on the second client, and acquiring text content corresponding to the first operation result;
and determining the first identifier, the third identifier and the data to be edited in the third operation result by using the first identifier, the third identifier and the data to be edited in the second operation result on the second client, and determining the second identifier in the third operation result based on the second identifier in the second operation result and the text content corresponding to the first operation result.
5. The method of claim 4, wherein determining the second identifier in the third operation result based on the second identifier in the second operation result and the text content corresponding to the first operation result comprises:
determining the display position of the data to be edited in the text content corresponding to the first operation result;
and performing shift operation on the second identifier in the second operation result based on the display position to obtain the second identifier in the third operation result.
6. The method according to claim 1, wherein the method further comprises:
acquiring a first text state and a second text state on the second client, wherein the first text state is used for describing data content which is input through the text editor last time, and the second text state is used for describing data content which is input through the text editor last time;
and determining the latest change data content on the second client based on the first text state and the second text state to obtain the second operation result.
7. The method according to claim 1, wherein the method further comprises:
When the second editing operation is a cancel operation, judging whether an anti-shake function is started on the second client side, wherein the anti-shake function is used for controlling the processing times of the cancel operation within a preset duration;
when the anti-shake function is not started on the second client, determining to remove the second operation result from the first stack, adding the second operation result to the second stack, and performing conversion operation on the first operation result and the second operation result by using the association relation between the second operation result and the first operation result to obtain the third operation result;
and when the anti-shake function is started on the second client, ignoring the second editing operation and closing the anti-shake function.
8. A text processing system, comprising: a first client and a second client;
the first client is used for executing a first editing operation on the target text through the text editor to obtain a first operation result and distributing the first operation result to the second client, wherein the first client is a remote client;
the second client is configured to perform a second editing operation on the target text through the text editor, and obtain a second operation result from the first stack, where the second editing operation includes one of: undoing and redoing operations, wherein the second operation result is the latest change data content of the target text on the second client; removing the second operation result from the first stack and adding the second operation result to the second stack, wherein when the second editing operation is a undo operation, the first stack corresponds to the undo operation and the second stack corresponds to a redo operation; when the second editing operation is a redo operation, the first stack corresponds to a redo operation, and the second stack corresponds to a undo operation; and executing conversion operation on the first operation result and the second operation result by utilizing the association relation between the second operation result added in the second stack and the first operation result obtained through the first editing operation to obtain a third operation result, wherein the association relation between the second operation result and the first operation result is determined by utilizing a remote operation identifier of the first operation result and a conversion operation identifier of the first stack, and the conversion operation is used for determining a target position to be edited in the target text and text data to be edited in the target position.
9. A text processing apparatus, comprising:
the first editing module is used for executing first editing operation on the target text through the text editor on the first client to obtain a first operation result and distributing the first operation result to the second client, wherein the first client is a remote client;
a second editing module, configured to perform a second editing operation on the target text by using the text editor on the second client, and obtain a second operation result from the first stack, where the second editing operation includes one of: undoing and redoing operations, wherein the second operation result is used for indicating the latest change data content of the target text corresponding to the second client;
an operation processing module, configured to remove, on the second client, the second operation result from the first stack and add the second operation result to a second stack, where, when the second editing operation is a undo operation, the first stack corresponds to the undo operation and the second stack corresponds to a redo operation; when the second editing operation is a redo operation, the first stack corresponds to a redo operation, and the second stack corresponds to a undo operation;
The conversion processing module is configured to execute, on the second client, a conversion operation on the first operation result and the second operation result by using an association relationship between the second operation result added in the second stack and the first operation result obtained by the first editing operation, to obtain a third operation result, where the association relationship between the second operation result and the first operation result is determined by using a remote operation identifier of the first operation result and a conversion operation identifier of the first stack, and the conversion operation is used to determine a target position to be edited in the target text and text data to be edited in the target position.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium comprises a stored program, wherein the program, when run, controls a device in which the computer-readable storage medium is located to perform the text processing method of any one of claims 1 to 7.
CN202111089345.5A 2021-09-16 2021-09-16 Text processing method, system, device and storage medium Active CN113836875B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111089345.5A CN113836875B (en) 2021-09-16 2021-09-16 Text processing method, system, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111089345.5A CN113836875B (en) 2021-09-16 2021-09-16 Text processing method, system, device and storage medium

Publications (2)

Publication Number Publication Date
CN113836875A CN113836875A (en) 2021-12-24
CN113836875B true CN113836875B (en) 2023-08-22

Family

ID=78959668

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111089345.5A Active CN113836875B (en) 2021-09-16 2021-09-16 Text processing method, system, device and storage medium

Country Status (1)

Country Link
CN (1) CN113836875B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5983242A (en) * 1997-07-01 1999-11-09 Microsoft Corporation Method and system for preserving document integrity
CN105653121A (en) * 2015-12-22 2016-06-08 山东大学 Method for realizing Undo/Redo in text edition on the basis of android system
CN112987915A (en) * 2021-02-04 2021-06-18 复旦大学 AST-based method applied to VR conference and whiteboard editing task

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7823060B2 (en) * 2002-06-07 2010-10-26 Microsoft Corporation Undo/redo architecture across multiple files
US7707191B2 (en) * 2007-01-18 2010-04-27 Microsoft Corporation Synchronizing undo/redo operations between different document views
US8209603B2 (en) * 2009-04-29 2012-06-26 Microsoft Corporation Maintaining undo and redo capability across metadata merges
US20110107246A1 (en) * 2009-11-03 2011-05-05 Schlumberger Technology Corporation Undo/redo operations for multi-object data
US9208137B2 (en) * 2010-08-19 2015-12-08 Cadence Design Systems, Inc. Method to preview an undo/redo list

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5983242A (en) * 1997-07-01 1999-11-09 Microsoft Corporation Method and system for preserving document integrity
CN105653121A (en) * 2015-12-22 2016-06-08 山东大学 Method for realizing Undo/Redo in text edition on the basis of android system
CN112987915A (en) * 2021-02-04 2021-06-18 复旦大学 AST-based method applied to VR conference and whiteboard editing task

Also Published As

Publication number Publication date
CN113836875A (en) 2021-12-24

Similar Documents

Publication Publication Date Title
US11907642B2 (en) Enhanced links in curation and collaboration applications
US10455014B2 (en) Method and apparatus for synchronizing content
CN106649446B (en) Information pushing method and device
WO2017032128A1 (en) Terminal unlocking method and terminal
EP3286665B1 (en) Rich attachment regeneration
CN110875871A (en) Management method of instant messaging application and electronic equipment
WO2018148926A1 (en) Card-based information management method and system
EP3408753B1 (en) Activity notification system
CN105446591A (en) Message reminding method and system and intelligent terminal
EP3506599B1 (en) Method for synchronizing contact information, apparatus and medium
WO2016154159A1 (en) Providing interactive preview of content within communication
CN110865834B (en) Application program interface updating method and device, readable storage medium and terminal equipment
CN108092872A (en) The means of communication and device
CN111625313A (en) Resource processing progress display method and device, electronic equipment and storage medium
CN107508969A (en) A kind of information processing method, device, computer installation and computer-readable recording medium
CN106953852A (en) Register method, device and the terminal device of radio receiver
CN111641554B (en) Message processing method and device and computer readable storage medium
CN113836875B (en) Text processing method, system, device and storage medium
CN105512945A (en) Social network interaction information processing method and device
EP2916529A1 (en) Method and device for accessing historical interface and mobile terminal
US11662886B2 (en) System and method for directly sending messages with minimal user input
US20150052451A1 (en) Real time text message system
CN113364915B (en) Information display method and device and electronic equipment
CN109213955B (en) Data processing method and related equipment
WO2017143931A1 (en) Method and apparatus for identifying smart card, method and apparatus for processing smart card identification data, and device

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