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

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

Info

Publication number
CN113836875A
CN113836875A CN202111089345.5A CN202111089345A CN113836875A CN 113836875 A CN113836875 A CN 113836875A CN 202111089345 A CN202111089345 A CN 202111089345A CN 113836875 A CN113836875 A CN 113836875A
Authority
CN
China
Prior art keywords
operation result
client
stack
text
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.)
Granted
Application number
CN202111089345.5A
Other languages
Chinese (zh)
Other versions
CN113836875B (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

Images

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

Abstract

The disclosure relates to a text processing method, system, device and storage medium. Wherein, the method comprises the following steps: 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; 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; on the second client, removing the second operation result from the first stack and adding the second operation result to the second stack; and on the second client, performing conversion operation on the first operation result by utilizing the incidence 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.

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 method, a system, an apparatus, and a storage medium for text processing.
Background
Currently, every time the input of the user is recorded in the local history of the editor, the editor is generally adopted to redo and undo the previous input record through the operations of ctrl + z/ctrl + shift + z. Since the rich text editor Draft-js opens the local history by default, the specific operation flow is as shown in fig. 1, each time through local or remote input, the current data must be updated through the application program editing interface, and each time a stack pushing operation is performed, the representation content of the latest editor is recorded, and when the representation content needs to be undone, the representation content can be fetched and restored back through the last stack.
In addition, fig. 2a, fig. 2b, and fig. 2c respectively show flowcharts of steps of a process of generating a stack undo, a process of executing a undo, and a process of executing a redo for a local input record and a remote input record in the prior art, and as can be seen from fig. 2a to fig. 2c, because the processing of OT, built-in stack entering, and built-in undo stack implemented by using the Json structure is adopted, after a remote user submits input data, the remote input data also enters the local undo stack, and it is impossible to distinguish whether the local input data or the remote input data, so that the content input by the remote user may be undone by a local undo operation.
In view of the above problems, no effective solution has been proposed.
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 the existing text processing method can not realize online editing at the same time by a remote client and a local client and that editing of one party is not influenced when the other party executes redo revocation.
According to an aspect of an embodiment of the present disclosure, there is provided a text processing method including: 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; 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 includes one of: undo operation and redo operation, where the second operation result is used to indicate the latest changed 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 a second stack on the second client, wherein the first stack and the second stack respectively correspond to an undo operation and a redo operation based on the operation type of the second editing operation; and on the second client, performing conversion operation 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 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 execute 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: undo operation and redo operation, wherein the second operation result is the latest changed 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 a second stack, wherein the first stack and the second stack respectively correspond to an 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 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.
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 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; 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 includes one of: undo operation and redo operation, where the second operation result is used to indicate the latest changed 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 a second stack on the second client, wherein the first stack and the second stack respectively correspond to an undo operation and a redo operation based on the operation type of the second editing operation; and on the second client, performing conversion operation 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 to obtain a third operation result.
According to another aspect of the embodiments of the present disclosure, there is also provided a computer-readable storage medium, where the computer-readable storage medium includes a stored program, and when the program runs, the apparatus where the computer-readable storage medium is located is controlled to execute any one of the text processing methods.
According to another aspect of the embodiments of the present disclosure, there is also provided a processor, 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 executed on a target text through a text editor on a first client to obtain a first operation result, and the first operation result is distributed to a second client; 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 includes one of: undo operation and redo operation, where the second operation result is used to indicate the latest changed 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 a second stack on the second client, wherein the first stack and the second stack respectively correspond to an undo operation and a redo operation based on the operation type of the second editing operation; and on the second client, performing conversion operation 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 to obtain a third operation result.
It is easily 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, a second operation result is obtained from a first stack, and by removing the second operation result from the first stack and adding the second operation result to a second stack at the local client, since the first stack and the second stack correspond to an undo operation and a redo operation, respectively, based on an operation type of the second editing operation; therefore, a conversion operation may 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 purposes that the remote client and the local client cannot simultaneously realize online editing and one party does not influence the editing of the other party when executing redo undo are achieved, the technical effects that the target text can be subjected to non-interfering undo operation or redo operation through the text editor under the condition of cooperation of multiple clients are achieved, and the technical problems that the remote client and the local client cannot simultaneously realize online editing and one party does not influence the editing of the other party when executing redo undo in the conventional text processing method are solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the disclosure and together with the description serve to explain the disclosure and not to limit the disclosure. In the drawings:
FIG. 1 is a flow diagram of an operation for implementing undo and redo of 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 process, according to the prior art;
FIG. 2b is a flow chart of steps for a local client to remote client input to perform a revocation process in accordance with the prior art;
FIG. 2c is a flowchart illustrating steps of a prior art redo process performed by local client and remote client input;
FIG. 3 is a flow diagram of a method of text processing according to an embodiment of the present disclosure;
FIG. 4 is a flowchart illustrating steps in an alternative local and remote input record generation revocation process, in accordance with embodiments of the present disclosure;
FIG. 5 is a flowchart illustrating steps of an optional local client and remote client performing a revocation procedure, according to an embodiment of the present disclosure;
FIG. 6 is a flowchart illustrating steps for an optional redo process performed by the local client and the remote client in accordance with an embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of a text processing apparatus according to an embodiment of the present disclosure.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those skilled in the art, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only some embodiments of the present disclosure, not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments disclosed herein without making any creative effort, shall fall within the protection 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 above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise 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, in order 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: a JavaScript (JS, a programming language) framework for building a rich text editor Draft that is a Facebook open source;
the data structure of Draft-js is as follows: data such as currentContent, selection and the like are encapsulated in a data object EditorState of Draft-js, wherein the currentContent describes storage of all rich texts, and the selection describes data of a cursor; the currentContent data structure comprises blocks and entityMap, wherein the blocks are data for describing each block, each block comprises a unique key, text content, text type (can be defined by user), data information and the like, and the key is a field corresponding to the entityMap; the eneityMap data structure is a hash structure, and the key in the eneityMap represents the key in the block.
Ot (operational transformation): an algorithm for automatically merging multiple modifications in collaborative editing was first published in 1989 and was subsequently popular for the massive use of Google in its online collaborative product, Google Wave.
And Ws communication: WebSocket is a protocol originally provided by HTML5 for full duplex communication over a single tcp connection.
Json: a data exchange format, as with groups, for storing data.
In accordance with an embodiment of the present disclosure, there is provided a method embodiment of text processing, it being noted that the steps illustrated in the flowchart of the figure may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in an order different than here.
The technical scheme of the method embodiment can be executed in a mobile terminal, a computer terminal or a similar arithmetic device. Taking the example of the Mobile terminal running on the Mobile terminal, the Mobile terminal may be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a Mobile Internet device (MID for short), a PAD, and the like. The mobile terminal may include one or more processors (which may include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (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 for a communication function, an input/output device, and a display device. It will be understood by those skilled in the art that the foregoing structural description is only illustrative and not restrictive of the structure of the mobile terminal. For example, the mobile terminal may also include more or fewer components than described above, or have a different configuration than described above.
The memory may be used to store a computer program, for example, a software program and a module of application software, such as a computer program corresponding to the text processing method in the embodiments of the present disclosure, and the processor executes various functional applications and data processing by running the computer program stored in the memory, that is, implements the text processing method described above. 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 located remotely from the processor, and these remote memories may be connected 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 to receive or transmit 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 (NIC) that can be connected to other Network devices through a base station to communicate with the internet. In one example, the transmission device may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner. The technical scheme of the embodiment of the method can be applied to various communication systems, such as: a Global System for Mobile communications (GSM) System, a Code Division Multiple Access (CDMA) System, a Wideband Code Division Multiple Access (WCDMA) System, a General Packet Radio Service (GPRS), a Long Term Evolution (Long Term Evolution, LTE) System, a Frequency Division Duplex (FDD) System, a Time Division Duplex (TDD), a Universal Mobile Telecommunications System (UMTS), a Worldwide Interoperability for Microwave Access (WiMAX) communication System, or a 5G System. Optionally, Device-to-Device (D2D for short) communication may be performed between a plurality of mobile terminals. Alternatively, the 5G system or the 5G network is also referred to as a New Radio (NR) system or an NR network.
The display device may be, for example, a touch screen type Liquid Crystal Display (LCD) and a touch display (also referred to as a "touch screen" or "touch display screen"). 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) with which a user can interact by touching finger contacts and/or gestures on a touch-sensitive surface, where the human-machine interaction function optionally includes the following interactions: executable instructions for creating web pages, drawing, word processing, making electronic documents, games, video conferencing, instant messaging, emailing, call interfacing, playing digital video, playing digital music, and/or web browsing, etc., for performing the above-described human-computer interaction functions, are configured/stored in one or more processor-executable computer program products or readable computer-readable storage media.
Fig. 3 is a flow chart of a text processing method according to an embodiment of the present disclosure, as shown in fig. 3, the method including the steps of:
step S102, a first editing operation is executed on a target text on a first client through a text editor to obtain a first operation result, 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 obtaining a second operation result from the first stack, where the second editing operation includes one of: undo operation and redo operation, where the second operation result is used to indicate the latest changed 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 a second stack, where the first stack and the second stack respectively correspond to an undo operation and a redo operation based on the operation type of the second editing operation;
step S108, on the second client, performing a conversion operation 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, so as to obtain a third operation result.
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, a second operation result is obtained from a first stack, and the second operation result is added to a second stack by removing the second operation result from the first stack at the local client, because the first stack and the second stack correspond to a undo operation and a redo operation, respectively, based on an operation type of the second editing operation; therefore, a conversion operation may 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 purposes that the remote client and the local client cannot simultaneously realize online editing and cancel mutual noninterference are achieved, the technical effect that the target text can be subjected to noninterference cancel operation or redo operation through the text editor under the condition of cooperation of multiple clients is achieved, and the technical problems that the remote client and the local client cannot simultaneously realize online editing and one party does not influence the other party when the other party performs redo cancel in the conventional text processing method are 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 may perform editing operations, such as undo operation and redo operation, 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, so-called what-you-get, and unlike a general text editor, by embedding the rich text editor in a local website or program downloaded over a network, a user can edit text, such as article text or information text, conveniently.
Optionally, the first editing operation includes one of: and canceling operation and redoing operation, wherein the first operation result is used for indicating the latest changed 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, a first editing operation is performed on a target text on the remote client through a text editor to obtain a first operation result, and the first operation result is distributed to the local client; and executing a second editing operation on the target text through the text editor on the local client, and acquiring a second operation result from the first stack, where the second operation result is used to indicate the latest changed data content of the target text corresponding to the second client.
As an alternative embodiment, the first stack and the second stack respectively correspond to an undo operation and a redo operation based on the operation type of the second editing operation; for example, when the second editing operation is a undo operation, the first stack corresponds to an 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 an undo operation.
As an alternative embodiment, the first stack is a redo stack, and is used for storing the first operation result and the second operation result, and when the redo operation is performed, the conversion operation can be properly executed to restore to a correct local operation; the second stack is an undo stack, and the contents of the undo stack and the redo stack are the same, but the operation type based on the second editing operation is transferred between the two stacks.
As an alternative embodiment, the association relationship between the second operation result and the first operation result is determined by using the remote operation identifier of the first operation result and the conversion operation identifier of the first stack.
Optionally, by marking the first operation result with the remote operation identifier and marking the first stack with the conversion operation identifier, and the second operation result is obtained from the first stack, the association relationship between the first operation result and the second operation result may be determined.
As an optional embodiment, it is determined whether the current operation on the target text is the operation of the remote client or the operation of the local client by monitoring a first operation result of the local client on the target text through the text editor or monitoring whether a second operation result pushed by the remote client to the local client is received, for example, when the second operation result of the local client is removed from the undo stack, the second operation result is added to the redo stack, and then the local client performs a conversion operation on the first operation result by using an association relationship between the second operation result added to the redo stack and the first operation result of the remote client to obtain a third operation result, which can ensure that the local undo operation does not undo the current editing operation of the remote client And stacking, and performing conversion operation on the first operation result by the local client by using the association relationship between the second operation result added in the revocation stack and the first operation result of the remote client to obtain a third operation result, so that the local redo operation can be prevented from being affected by the current editing operation of the remote client.
For example, a plurality of user clients edit simultaneously, and both the remote user a and the local user B edit the target text at the same time, but the remote user a can only redo and undo the text content input by itself, and the first operation result is distributed to the local client B through the shared database, and the redo operation or undo operation cannot be performed on the second operation result of the local client B.
As an alternative embodiment, the method further includes: and the second client sends the third operation result to the first client.
As an alternative embodiment, performing a conversion operation on the first operation result by using the association relationship between the second operation result and the first operation result, and obtaining the third operation result includes:
step S202, obtaining a first identifier, a second identifier, a third identifier and data to be edited in the second operation result on the second client, and obtaining 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, on the basis of 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 the editing operation of a local client side from the editing operation of a remote client side by recording the identity identification number of the current historical record and the identity identification number of the next pushed historical record; moreover, an operation conversion key required by conversion operation can be set, wherein each of the undo stack and the redo stack corresponds to a unique conversion operation key.
As an alternative 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 a 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.
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, for describing a set of operations, such as [ { p: [ 'a', 0], ld:100} ], at index 0 on path a, delete 100 this element; the third operation result newOp is obtained by shifting 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 character on the current a is abcd, the second operation result localOp [ { p: [ 'a', 2], li:100} ], the third operation result obtained by conversion is ab100cd, the first operation result remoteOp [ { p: [ 'a', 2], ld: b } ], a100cd, and the second operation result localOp is directly adopted by rolling back the local operation, which may cause a problem, and the third operation result newOp [: [ { p: [ 'a', 1} ] may be obtained after the conversion processing.
As an alternative embodiment, the method further includes:
step S402, obtaining a first text state and a second text state on the second client, wherein the first text state is used for describing the latest input data content through the text editor, and the second text state is used for describing the last input data content through the text editor;
step S404, determining the latest changed data content based on the first text status and the second text status on the second client, and obtaining the second operation result.
In the embodiment of the present disclosure, based on the collaborative text editing logic of the rich text editor Draft-js, the granularity of a single operation on the rich text editor each time may be obtained by calculating a text state difference value according to the latest input data content and the last input data content of the text editor, for example, the latest change data content may be determined by calculating a text state difference value between text states determined by data contents of any two input operations.
As an alternative embodiment, in order to more accurately calculate a text state difference value between the latest input data content and the last input data content of the rich text editor, after waiting for a preset time period, calculation of the latest input data content and the last input data content may be started again, and the latest changed data content may be determined to obtain the second operation result.
As an alternative embodiment, as shown in fig. 4, when receiving input content of a remote client, triggering a remote callback event, and distributing the first operation result to a local client; when receiving the input content of the local client, triggering a local callback event to execute a stack pushing operation, namely executing a second editing operation on the target text on the second client through the text editor, acquiring a second operation result from the first stack, removing the second operation result from the first stack and adding the second operation result to the second stack on the second client.
As an alternative embodiment, the method further includes:
step S502, when the second editing operation is a undo operation, determining 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 undo operation within a preset time length;
step S504, when the anti-shake function is not activated on the second client, determining to remove the second operation result from the first stack, add the second operation result to the second stack, and perform a conversion operation on the first operation result by using the 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 activated on the second client, ignoring the second editing operation and deactivating the anti-shake function.
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 processing times of the undo operation within a preset time period. 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 the association relationship 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, closing the anti-shake function, detecting whether the time limit for text submission 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 the server.
In the disclosed embodiment, since the result of the calculation operation needs to consume a large amount of local calculation power, anti-shake logic is added for, for example, no longer inputting within 1 second after inputting, i.e., turning off and submitting, and ignoring if inputting is still in process.
As an alternative 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: a first identifier and a second identifier, wherein the first identifier is used for determining a 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 includes: the third identifier is used for determining an editing operation type to be executed at the target position, and the data to be edited is operation data corresponding to the editing operation type.
As follows, the above description information is schematically explained in an alternative embodiment, for example, the current character is abcd, and the input is ab1cd, if the description information of the first operation result and the second operation result includes: [ { p: [ 'a', 2], li:1}, i.e. a first component p: [ 'a', 2] and a second component li:1, wherein the first identifier 'a' in the first component is used for determining a start position of a character string to be edited in the target text, the second identifier 2 is used for indexing the target position in the character string to be edited according to the start position, the third identifier li in the second component is used for determining an editing operation type to be executed at the target position, and the data 1 to be edited is operation data corresponding to the editing operation type, i.e. a data 1 to be edited is inserted at the position of the 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, the following two cases exist to perform the revocation operation: when no input content needs to be submitted, namely the anti-jitter function is not started, stack popping operation of a revocation stack needs to be executed, and a conversion operation key corresponding to the revocation stack is converted, so that revoked content can be obtained; the content is currently input, and the content is not submitted to the server, at this time, 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 executing the revocation process specifically includes: the local client executes revocation operation; responding to a cancel operation request by the rich text editor, detecting whether an anti-jitter function is started, if the anti-jitter function is detected to be started, discarding current input data and stopping the anti-jitter function, adding the cancel operation to the second stack, and returning a processing result to a local client; if the anti-shaking function is detected not to be started, executing an interception operation, and acquiring the last stack in the first stack, wherein the anti-shaking function is used for reducing the local calculation consumption of the rich text editor based on anti-shaking logic; removing the last stack from the first stack, adding the last stack to the second stack, and obtaining a second operation result corresponding to the last stack; converting a second operation result corresponding to the last stack and the associated remote operation description information to obtain new operation description information; and obtaining a stack needing to be cancelled by applying the current stack, namely determining the state information of the operation to be redone by adopting the new operation description information, executing the state restoring operation to restore the operation to be redone to the last operation, and obtaining the local cancelling result.
As another alternative, as shown in fig. 6, the local client performs the redo operation; after the redo operation request is detected, executing interception operation and acquiring the last stack in the second stack; removing the last stack from the second stack, adding the last stack to the first stack, and obtaining a second operation result corresponding to the last stack; converting a second operation result corresponding to the last stack and associated remote operation description information to obtain new operation description information, wherein the second operation result may be, but is not limited to, a state difference value between a last text content of the rich text editor and the current text content; updating the new operation description information to a current stack, and obtaining a stack needing to be cancelled by applying the current stack, namely determining state information of the operation to be redone by adopting the new operation description information, and executing a state reduction operation to reduce the operation to be redone into the last operation to obtain the local redo result; and after the local redo result is rendered, returning the rendering result to the local client.
According to an embodiment 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 execute 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: undo operation and redo operation, wherein the second operation result is the latest changed 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 a second stack, wherein the first stack and the second stack respectively correspond to an 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 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.
According to an embodiment of the present disclosure, an apparatus embodiment for implementing the text processing method is further provided, and fig. 7 is a schematic structural diagram of a text processing apparatus according to an embodiment of the present disclosure, and as shown in fig. 7, the text processing apparatus includes: a first editing module 80, a second editing module 82, an operation processing module 84, and a conversion processing module 86, wherein:
a first editing module 80, configured to perform a first editing operation on a target text through a text editor on a first client to obtain a first operation result, and distribute the first operation result to a second client; a second editing module 82, configured to perform a second editing operation on the target text through 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: undo operation and redo operation, where the second operation result is used to indicate the latest changed 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 a second stack on the second client, where the first stack and the second stack respectively correspond to an undo operation and a redo operation based on an operation type of the second editing operation; an operation processing module 86, configured to execute, on the second client, 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 through the first editing operation, so as to obtain a third operation result.
It should be noted that the above modules may be implemented by software or hardware, for example, for the latter, the following may be implemented: the modules can be located in the same processor; alternatively, the modules 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 modules are the same as the corresponding steps in the implementation example and the application scenario, but are not limited to the disclosure in the method embodiment. It should be noted that the modules described above may be implemented in a computer terminal as part of an apparatus.
It should be noted that, for alternative or preferred embodiments of the present embodiment, reference may be made to the related description in the method embodiment, and details are not described herein again.
The text processing device may further include a processor and a memory, and the first editing module 80, the second editing module 82, the operation processing module 84, the conversion processing module 86, and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions.
The processor comprises a kernel, and the kernel calls a corresponding program unit from the memory, wherein one or more than one kernel can be arranged. The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or a 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 when the program runs, the apparatus where the computer-readable storage medium is located is controlled to execute any one of the text processing methods.
Optionally, in this embodiment, the computer-readable storage medium may be located in any one of a group of computer terminals in a computer network, or in any one of a group of mobile terminals, and the computer-readable storage medium includes a stored program.
Optionally, the program controls, when executed, an apparatus on which the computer-readable storage medium is located to perform the following functions: 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; 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 includes one of: undo operation and redo operation, where the second operation result is used to indicate the latest changed 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 a second stack on the second client, wherein the first stack and the second stack respectively correspond to an undo operation and a redo operation based on the operation type of the second editing operation; and on the second client, performing conversion operation 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 to obtain a third operation result.
Optionally, the program controls, when executed, an apparatus on which the computer-readable storage medium is located to perform the following functions: when the second editing operation is a undo operation, the first stack corresponds to an 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 an undo operation.
Optionally, the program controls, when executed, an apparatus on which the computer-readable storage medium is located to perform the following functions: and the second client sends the third operation result to the first client.
Optionally, the program controls, when executed, an apparatus on which the computer-readable storage medium is located to perform the following functions: 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, 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, on the basis of 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.
Optionally, the program controls, when executed, an apparatus on which the computer-readable storage medium is located to perform the following functions: determining the display position of the data to be edited in the text content corresponding to the first operation result; and performing a shifting 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 program controls, when executed, an apparatus on which the computer-readable storage medium is located to perform the following functions: 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 input latest by the text editor, and the second text state is used for describing the data content input last time by the text editor; 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 program controls, when executed, an apparatus on which the computer-readable storage medium is located to perform the following functions: 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 time length; 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 using an association relationship between the second operation result and the first operation result to obtain a third operation result when the anti-shake function is not activated on the second client; 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 the embodiment of the application, the embodiment of the processor is also provided. Optionally, in this embodiment, the processor is configured to execute a program, where the program executes any one of the text processing methods.
The present application further provides a computer program product adapted to perform a program for initializing the following method steps when executed on a data processing device: 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; 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 includes one of: undo operation and redo operation, where the second operation result is used to indicate the latest changed 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 a second stack on the second client, wherein the first stack and the second stack respectively correspond to an undo operation and a redo operation based on the operation type of the second editing operation; and on the second client, performing conversion operation 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 to obtain a third operation result.
The above-mentioned serial numbers of the embodiments of the present disclosure are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present disclosure, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the above-described division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit may be stored in a computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as a separate product. Based on such understanding, the technical solution of the present disclosure may be embodied in the form of a software product, which is stored in a computer-readable storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to perform all or part of the steps of the above-described method according to the embodiments of the present disclosure. And the aforementioned computer-readable storage media comprise: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and 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 embellishments could be made by those skilled in the art without departing from the principle of the present disclosure, and these should also be considered as the protection scope of the present disclosure.

Claims (12)

1. A method of text processing, 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;
executing a second editing operation on the target text through the text editor on the second client, and obtaining a second operation result from the first stack, wherein the second editing operation comprises one of the following operations: canceling operation and redoing operation, wherein the second operation result is used for indicating the latest changed data content of the target text corresponding to the second client;
on the second client, removing the second operation result from the first stack and adding the second operation result to a second stack, wherein the first stack and the second stack respectively correspond to an undo operation and a redo operation based on the operation type of the second editing operation;
and on the second client, performing conversion operation 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 through the first editing operation to obtain a third operation result.
2. The method of claim 1, wherein the first stack and the second stack correspond to undo operations and redo operations, respectively, based on the operation type of the second editing operation, comprising:
when the second editing operation is a undo operation, the first stack corresponds to an 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 an undo operation.
3. The method of claim 1, further comprising:
and the second client sends the third operation result to the first client.
4. The method of claim 1, wherein the description information of the first operation result and the second operation result comprises: 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 part includes: the method comprises the steps of obtaining a first identifier and a second identifier, wherein 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 includes: the third identifier is used for determining an editing operation type to be executed at the target position, and the data to be edited is operation data corresponding to the editing operation type.
5. The method of claim 4, wherein performing a conversion operation on the first operation result by using the association relationship between the second operation result and the first operation result, and 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 on the second client by using the first identifier, the third identifier and the data to be edited in the second operation result, 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.
6. The method of claim 5, 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 shifting 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.
7. The method of claim 1, further comprising:
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 input latest through the text editor, and the second text state is used for describing the data content input last time through the text editor;
and determining the latest changed data content on the second client based on the first text state and the second text state to obtain the second operation result.
8. The method of claim 1, further comprising:
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 time length;
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 a 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.
9. The method of claim 1, wherein 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 translation operation identifier of the first stack.
10. 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;
the second client is configured to execute 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: canceling operation and redoing operation, wherein the second operation result is the latest changed 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 a second stack, wherein the first stack and the second stack respectively correspond to an 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 incidence 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.
11. A text processing apparatus, comprising:
the first editing module is used for executing first editing operation on the target text on the first client through the text editor to obtain a first operation result and distributing the first operation result to the second client;
a second editing module, configured to perform a second editing operation on the target text through 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: canceling operation and redoing operation, wherein the second operation result is used for indicating the latest changed data content of the target text corresponding to the second client;
an operation processing module, configured to remove the second operation result from the first stack and add the second operation result to a second stack on the second client, where the first stack and the second stack respectively correspond to an undo operation and a redo operation based on an operation type of the second editing operation;
and the conversion processing module is used for executing conversion operation on the first operation result on the second client by utilizing the incidence 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.
12. A computer-readable storage medium, comprising a stored program, wherein the program, when executed, controls an apparatus in which the computer-readable storage medium is located to perform the text processing method according to any one of claims 1 to 9.
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 true CN113836875A (en) 2021-12-24
CN113836875B 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 (8)

* 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
US20040205663A1 (en) * 2002-06-07 2004-10-14 Microsoft Corporation Undo/redo architecture across multiple files
US20080177800A1 (en) * 2007-01-18 2008-07-24 Microsoft Corporation Synchronizing undo/redo operations between different document views
US20100281362A1 (en) * 2009-04-29 2010-11-04 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
US20120047434A1 (en) * 2010-08-19 2012-02-23 Cadence Design Systems, Inc. Method to preview an undo/redo list
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

Patent Citations (8)

* 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
US20040205663A1 (en) * 2002-06-07 2004-10-14 Microsoft Corporation Undo/redo architecture across multiple files
US20080177800A1 (en) * 2007-01-18 2008-07-24 Microsoft Corporation Synchronizing undo/redo operations between different document views
US20100281362A1 (en) * 2009-04-29 2010-11-04 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
US20120047434A1 (en) * 2010-08-19 2012-02-23 Cadence Design Systems, Inc. Method to preview an undo/redo list
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
CN113836875B (en) 2023-08-22

Similar Documents

Publication Publication Date Title
US11907642B2 (en) Enhanced links in curation and collaboration applications
EP3349400A1 (en) Method and device for realizing service function
CN104461474A (en) Mobile terminal and screen-shooting method and device therefor
CN106649446B (en) Information pushing method and device
CN110825807B (en) Data interactive conversion method, device, equipment and medium based on artificial intelligence
US10938773B2 (en) Method and apparatus for synchronizing contact information and medium
CN108549586B (en) Information processing method and device
CN111638838A (en) Text editing method and device and electronic equipment
CN104142975A (en) Microblog information promotion method, device and system
CN113127432A (en) Operation execution method, device, electronic equipment and medium
CN106953852A (en) Register method, device and the terminal device of radio receiver
CN107508969A (en) A kind of information processing method, device, computer installation and computer-readable recording medium
CN110442819A (en) Data processing method, device, storage medium and terminal
CN107846344A (en) The method, apparatus and electronic equipment of batch PUSH message in immediate communication tool
CN111641554B (en) Message processing method and device and computer readable storage medium
CN106411718B (en) Data synchronization method and device based on instant messaging application
CN113836875B (en) Text processing method, system, device and storage medium
EP2916529A1 (en) Method and device for accessing historical interface and mobile terminal
CN106954191A (en) Broadcast transmission method, device and terminal device
US11662886B2 (en) System and method for directly sending messages with minimal user input
EP4351117A1 (en) Information display method and apparatus, and electronic device
CN110881001B (en) Electronic red packet detection method, system and terminal equipment
CN113342755A (en) Display control method and device
CN109213955B (en) Data processing method and related equipment
EP3289544A1 (en) Insertion of unsaved content via content channel

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