Method for generating and displaying revision records of multi-version documents based on jsdiff

Through the generation and display method of multi-version document revision record generation and display of multi-version document revision history and display in the existing technology, the problem of multi-version revision history and display of text and multimedia elements is achieved, and a clear revision history view is provided.

CN119475059BActive Publication Date: 2025-03-25CHENGDOU HUAQIYUN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510057671.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-14
Publication Date
2025-03-25
Estimated Expiration
2045-01-14

AI Technical Summary

Technical Problem

The prior art is difficult to efficiently and accurately record and display the history of multi-version revisions of documents, especially when dealing with the comparison of multimedia elements and multiple versions, resulting in inaccurate comparison results and poor user experience.

Method used

The multi-version document revision record generation and display method based on jsdiff, extracting multimedia element information, replacing it with a simplified placeholder format, and creating a mapping table to achieve accurate processing and display of multimedia elements. At the same time, jsdiff is used for version comparison, merge and filter revision records to generate detailed revision records.

Benefits of technology

It realizes accurate recording and display of changes in text and non-text content, can display revision records of multimedia elements in the original text location, provides a clear revision history view, and simplifies the process of finding specific revision content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119475059B_ABST
    Figure CN119475059B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of document modification, and in particular to a method for generating and displaying revision records of multiple versions of manuscripts based on jsdiff, including S100. Saving the modified content of each version in the manuscript into a database; S200. Extracting the text content with multimedia elements and converting it into a unified data format, replacing the labels of the corresponding multimedia elements in the text with unique identifiers; S300. When performing text comparison, using jsdiff to sequentially compare the modification records of version v and version v+1 according to the manuscript submission record, and recording each comparison result record and version information; S400. Merging and filtering the revision records of multiple versions; S500. Generating detailed revision records; S600. Visual display. The beneficial effects achieved by the present invention are: it can record changes in both text content and non-text elements; it can display changes in multiple versions, simplifying the process of finding specific revision content, and saving time and energy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of text revision, and in particular to a method for generating and displaying multi-version manuscript revision records based on jsdiff. Background Art

[0002] In the process of document coordination and management, multiple revisions of documents are common. In order to maintain the history of documents, track the changes of each version, and understand when, who, and what changes were made, an effective version control mechanism is essential.

[0003] However, the existing revision comparison method has the following limitations: 1. It can only compare two adjacent revisions, and cannot compare multiple revisions at the same time, resulting in users having to perform multiple operations to view the complete revision history. 2. It can only compare the text content of the revision text, and cannot process non-text elements such as pictures, videos, and audio, making the comparison results incomplete. 3. It cannot display multimedia elements in the original text position. Even if there are comparison results for non-text elements, they cannot be displayed intuitively in the original text position, affecting the user experience.

[0004] Based on the limitations of the above-mentioned existing document revision technologies, our company has developed a method for generating and displaying multi-version document revision records based on jsdiff. Summary of the invention

[0005] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a jsdiff-based multi-version document revision record generation and display method to solve the problem in the prior art that it is difficult to efficiently and accurately record and display the multi-version revision history of a document, and achieve "the ability to simultaneously process changes in text and non-text content, and display revision records of multimedia elements in the original position, providing users with a clear revision history view."

[0006] It should be noted that in the current document version modification, when comparing document versions, the images, videos and audio elements in rich text have complex label forms, and direct single character comparison will lead to inaccurate comparison results. For example, when the video source address is changed from xxx.com / ebrhfehv.mp4 to xxx.com / earffehv.mp4, the comparison result is displayed as <video src="xxx.com / xxx.com / ebarhffehv.mp4" controls>< / video> , which obviously does not meet the expected comparison.

[0007] In addition, in the current jsdiff-based document modification, only two adjacent modified versions can be compared. When modifying some documents with special requirements, all versions cannot be displayed on the interface. Users need to perform multiple operations to view the complete revision history, which is very troublesome.

[0008] Mainly based on the above two problems, the present invention provides corresponding solutions to solve them.

[0009] The purpose of the present invention is achieved by the following technical solution: a method for generating and displaying multi-version manuscript revision records based on jsdiff, comprising:

[0010] S100. Save the modified content of each version in the manuscript into the database;

[0011] S200. Extract the text content with multimedia elements and convert it into a unified data format. The specific steps are as follows:

[0012] S201. Extract multimedia element information: Extract all from rich text , <video>and <audio>Tag, and record its src attribute as well as width and controls attributes; store these attribute information in a mapping table;

[0013] S202. Replace the label of the multimedia element: replace the label of each multimedia element with a simplified placeholder format, generate a unique identifier, and replace the label of the corresponding multimedia element with the unique identifier in the text;

[0014] S203. Create a mapping table to associate each unique identifier with the corresponding multimedia element attribute information;

[0015] S300. When performing text comparison, use jsdiff to compare the modification records of version v and version v+1 in turn according to the manuscript submission record, and record the comparison result and version information of each time, as follows:

[0016] S301. Get author information: traverse all modified versions, remove duplicate operator information, and put it into user information data;

[0017] S302. Obtain the color value corresponding to the author modification: traverse the multiple distinct colors that have been set, and correspond one color to one author in turn;

[0018] S303. Break up the deletion operation of each version according to the comparison result, specifically including the following steps:

[0019] Check the comparison results: Check the comparison results of each version to see if there is a deletion operation; if it is not a deletion operation, that is, an addition or no modification operation, directly merge these results into the final revision record; if the comparison result is a deletion operation, if the comparison result is a deletion operation, split the deletion operation data item into multiple data items with a length of 1, where each split data item has the attributes of the deleted data item before the split;

[0020] S400. Merge and filter multiple version revision records;

[0021] S401. Initialize merged data: initialize an array mergeDiffData, which is used to store the merged data;

[0022] S402. Traverse the changed data of the version to be merged and merge it with the first version: compare the current version with the previous version, find the difference, and then merge the difference with the first version; after traversing all versions in turn, merge accordingly;

