A method and system for implementing document editing based on rich text

By constructing an operation feature extraction library and a dynamic parsing cycle, and combining density clustering algorithm to identify and handle format conflicts, the problem of format disorder caused by fixed parsing cycles in high-frequency operations of document editing tools is solved, thereby improving user experience and editing efficiency.

CN121168418BActive Publication Date: 2026-02-27SHANGHAI XINGKE TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511336312.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-18
Publication Date
2026-02-27
Estimated Expiration
2045-09-18

AI Technical Summary

Technical Problem

Existing document editing tools, when performing high-frequency editing operations, have fixed parsing cycles that lead to frequent format conflicts. Existing conflict detection methods cannot identify complex nesting and rendering dependencies, resulting in formatting errors and low user efficiency.

Method used

By collecting users' historical editing operation data, an operation feature extraction library is constructed, the parsing cycle is dynamically adjusted, the format conflict type is determined by combining the complexity and frequency of operation instructions, and a density clustering algorithm is used to identify cross-element style conflict chains and formulate targeted processing strategies.

Benefits of technology

It achieves precise matching between parsing cycle and operation data volume, improves the accuracy and efficiency of format conflict identification and processing, reduces repetitive operations, and enhances the smoothness and stability of document editing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121168418B_ABST
    Figure CN121168418B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of rich text editing, and discloses a method and system for realizing document editing based on rich text. The method aims to improve the accuracy and efficiency of format conflict processing in document editing. First, the method collects user historical editing operation data to construct an operation feature extraction library, simultaneously collects real-time editing operation flow, and determines a dynamic analysis period according to the data amount of the real-time operation flow; then, all rich text element operation instructions in the period are captured, the average complexity of the operation instructions is calculated and taken as an analysis accuracy threshold, the operation instructions are subjected to conflict detection in combination with the operation feature extraction library, and abnormal operation nodes with format conflict risks are marked; when the abnormal operation nodes are detected, the element nesting depth and rendering dependency relationship of each node are extracted to determine the format conflict type, and after it is confirmed that a conflict exists, an initial layout risk value is calculated based on the conflict operation frequency, thereby providing guarantee for the format stability of document editing.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of rich text editing, in particular to a method and system for realizing document editing based on rich text. BACKGROUND

[0002] With the rapid development of Internet technology, document editing tools are increasingly widely used in office collaboration, education and teaching, content creation and other fields, and users' demand for the richness of document editing functions, the smoothness of operation and the stability of format is constantly increasing. As the core carrier of document editing, rich text can support the mixed layout of various elements such as text, pictures, tables and formulas. However, due to differences in user operation habits, cross interference of operation instructions during multi-user collaborative editing, and adaptation differences of rich text rendering rules on different terminal devices, format conflict phenomena frequently occur.

[0003] Most document editing tools use a static parsing mechanism to process rich text operation instructions, i.e., a fixed parsing period is set to process user operations in batches. This approach can meet the basic needs when the user operation frequency is low, but when the user performs high-frequency editing operations, such as quickly inserting multiple complex elements and frequently modifying paragraph styles, the fixed parsing period cannot match the data volume changes of real-time operation flow, which may cause parsing delay and further lead to operation instruction accumulation, increasing the risk of format conflicts. At the same time, existing conflict detection methods mostly rely on pre-set format rule libraries, which can only identify known types of format conflicts and lack effective identification capabilities for new conflicts caused by excessive element nesting depth and complex rendering dependencies. For example, when the user nests multiple layers of text boxes in a table cell and sets different font styles, existing tools often cannot accurately determine the inheritance relationship between the styles of various elements, resulting in font disorder and alignment abnormalities in the final rendering result.

[0004] In the format conflict processing link, existing technologies usually directly use a unified repair strategy, such as reverting to the last normal layout state, after detecting a conflict. This approach does not consider the frequency of conflict operations and the clustering characteristics of conflict nodes, which may cause effective editing operations to be mistakenly deleted, reducing user editing efficiency. At the same time, for cross-element style conflict chains, i.e., a chain of conflicts formed between multiple elements due to style inheritance or layout constraints, existing technologies lack effective identification means and can only handle individual conflict nodes one by one, which cannot fundamentally solve the problem of conflict spread, affecting the stability of document layout and increasing the user's repeated operation cost, thereby restricting the improvement of user experience of document editing tools. SUMMARY

[0005] The present application aims to provide a method for realizing document editing based on rich text to solve the problems raised in the background.

[0006] To achieve the above object, the application provides a method for realizing document editing based on rich text, which comprises the following steps:

[0007] collecting user historical editing operation data to construct an operation feature extraction library, collecting real-time editing operation flow, and determining a dynamic analysis period according to the data volume of the real-time editing operation flow;

[0008] capturing all rich text element operation instructions within the dynamic analysis period and calculating the average complexity of the operation instructions, taking the average complexity of the operation instructions as an analysis accuracy threshold, performing conflict detection on the rich text element operation instructions according to the analysis accuracy threshold and the operation feature extraction library, and marking abnormal operation nodes with format conflict risks;

[0009] when detecting the abnormal operation nodes, extracting the element nesting depth and rendering dependency relationship of each abnormal operation node, determining the format conflict type according to the element nesting depth and rendering dependency relationship, and calculating an initial layout risk value based on the conflict operation frequency when confirming the existence of format conflicts;

[0010] analyzing the format conflict nodes and identifying element types, style inheritance chains and layout constraint conditions, converting the layout constraint conditions into feature vectors, performing clustering analysis on all format conflict nodes based on a density clustering algorithm, and determining whether there is a cross-element style conflict chain according to the clustering results.

[0011] Preferably, when determining the dynamic analysis period according to the data volume of the real-time editing operation flow, the method comprises the following steps:

[0012] comparing the data volume with a first operation volume threshold and a second operation volume threshold respectively, and determining the dynamic analysis period according to the comparison result; the first operation volume threshold is smaller than the second operation volume threshold;

[0013] when the data volume is smaller than or equal to the first operation volume threshold, the dynamic analysis period is determined as a long-period analysis mode; when the data volume is greater than the first operation volume threshold and smaller than or equal to the second operation volume threshold, the dynamic analysis period is determined as a medium-period analysis mode; and when the data volume is greater than the second operation volume threshold, the dynamic analysis period is determined as a short-period analysis mode; the analysis time length of the long-period analysis mode is greater than that of the medium-period analysis mode, and the analysis time length of the medium-period analysis mode is greater than that of the short-period analysis mode.

[0014] Preferably, when performing conflict detection on the rich text element operation instructions according to the analysis accuracy threshold and the operation feature extraction library, the method comprises the following steps:

[0015] matching an element type of each rich-text element operation instruction with the operation feature extraction library, and comparing a rendering complexity of each rich-text element operation instruction with the operation instruction average complexity;

[0016] when the rendering complexity of the rich-text element operation instruction exceeds the operation instruction average complexity setting multiple, marking the operation instruction as an abnormal operation node;

[0017] when the element type of the rich-text element operation instruction is not registered in the operation feature extraction library, marking the operation instruction as an abnormal operation node.

[0018] Preferably, when the element nesting depth and the rendering dependency relationship determine the format conflict type, it includes:

[0019] when the element nesting depth of the abnormal operation node exceeds the depth threshold of the same type of element in the operation feature extraction library, it is determined that the node has a structural format conflict;

[0020] when the rendering dependency relationship of the abnormal operation node forms a closed loop reference chain, it is determined that the node has a circular dependency format conflict.

[0021] Preferably, when calculating the initial layout risk value based on the conflict operation frequency, it includes:

[0022] accumulate the number of times of the same conflict type operation as the conflict operation frequency, extract the reference weight parameter of the corresponding conflict type in the operation feature extraction library, and calculate the initial layout risk value according to the deviation amplitude of the conflict operation frequency and the reference weight parameter.

[0023] Preferably, when performing clustering analysis on all format conflict nodes based on the density-based clustering algorithm, it includes:

[0024] the layout constraint condition includes a positioning coordinate offset and an adjacent element spacing change rate;

[0025] determine the clustering boundary range through the neighborhood radius parameter, and set the minimum neighborhood node number as the initial value;

[0026] take the feature vector of each format conflict node as a space coordinate point, scan all coordinate points, and select the coordinate points with the number of neighborhood coordinate points reaching the minimum neighborhood node number as core nodes;

[0027] start from the core node to diffuse the association, if the neighborhood coordinate point is a core node, expand the clustering cluster, if the neighborhood coordinate point is a boundary node, return to the current clustering cluster, and mark the coordinate point that cannot be classified as an isolated conflict node;

[0028] When there is a cluster containing at least two format conflict nodes and a style inheritance relationship between the nodes, it is determined that the cluster forms a cross-element style conflict chain.

[0029] Preferably, when it is determined that there is a cross-element style conflict chain, the step of determining the layout adjustment coefficient according to the characteristics of the cross-element style conflict chain to modify the initial layout risk value comprises:

[0030] The characteristics of the cross-element style conflict chain include a conflict chain length and a conflict element type combination mode.

[0031] The characteristics of the cross-element style conflict chain are matched with a historical conflict solution library in terms of similarity, and the historical conflict solution library stores a mapping relationship between historical conflict chain characteristics and historical layout adjustment coefficients.

[0032] A similarity value of the current conflict chain characteristics and the historical conflict chain characteristics is calculated.

[0033] When there is a matching solution with a similarity value exceeding a set threshold, a historical layout adjustment coefficient corresponding to the maximum similarity value is used to modify the initial layout risk value.

[0034] When all similarity values are lower than the set threshold, a layout adjustment coefficient is generated according to the conflict chain length to modify the initial layout risk value.

[0035] Preferably, the step of generating the layout adjustment coefficient according to the conflict chain length comprises:

[0036] The layout adjustment coefficient has a positive correlation growth trend with the conflict chain length, and the numerical interval of the layout adjustment coefficient is greater than 1 and does not exceed 1.5.

[0037] Preferably, the step of adjusting the next dynamic analysis period according to the modified layout risk value comprises:

[0038] The modified layout risk value is input into a period compression coefficient calculation model, and the length of the next dynamic analysis period is shortened according to the period compression coefficient, the period compression coefficient has a negative correlation with the modified layout risk value, and the value interval of the period compression coefficient is 0.5 to 1.

[0039] Preferably, the present application further comprises a system for realizing document editing based on rich text, which comprises a memory, a processor, and a computer program stored in the memory and running on the processor, and the processor realizes the steps of the above-mentioned method for realizing document editing based on rich text when executing the computer program.

[0040] Compared with the prior art, the present application has the following beneficial effects:

[0041] The method for realizing document editing based on rich text constructs an operation feature extraction library by collecting user historical editing operation data, and determines a dynamic analysis period according to the data amount of a real-time editing operation flow, so as to realize accurate matching of the analysis period and the operation data amount. When the user performs a low-frequency editing operation, the dynamic analysis period can be appropriately extended to reduce unnecessary analysis resource consumption; when the user performs a high-frequency operation with a large order of magnitude, the analysis period can be automatically shortened to ensure that the operation instruction can be processed in time, avoid analysis delay caused by instruction accumulation, reduce the probability of format conflict from the source, and improve the smoothness of the rich text editing process.

