Disclosure of Invention
The invention mainly aims to provide an editing information change tracking method and system based on a rich text editor, which aim to solve the technical problem of how to effectively track change information.
In order to achieve the above object, the present invention provides an editing information change tracking method based on a rich text editor, the editing information change tracking method based on a rich text editor includes:
Capturing an input event of a user operating a rich text editor, creating a change ID according to the input event, and determining a change type corresponding to the input event;
determining a character processing rule corresponding to the input event according to the change type;
Performing data processing on the input event based on the character processing rule to obtain change information, and creating a change object based on the change information, wherein the change ID is associated with the change object;
inserting the change information into a node, and realizing editing information change tracking through the node.
Optionally, the step of determining the change type corresponding to the input event includes:
identifying a function key according to the input event;
And determining a change type according to the function key, wherein the change type comprises a delete key, a line feed key and an insert key.
Optionally, the step of determining the character processing rule corresponding to the input event according to the change type includes:
Identifying character keys according to the input event, and determining character operation modes according to the function keys and the character keys, wherein the character operation modes comprise a conventional node operation mode and a special node operation mode, and the special node operation modes comprise a comment node operation mode, a phonetic notation node operation mode, a deletion node operation mode and an external byte point operation mode;
And determining a character processing rule corresponding to the character operation mode based on the change type.
Optionally, after the step of inserting the change information into the node, the method further includes:
and performing style setting on the changed label according to the change type so as to realize the distinction of different change types.
Optionally, after the step of performing style setting on the label after the modification according to the modification type, the method further includes:
After the end of the change is detected, updating the document structure according to the change information, and identifying the current cursor position;
After detecting the update of the document structure, the current cursor position is subjected to a reset process.
Optionally, the step of performing a reset process on the current cursor position includes:
Determining a cursor event corresponding to the current cursor position, wherein the cursor event comprises mousedown events, mouseup events, keyup events, keydown events, keypress events, document change events, window change events and selection change events;
determining a cursor processing rule according to the cursor event;
and resetting the current cursor position according to the cursor processing rule.
In addition, in order to achieve the above object, the present invention further provides an editing information change tracking system based on a rich text editor, the editing information change tracking system based on the rich text editor includes:
the creation module is used for capturing an input event of a user operating the rich text editor, creating a change ID according to the input event and determining a change type corresponding to the input event;
the determining module is used for determining a character processing rule corresponding to the input event according to the change type;
The processing module is used for carrying out data processing on the input event based on the character processing rule so as to obtain change information, and creating a change object based on the change information, wherein the change ID is associated with the change object;
and the tracking module is used for inserting the change information into the node and realizing editing information change tracking through the node.
In addition, in order to achieve the aim, the invention also provides editing information change tracking equipment based on the rich text editor, which comprises a memory, a processor and an editing information change tracking program based on the rich text editor, wherein the editing information change tracking program based on the rich text editor is stored on the memory and can run on the processor, and the editing information change tracking program based on the rich text editor is configured to realize the steps of the editing information change tracking method based on the rich text editor.
In addition, in order to achieve the above object, the present invention also proposes a storage medium having stored thereon an editing information change tracking program based on a rich text editor, which when executed by a processor, implements the steps of the editing information change tracking method based on a rich text editor as described above.
The method comprises the steps of firstly capturing an input event of a user operating a rich text editor, creating a change ID according to the input event, determining a change type corresponding to the input event, determining a character processing rule corresponding to the input event according to the change type, then carrying out data processing on the input event based on the character processing rule to obtain change information, creating a change object based on the change information, associating the change ID with the change object, finally inserting the change information into a node, and realizing editing information change tracking through the node. According to the invention, the change ID is associated with the change object, and then the change information is inserted into the node, so that the change in the text editing is recorded and displayed in real time, and the transparency and traceability of the document are enhanced.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of an editing information change tracking device based on a rich text editor in a hardware running environment according to an embodiment of the present invention.
As shown in fig. 1, the rich text editor-based editing information change tracking device may include a processor 1001, such as a central processing unit (Central Processing Unit, CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display, an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may further include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a Wireless interface (e.g., a Wireless-Fidelity (Wi-Fi) interface). The Memory 1005 may be a high-speed random access Memory (Random Access Memory, RAM) or a stable nonvolatile Memory (NVM), such as a disk Memory. The memory 1005 may also optionally be a storage system separate from the processor 1001 described above.
Those skilled in the art will appreciate that the structure shown in FIG. 1 does not constitute a limitation of the rich text editor-based editing information change tracking device, and may include more or fewer components than shown, or may combine certain components, or may be a different arrangement of components.
As shown in fig. 1, an operating system, a network communication module, a user interface module, and an edit information change tracking program based on a rich text editor may be included in the memory 1005 as one storage medium.
In the editing information change tracking device based on the rich text editor shown in fig. 1, the network interface 1004 is mainly used for data communication with a network server, the user interface 1003 is mainly used for data interaction with a user, and the processor 1001 and the memory 1005 in the editing information change tracking device based on the rich text editor can be arranged in the editing information change tracking device based on the rich text editor, and the editing information change tracking device based on the rich text editor calls the editing information change tracking program based on the rich text editor and stored in the memory 1005 through the processor 1001 and executes the editing information change tracking method based on the rich text editor provided by the embodiment of the invention.
The embodiment of the invention provides an editing information change tracking method based on a rich text editor, and referring to fig. 2, fig. 2 is a flow diagram of a first embodiment of the editing information change tracking method based on the rich text editor.
In this embodiment, the editing information change tracking method based on the rich text editor includes the following steps:
And S10, capturing an input event of a user operating the rich text editor, creating a change ID according to the input event, and determining a change type corresponding to the input event.
It is to be understood that the execution subject of the present embodiment may be an editing information change tracking system based on a rich text editor with functions of data processing, network communication, program running, etc., or may be other computer devices with similar functions, etc., and the present embodiment is not limited thereto.
In this embodiment, the input event may be an event input by the user through a keyboard (i.e. monitor keyboard press, lift, input characters), or may be an event input through a non-keyboard.
It should be further noted that, according to the operation type (i.e. deleting, inserting or line feeding), the operation element, the attribute and the value of the operation, a policy is generated by a preset ID to generate a change ID corresponding to the input event.
It should also be appreciated that the change type of the input event may be a delete type, an insert type, a wrap type, or the like.
Further, the function key may be identified according to the input event, and the function key may be a function key for presetting a corresponding change type, and then the corresponding change type may be determined after the user operates the function key.
And step S20, determining a character processing rule corresponding to the input event according to the change type.
Further, character keys are identified according to the input event, character operation modes are determined according to the function keys and the character keys, the character operation modes comprise a conventional node operation mode and a special node operation mode, the special node operation modes comprise a comment node operation mode, a phonetic notation node operation mode, a deletion node operation mode and an external byte point operation mode, and character processing rules corresponding to the character operation modes are determined based on the change types.
The conventional node operation mode and the special node operation mode corresponding to the deleting operation, the conventional node operation mode corresponding to the line feed operation, the conventional node operation mode corresponding to the inserting operation and the special node operation mode can be respectively determined according to the function key and the character key.
In the specific implementation, the deleting operation comprises the conventional focus backspace deleting and the range deleting is carried out according to the mouse selection area according to the character processing rule corresponding to the deleting conventional node operation mode. The deleting operation encounters a special node (namely, a special node operation mode corresponding to the deleting operation), and the special node needs to be processed to protect special elements in the deleting operation.
And the comment element is operated in the system by a user, and the side effect is processed by removing the style of the comment node and synchronously removing the corresponding comment outside the editor. And the character processing rule corresponding to the phonetic notation node is that the phonetic notation node is similar to the Chinese phonetic alphabet node in Japanese, the editor is wrapped by using a < ruby > tag, and the side effect is that the phonetic notation node is skipped, and the phonetic notation node is destroyed after the text node to be phonetic notation is deleted. And the character processing rule corresponding to the deleted node is that the user can check the past deleted content node in the change history, and the processing of side effects is that the phonetic notation node is skipped, and the phonetic notation node is destroyed after the text node to be phonetic notation is deleted. The character processing rule corresponding to the outer byte point is that special characters are inserted into the editor by a user, characters which can be displayed only by special support and an additional character set are needed, and the side effect is that the length of a selected area is calculated according to the outer character coding mode, and the outer character characters in the selected area are deleted.
It should be noted that, when processing these special nodes, the side effects after deletion are eliminated according to the identified deletion result.
Further, the line feed operation divides the paragraph and the selected area moves to the next line, wherein the format of the new paragraph inherits the last selected area.
Further, the insertion operation is divided into two types, one is that the user makes a conventional input by typing and the other is that a specific input is made through a specific tool provided by an editor.
And conventionally inputting, namely displaying input content in real time, maintaining a cursor position, wherein the input method combination key can cause abnormal withdrawal function, and special treatment is required for the input method combination key.
Special input the special input is provided by the tool of the editor, and the rule of the insertion mode for inserting the special node into the special node is as follows in combination with the conventional input of the user:
And clicking a comment tool after the selection area of the mouse is determined, and changing the comment nodes by characters in the selection area.
And the phonetic notation node is used for clicking a phonetic notation tool after the mouse selection area is determined, completing the form in the popup window, and changing the phonetic notation node by characters in the selection area.
And clicking an outer word tool to finish the form in the popup window, and adding the outer word node and the outer word character after the cursor.
And step S30, carrying out data processing on the input event based on the character processing rule to obtain change information, and creating a change object based on the change information, wherein the change ID is associated with the change object.
The change information comprises user information, basic information and metadata information, wherein the user information comprises information for recording a change operation executor, the user identifier comprises an ID, a right and a role, the operation context comprises an operation environment, an operation time and an operation source, the basic information comprises a change type, a change content and a change position, and the metadata information comprises an operation time, an operation user and a change reason.
It should also be understood that the change object includes basic information and metadata information.
And S40, inserting the change information into a node, and realizing editing information change tracking through the node.
In a specific implementation, the change information is inserted into the node, so that the retrieval and tracking are facilitated.
And further, determining a change type according to the change information, and setting a style of the changed label according to the change type so as to realize the distinction of different change types.
After the end of the change is detected, updating the document structure according to the change information, and identifying the current cursor position; after detecting the update of the document structure, the current cursor position is subjected to a reset process.
The processing mode of resetting the current cursor position comprises the steps of determining a cursor event corresponding to the current cursor position, wherein the cursor event comprises mousedown events, mouseup events, keyup events, keydown events, keypress events, document change events, window change events and selection change events, determining a cursor processing rule according to the cursor event, and resetting the current cursor position according to the cursor processing rule.
In a specific implementation, after a change is confirmed, the cursor position needs to be repositioned, the cursor is at the end of the reserved content for the confirmed change, and the cursor returns to the position before the change for the rejected change, wherein:
Updating the document structure, namely adding new content into the document after the change confirmation is executed, updating the document structure by using the stored information, and resetting the cursor position;
Resetting cursor position, processing mouse mousedown, mouseup event, processing keyboard keyup, keydown, keypress event, monitoring document, window, selection change, and processing three special cases as follows:
empty content processing, namely detecting whether a node only contains empty characters, inserting a zero-width blank space (# -8203;) as a placeholder, and using an empty text maintenance structure;
The cross-node area selection processing comprises three key steps of area selection analysis, node segmentation and cursor reconstruction, wherein:
Determining the starting and ending positions of the selected area, and acquiring all nodes in the selected area range;
Node segmentation, namely segmenting a starting node and an ending node, and processing all complete nodes in the middle;
The cursor position processing when combining adjacent changed nodes comprises the steps of 1, checking adjacent inserted nodes, combining continuous inserted contents of the same user, 2, after original cursor contents are stored, executing cursor combining operation, detecting whether adjacent node type verification can be combined or not in the combining process, calculating cursor offset if the adjacent node type verification can be combined, updating the cursor position and then applying the cursor position to a selected area, and 3, recovering the cursor position and clearing redundant marks. By these mechanisms, it can be ensured that the cursor position is maintained correctly in a variety of complex situations.
In this embodiment, firstly, an input event of a user operating a rich text editor is captured, a change ID is created according to the input event, a change type corresponding to the input event is determined, then a character processing rule corresponding to the input event is determined according to the change type, then data processing is performed on the input event based on the character processing rule to obtain change information, a change object is created based on the change information, the change ID is associated with the change object, finally, the change information is inserted into a node, and editing information change tracking is achieved through the node. According to the embodiment, the change ID is associated with the change object, and then the change information is inserted into the node, so that the change in the text editing is recorded and displayed in real time, and the transparency and traceability of the document are enhanced.
Referring to fig. 3, fig. 3 is a block diagram showing the structure of a first embodiment of the editing information change tracking system based on a rich text editor according to the present invention.
As shown in fig. 3, the editing information change tracking system based on the rich text editor according to the embodiment of the invention includes:
The creation module 3001 is configured to capture an input event of a user operating the rich text editor, create a change ID according to the input event, and determine a change type corresponding to the input event;
A determining module 3002, configured to determine a character processing rule corresponding to the input event according to the change type;
A processing module 3003, configured to perform data processing on the input event based on the character processing rule, so as to obtain change information, and create a change object based on the change information, where the change ID is associated with the change object;
and the tracking module 3004 is used for inserting the change information into a node and realizing editing information change tracking through the node.
Other embodiments or specific implementation manners of the editing information change tracking system based on the rich text editor of the present invention may refer to the above method embodiments, and will not be described herein.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. read-only memory/random-access memory, magnetic disk, optical disk), comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.