[0023] S500. Generate detailed revision records;

[0024] S600. Visual display, including the following steps:

[0025] S601. Render the output result in S500, and display the delete and add operations in the interface;

[0026] S602. Restore the processing of multimedia elements in step S200;

[0027] S603. According to the index information in the changed data item, the operator and the color and version information corresponding to the operator are obtained and bound, and the user can display the corresponding information by moving the mouse.

[0028] Furthermore, in the above S202, the generated unique identifier is formed by the following symbols: a symbol indicating the type of the self-media element, and a placeholder; wherein each placeholder corresponds to the src attribute, and the width and controls attributes of a multimedia element.

[0029] Furthermore, the process of restoring the multimedia element in step S200 in step S602 refers to: restoring the displacement identifier to a tag corresponding to the corresponding self-media element.

[0030] Furthermore, in the above S303, the deletion operation data item and the data items split into multiple data items of length 1 all have attributes. The attributes include: count: the number of characters; removed: whether it is deleted, which is true; added: whether it is added, which is undefined; value: the specific value of the character; source: the original string; index: the index position of the character in the original string. When the deletion operation data item is split into multiple data items of length 1: only count and value in the attributes of the data item of length 1 are changed, and removed, added, source, and index in the attributes of the data item of length 1 are consistent with the corresponding contents in the attributes of the deletion operation data item.

[0031] Furthermore, when the corresponding operation is performed in S402, curtotal is automatically generated through jsdiff; curtotal represents the position index of the modification record of the current manuscript version.

[0032] Further, after the corresponding merging operation is performed in S402, in generating the detailed revision record through S500, the merging operation includes processing the deletion operation;

[0033] The processing deletion operation is divided into direct insertion method and segmentation insertion method;

[0034] When using direct insertion method for deletion operation:

[0035] ① Compare the current version with the previous version, from the beginning to the end, to find out how many changes have been made. Each change is recorded and represented by a data item; the data item includes the number of changes, the position index value of the change, the number of characters changed, the specific deleted content, and whether the changes have been deleted;

[0036] ② Every time a modification is found in the comparison, the specific content of the modification is merged into the first version of the manuscript; at the same time, the data items to be merged in the current version are merged into the list generated by the merged data items to form a new list of merged data items;

[0037] When merging: if the following judgment condition 1 is met - if the index value of the mth data item of the current version to be merged is equal to the index value of the nth data item of the merged version plus the number of modified characters of the nth data item of the merged version, and the n+1th data item of the merged version has the attribute of not being deleted, then "the specific deleted content in the mth data item of the current version to be merged" is directly inserted after the nth data item of the merged version; if the n+1th data item of the merged version has the attribute of being deleted, then continue to search backwards until the n+wth data item that does not meet the judgment condition 1 is found in the merged version, w>1, then "the specific deleted content in the mth data item of the current version to be merged" is directly inserted after the n+w-1th data item of the merged version that meets the judgment condition 1;

[0038] When using the split insertion method for deletion:

[0039] The same operation ① and ② as in the above deletion operation is performed by the direct insertion method, the difference is the merging process;

[0040] When merging: If the following judgment condition 2 is met - if the position index value of the mth data item of the current version to be merged is greater than the position index value of the nth data item of the merged version, and is less than "the index value of the nth data item of the merged version plus the number of modified characters of the nth data item of the merged version", then the "specific merged content in the nth data item of the merged version" will be split according to the split point, which is "the index value of the mth data item of the version to be merged minus the index value of the nth data item of the merged version", and then the "specific deleted content in the mth data item of the current version to be merged" will be inserted into the split point of the nth data item of the merged version.

[0041] Furthermore, after the corresponding merging operation is performed in S402, in generating the detailed revision record through S500, the merging operation also includes processing adding operation; processing adding operation is also divided into direct insertion method and split insertion method;

[0042] When adding operations using the direct insertion method:

[0043] ① Compare the current version with the previous version, from the beginning to the end, to find out how many additions have occurred. Each addition is recorded and represented by a data item; the data item includes the number of additions, the position index value of the addition, the number of modified characters, the specific addition content, and whether the addition has been made;

[0044] ② Every time a modification is found in the comparison, the specific content of the modification is merged into the first version of the manuscript; at the same time, the data items to be merged in the current version are merged into the list generated by the merged data items to form a new list of merged data items;

[0045] When merging: If the following judgment condition 3 is met - if the index value of the mth data item of the current version to be merged is equal to the index value of the nth data item of the merged version plus the number of modified characters of the nth data item of the merged version, and the n+1th data item of the merged version has the non-deletion attribute, then directly insert "the specific additions of the mth data item of the current version to be merged" after the nth data item of the merged version; if the n+1th data item of the merged version has the deletion attribute, continue to search backward until the n+wth data item that does not meet the judgment condition 3 is found in the merged version, w>1, then directly insert "the specific additions in the mth data item of the current version to be merged" after the n+w-1th data item of the merged version;

[0046] When using the split insertion method to add operations:

[0047] The same operation ① and ② as in the above adding operation is performed by the direct insertion method, except that the operation is merged;

[0048] When merging: If the following judgment condition 4 is met - if the position index value of the mth data item of the current version to be merged is greater than the position index value of the nth data item of the merged version, and is less than "the index value of the nth data item of the merged version plus the number of modified characters of the nth data item of the merged version", then the "specific merged content of the mth data item of the merged version" will be split according to the split point, which is "the index value of the mth data item of the version to be merged minus the index value of the nth data item of the merged version", and then the "specific added content in the mth data item of the current version to be merged" will be inserted into the split point of the nth data item of the merged version.