[0042] In the conflict detection link, the method takes the average complexity of all rich text element operation instructions in the dynamic analysis period as the analysis accuracy rate threshold, and combines the operation feature extraction library to perform conflict detection, so as to significantly improve the accuracy of conflict identification. The average complexity of the operation instruction reflects the overall complexity of the current editing operation, and the threshold can dynamically adjust the conflict detection standard according to the operation difficulty. For simple operations, a lower accuracy threshold can meet the detection requirements, avoiding excessive detection; for complex operations such as multi-element nesting and batch style modification, by increasing the accuracy threshold and combining various complex operation conflict patterns stored in the historical operation feature library, potential format conflict risks caused by abnormal element nesting depth and disordered rendering dependency can be effectively identified, and abnormal operation nodes can be accurately marked, solving the problem that the static threshold in the prior art cannot adapt to operations with different complexities and lacks new conflict identification capabilities.

[0043] When the abnormal operation node is detected, the method determines the format conflict type by extracting the element nesting depth and rendering dependency of the abnormal node, and calculates an initial layout risk value based on the conflict operation frequency, so as to provide more targeted basis for conflict processing. Different types of format conflicts have different degrees of influence on document layout, for example, text font style conflicts have relatively small influence on overall layout, while table structure and text box layout conflicts may cause the entire page layout to be disordered, and the severity of the conflict can be distinguished by determining the conflict type; at the same time, the conflict operation frequency can reflect the probability of the occurrence of this type of conflict, and high-frequency conflicts often mean that there are common operation loopholes or rule defects, and the initial layout risk value calculated based on this can help the subsequent processing link to prioritize solving high-risk conflicts, avoid ignoring critical issues due to blindly processing low-risk conflicts, and improve the efficiency and rationality of conflict processing.

[0044] In the aspect of conflict node analysis and processing, the method can effectively identify the cross-element style conflict chain by analyzing the element type, style inheritance chain and layout constraint condition of the format conflict node, and converting the layout constraint condition into a feature vector, and using the density clustering algorithm to perform clustering analysis on all conflict nodes. The density clustering algorithm can aggregate conflict nodes with the same or similar conflict mode, style inheritance or layout constraint association into a class according to the similarity of the feature vector of the conflict node, and further discover the chain conflict relationship formed between multiple elements. By identifying the cross-element style conflict chain, the overall repair strategy can be developed from the root of the conflict, rather than processing individual conflict nodes one by one, avoiding the spread of conflicts, reducing the repeated operation of the user, while ensuring the stability of the document layout, and improving the user experience in the document editing process. In addition, the construction of the operation feature extraction library can be continuously optimized with the accumulation of user editing operation data, so as to continuously improve the accuracy of conflict detection and the adaptability of conflict processing, enhance the expansibility and adaptability of the method, and better meet the document editing needs of different users in different scenarios. BRIEF DESCRIPTION OF DRAWINGS

[0045] Figure 1 The working principle diagram of the method for realizing document editing based on rich text according to the present application;

[0046] Figure 2 The method flow chart for determining the dynamic analysis period;

[0047] Figure 3 The method flow chart for determining the format conflict type;

[0048] Figure 4 The method flow chart for clustering analysis based on the density clustering algorithm. DETAILED DESCRIPTION

[0049] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0050] Please refer to Figure 1 The present application provides a method and system for realizing document editing based on rich text, which comprises:

[0051] The user historical editing operation data is collected, an operation feature extraction library is constructed, feature mining is performed on the massive historical editing operation data through a large model call, typical features of different rich text element operation instructions, common nesting depth thresholds and rendering dependency patterns are extracted, the comprehensiveness and accuracy of the feature dimensions in the operation feature extraction library are improved, and more rich feature references are provided for subsequent conflict detection. The library records the features of various rich text element operation instructions, common nesting depth thresholds, rendering dependency patterns and historical conflict type weights. In the real-time editing process, the system captures the user operation flow and dynamically adjusts the analysis period according to the data volume of the operation flow. In each analysis period, the average complexity of all operation instructions in the period is calculated and used as the analysis accuracy threshold. Each rich text element operation instruction in the period is matched with the operation feature extraction library, and conflict detection is performed to mark abnormal operation nodes at risk. For the marked abnormal nodes, the element nesting depth and rendering dependency relationship are further analyzed to determine the specific format conflict type. When the combination mode of the element nesting depth and the rendering dependency relationship is complex, historical conflict type cases are matched through a large model call to assist in quickly determining structural format conflicts or circular dependency format conflicts, improving the efficiency of conflict type determination, especially suitable for new nesting structures or complex dependency relationship scenarios. Once a conflict is confirmed, an initial layout risk value is calculated based on the conflict operation frequency. The system analyzes the element type, style inheritance chain and layout constraint condition of the conflict node, converts the layout constraint condition into a feature vector, and uses a density clustering algorithm to cluster all conflict nodes for analysis to determine whether there is a cross-element style conflict chain.

[0052] Embodiment 1: see Figure 2 In the determination process of the dynamic analysis period, the system continuously monitors the data volume of the user's real-time editing operation flow. This data volume is not a single indicator, but a comprehensive consideration of the number of operation instructions and the amount of information they carry (usually estimated in byte size). The system internally presets two key operation volume thresholds: a first operation volume threshold and a second operation volume threshold, where the first operation volume threshold is less than the second operation volume threshold. These two thresholds are based on statistical analysis of historical user operation data, reflecting typical data volume dividing points under different editing intensities. The system compares the current operation flow data volume obtained through real-time collection and calculation with the two preset thresholds in real time, and dynamically selects and applies the corresponding analysis period mode according to the comparison result.