[0049] Furthermore, after the corresponding merge operation is performed in S402 and the detailed revision record is generated through S500, the merge operation also includes handling special cases. If the index value of the mth data item of the version to be merged is 1, and it is a deletion or addition operation, then "the specific deletion content or specific addition content of the mth data item of the current version" is directly inserted before the first data item of the merged version; if the index value of the mth data item of the version to be merged is greater than the index value of the last data item of the merged version plus the number of modified characters of the last data item of the merged version and it is a deletion or addition operation, then "the specific deletion content or specific addition content of the mth data item of the current version" is directly inserted after the last data item of the merged version.

[0050] Furthermore, after the corresponding merge operation is performed in S402 and the detailed revision record is generated through S500, the merge operation also includes correcting the index. When the adjacent versions are processing the merge and add operation in S402, if the "specific merged content of the mth data item of the version to be merged" has been inserted into the "corresponding position of the corresponding data item of the merged version", and the "index value of the specific merged content after insertion" has been modified - that is, m has been changed to m', but the index value of the n+1th data item of the merged version and the index values ​​of the data items after the n+1th data item of the merged version have not been changed, then the index values ​​of the data items after the n+1th data item of the merged version and n+1th data item of the merged version need to be corrected. The correction method is: "the index value of the nth data item of the merged version after correction" is equal to "the index value of the m'th data item" plus "the number of modified characters of the m'th data item".

[0051] Technical explanation:

[0052] The present invention is developed based on jsdiff. When revising a text, jsdiff can record the position index of each revision record of the current manuscript version, and use curcotal to represent the index value.

[0053] The present invention has the following advantages:

[0054] (1) It can record not only changes in text content, but also changes in non-text elements (multimedia elements), providing a comprehensive revision history. When displaying the revision history of multimedia elements in the original text position, it can still provide users with a clear revision history view even in the case of multiple revisions.

[0055] It should be noted that in the existing text modification solution based on jsdiff, when comparing document versions, multimedia tags are directly compared by single characters. The reason is that due to the complex tag forms of pictures, videos and audio elements in rich text, direct single character comparison will lead to inaccurate comparison results. For example, when the video source address is changed from xxx.com / ebrhfehv.mp4 to xxx.com / earffehv.mp4, the comparison result is displayed as <video src="xxx.com / xxx.com / ebarhffehv.mp4" controls>< / video> , which is obviously not in line with expectations; in particular, after modifying multiple versions and comparing them continuously, the final result is extremely inaccurate;

[0056] In this solution, the tags of all multimedia elements are extracted from the rich text, and their src attributes and other related attributes (such as width, controls, etc.) are recorded and stored in a mapping table; then the tag of each multimedia element is replaced as a whole with a simplified placeholder format; and a mapping table is created to associate each placeholder with its corresponding multimedia element information; in this way, when revising the manuscript, there is no need to worry about the complexity of the multimedia tags, which may lead to inaccurate comparison results; this method, when used in the comparison of multiple versions of changes, makes the comparison results very accurate;

[0057] (2) The changes of each version of the document can be clearly seen, and multiple versions can be compared;

[0058] In the prior art, document modification based on jsdiff can usually only compare adjacent versions, but cannot compare multiple versions.

[0059] In this solution, multiple modified versions can be displayed, so that users can see the modification status of each version, thereby realizing the comparison of multiple versions;

[0060] (3) It simplifies the process of finding specific revision content, saving time and effort. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Figure 1 It is a schematic diagram of the process of the present invention;

[0062] Figure 2 It is a schematic diagram showing the interface of the present invention. DETAILED DESCRIPTION

[0063] The present invention is further described below in conjunction with the accompanying drawings, but the protection scope of the present invention is not limited to the following description.

[0064] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0065] like Figure 1 and Figure 2 As shown in the figure, the method for generating and displaying multi-version document revision records based on jsdiff includes:

[0066] S100. Save the modified content of each version in the manuscript into the database;

[0067] S200. Extracting text content with multimedia elements and converting it into a unified data format, replacing the corresponding multimedia element label in the text with a unique identifier;

[0068] S300. When performing text comparison, use jsdiff to compare the modification records of version v and version v+1 in turn according to the manuscript submission record, and record the comparison result and version information of each time;

[0069] S400. Merge and filter multiple version revision records;

[0070] S500. Generate detailed revision records;

[0071] S600. Visual display.

[0072] The S200 is further described below.

[0073] S201. Extract multimedia element information: Extract all from rich text , <video>and <audio>Tag, and record its src attribute as well as width and controls attributes; store these attribute information in a mapping table to facilitate subsequent restoration operations;

[0074] It should be noted that , <video>and <audio>They refer to pictures, videos, and audio multimedia respectively, and of course they can also be other multimedia. The src attribute is used to specify the source of the resource (multimedia). The src attribute, width attribute, and controls attribute are all conventional attributes in multimedia. Of course, this specific embodiment is just an example, and other conventional attributes can also be used in multimedia tags.

[0075] For example, the extracted multimedia element information is as follows:

[0076] picture: ;

[0077] ;

[0078] video: <video src="xxx.com / ebrhfehv.mp4" controls="true"> Video 1< / video> ;

[0079] <video src="xxx.com / another-video.mp4" controls="true"> Video 2< / video> ;

[0080] Audio: <audio src="xxx.com / ebrhfehv.mp3" controls="true"> Audio 1< / audio> ;

[0081] <audio src="xxx.com / another-audio.mp3" controls="true"> Audio 2< / audio> .

[0082] S202. Replace the label of the multimedia element: replace the label of each multimedia element with a simplified placeholder format, generate a unique identifier, and replace the label of the corresponding multimedia element with the unique identifier in the text.

[0083] Exemplarily, the content illustrated in the above S201 is further processed by S202:

[0084] Image: Label the image Replaced by TaT;

[0085] Label the image Replaced with TbT;

[0086] video:

[0087] Label the video <video src="xxx.com / ebrhfehv.mp4" controls="true"> Video 1< / video> Replaced by SaS;

[0088] Label the video <video src="xxx.com / another-video.mp4" controls="true"> Video 2< / video> Replaced with SbS;

[0089] Audio:

[0090] Add audio tag <audio src="xxx.com / ebrhfehv.mp3" controls="true"> Audio 1< / audio> Replaced with YaY;

[0091] Add audio tag <audio src="xxx.com / another-audio.mp3" controls="true"> Audio 2< / audio> Replace with YbY;

[0092] S203. Create a mapping table to associate each unique identifier with corresponding multimedia element attribute information.

[0093] Exemplarily, the content of the example in S202 is further processed by S203 to create a mapping table as follows:

[0094] "T": {

[0095] "a": { "src": "xxx.com / ebrhfehv.jpg", "width": "320"},

[0096] "b": { "src": "xxx.com / another-image.jpg", "width": "640"}},

[0097] "S": {

[0098] "a": { "src": "xxx.com / ebrhfehv.mp4", "controls": "true"},

[0099] "b": { "src": "xxx.com / another-video.mp4", "controls": "true"}},

[0100] "Y": {

[0101] "a": { "src": "xxx.com / ebrhfehv.mp3", "controls": "true"},

[0102] "b": { "src": "xxx.com / another-audio.mp3", "controls": "true"}

[0103] }

[0104] }.

[0105] In this way, through steps S201 to S203, multimedia element information can be extracted from the rich text, the multimedia element tags can be replaced and a mapping table can be generated, so that the multimedia elements can be accurately restored in subsequent processing.

[0106] S300 is described in further detail below.

[0107] S301. Get author information: traverse all modified versions, remove duplicate operator information, and put it into the user information data.

[0108] S302. Obtain the color value corresponding to the author's modification: traverse the multiple distinct colors that have been set, and correspond one color to one author in turn.

[0109] First, you need to pick a variety of different colors, which can be any colors you like, such as red, blue, green, yellow, etc. Each color has a specific code, usually expressed in hexadecimal, for example, the code for red is #FF0000, the code for blue is #0000FF, and the code for green is #00FF00.

[0110] Put these color codes into a list, which is like a color library from which you can pick any color, e.g. [

[0112] "#FF0000", / / red

[0113] "#0000FF", / / Blue

[0114] "#00FF00", / / Green

[0115] "#FFFF00", / / yellow

[0116] "#800080", / / Purple ...

[0117] ].

[0118] S303. Break up the deletion operation of each version according to the comparison result, specifically including the following steps:

[0119] Check the comparison results: You need to check the comparison results of each version to see if there is any deletion operation;

[0120] The comparison results may include the following situations:

[0121] ① If the comparison result is not a deletion operation, that is, it is an addition or no modification, then these results are directly merged into the final revision record;

[0122] ② If the comparison result is a deletion operation, the deletion operation data item is split into multiple data items of length 1, where each split data item has the attributes of the deleted data item before the split;

[0123] It is described that both the deleted operation data item and the split into multiple data items with a length of 1 have attributes; among them, the attributes include: count: the number of characters; removed: whether it is deleted, which is true; added: whether it is added, which is undefined; value: the specific value of the character; source: the original string; index: the index position of the character in the original string;

[0124] When splitting the deleted operation data item into multiple data items with a length of 1: only count and value in the attributes of the data item with a length of 1 change, and removed, added, source, and index in the attributes of the data item with a length of 1 are the same as the corresponding contents in the attributes of the deleted operation data item.

[0125] Exemplarily, S303 is illustrated as follows:

[0126] Suppose the deleted string is "result", and the processed result is two separate objects, each representing a character;

[0127] Example:

[0128] Suppose the deleted string is "result", and the comparison result is:

[0129] {

[0130] count: 2,

[0131] removed: true,

[0132] added: undefined,

[0133] value: ‘result’,

[0134] sourse:‘result’,

[0135] index: 100

[0136] },

[0137] The processed result is:

[0138] [{

[0139] count: 1,

[0140] removed: true,

[0141] added: undefined,

[0142] value: ‘结’,

[0143] sourse:'result',

[0144] index: 100

[0145] },{

[0146] count: 1,

[0147] removed: true,

[0148] added: undefined,

[0149] value: 'fruit',

[0150] sourse:'result',

[0151] index: 101

[0152] }].

[0153] The following further describes S400-merging and filtering multiple version revision records.

[0154] S401. Initialize merged data: initialize an array mergeDiffData, which is used to store the merged data.

[0155] S402. Traverse the changed data of the version to be merged and merge it with the first version: compare the current version with the previous version, find the difference, and then merge the difference with the first version; after traversing all versions in turn, perform the corresponding merge.

[0156] 1. "Compare the current version with the previous version, find the difference, and then merge the difference with the first version", including processing the deletion operation. Processing the deletion operation includes direct insertion method for deletion and split insertion method for deletion.

[0157] (1) When using the direct insertion method for deletion:

[0158] ① Compare the current version with the previous version, from the beginning to the end, to find out how many changes have been made. Each change is recorded and represented by a data item; the data item includes the number of changes, the position index value of the change, the number of characters changed, the specific deleted content, and whether the changes have been deleted;

[0159] ② Every time a modification is found in the comparison, the specific content of the modification is merged into the first version of the manuscript; at the same time, the data items to be merged in the current version are merged into the list generated by the merged data items to form a new list of merged data items;

[0160] When merging: if the following judgment condition 1 is met - if the index value of the mth data item of the current version to be merged is equal to the index value of the nth data item of the merged version plus the number of modified characters of the nth data item of the merged version, and the n+1th data item of the merged version has the attribute of not being deleted, then "the specific deleted content in the mth data item of the current version to be merged" is directly inserted after the nth data item of the merged version; if the n+1th data item of the merged version has the attribute of being deleted, then continue to search backwards until the n+wth data item that does not meet the judgment condition 1 is found in the merged version, w>1, then "the specific deleted content in the mth data item of the current version to be merged" is directly inserted after the n+w-1th data item of the merged version that meets the judgment condition 1;

[0161] For example, the deletion operation is performed by direct insertion, and an example is given:

[0162] 1) If there are multiple modifications in the current version of the manuscript from the beginning to the end, a data item (in the form of a list) is generated after each modification; for example, in the current version of the manuscript, the nth and n+1th locations have been merged; then the mth deleted and modified location of the current version of the manuscript is merged, and the specific operation is as follows: Table 1 When the merged version is at the nth data item / nth modification location and the n+1th data item / nth modification location, the corresponding data item list

[0163]

[0164] In Table 1: data items n and n+1 are the data items of the merged version, specifically referring to the modifications at the nth and n+1th locations in the manuscript of the merged version; curtotal refers to the position index value of the merged version at the corresponding data item, or in layman's terms, the position index value of the merged version at the corresponding modification, which is automatically generated by jsdiff; count refers to the number of modified characters in the merged version at the current data item / modification (the number of characters deleted here); content refers to the specific deleted content in the merged version at the corresponding data item; removed indicates whether the merged version has deleted the corresponding data item. If true, deletion has been performed, and if blank, deletion has not been performed; the row where data item n+1 (or n+1th data item) is located in Table 1 means: at the n+1th data item (or data item n+1, or n+1th modification) of the merged version, at the index position value of 10, the 6 characters "FGHIJK" have been deleted;

[0165] Table 2 List of data items corresponding to the mth data item / modification in the version to be merged

[0166]

[0167] 2) Now, if you need to directly insert the "specific modification content of the mth data item of the version to be merged" in Table 2 into the merged version in Table 1, perform the following operations:

[0168] Judgment condition 1: If the index value of the mth data item of the version to be merged (15) is equal to the index value of the nth data item of the merged version (10) plus the number of modified characters of the nth data item of the merged version (5), and the removed of the n+1th data item of the merged version is not equal to true, then insert it directly after the nth data item of the merged version; if the removed of the data item n+1 of the merged version is equal to true, search from the n+1 data item in the merged version backward until the data item that meets judgment condition 1 is found in the merged version, and then insert the "content of the mth data item of the version to be merged" (here is X) directly after the last data item of the merged version that meets judgment condition 1.

[0169] (2) When using the split insertion method for deletion:

[0170] The same operation ① and ② as in the above deletion operation is performed by the direct insertion method, the difference is the merging process;

[0171] When merging: if the following judgment condition 2 is met - if the position index value of the mth data item of the current version to be merged is greater than the position index value of the nth data item of the merged version, and is less than "the index value of the nth data item of the merged version plus the number of modified characters of the nth data item of the merged version", then the "specific merged content in the nth data item of the merged version" is split according to the split point, which is "the index value of the mth data item of the version to be merged minus the index value of the nth data item of the merged version", and then the "specific deleted content in the mth data item of the current version to be merged" is inserted into the split point of the nth data item of the merged version;

[0172] Exemplarily, the segmentation insertion method is used to perform the deletion operation, and an example is given:

[0173] 1) If there are multiple modifications in the previous and next parts of the version to be merged, a data item (in the form of a list) is generated after each modification; for example, the merged version has been merged at the nth and n+1th parts, as shown in Table 3;

[0174] Table 3 List of merged data items after the current version of the manuscript is modified at position n and position n+1

[0175]

[0176] Table 4 The data items to be merged in the mth modification of the current version of the manuscript

[0177]

[0178] 2) Now we need to insert the mth data item of the version to be merged (as shown in Table 4) into the merged version, and perform the following operations:

[0179] Judgment condition 2: If the index value of the mth item in the version to be merged (12) is greater than the index value of the nth item in the merged version (10), and less than "the index value of the nth item in the merged version (10) plus the number of modified characters in the nth item (15)", since 10<12<(10+5), judgment condition 2 is met;

[0180] Find the split point: 12-10=2, and use ABCDE as the split point at the second position - that is, split into AB and CDE;

[0181] Insertion: X is then inserted between AB and CED, and the final result is ABXCDE.

[0182] Second, "compare the current version with the previous version, find the difference, and then merge the difference with the first version", including processing the add operation. Processing the add operation includes adding by direct insertion method and adding by split insertion method.

[0183] (1) When adding using the direct insertion method:

[0184] ① Compare the current version with the previous version, from the beginning to the end, to find out how many additions have occurred. Each addition is recorded and represented by a data item; the data item includes the number of additions, the position index value of the addition, the number of modified characters, the specific addition content, and whether the addition has been made;

[0185] ② Every time a modification is found in the comparison, the specific content of the modification is merged into the first version of the manuscript; at the same time, the data items to be merged in the current version are merged into the list generated by the merged data items to form a new list of merged data items;

[0186] When merging: If the following judgment condition 3 is met - if the index value of the mth data item of the current version to be merged is equal to the index value of the nth data item of the merged version plus the number of modified characters of the nth data item of the merged version, and the n+1th data item of the merged version has the non-deletion attribute, then directly insert "the specific additions of the mth data item of the current version to be merged" after the nth data item of the merged version; if the n+1th data item of the merged version has the deletion attribute, continue to search backward until the n+wth data item that does not meet the judgment condition 3 is found in the merged version, w>1, then directly insert "the specific additions in the mth data item of the current version to be merged" after the n+w-1th data item of the merged version;

[0187] Exemplarily;

[0188] For example, the addition operation is performed by direct insertion, and an example is given:

[0189] 1) If the version to be merged is merged at the nth data item and the n+1th data item, as shown in Table 5; Table 5 List of data items formed after the merged version is merged at the nth data item and the n+1th data item

[0190]

[0191] In Table 5, data items n and n+1 refer to the modifications of the merged version at the nth and n+1th positions in the merged version; curtotal is the position index of the corresponding data item (n or n+1) in the merged version after the merge, which is automatically generated by jsdiff; count refers to the number of modified characters in the corresponding data item (n or n+1) of the merged version (here, the number of added characters, such as 5 or 1); content refers to the specific added content (such as ABCDE, or F); added indicates whether the addition is performed. If it is true, the addition is performed, and if it is blank, it is not added; the corresponding row of data item n+1 in Table 5 means: at the n+1th modification of the merged version, at the index position 15, the addition operation of the character "F" is performed;