[0053] Consider a scenario where a user is editing a rich text document. In the initial stage, the user can only be doing simple text input, such as typing characters in succession. At this time, the system captures an operation stream mainly composed of successive insertText instructions, each carrying a small amount of data (mainly the inserted character code) and generated at a relatively stable frequency. The system calculates the accumulated operation stream data volume in this time period. Suppose that within a certain time window, the accumulated data volume is calculated to be below a preset first operation volume threshold. The system determines that the current editing activity is in a low-intensity state based on this. In this case, the system chooses to enable a long-period parsing mode. The long-period parsing mode means that the system does not immediately process every subtle operation, but sets a relatively long waiting and accumulation time window. For example, the system can set to start a complete parsing process only after accumulating several seconds of user operations or reaching a larger operation instruction buffer queue. The advantage of this mode is that it significantly reduces the computational resource overhead brought by frequent parsing, especially when the user is doing a lot of continuous input but of low complexity, avoiding unnecessary performance loss. System resources can be more efficiently allocated to other background tasks or to maintain the smooth response of the user interface. The long-period mode is suitable for the stage when the user focuses on content creation rather than complex format arrangement.

[0054] As the editing progresses, the user's operations can become more complex. For example, the user starts to insert pictures, tables, or apply multiple styles to the text (such as bold, italic, change font color, adjust paragraph indentation, etc.). The operation instruction for inserting a picture not only contains the identifier or data of the picture resource, but also may contain its size, position, wrapping method, etc. The data volume of a single instruction is much larger than that of a pure text insertion instruction. Creating a table involves defining row, column, cell style, etc., which also generates a large data volume of operation instruction stream. When the user continuously performs such operations, the real-time operation stream data volume monitored by the system begins to rise. At a certain point in time, the system calculates that the accumulated data volume has exceeded the first operation volume threshold but has not yet reached the second operation volume threshold. At this time, the system determines that the editing activity enters a medium intensity. The system immediately switches from the long-period parsing mode to the medium-period parsing mode. The medium-period parsing mode shortens the time interval between two complete parses or reduces the operation instruction buffer volume required to trigger parsing. It seeks to balance between parsing real-time and system resource consumption. The system more frequently "checks" the user's operation sequence so that it can more timely discover potential format problems that may be introduced by complex operations, but without the heavy computational burden that real-time processing brings. This mode adapts to the editing rhythm of the user when doing regular format setting and content organization.

[0055] Further assume the case where the user performs high-intensity editing operations, for example, the user copies a piece of content containing complex formatting (such as nested lists, multi-level headings, inline styles, floating elements) from other documents or web pages and pastes it into the currently edited rich text document. The paste operation can instantly generate a large number of operation instructions that need to reconstruct the complex structure and style of the source content, and each instruction can carry a large amount of attribute information. Alternatively, the user performs a batch operation, such as selecting all the text of a certain style in the document and uniformly modifying its font and color, which also generates a dense and large amount of operation instruction stream. When the system monitors that the real-time operation stream data volume increases sharply in a short time and quickly exceeds the preset second operation volume threshold, the system immediately determines that it is currently in a high-intensity editing state. The system immediately enables the short-period parsing mode. In the short-period mode, the system significantly compresses the parsing period. It can process operation instructions in near real time, or start the parsing process after accumulating a very small amount of new operation instructions. For example, the system can perform local or fast parsing immediately after the user performs a few key operations, or even after a single operation that can trigger complex changes. The purpose of this mode is to minimize the accumulation of operation instructions, ensure that format conflicts and rendering abnormalities that may be caused by dense or complex operations can be quickly captured and responded to, and prevent small problems from accumulating and spreading into global errors that are difficult to handle. The short-period mode is necessary to protect the user from large-scale and high-complexity editing.

[0056] During the entire editing process, the system does not fix on a certain mode, but dynamically switches between the above three modes as the user's operation intensity changes. For example, when the user ends the batch paste operation and turns to small-range text proofreading, the operation stream data volume will quickly decrease. The system detects that the data volume falls below the first operation volume threshold, and automatically switches the parsing mode from the short period to the long period. This dynamic adjustment mechanism ensures that system resources are always used efficiently, ensuring the stability and accuracy of rich text editing while providing a smooth user experience. The system's monitoring of the operation stream data volume is continuous, and the comparison of the threshold and the switching decision of the parsing mode are also updated in real time, so that the entire editing environment can intelligently adapt to the user's changing operation behavior.

[0057] Embodiment 2: see Figure 3In the implementation of the conflict detection, the system first conducts an overall analysis of all the rich text element operation instructions captured in a dynamic parsing cycle. The system calculates the average complexity of these operation instructions. The complexity of an operation instruction is a comprehensive measure that takes into account the number of Document Object Model nodes that the instruction operates on, the number of style attributes that the instruction needs to modify or set, and the depth of the document structure tree that the instruction can cause to change. For example, a simple text insertion instruction has a low complexity because it usually involves only the update of one text node and a small amount of style inheritance. In contrast, an instruction that inserts a complex table has a high complexity because it needs to create multiple nested table row and cell elements and apply a series of border, background, alignment, and other style attributes to these elements, possibly affecting the layout flow of the surrounding content. The system aggregates the individual complexities of all the instructions in the cycle and calculates the arithmetic mean, which is established as the accuracy threshold for the parsing process of the cycle. This threshold represents the system's expectation of the "typical" operation complexity in the cycle and will serve as the benchmark for the screening of subsequent individual instructions.