[0192] Table 6 List of data items formed after adding and merging the mth data item in the version to be merged

[0193]

[0194] 2) Now if you need to add and merge the "mth data item of the version to be merged" by direct insertion, the operation is as follows:

[0195] Judgment condition 3: If the index value (15) of the mth data item of the version to be merged is equal to the index value (10) of the nth data item of the merged version plus the number of modified characters (5) of the nth data item of the merged version, and removed of the data item n+1 of the merged version is not equal to true, then insert it directly after the nth data item; if removed of the data item n+1 of the merged version is equal to true, continue to search backward until a data item that does not meet judgment condition 3 is found in the data items of the merged version, then insert "the specific content of the data item of the version to be merged" directly after the last data item of the merged version that meets judgment condition 3.

[0196] (2) When using the split insertion method to perform the addition operation:

[0197] The same operation ① and ② as in the above adding operation is performed by the direct insertion method, except that the operation is merged;

[0198] When merging: if the following judgment condition 4 is met - if the position index value of the mth data item of the current version to be merged is greater than the position index value of the nth data item of the merged version, and is less than "the index value of the nth data item of the merged version plus the number of modified characters of the nth data item of the merged version", then the "specific merged content of the mth data item of the merged version" is split according to the split point, which is "the index value of the mth data item of the version to be merged minus the index value of the nth data item of the merged version", and then the "specific added content in the mth data item of the current version to be merged" is inserted into the split point of the nth data item of the merged version;

[0199] Exemplarily, the split insertion method is used to perform the adding operation, and an example is given:

[0200] 1) If the version to be merged is merged at the nth data item and the n+1th data item, a data item list is formed - as shown in Table 7;

[0201] Table 7 List of data items formed after the merged version is modified at the nth position and merged at the n+1th position

[0202]

[0203] Table 8 List of data items formed after the version to be merged is modified at the mth position

[0204]

[0205] 2) Now if you need to merge the "modified content at position m of the version to be merged" using the split insertion method, the operation is as follows:

[0206] Judgment condition 4: If the index value of the mth data item of the version to be merged (13) is greater than the index value of the nth data item of the merged version (10), and is less than "the index value of the nth data item of the merged version (10) plus the number of modified characters of the nth data item of the merged version (5)", that is, 10<13<(10+5);

[0207] Find the split point: 13-10=3. The split point is after the third position in ABCDE. After splitting, ABC and DE are formed.

[0208] Insert: Insert XYZ at the split point to form ABCXYZDE.

[0209] 3. "Compare the current version with the previous version, find the differences, and then merge the differences with the first version", also includes special processing.

[0210] Specifically:

[0211] If the index value of the mth data item of the version to be merged is 1, and it is a deletion or addition operation, then "the specific deletion content or specific addition content of the mth data item of the current version" is directly inserted before the first data item of the merged version;

[0212] If the index value of the mth data item of the version to be merged is greater than the index value of the last data item of the merged version plus the number of modified characters of the last data item of the merged version and it is a deletion or addition operation, then "the specific deletion content or specific addition content of the mth data item of the current version" is inserted directly after the last data item of the merged version.

[0213] 4. "Compare the current version with the previous version, find the differences, and then merge the differences with the first version", which also includes correcting the index.

[0214] Specifically: when the adjacent versions are processing the merge and add operation in S402, if the "specific merged content of the mth data item of the version to be merged" has been inserted into the "corresponding position of the corresponding data item of the merged version", and the "index value of the inserted specific merged content" has been modified, that is, m has been changed to m', but the index value of the n+1th data item of the merged version and the index values ​​of the data items after the n+1th data item of the merged version have not been changed, then the index values ​​of the data items after the n+1th data item of the merged version need to be corrected;

[0215] The correction method is: "the index value of the nth data item of the corrected merged version" is equal to "the index value of the m'th data item" plus "the number of modified characters of the m'th data item".

[0216] Exemplarily, the above correction index is explained.

[0217] 1) When two versions are merged, as shown in Table 9: the data item of the version to be merged has been inserted into the data item of the merged version (referred to as the inserted item m' in this case), and the position index of the inserted item m' has also been modified;

[0218] Table 9 List of data items after the merged version has inserted the data items of the version to be merged and the position index of the inserted items has been modified

[0219]

[0220] 2) Then, you also need to modify the index values ​​of the merged version n+1 and subsequent data items. The operation is as follows:

[0221] For example, when the index value of the n+1 data item of the merged version is modified: the curtotal value corresponding to n+1 in Table 9 should be modified to "the curtotal value of the inserted item m'+the count value of the inserted item m'", that is, 15 is changed to (15+2). The modified corresponding data item list is shown in Table 10;

[0222] Table 10 List of data items after index correction

[0223]

[0224] 3) In this way, the index values ​​of the merged version n+2, n+3, and subsequent items are modified in sequence.

[0225] S500. Generate a detailed revision record.

[0226] Exemplarily, a detailed revision record, e.g. 0:

[0228] Count: 6

[0229] curtotal: 6

[0230] index:1

[0231] value: "Domestic Tourism J Country"

[0232] [[Prototype]]: 0bject

[0233] 1: {count: 1, removed: true, added: unedfined, value: 'Ji', sourceValue: 'Ji', ...}

[0234] 2: {count: 1, removed: true, added: unedfined, value: 'inside', index: 1}

[0235] 3: {count: 6, value: 'tourism, refers to international', index: 1, curtotal: 13}

[0236] 4: {count: 1, added: true, removed: undefined, value: 'home', index: 1, ...}

[0237] 5: {count: 48, removed: undefined, added: undefined, value: 'A trip taken by domestic residents leaving their permanent residence to another place in the country. Its characteristic is that there is no nationality restriction on the people who engage in such tourism activities.', index: 1, ...}