[0058] The system then iterates through each rich text element operation instruction in the cycle and conducts two checks on it. The first check is for element type matching. The system compares the element type that the current instruction operates on or creates (e.g., Paragraph, image, The history element types registered in the operation feature extraction library are compared with the element types in the current document (e.g., in-line containers, etc.). The operation feature extraction library is built by continuously collecting user history editing operation data during system operation, and records all element types and their common operation patterns that have occurred in the past. For example, in a system mainly used for text editing, and This would be the registration type most commonly found in libraries. If the system, while processing an instruction, finds that the target element type is one that it does not recognize (e.g., a custom, rarely used <custom-widget>If the system cannot find any matching record in the operation feature extraction library, i.e. the type is a new type that the system has never or rarely handled, the system will immediately mark the instruction as an abnormal operation node. This marking is because the element of unknown type can introduce unpredictable rendering behavior or format conflicts.

[0059] The second check is on the rendering complexity of the instruction itself. The system calculates the individual rendering complexity of the current instruction and compares it with the average complexity of the operation instructions in the current period. The system has a threshold of multiple (e.g. 2 or 3) set internally. If the individual rendering complexity of an operation instruction exceeds the set multiple of the average complexity of the operation instructions in the current period, the instruction will be marked as an abnormal operation node. For example, in a period dominated by text operations, the average complexity is low. At this time, the user suddenly performs an operation to insert a complex visualization chart component containing a large amount of JavaScript interaction logic and data binding. The complexity of the inserted instruction (involving the creation of multiple nested div, svg elements, binding events, initializing data, etc.) will be much higher than the average complexity of the current period, triggering an abnormal marking. Conversely, in a period of intensive user adjustment of table styles, the average complexity is already high. At this time, the insertion of a complex chart may not significantly deviate from the average, and may not be marked.

[0060] For the marked abnormal operation nodes, the system will perform a deeper diagnosis to analyze the element nesting depth and rendering dependency. The element nesting depth refers to the level of the element in the Document Object Model tree. The system queries the historical nesting depth records of the type of element from the operation feature extraction library and obtains a statistical depth threshold (e.g. 5). If the nesting depth of the element exceeds the statistical depth threshold, the system will mark the instruction as an abnormal operation node. For example, in a period dominated by text operations, the average nesting depth is low. At this time, the user suddenly performs an operation to insert a complex visualization chart component containing a large amount of JavaScript interaction logic and data binding. The nesting depth of the inserted instruction (involving the creation of multiple nested div, svg elements, binding events, initializing data, etc.) will be much higher than the average nesting depth of the current period, triggering an abnormal marking. Elements are generally less deep than may be nested deeper). The system measures the actual nesting depth of the current abnormal node. If it finds that the nesting depth of this node exceeds the depth threshold recorded in the library for the same type of element, the system determines that the node has a structural format conflict. Such over-deep nesting can cause CSS style inheritance to become complex and uncontrollable, or cause DOM query and update performance to decline, thereby triggering rendering layout errors. For example, a An element is abnormally nested more than 10 levels, far exceeding the average of 3 levels in the database, which will be judged as a structural conflict.

[0061] Rendering dependencies describe how an element depends on its parent, child, sibling elements, or external resources (such as style sheets and font files) during rendering. The system analyzes the element's style rules (e.g., via `window.getComputedStyle`) and resource references (e.g., ... src <link> The system constructs its dependency graph using the `href` attribute of the element and DOM access paths within the script. It then checks for closed loops within this dependency graph. For example, the layout height of element A might depend on the rendering height of its child element B, while the width of element B might indirectly depend on the width of element A via CSS calculations. If the system detects such a circular reference chain, it determines that the abnormal operation node has a circular dependency format conflict. This circular dependency can cause the browser's rendering engine to be unable to determine the final style and layout values, resulting in rendering errors or layout jitter.

[0062] Example 3: See Figure 4 Upon confirming a formatting conflict, the system initiates a quantitative evaluation process. This process first accumulates the number of occurrences of each identified specific conflict type within a time window, i.e., the conflict operation frequency. This frequency reflects the activity and concentration of that type of conflict in recent editing activities. The system then accesses an operation feature extraction library, which stores baseline weight parameters for various conflicts derived from long-term historical data analysis. This weight parameter is an empirical value, representing the average level of the potential impact of a specific conflict type on the overall document layout stability. For example, a conflict affecting text flow layout may have a higher baseline weight than a conflict that only affects font color.

[0063] The system calculates an initial layout risk value based on the deviation between the frequency of conflict operations and the baseline weight parameters through weighted calculation. This calculation process aims to capture the degree to which current conflict behavior deviates from historical norms. A larger deviation indicates a more abnormal current conflict pattern, and its weight in the weighted calculation increases accordingly, leading to a higher initial layout risk value. This risk value provides a preliminary numerical estimate of the instability of the current layout state. The initial risk value can be calculated as follows:

[0064]

[0065] in: This represents the calculated initial layout risk value. This represents the total number of different conflict types identified during the current analysis period. Indicates the first feature obtained from the operation feature extraction library. Baseline weight parameter of class conflict. Represents the observed frequency of the i-th class conflict in the current period. Actual frequency of the i-th class conflict. Represents the statistical frequency of the i-th class conflict based on historical data. Long-term average of the frequency of the i-th class conflict. Represents the statistical frequency of the i-th class conflict based on historical data. Long-term standard deviation of the frequency of the i-th class conflict, used to measure the degree of dispersion of historical frequency. is a system preset scaling coefficient, used to adjust the influence strength of deviation amplitude on the final risk value.

[0066] The system performs a more detailed analysis on all nodes marked as having format conflicts. This analysis aims to deeply understand the internal characteristics and mutual relationships of each conflict node. The system identifies the specific element types of each conflict node, such as paragraphs, images, tables, or custom components. The system traces the style inheritance chain of each node, clearly identifying which ancestor elements its style attributes are inherited from, and whether there are any cascading style sheet overrides or conflicts. The system extracts the layout constraint conditions of each node, which usually include the offset of positioning coordinates and the variation rate of spacing with its adjacent elements. These layout constraint conditions are key quantitative indicators describing the spatial characteristics of conflicts.

[0067] The system converts the layout constraint conditions of each conflict node into a multi-dimensional feature vector, which maps the abstract layout problem to a calculable spatial coordinate. Based on these feature vectors, the system uses a density clustering algorithm to perform clustering analysis on all format conflict nodes. This algorithm requires two key parameters to be preset: one is the neighborhood radius parameter, which defines the distance threshold in the feature space to determine whether two points are adjacent, thereby determining the boundary range of clustering; the other is the minimum neighborhood node number, which is used as an initial value to determine whether a point can become the core of a condensed class.

[0068] The execution process of the algorithm is as follows: the algorithm takes the feature vector of each format conflict node as a coordinate point in a multi-dimensional space. The system scans all coordinate points in the space and filters out those points that contain the number of coordinate points within their neighborhood radius reaching or exceeding the minimum neighborhood node number. These points are identified as core nodes. The clustering process starts from these core nodes and spreads through density accessibility. If a core node's neighborhood radius contains points that are also core nodes, they will be included in the current cluster and the boundaries of the cluster will be further expanded. If a core node's neighborhood radius contains points that are not core nodes (usually referred to as boundary nodes), they will be included in the cluster where the current core node is located, but the expansion will not be centered on this boundary node. Those coordinate points that cannot be associated through any core node, i.e., are not within the neighborhood of any core node, are marked as isolated conflict nodes, which represent individual and possibly independent layout problems.

[0069] The system not only checks the number of conflict nodes contained in the cluster, but more importantly analyzes the association between nodes. If the system finds that there is a cluster containing at least two format conflict nodes and that there is a direct or indirect style inheritance relationship between these nodes through analysis of the style inheritance chain, it is determined that the cluster forms a cross-element style conflict chain. The discovery of such a conflict chain means that a local format problem may affect a series of associated elements through style inheritance relationships, revealing potential problem propagation paths.

[0070] Embodiment 4: After identifying the cross-element style conflict chain, the system enters the risk correction phase, the core task of which is to fine-tune the initial layout risk value calculated previously according to the specific characteristics of the conflict chain. The characteristics of the cross-element style conflict chain are mainly described from two dimensions: conflict chain length and conflict element type combination pattern. Conflict chain length is a quantitative indicator that refers to the total number of interrelated conflict nodes contained in the conflict chain. Conflict element type combination pattern is a qualitative or patternized description that records the specific arrangement and combination sequence of the element types to which the conflict nodes belong in the chain. For example, a conflict chain may present the pattern of "header element -> paragraph element -> image element", while another may present the pattern of "table element -> table cell element -> inline text element".

[0071] The system matches these extracted feature data from the current conflict chain with the records stored in the historical conflict resolution library. The historical conflict resolution library is a growing repository that systematically stores the case data of various cross-element style conflict chains encountered and successfully resolved in past editing sessions. Each historical record contains two key parts: one is the feature information of the historical conflict chain, including its chain length and element type combination pattern at that time; the other is the historical typesetting adjustment coefficient that the historical case has proven to be effective, which is a multiplier factor for modifying the risk value. There is a clear mapping relationship between the historical typesetting adjustment coefficient and the historical conflict chain features.

[0072] The system starts the matching algorithm and calculates the similarity value between the current conflict chain features and each historical conflict chain feature in the library. This similarity calculation is a comprehensive process that considers both the chain length difference and the pattern matching degree. For chain length, the system calculates the relative difference between the current chain length and the historical chain length. For the element type combination pattern, the system uses a sequence alignment algorithm to analyze the degree of fit between the current pattern and the historical pattern in terms of element type category, appearance order, and adjacent relationship. Finally, a comprehensive similarity value between zero and one is output, with a higher value representing a higher degree of matching.

[0073] The system internally presets a similarity threshold to determine whether the matching is successful. The system traverses the entire historical conflict resolution library to find all matching solutions with a similarity value exceeding the set threshold. If such matching solutions exist, the system selects the historical record with the highest similarity value from all matching solutions. Subsequently, the system uses the historical typesetting adjustment coefficient corresponding to this best matching record to directly modify the initial typesetting risk value. This modification is essentially an analogical reasoning based on historical experience, assuming that in highly similar conflict situations, past effective adjustment strategies can also produce comparable results in the current situation.

[0074] If the system completes the traversal of the entire historical conflict resolution library and finds that the similarity values of all historical records with the current conflict chain features are below the preset threshold, i.e., no sufficiently similar historical cases can be found for reference, the system will enable the backup strategy. In this case, the system generates a new typesetting adjustment coefficient based on the conflict chain length of the current conflict chain through built-in algorithm rules. This generation logic follows a basic principle that the conflict chain length is positively correlated with the typesetting adjustment coefficient. The longer the chain length, the more likely the potential impact is widespread, and the system therefore assigns a larger adjustment coefficient, thereby making a more substantial upward modification to the initial typesetting risk value. The generated typesetting adjustment coefficient is strictly limited within a numerical interval, as shown in Table 1.

[0075] Table 1: Historical conflict resolution library records.

[0076]

[0077] For example, the current system identifies a conflict chain characterized by a chain length of 4 and an element type combination pattern of "Div->Paragraph->Image->Caption". The system matches this feature with the library records shown in the above table. After calculation, the similarity value with record HC-004 is the highest and exceeds the preset threshold. The system thus directly adopts the historical layout adjustment coefficient 1.22 stored in record HC-004 to correct the initial layout risk value. For another example, a brand-new conflict chain appears, characterized by a chain length of 5 but an element type combination pattern of "CustomWidget->Canvas->SVG", which does not exist in the historical library with a highly similar record, and all the similarity values calculated by matching are lower than the threshold. The system then generates a layout adjustment coefficient according to its chain length of 5 through the built-in rule, which will be within the coefficient range of similar length historical records (such as 1.28 of HC-002 and 1.22 of HC-004), for example, 1.25, and corrects the initial risk value with this value.

[0078] After obtaining the corrected layout risk value, the system starts the parsing cycle adjustment mechanism. This mechanism aims to dynamically optimize the response frequency of subsequent conflict detection according to the evaluation results of the current layout risk. The system inputs the corrected layout risk value into a preset cycle compression coefficient calculation model. This model is a function mapping relationship, whose input is the layout risk value and output is a cycle compression coefficient between 0.5 and 1. The design of this model follows a core principle: the corrected layout risk value and the output cycle compression coefficient present a negative correlation. This means that when the input layout risk value is higher, the model output cycle compression coefficient is smaller; on the contrary, when the layout risk value is lower, the output cycle compression coefficient is larger, tending to 1. This negative correlation design ensures that the system can take a more active monitoring strategy in a high-risk state.

[0079] The cycle compression coefficient calculation model internally defines the mapping rule between the risk value and the compression coefficient. This rule ensures that the compression coefficient decreases smoothly as the risk value increases. When the risk value is at the lower limit of its possible range, the compression coefficient is close to or equal to 1, indicating that there is almost no need to compress the parsing duration of the next cycle. As the risk value gradually rises, the compression coefficient starts to decrease from 1. The higher the risk value, the greater the amplitude of the compression coefficient decrease. The constraint condition of the model strictly limits the output value to be within the closed interval of 0.5 to 1. Even in the face of extremely high layout risk values, the compression coefficient will not be lower than 0.5, preventing the system from being overwhelmed or the parsing quality from declining due to too short cycles. Similarly, the compression coefficient corresponding to the minimum risk value will not exceed 1, ensuring that the adjustment only compresses when necessary.

[0080] After the system obtains the period compression coefficient calculated by the model, it applies it to determine the actual length of the next dynamic analysis period. The system internally maintains a reference analysis period length, which is the default value adopted by the system in the initial state or low-risk state, for example, the length corresponding to the medium-period analysis mode. The system multiplies this reference analysis period length by the calculated period compression coefficient to obtain the actual set length of the next dynamic analysis period. Since the period compression coefficient is less than or equal to 1, the calculated actual length must be less than or equal to the reference length, achieving the shortening of the period. For example, assuming that the current reference analysis period length of the system is T seconds. If the calculated period compression coefficient is 0.8, then the length of the next analysis period will be set to 0.8*T seconds. If the period compression coefficient is 0.6, then the next period length is set to 0.6*T seconds. If the risk value is very low, the compression coefficient is 1, and the next period remains the reference length T seconds. This calculation method intuitively quantifies risk as a regulation of time resources.

[0081] The direct impact of this adjustment is that the frequency at which the system performs analysis and conflict detection changes. Higher revision layout risk values result in smaller period compression coefficients, which in turn result in shorter lengths of the next analysis period. Shorter analysis periods mean that the system will start the analysis process more frequently. For example, originally, a complete analysis is performed every 5 seconds (T=5), and in a high-risk state, the period may be compressed to every 3 seconds (0.65=3) or even every 2.5 seconds (0.55=2.5). The increase in frequency allows the system to more closely monitor the user's operation flow, capture newly generated operation instructions more quickly, and identify, mark, and re-evaluate the risk of potential problems before they spread or trigger more serious chain reactions. This rapid response capability is crucial for containing the deterioration of format problems in high-risk states.

[0082] When the system enters the shortened new analysis period, its operation flow is consistent with the previous one: capture the operation flow within the period, calculate the average complexity of operation instructions as a threshold, perform conflict detection, mark abnormal nodes, determine the conflict type, calculate the new initial layout risk value, perform clustering analysis to determine the conflict chain, and revise the layout risk value according to the new conflict chain characteristics. This revised new risk value will be input again into the period compression coefficient calculation model to determine the length of the next analysis period. This cycle continues, forming a closed-loop dynamic adjustment system.

[0083] If the user's subsequent operations tend to be simple, or the previous risk control measures take effect, the newly calculated typesetting risk value can decrease. According to the negative correlation model, the decreased risk value will cause the calculated cycle compression coefficient to increase (approach 1). The increased compression coefficient causes the length of the next analysis cycle to be extended relative to the compressed cycle before (although it can still be shorter than the baseline length). For example, from the compressed 2.5-second cycle, it is extended to a 3-second or 3.5-second cycle. This reflects that the system appropriately relaxes the monitoring frequency after perceiving the risk level to decrease, in order to save computing resources. Conversely, if the risk continues or increases, the cycle will remain compressed or be shortened further. This dynamic scaling feature enables the system to intelligently balance the risk prevention and control needs and resource utilization efficiency, and always adapt the analysis frequency to the actual stability needs of the current document.

[0084] It should be noted that the relational terms herein, such as first and second, are used solely to distinguish one from another entity or action, without necessarily requiring or implying any such actual relationship or order between such entities or actions. Moreover, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus.

[0085] While the embodiments of the application have been illustrated and described, it will be understood by those skilled in the art that various changes, modifications, substitutions, and alterations can be made therein without departing from the spirit and scope of the application, which is defined by the following claims and their equivalents. Table,

Claims

1. A method for document editing based on rich text, characterized in that, include: Collect historical user editing operation data to construct an operation feature extraction library, collect real-time editing operation streams, and determine the dynamic parsing cycle based on the data volume of the real-time editing operation streams; Capture all rich text element operation instructions within the dynamic parsing cycle and calculate the average complexity of the operation instructions. Use the average complexity of the operation instructions as the parsing accuracy threshold. Based on the parsing accuracy threshold and the operation feature extraction library, perform conflict detection on the rich text element operation instructions and mark abnormal operation nodes with format conflict risks. When an abnormal operation node is detected, the element nesting depth and rendering dependency of each abnormal operation node are extracted. The format conflict type is determined based on the element nesting depth and rendering dependency. When a format conflict is confirmed, the initial layout risk value is calculated based on the frequency of conflict operations. The format conflict nodes are parsed and element types, style inheritance chains and layout constraints are identified. The layout constraints are converted into feature vectors. All format conflict nodes are clustered based on density clustering algorithm. Based on the clustering results, it is determined whether there is a cross-element style conflict chain.

2. The method for document editing based on rich text according to claim 1, characterized in that, When determining the dynamic parsing cycle based on the data volume of the real-time editing operation stream, the following are included: The data volume is compared with a first operation volume threshold and a second operation volume threshold, respectively, and the dynamic parsing period is determined based on the comparison results; the first operation volume threshold is less than the second operation volume threshold. When the data volume is less than or equal to the first operation volume threshold, the dynamic parsing cycle is determined to be a long-cycle parsing mode; when the data volume is greater than the first operation volume threshold and less than or equal to the second operation volume threshold, the dynamic parsing cycle is determined to be a medium-cycle parsing mode; when the data volume is greater than the second operation volume threshold, the dynamic parsing cycle is determined to be a short-cycle parsing mode; the parsing duration of the long-cycle parsing mode is greater than that of the medium-cycle parsing mode, and the parsing duration of the medium-cycle parsing mode is greater than that of the short-cycle parsing mode.

3. The method for document editing based on rich text according to claim 2, characterized in that, When performing conflict detection on the rich text element operation instructions based on the parsing accuracy threshold and the operation feature extraction library, the following are included: The element type of each rich text element operation instruction is matched with the operation feature extraction library, and the rendering complexity of each rich text element operation instruction is compared with the average complexity of the operation instructions. When the rendering complexity of the rich text element operation instruction exceeds the set multiple of the average complexity of the operation instruction, the operation instruction is marked as an abnormal operation node. When the element type of the rich text element operation instruction is not registered in the operation feature extraction library, the operation instruction is marked as an abnormal operation node.

4. The method for document editing based on rich text according to claim 3, characterized in that, When determining the type of format conflict based on the element nesting depth and rendering dependency, it includes: When the nesting depth of the elements in the abnormal operation node exceeds the depth threshold of the same type of elements in the operation feature extraction library, it is determined that the node has a structural format conflict. When the rendering dependencies of the abnormal operation node form a closed reference chain, it is determined that the node has a circular dependency format conflict.

5. The method for document editing based on rich text according to claim 4, characterized in that, When calculating the initial typesetting risk value based on the frequency of conflicting operations, the following are included: The cumulative number of operations of the same conflict type is used as the conflict operation frequency. The baseline weight parameter of the corresponding conflict type is extracted from the operation feature extraction library. The initial layout risk value is calculated by weighting the deviation between the conflict operation frequency and the baseline weight parameter.

6. The method for document editing based on rich text according to claim 5, characterized in that, When performing clustering analysis on all format-conflicting nodes using density-based clustering algorithms, including: The layout constraints include the positioning coordinate offset and the rate of change of the spacing between adjacent elements; The cluster boundary range is determined by the neighborhood radius parameter, and the minimum number of neighborhood nodes is set as the initial value; The feature vector of each conflict node is used as a spatial coordinate point. All coordinate points are scanned, and the coordinate point with the minimum number of neighboring nodes is selected as the core node. The association expands from the core node. If the coordinate point in the neighborhood is a core node, the cluster is expanded. If the coordinate point in the neighborhood is a boundary node, it is assigned to the current cluster. Coordinate points that cannot be classified are marked as isolated conflict nodes. When there is a cluster containing at least two conflicting nodes and a style inheritance relationship between the nodes, the cluster is determined to form a cross-element style conflict chain.

7. The method for document editing based on rich text according to claim 6, characterized in that, When a cross-element style conflict chain is determined, the initial layout risk value is corrected by determining a layout adjustment coefficient based on the characteristics of the cross-element style conflict chain, including: The characteristics of the cross-element style conflict chain include the combination pattern of conflict chain length and conflict element type; The features of the cross-element style conflict chain are matched with the historical conflict solution library for similarity. The historical conflict solution library stores the mapping relationship between the features of the historical conflict chain and the historical typography adjustment coefficient. Calculate the similarity value between the current conflict chain features and the historical conflict chain features; When there is a matching scheme with a similarity value exceeding the set threshold, the initial layout risk value is corrected by using the historical layout adjustment coefficient corresponding to the maximum similarity value. When all similarity values ​​are below a set threshold, a layout adjustment coefficient is generated based on the length of the conflict chain to correct the initial layout risk value.

8. The method for document editing based on rich text according to claim 7, characterized in that, When generating layout adjustment coefficients based on the length of the conflict chain, the following is included: The layout adjustment coefficient shows a positive correlation with the length of the conflict chain, and the numerical range of the layout adjustment coefficient is greater than 1 and does not exceed 1.

5.

9. The method for document editing based on rich text according to claim 8, characterized in that, When adjusting the next dynamic parsing cycle based on the revised typesetting risk value, the following should be included: The corrected typesetting risk value is input into the cycle compression coefficient calculation model. The duration of the next dynamic analysis cycle is shortened according to the cycle compression coefficient. The cycle compression coefficient is negatively correlated with the corrected typesetting risk value. The value range of the cycle compression coefficient is 0.5 to 1.

10. A system for document editing based on rich text, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method for document editing based on rich text as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Page data capturing method and system

    CN104317948A

  • Collaborative editing method and device for rich text format document and storage medium

    CN119692311A