[0238] 6: {count: 1, removed: true, added: undefined, value: 'TbT', sourceValue: 'TbT', ...}

[0239] 7: {count: 39, added: true, removed: undefined, value: 'Both citizens and foreign residents with legal residency can travel within the country', index: 2, ...}

[0240] 8: {count: 99, removed: undefined, added: undefined, value: 'In 2023, the number of domestic tourists reached 4.891 billion, an increase of 2.361 billion over the same period last year, a year-on-year increase of 94.9%; the number of domestic tourists from rural residents reached 1.133 billion, a year-on-year increase of 88.5%.', index: 1, ...}

[0241] 9: {count: 26, added: true, removed: undefined, value: 'This shows that the domestic tourism market has recovered strongly, and the demand for urban and rural travel has increased significantly. ', index: 3, ...}

[0242] 10: {count: 3, added: true, removed: undefined, value: 'SaS', index: 2, …}

[0243] 11: {count: 141, removed: undefined, added: undefined, value: 'On May 6, 2024, the Ministry of Culture and Tourism announced the cultural and tourism market situation during the 2024 May Day holiday. During the 5-day holiday, domestic tourists spent 166.89 billion yuan, a year-on-year increase of 12.7%, and a comparable increase of 13.5% over the same period in 2019. ', index: 1, …}

[0244] 12: {count: 3, added: true, removed: undefined, value: 'YaY', index: 2, ...}

[0245] 13: {count: 97, removed: undefined, added: undefined, value: 'On July 26, 2024, the Ministry of Culture and Tourism released domestic tourism data for the first half of 2024. In the first half of 2024, the number of domestic tourists reached 2.725 billion, a year-on-year increase of 14.3%. The total expenditure of domestic tourists was 2.73 trillion yuan, a year-on-year increase of 19.0%. ', index: 1, …}

[0246] 14: {count: 3, added: true, removed: undefined, value: 'TaT', index: 2, ...}

[0247] length:15

[0248] [[Prototype]]:Array(0).

[0249] The visual display of S600 is further explained below.

[0250] S601. Render the output result in S500, and display the delete and add operations in the interface;

[0251] S602. Restore the processing of multimedia elements in step S200;

[0252] S603. According to the index information in the changed data item, the operator and the color and version information corresponding to the operator are obtained and bound, and the user can display the corresponding information by moving the mouse.

[0253] For example, after S600 processing, the visual display effect is shown in Figure 2 shown.

[0254] The above embodiments only express preferred implementation modes, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present invention. It should be pointed out that, for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention.< / audio> < / video> < / audio> < / video> < / audio> < / video>

Claims

1. A method for generating and displaying multi-version document revision records based on jsdiff, characterized in that: include: S100. Save the modified content of each version in the manuscript into the database; S200. Extract the text content with multimedia elements and convert it into a unified data format. The specific steps are as follows: S201. Extract multimedia element information: Extract all from rich text , <video>and <audio> Tag, and record its src attribute as well as width and controls attributes; store these attribute information in a mapping table;< / audio> < / video> S202. Replace the label of the multimedia element: replace the label of each multimedia element with a simplified placeholder format, generate a unique identifier, and replace the label of the corresponding multimedia element with the unique identifier in the text; S203. Create a mapping table to associate each unique identifier with the corresponding multimedia element attribute information; S300. When performing text comparison, use jsdiff to compare the modification records of version v and version v+1 in turn according to the manuscript submission record, and record the comparison result and version information of each time, as follows: S301. Get author information: traverse all modified versions, remove duplicate author information, and put it into the author information data; S302. Obtain the color value corresponding to the author's modification: traverse the multiple distinct colors that have been set, and correspond one color to one author in turn; S303. Break up the deletion operation data items of each version according to the comparison results, specifically including the following steps: Check the comparison results: Check the comparison results of each version to see if there is a deletion operation; if it is not a deletion operation, that is, an addition or no modification operation, directly merge these results into the final revision record; if the comparison result is a deletion operation, split the deletion operation data item into multiple data items with a length of 1, where each split data item has the attributes of the deletion operation data item before the split; S400. Merge and filter multiple version revision records; S401. Initialize merged data: initialize an array mergeDiffData, which is used to store the merged data; S402. Traverse the changed data of the version to be merged and merge it with the first version: compare the current version with the previous version, find the difference, and then merge the difference with the first version; after traversing all versions in turn, merge accordingly; S500. Generate detailed revision records; S600. Visual display, including the following steps: S601. Render the output result in S500, and display the delete and add operations in the interface; S602. Restore the processing of multimedia elements in step S200; S603. According to the index information in the changed data item, the operator and the color and version information corresponding to the operator are obtained and bound, and the user can display the corresponding information by moving the mouse.

2. The method for generating and displaying multi-version document revision records based on jsdiff according to claim 1, characterized in that: In the above S202, the generated unique identifier is formed by the following symbols together: a symbol indicating the type of the self-media element, a placeholder; Each placeholder corresponds to the src attribute, width and controls attributes of a multimedia element.

3. The method for generating and displaying multi-version document revision records based on jsdiff according to claim 1 or 2, characterized in that: The processing of the multimedia element in step S200 in step S602 is to restore the unique identifier to the label corresponding to the corresponding self-media element.

4. The method for generating and displaying multi-version document revision records based on jsdiff according to claim 1 is characterized in that: In the above S303, the deletion operation data item and the splitting into multiple data items of length 1 both have attributes; The properties include: count: the number of characters; removed: whether it is deleted, which is true; added: whether it is added, which is undefined; value: the specific value of the character; source: the original string; index: the index position of the character in the original string; When the deletion operation data item is split into multiple data items of length 1: only count and value in the attributes of the data item of length 1 have changed, and removed, added, source, and index in the attributes of the data item of length 1 are consistent with the corresponding contents in the attributes of the deletion operation data item.

5. The method for generating and displaying multi-version document revision records based on jsdiff according to claim 4 is characterized in that: When the corresponding operation is performed in S402, curtotal is automatically generated by jsdiff; curtotal represents the position index of the modification record of the current document version.

6. The method for generating and displaying multi-version document revision records based on jsdiff according to claim 5 is characterized in that: After the corresponding merging operation is performed in S402, in generating the detailed revision record through S500, the merging operation includes processing the deletion operation; The processing deletion operation is further divided into direct insertion method and segmentation insertion method; When using direct insertion method for deletion operation: ① Compare the current version with the previous version, from the beginning to the end, to find out how many changes have been made. Each change is recorded and represented by a data item; the data item includes the number of changes, the position index value of the change, the number of characters changed, the specific deleted content, and whether the changes have been deleted; ② Every time a modification is found in the comparison, the specific content of the modification is merged into the first version of the manuscript; at the same time, the data items to be merged in the current version are merged into the list generated by the merged data items to form a new list of merged data items; When merging: if the following judgment condition 1 is met - if the index value of the mth data item of the current version to be merged is equal to the index value of the nth data item of the merged version plus the number of modified characters of the nth data item of the merged version, and the n+1th data item of the merged version has the attribute of not being deleted, then "the specific deleted content in the mth data item of the current version to be merged" is directly inserted after the nth data item of the merged version; if the n+1th data item of the merged version has the attribute of being deleted, then continue to search backwards until the n+wth data item that does not meet the judgment condition 1 is found in the merged version, w>1, then "the specific deleted content in the mth data item of the current version to be merged" is directly inserted after the n+w-1th data item of the merged version that meets the judgment condition 1; When using the split insertion method for deletion: The same operation ① and ② as in the above deletion operation is performed by the direct insertion method, the difference is the merging process; When merging: If the following judgment condition 2 is met - if the position index value of the mth data item of the current version to be merged is greater than the position index value of the nth data item of the merged version, and is less than "the index value of the nth data item of the merged version plus the number of modified characters of the nth data item of the merged version", then the "specific merged content in the nth data item of the merged version" will be split according to the split point, which is "the index value of the mth data item of the version to be merged minus the index value of the nth data item of the merged version", and then the "specific deleted content in the mth data item of the current version to be merged" will be inserted into the split point of the nth data item of the merged version.

7. The method for generating and displaying multi-version document revision records based on jsdiff according to claim 6 is characterized in that: After the corresponding merging operation is performed in S402, in generating the detailed revision record through S500, the merging operation also includes processing the adding operation; Processing add operations is also divided into direct insertion method and split insertion method; When adding operations using the direct insertion method: ① Compare the current version with the previous version, from the beginning to the end, to find out how many additions have occurred. Each addition is recorded and represented by a data item; the data item includes the number of additions, the position index value of the addition, the number of modified characters, the specific addition content, and whether the addition has been made; ② Every time a modification is found in the comparison, the specific content of the modification is merged into the first version of the manuscript; at the same time, the data items to be merged in the current version are merged into the list generated by the merged data items to form a new list of merged data items; When merging: If the following judgment condition 3 is met - if the index value of the mth data item of the current version to be merged is equal to the index value of the nth data item of the merged version plus the number of modified characters of the nth data item of the merged version, and the n+1th data item of the merged version has the non-deletion attribute, then directly insert "the specific additions of the mth data item of the current version to be merged" after the nth data item of the merged version; if the n+1th data item of the merged version has the deletion attribute, continue to search backward until the n+wth data item that does not meet the judgment condition 3 is found in the merged version, w>1, then directly insert "the specific additions in the mth data item of the current version to be merged" after the n+w-1th data item of the merged version; When using the split insertion method to add operations: The same operation ① and ② as in the above adding operation is performed by the direct insertion method, except that the operation is merged; When merging: If the following judgment condition 4 is met - if the position index value of the mth data item of the current version to be merged is greater than the position index value of the nth data item of the merged version, and is less than "the index value of the nth data item of the merged version plus the number of modified characters of the nth data item of the merged version", then the "specific merged content of the mth data item of the merged version" will be split according to the split point, which is "the index value of the mth data item of the version to be merged minus the index value of the nth data item of the merged version", and then the "specific added content in the mth data item of the current version to be merged" will be inserted into the split point of the nth data item of the merged version.

8. The method for generating and displaying multi-version document revision records based on jsdiff according to claim 7 is characterized in that: After the corresponding merging operation is performed in S402, in generating a detailed revision record through S500, the merging operation also includes handling special situations; If the index value of the mth data item of the version to be merged is 1, and it is a deletion or addition operation, then "the specific deletion content or specific addition content of the mth data item of the current version" is directly inserted before the first data item of the merged version; If the index value of the mth data item of the version to be merged is greater than the index value of the last data item of the merged version plus the number of modified characters of the last data item of the merged version and it is a deletion or addition operation, then "the specific deletion content or specific addition content of the mth data item of the current version" is inserted directly after the last data item of the merged version.

9. The method for generating and displaying multi-version document revision records based on jsdiff according to claim 7 or 8, characterized in that: After the corresponding merging operation is performed in S402, in generating a detailed revision record through S500, the merging operation also includes revising the index; When the adjacent versions are processing the merge and add operation in S402, if the "specific merged content of the mth data item of the version to be merged" has been inserted into the "corresponding position of the corresponding data item of the merged version", and the "index value of the inserted specific merged content" has been modified, that is, m has been changed to m', but the index value of the n+1th data item of the merged version and the index values ​​of the data items after the n+1th data item of the merged version have not been changed, then the index values ​​of the data items after the n+1th data item of the merged version need to be corrected; The correction method is: "the index value of the nth data item of the corrected merged version" is equal to "the index value of the m'th data item" plus "the number of modified characters of the m'th data item".

Citation Information

Patent Citations

  • Document modification method and device

    CN115048914A

  • Method and apparatus for composing multimedia documents

    US20040194026A1