Document editing method and device, electronic equipment and storage medium

CN122927232APending Publication Date: 2026-10-16BEIJING KINGSOFT OFFICE SOFTWARE INC +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611263345.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-19
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

[0004]本申请提供了一种文档编辑方法、装置、电子设备及存储介质,以解决现有技术中用户自定义内容块需求依赖于服务商开发上线,导致无法满足多样化编辑需求的技术问题

Benefits of technology

[0025]Compared with the prior art, the technical solution provided in this application has the following advantages: The method provided in this application, by obtaining user-inputted content block definition information, allows users to freely define the structure, style, and interaction logic of content blocks according to their own needs. Since the content block definition information does not have predefined business type restrictions, users are not limited to the fixed content block types preset by the document editing system, thus satisfying diverse personalized editing needs. By performing compliance checks on the content block definition information according to a preset set of security constraint rules, and by using the security constraint rule set to limit the scope of elements, attributes, and/or program interfaces allowed in the content block definition information, a clear security boundary is defined for the content block definition information. Within the boundary, users can freely define and create; outside the boundary, the system intercepts, ensuring both the user's creative freedom and isolating all unsafe and non-compliant elements and code, thereby ensuring the system's security and stability. By associating and storing the content block definition information with the target document after the compliance check is passed, persistent storage of custom content blocks is achieved, allowing users' customization results to be continuously reused throughout the document's lifecycle without being lost due to page refresh or closing. By rendering content block definition information into the target document in a way that isolates it from the target document's document object model, the target content block is isolated from the main document in terms of style and DOM structure, avoiding style pollution and naming conflicts between multiple custom content blocks and between custom content blocks and the main document. Simultaneously, the interactive program code of the target content block runs in the global runtime environment of the target document, allowing the target content block to directly call global methods and access global variables of the main document. This achieves seamless interaction and true editability with the main document, fundamentally different from existing technologies that embed external web pages via iframes (which rely on cross-document communication mechanisms for interaction and have inherent limitations in scenarios requiring deep interaction with the main document). In summary, this application's technical solution, while ensuring the security of the document editing system, empowers users to freely define content blocks of any type within the document. This satisfies diverse and personalized editing needs while ensuring the security and stability of the document editing system. Furthermore, isolated rendering balances document consistency and editability even with multiple content blocks coexisting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122927232A_ABST
    Figure CN122927232A_ABST
Patent Text Reader

Abstract

The application relates to a document editing method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring content block definition information input by a user; performing compliance checking on the content block definition information according to a preset security constraint rule set; the security constraint rule set is used for limiting the range of elements, attributes and / or program interfaces allowed to be used in the content block definition information; in response to the compliance checking passing, storing the content block definition information in association with a target document; rendering the content block definition information into the target document in a manner isolated from a document object model of the target document to present a target content block; and the interactive program code of the target content block runs in a global running environment of the target document. Thus, the user can freely define the structure, style and interactive logic of the content block in the document, and the security and consistency of the document system can be ensured through the security constraint mechanism.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and more particularly to a document editing method, apparatus, electronic device, and storage medium. Background Technology

[0002] With the increasing popularity of document editing tools, users' demand for personalized document content is growing.

[0003] Traditional document editing systems typically offer only fixed content block types and predefined formatting options, such as text blocks, image blocks, and table blocks. Users can only choose from a few templates or layouts limited by the system, making it difficult to flexibly customize according to their own business scenarios or aesthetic preferences. Summary of the Invention

[0004] This application provides a document editing method, apparatus, electronic device, and storage medium to solve the technical problem in the prior art where the demand for user-defined content blocks depends on the development and launch by service providers, resulting in the inability to meet diverse editing needs.

[0005] Firstly, this application provides a document editing method, the method comprising: Get the content block definition information input by the user; The content block definition information is subjected to compliance checks based on a preset set of security constraint rules; the set of security constraint rules is used to limit the scope of elements, attributes and / or program interfaces that are allowed to be used in the content block definition information. In response to the compliance check being passed, the content block definition information is associated with and stored in the target document; The content block definition information is rendered into the target document in a manner isolated from the document object model of the target document to present the target content block; wherein, the interactive program code of the target content block runs in the global runtime environment of the target document.

[0006] In one possible implementation, the method further includes: In response to the failure of the compliance check, the content block definition information is refused to be associated with the target document for storage, and a corresponding prompt message is output.

[0007] In one possible implementation, obtaining the content block definition information input by the user includes one of the following methods: Obtain the source code entered by the user in the content block editing interface, and use the source code as the content block definition information; Obtain the webpage address specified by the user, and download the webpage source code corresponding to the webpage address as the content block definition information.

[0008] In one possible implementation, the content block editing interface includes at least one of the following: The source code editing area is used for users to input and edit the source code defining the content blocks; The preview area is used to preview the rendering effect corresponding to the content block definition information in real time. The verification area is used to display the results of the compliance check.

[0009] In one possible implementation, the target content block is presented in the target document at the position corresponding to the preset operation; Alternatively, the target content block may be presented at a position determined by a set adaptive layout method.

[0010] In one possible implementation, the step of associating and storing the content block definition information with the target document includes: The content block definition information is compressed. The compressed data is then encoded. The encoded data is written into the storage structure of the target document.

[0011] In one possible implementation, rendering the content block definition information into the target document in a manner isolated from the document object model of the target document to present the target content block includes: Create a rendering container isolated from the document object model of the target document; The content block definition information is rendered in the rendering container to generate a target content block isolated from the document object model.

[0012] In one possible implementation, before rendering the content block definition information in the rendering container, the method further includes: Based on the set of security constraint rules, a compliance check is performed again on the content block definition information.

[0013] In one possible implementation, performing a compliance check on the content block definition information again based on the set of security constraint rules includes: In response to an update to the set of security constraint rules configured in the cloud, a compliance check is performed again on the content block definition information based on the updated set of security constraint rules.

[0014] In one possible implementation, the method further includes: In response to the editing operation on the target content block, the edited content block definition information is obtained; Based on the set of security constraint rules, a compliance check is performed on the edited content block definition information; In response to the compliance check being passed, the edited content block definition information is associated with the target document and stored to overwrite the target content block.

[0015] In one possible implementation, after obtaining the edited content block definition information in response to an editing operation on the target content block, the method further includes: In response to the interaction result data associated with the target content block involved in the editing operation, the interaction result data is processed accordingly based on the type of the editing operation.

[0016] In one possible implementation, the method further includes: In response to the failure of the compliance check, the original content block definition information of the target content block is retained, and a message is displayed indicating that the edited content block definition information is non-compliant.

[0017] In one possible implementation, the method further includes: Set the creator of the target content block as the owner of the target content block; The owner of the target content block has the authority to set editing and / or deletion permissions for the target content block.

[0018] In one possible implementation, the content block definition information of the target content block has a heterogeneous data structure with other content in the target document, and the permission management and user data management of the target content block are uniformly performed by the target document.

[0019] In one possible implementation, the displayed content of the target content block is determined based on the identity information of the user viewing the target content block; when different users view the same target content block, the displayed content and / or interaction state are different.

[0020] In one possible implementation, the displayed content of the target content block is determined based on the current interaction state of the target content block; in response to different operations performed by the same user on the target content block, the target content block presents different display states and / or interaction options.

[0021] In one possible implementation, the method further includes: Acquire additional data generated during the interaction with the target content block; The additional data is associated with and stored in relation to the target content block; The display content of the target content block is updated based on the additional data, while the structural and style information of the target content block remains unchanged.

[0022] Secondly, this application provides a document editing apparatus, the apparatus comprising: The content block definition acquisition module is used to acquire content block definition information input by the user; The compliance check module is used to perform compliance checks on the content block definition information according to a preset set of security constraint rules; the set of security constraint rules is used to limit the scope of elements, attributes and / or program interfaces that are allowed to be used in the content block definition information. The storage module is used to associate and store the content block definition information with the target document in response to the compliance check being passed; The rendering module is used to render the content block definition information into the target document in a manner isolated from the document object model of the target document, so as to present the target content block; wherein, the interactive program code of the target content block runs in the global runtime environment of the target document.

[0023] Thirdly, this application provides an electronic device, including: a processor and a memory, wherein the processor is configured to execute a document editing program stored in the memory to implement the document editing method described in any one of the first aspects.

[0024] Fourthly, this application provides a storage medium storing one or more programs that can be executed by one or more processors to implement the document editing method described in any one aspect.

[0025] Compared with the prior art, the technical solution provided in this application has the following advantages: The method provided in this application, by obtaining user-inputted content block definition information, allows users to freely define the structure, style, and interaction logic of content blocks according to their own needs. Since the content block definition information does not have predefined business type restrictions, users are not limited to the fixed content block types preset by the document editing system, thus satisfying diverse personalized editing needs. By performing compliance checks on the content block definition information according to a preset set of security constraint rules, and by using the security constraint rule set to limit the scope of elements, attributes, and / or program interfaces allowed in the content block definition information, a clear security boundary is defined for the content block definition information. Within the boundary, users can freely define and create; outside the boundary, the system intercepts, ensuring both the user's creative freedom and isolating all unsafe and non-compliant elements and code, thereby ensuring the system's security and stability. By associating and storing the content block definition information with the target document after the compliance check is passed, persistent storage of custom content blocks is achieved, allowing users' customization results to be continuously reused throughout the document's lifecycle without being lost due to page refresh or closing. By rendering content block definition information into the target document in a way that isolates it from the target document's document object model, the target content block is isolated from the main document in terms of style and DOM structure, avoiding style pollution and naming conflicts between multiple custom content blocks and between custom content blocks and the main document. Simultaneously, the interactive program code of the target content block runs in the global runtime environment of the target document, allowing the target content block to directly call global methods and access global variables of the main document. This achieves seamless interaction and true editability with the main document, fundamentally different from existing technologies that embed external web pages via iframes (which rely on cross-document communication mechanisms for interaction and have inherent limitations in scenarios requiring deep interaction with the main document). In summary, this application's technical solution, while ensuring the security of the document editing system, empowers users to freely define content blocks of any type within the document. This satisfies diverse and personalized editing needs while ensuring the security and stability of the document editing system. Furthermore, isolated rendering balances document consistency and editability even with multiple content blocks coexisting. Attached Figure Description

[0026] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0027] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0028] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0029] Figure 1 A flowchart illustrating an embodiment of a document editing method provided in this application; Figure 2 A schematic diagram of a content block editing interface provided in an embodiment of this application; Figure 3 This is a schematic diagram illustrating an application scenario of the custom content block provided in an embodiment of this application; Figure 4 A schematic diagram illustrating another application scenario of the custom content block provided in the embodiments of this application; Figure 5 This is a schematic diagram illustrating another application scenario of the custom content block provided in the embodiments of this application; Figure 6 This is a schematic diagram illustrating another application scenario of the custom content block provided in the embodiments of this application; Figure 7 A flowchart illustrating an embodiment of another document editing method provided in this application; Figure 8 A flowchart illustrating another embodiment of the document editing method provided in this application; Figure 9 A block diagram illustrating an embodiment of a document editing device provided in this application; Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0030] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0031] The following disclosure provides numerous different embodiments or examples for implementing various structures of this application. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of this application. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.

[0032] To address the technical problem that existing technologies rely on service providers to develop and deploy user-defined content blocks, thus failing to meet diverse editing needs, this application provides a document editing method, apparatus, electronic device, and storage medium that enables users to freely define the structure, style, and interaction logic of content blocks in documents, while ensuring the security and consistency of the document system through security constraint mechanisms.

[0033] Figure 1 This is a flowchart illustrating an embodiment of a document editing method provided in this application. Figure 1 As shown, the method includes the following steps: Step 101: Obtain the content block definition information input by the user.

[0034] First, the method provided in this application can be applied to various document processing scenarios, including but not limited to online document systems, local document editing software, mobile applications that support document editing, and various web applications or client programs with document editing functions. For ease of description, these are collectively referred to as document editing systems. In the technical solution provided in this application, users can submit data information for defining target content blocks, i.e., content block definition information, through the input interface provided by the document editing system, according to their own needs.

[0035] Content block definition information refers to user-defined data used to describe an independent content unit, including but not limited to the content block's structural information (such as the DOM tree structure composed of HTML tags), style information (such as appearance styles such as fonts, colors, and margins), and interactive program code (such as JavaScript scripts used to respond to user clicks, data submissions, and other operations).

[0036] It should be noted that, in the embodiments of this application, the content block definition information does not have predefined business type restrictions, that is, it does not limit users to select fixed types such as "text block", "chart block", "form block" or "text block". Users can freely define the internal structure, style and interactive behavior of the content block according to their own needs, so as to achieve true personalized customization.

[0037] In one embodiment, the method for obtaining user-inputted content block definition information can be: obtaining the source code entered by the user in the content block editing interface, and using the source code as the content block definition information. Specifically, the content block editing interface provides a source code editing area where users can directly write or paste HTML, CSS, or JavaScript source code. The execution entity (i.e., the document editing system) in this embodiment uses this source code as the content block definition information. This method can maximize the satisfaction of personalized customization needs.

[0038] In another embodiment, the method for obtaining the content block definition information input by the user can be: obtaining the webpage address specified by the user and downloading the webpage source code corresponding to the webpage address as the content block definition information. Specifically, the user can directly enter the webpage address in the source code editing area of ​​the content block editing interface. The document editing system will access the webpage address and download the corresponding webpage source code, using the downloaded source code as the content block definition information. This method lowers the barrier to entry for users; users do not need to manually write code, but only need to provide the URL of an existing webpage or component to automatically obtain its source code as the basis for custom content blocks.

[0039] Building upon this foundation, the source code editing area also supports the display and secondary editing of downloaded source code. Specifically, after downloading the webpage source code, the document editing system displays the acquired source code in an editable format in the source code editing area. Users can modify, add, delete, or adjust this code to meet their personalized customization needs. This method combines the advantages of automatic acquisition and manual editing: on the one hand, users do not need to write code from scratch; they can obtain the implementation of an existing webpage or component as a basic template simply by entering a URL; on the other hand, users retain full customization capabilities, allowing them to further adjust the structure, style, or interaction logic on top of the downloaded source code without being limited by the original webpage's established implementation. Through these methods, this embodiment further lowers the user's barrier to entry while retaining ample flexibility and customizability.

[0040] In one embodiment, the content block editing interface includes a preview area and a validation area in addition to the source code editing area. The preview area renders the user-inputted or edited source code in real time, allowing users to visually preview the final rendering effect of the content block definition information in the document before submission, facilitating timely adjustments and optimizations. The validation area displays the results of subsequent compliance checks. When the user-inputted source code contains non-compliant content, the validation area clearly indicates the specific location and reason for the non-compliance, helping users quickly locate and correct the problem.

[0041] See Figure 2 This is a schematic diagram of a content block editing interface provided in an embodiment of this application. Figure 2This illustration only demonstrates one possible interface layout and does not constitute any limitation on the embodiments of this application.

[0042] like Figure 2 As shown, the content block editing interface includes a left panel, a code editing area, and a right preview area.

[0043] The left panel displays multiple rule tabs corresponding to the set of security constraint rules, including but not limited to "TAG Whitelist," "Style Whitelist," "Style Blacklist," and "API Whitelist." Users can click on each tab to view the specific rule entries currently in effect, thereby intuitively understanding the security boundaries of custom content blocks and proactively avoiding the use of non-compliant elements, styles, or APIs when writing code, thus reducing the failure rate of compliance checks.

[0044] The code editing area (i.e., the source code editing area described above) is used for users to input and edit the source code defining content blocks, supporting direct writing or pasting of HTML, CSS, and JavaScript code. The code editing area also provides several functional controls, including but not limited to a "read-only" switch, a "self-adaptive" switch, a "compliance check" button, and a "preview" button. The "read-only" switch restricts whether a content block can continue to be edited after entering the document (for example, inserting a copyright notice content block can be set to read-only, preventing anyone from modifying it in the main document; it can only be modified through the content block editor. Similarly, inserting a child editor block that responds to keyboard input allows authorized collaborators to directly edit it in the main document). The "self-adaptive" switch sets whether the width and height of the content block are self-adaptive; when enabled, the document editing system optimizes the layout of the content block during the rendering stage. The "compliance check" button triggers a compliance check of the current source code. The "preview" button triggers a preview of the current source code's rendering effect in the right-hand preview area. Furthermore, the code editing area can also display source code downloaded from a user-specified web address, allowing users to make further modifications.

[0045] The preview area on the right is used to render the source code in the current code editing area in real time or on demand to present a preview view of the content block, so that users can intuitively understand its final rendering effect in the document before submission, which is convenient for timely adjustment and optimization.

[0046] Step 102: Perform a compliance check on the content block definition information according to the preset set of security constraint rules; the set of security constraint rules is used to limit the scope of elements, attributes and / or program interfaces that are allowed to be used in the content block definition information.

[0047] In step 102, the document editing system performs a comprehensive check on the content block definition information submitted by the user based on the pre-configured set of security constraint rules to determine whether it complies with the security specifications of the document editing system.

[0048] Here, the "security constraint rule set" is a predefined set of rules used to limit the scope of elements, attributes, and / or program interfaces allowed in the content block definition information. This security constraint rule set serves a dual function in this embodiment: Firstly, it defines the behavioral boundaries of user-defined content blocks. The document editing system does not predefine the business type of the content blocks (i.e., it does not limit what types of content blocks users can create), but rather constrains the behavioral boundaries of the content blocks by defining the boundaries of "what is allowed and what is prohibited." Within these boundaries, users can freely define arbitrary structures, styles, and interaction logic, and the document editing system does not impose any restrictions on the specific business uses of the content blocks. Secondly, since the target content block ultimately shares the global runtime environment (i.e., the same JavaScript execution context) with the target document, its interactive program code can access global objects and methods. Therefore, compliance checks are necessary to prevent malicious code or non-compliant content from harming the security and stability of the document editing system, and these compliance checks are based precisely on this security constraint rule set. In other words, the set of security constraint rules is both the "free boundary" of user-defined content blocks and the "firewall" to ensure system security. While giving users full freedom of customization, it limits the behavior of interactive program code to a safe and controllable range, thus balancing flexibility and security.

[0049] Step 102 is a crucial step in ensuring the security of the document editing system in this application. All content block definition information submitted by users must undergo compliance checks at this step.

[0050] As can be seen from the above description, the core idea of ​​compliance checking in this application embodiment is "defining security boundaries, with free definition within those boundaries." Traditional solutions constrain users by predefining limited content block types (such as text blocks, chart blocks, form blocks, etc.). Each new type requires service provider intervention in development and deployment, resulting in poor scalability and slow response. This application, however, defines "allowed elements, style attributes, and API scope" through a set of security constraint rules. As long as the elements, style attributes, and API calls used in the content block definition information fall within this security boundary, regardless of its business purpose, structural design, or style presentation, it can pass compliance checking and be put into use. In other words, the document editing system doesn't care whether the user defines a "voting block," an "information collection block," or any other type; it only checks whether it crosses the security boundary. If it doesn't cross the boundary, it's legal. This "boundary-type constraint" design concept allows users to freely define any type of content block within the security boundary without waiting for service provider development and deployment, thus truly achieving customization flexibility and immediacy.

[0051] In one embodiment, the set of security constraint rules specifically includes an element whitelist, a style whitelist, a style blacklist, and a program interface whitelist. The element whitelist limits the allowed elements, such as HTML tags (e.g., ...). 、 、 、

[0052]

[0053]

[0054]

[0055]

[0056]

[0057]

[0058]

[0059]

[0060]

[0061]

[0062]

[0063]

[0064]

[0065]

[0066]

[0067]

[0068]

[0069]

[0070]

[0071] <link href="xxx.js">

[0072]

[0073]

[0074]

[0075]

[0076]

[0077]

[0078]

[0079]

[0080]

[0081]

[0082]

[0083]

[0084]

[0085]

[0086]

[0087]

[0088]

[0089] Figure 1

[0090]

[0091] Figure 3 Figure 3

[0092] Figure 4 Figure 4

[0093] Figure 5 Figure 5 Figure 5

[0094] Figure 6 Figure 6

[0095] Figures 3 to 6

[0096]

[0097]

[0098]

[0099]

[0100]

[0101]

[0102]

[0103] Figure 7 Figure 7 Figure 1

[0104]

[0105]

[0106]

[0107]

[0108]

[0109]

[0110]

[0111]

[0112]

[0113] Figure 7 Figure 1

[0114] Figure 8 Figure 8 Figure 1

[0115]

[0116]

[0117]

[0118]

[0119]

[0120]

[0121]

[0122]

[0123]

[0124]

[0125]

[0126] <iframe>The message includes prompts such as "The tag is not in the element whitelist"; the category to which the non-compliant content belongs, for example, "The prohibited style property position:fixed was used" or "The unauthorized API eval() was called"; and the correspondence between the non-compliant content and the set of security constraint rules, for example, "This element is not in the TAG whitelist" or "This style property is prohibited in the blacklist". These prompts allow users to quickly understand the specific reasons for the non-compliance of the content block definition, and then modify the source code accordingly before resubmitting, thereby improving editing efficiency and user experience.

[0127] In another embodiment, the prompt message also includes modification suggestions, such as prompting the user "It is recommended to modify..."<iframe> Replace with The message "or suggest removing the position:fixed style property" can be displayed in the validation area of ​​the content block editing interface to further reduce the user's correction costs.

[0128] Step 811: Retain the original content block definition information of the target content block and prompt that the edited content block definition information is not compliant.

[0129] For ease of understanding, steps 805 to 809 and step 811 are explained in a unified manner below: In step 805, when a user initiates an edit operation on the target content block, the document editing system obtains the edited content block definition information. Specific implementation methods for the edit operation include, but are not limited to: setting the `contenteditable` property of the target content block's top-level container to an editable state, directly modifying the content block using the browser's native editing capabilities; editing using a custom editor implemented within the target content block; or editing using a general source code editor provided by the document editing system. Regardless of the editing method used, the edited content block definition information is obtained after the editing is completed.

[0130] Since the target content block may have already generated associated interaction result data during previous interactions (e.g., user voting records collected in the voting block, submitted data in the form block, signed signature images in the signature block, etc.), the editing operation may affect this existing data. Therefore, in step 806, it is first determined whether the editing operation involves the interaction result data associated with the target content block. If it does, step 807 is executed to process the interaction result data accordingly based on the type of editing operation; if it does not, step 808 is executed directly.

[0131] In step 807, the interaction result data is processed accordingly based on the type of editing operation. Specifically, a corresponding data processing strategy is adopted based on the type of change made to the content block definition information by the editing operation.If the editing operation deletes an element or field in the content block, all existing interaction result data corresponding to the element or field will be deleted, or marked as an invalid state; if the editing operation modifies an element or field in the content block (such as modifying the text of a voting option, adjusting the name of a form field), the existing interaction result data will be mapped to the modified new element or new field, or the user will be prompted to select a data migration mode; if the editing operation adds a new element or field, all existing interaction result data will be retained, and the data record of the newly added part is empty. Through the above processing, it is ensured that the edited content block definition information is logically consistent with the existing interaction result data.

[0132] In step 808, a compliance check is re-performed on the edited content block definition information according to the set of security constraint rules. The compliance check is performed again here because the content block definition information edited by the user may introduce new elements, styles or API calls, and the compliance check is required to ensure that it is still within the security boundary. In response to the passing of the compliance check, step 809 is executed to associate and store the edited content block definition information with the target document, so as to overwrite the original target content block definition information, so that the edited version is rendered subsequently, and the overwriting operation does not affect the interaction result data that has been processed in step 807; in response to the failure of the compliance check, step 811 is executed to retain the original content block definition information of the target content block, and prompt the user that the edited content block definition information is non-compliant, and the user can correct it according to the prompt information and resubmit.

[0133] The process shown in Figure 8 is based on the process shown in Figure 1. Through the mechanism of "secondary compliance check after editing, overwriting if passed, and retaining the original content if not passed", it is ensured that the edited content block definition information still conforms to the limitation of the set of security constraint rules, and new security risks will not be introduced due to the editing operation.

[0134] The present application further provides the following embodiments:In one embodiment, the creator of the target content block is set as the owner of the target content block; the owner of the target content block has the authority to set the editing authority and / or deletion authority of the target content block.

[0135] In this embodiment, the creator of the target content block automatically becomes the owner of the content block, that is, has the highest management authority over the content block.Specifically, the owner has the authority to set editing and / or deletion permissions for the target content block, including: allowing or prohibiting other users from editing the content block; allowing or prohibiting other users from deleting the content block; and granting or revoking the above permissions to other users. Through this mechanism, the owner of the content block can control the access and operation boundaries of the content block, ensuring the security and controllability of the content block in multi-user collaborative scenarios.

[0136] In one embodiment, the content block definition information of the target content block has a heterogeneous data structure with other content in the target document, and the permission management and user data management of the target content block are uniformly executed by the target document.

[0137] In this embodiment, the content block definition information of the target content block has a heterogeneous data structure with other content in the target document. Specifically, the content block definition information (i.e., the structural information, style information, and interactive program code defined by the user when customizing the content block) adopts a different data format and storage method than the native document content data of the document editing system. The content block definition information exists in the form of HTML fragments, while the ordinary content in the document may be stored in structured data or rich text format, and the two are heterogeneous in terms of data organization. Despite the heterogeneous data structure, the permission management and user data management of the target content block are still uniformly executed by the target document. This means that the target content block does not manage user permissions and data independently outside the document system, but follows the unified permission system and management specifications of the document system. For example, the document system uniformly controls which users have permission to access the document and which users have permission to view additional data associated with the content block. This mechanism ensures that after the custom content block is integrated into the document system, its permission and data management behavior is consistent with the overall management strategy of the document system, avoiding management fragmentation caused by heterogeneous content block data.

[0138] In one embodiment, the display content of the target content block is determined based on the identity information of the user viewing the target content block; when different users view the same target content block, the displayed content and / or interaction state are different.

[0139] In this embodiment, the displayed content of the target content block is determined based on the identity information of the user viewing the target content block. When different users view the same target content block, the displayed content and / or interaction state are different. Specifically, the user identity information is used to identify the permission level, interaction state (such as whether a vote has been cast), or user role of the user currently viewing the content block.The document editing system presents different interface states to different users in the same target content block according to user identity information. For example, a user who has not voted sees an interactive interface containing voting options and a submit button, while a user who has voted sees a voting result display interface; an ordinary user sees content that can only be viewed, while a user with management permissions additionally sees management entrances such as "Edit", "Export Data", and "Delete". Through this mechanism, the custom content block can dynamically adjust the presented content according to user identities in a multi-person collaboration scenario, which improves the applicability and security of the content block in the collaboration environment.

[0140] In one embodiment, the display content of the target content block is determined according to the current interaction state of the target content block; in response to different operations performed by the same user on the target content block, the target content block presents different display states and / or interaction options.

[0141] In this embodiment, the display content of the target content block is determined according to the current interaction state of the target content block. In response to different operations performed by the same user on the target content block, the target content block presents different display states and / or interaction options. Specifically, the content block maintains its current interaction state internally (such as an initial state, an in-operation state, a completed state, etc.). After each user operation, the content block updates its own state and renders different interfaces according to the current state. Taking a voting block as an example: the interface seen by the user in the unvoted state includes voting options and a "Submit" button; after the user clicks the "Submit" button, the interface switches to the "Submitting..." state, and the button is grayed out and cannot be clicked repeatedly; after the system confirms that the voting is successful, the interface switches to the voting result display state, the voting options disappear, and real-time voting data is displayed. Throughout the whole process, the structural information and style information of the content block remain unchanged, and only the display content and available interaction options are updated according to the switching of the interaction state. Through this mechanism, the content block is equipped with complete interaction state management capabilities, which can provide users with clear operation feedback and process guidance, and improve the interaction experience.

[0142] Figure 9 is a block diagram of an embodiment of a document editing apparatus provided in the embodiments of the present application.As shown in Figure 9, the apparatus includes: a content block definition acquisition module 91, configured to acquire content block definition information input by a user; a compliance check module 92, configured to perform compliance check on the content block definition information according to a preset set of security constraint rules, where the set of security constraint rules is used to limit the scope of elements, attributes and / or program interfaces allowed to be used in the content block definition information; a storage module 93, configured to, in response to the compliance check being passed, associate and store the content block definition information with a target document; a rendering module 94, configured to render the content block definition information into the target document in a manner isolated from a document object model of the target document, so as to present a target content block, where interactive program code of the target content block runs in a global operating environment of the target document.

[0143] In a possible embodiment, the apparatus further includes: a first exception handling module, configured to, in response to the compliance check not being passed, refuse to associate and store the content block definition information with the target document, and output corresponding prompt information.

[0144] In a possible embodiment, the content block definition acquisition module 91 includes: a source code input unit, configured to acquire source code input by the user in a content block editing interface, and take the source code as the content block definition information; a web address downloading unit, configured to acquire a web address specified by the user, and download web page source code corresponding to the web address as the content block definition information.

[0145] In a possible embodiment, the content block editing interface includes at least one of the following: a source code editing area, configured for the user to input and edit the source code of the content block definition information; a preview area, configured to preview the rendering effect corresponding to the content block definition information in real time; a verification area, configured to display the check result of the compliance check.

[0146] In a possible embodiment, the target content block is presented at a position corresponding to a preset operation in the target document; or, the target content block is presented at a position determined by a set adaptive layout manner.

[0147] In one possible embodiment, the storage module 93 includes: A compression unit is used to compress the content block definition information; The encoding unit is used to encode the compressed data. The writing unit is used to write the encoded data into the storage structure of the target document.

[0148] In one possible implementation, the rendering module 94 includes: A container creation unit is used to create a rendering container that is isolated from the document object model of the target document; An isolated rendering unit is used to render the content block definition information in the rendering container to generate a target content block isolated from the document object model.

[0149] In one possible embodiment, the device further includes: The secondary inspection module is used to perform a compliance check on the content block definition information again according to the set of security constraint rules before rendering the content block definition information in the rendering container.

[0150] In one possible implementation, the secondary inspection module is specifically used for: In response to an update to the set of security constraint rules configured in the cloud, a compliance check is performed again on the content block definition information based on the updated set of security constraint rules.

[0151] In one possible embodiment, the device further includes: The editing acquisition module is used to acquire the edited content block definition information in response to the editing operation on the target content block; The editing and checking module is used to perform compliance checks on the edited content block definition information according to the set of security constraint rules; The overwrite storage module is used to, in response to the compliance check being passed, associate the edited content block definition information with the target document and store it to overwrite the target content block.

[0152] In one possible embodiment, the device further includes: An interactive data processing module is configured to, after obtaining the edited content block definition information in response to the editing operation on the target content block, process the interactive result data associated with the target content block in response to the editing operation according to the type of the editing operation.

[0153] In one possible embodiment, the device further includes: The second exception handling module is used to respond to the failure of the compliance check by retaining the original content block definition information of the target content block and prompting that the edited content block definition information is non-compliant.

[0154] In one possible embodiment, the device further includes: The permission settings module is used to set the creator of the target content block as the owner of the target content block; The owner of the target content block has the authority to set editing and / or deletion permissions for the target content block.

[0155] In one possible implementation, the content block definition information of the target content block has a heterogeneous data structure with other content in the target document, and the permission management and user data management of the target content block are uniformly performed by the target document.

[0156] In one possible implementation, the display content of the target content block is determined based on the identity information of the user viewing the target content block; when different users view the same target content block, the displayed content and / or interaction state are different.

[0157] In one possible implementation, the display content of the target content block is determined according to the current interaction state of the target content block; in response to different operations performed by the same user on the target content block, the target content block presents different display states and / or interaction options.

[0158] In one possible embodiment, the device further includes: The display update module is used to acquire additional data generated during the interaction of the target content block; associate and store the additional data with the target content block; update the display content of the target content block according to the additional data, while keeping the structural and style information of the target content block unchanged.

[0159] As shown in Figure 10, an embodiment of the present application provides an electronic device, comprising a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 complete mutual communication via the communication bus 114;the memory 113 is configured to store a computer program;In an embodiment of the present application, when the processor 111 executes the program stored in the memory 113, the document editing method provided by any one of the foregoing method embodiments is implemented, comprising:acquiring content block definition information input by a user;performing compliance check on the content block definition information according to a preset set of security constraint rules; wherein the set of security constraint rules is used to limit the scope of elements, attributes and / or program interfaces allowed to be used in the content block definition information;in response to the compliance check being passed, storing the content block definition information in association with a target document;rendering the content block definition information into the target document in a manner isolated from the document object model of the target document, so as to present a target content block; wherein the interactive program code of the target content block runs in the global operating environment of the target document.

[0160] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the document editing method provided by any one of the foregoing method embodiments are implemented.

[0161] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed over a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0162] Through the description of the above embodiments, those skilled in the art can clearly understand that each of the embodiments can be implemented by means of software plus a general hardware platform, and of course can also be implemented by hardware.Based on this understanding, the above technical solutions, or the parts that contribute to the relevant technologies, can be embodied in the form of software products. These computer software products can be stored in computer-readable storage media, such as ROM / RAM, magnetic disks, optical disks, etc., and include several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in various embodiments or some parts of the embodiments.

[0163] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "a," "an," and "described" as used herein may also mean including the plural forms. The terms "comprising," "including," "containing," and "having" are inclusive and therefore indicate the presence of the stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not to be construed as requiring them to be performed in a particular order described or illustrated unless the order of performance is explicitly indicated. It should also be understood that additional or alternative steps may be used.

[0164] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.< / iframe> Elements not in the whitelist will be rejected; the style whitelist limits the allowed style attributes and / or style attribute values ​​(such as font-size, color, display:flex, etc.), and styles or style attribute values ​​not in the whitelist will be rejected; the style blacklist is used to explicitly prohibit the use of style attributes and / or style attribute values ​​(such as position:absolute, display:none, pointer-events:none, etc.); the program interface whitelist limits the program interfaces that are allowed to be called. Optionally, the element whitelist includes at least one of the following categories: text elements, such as; text block elements, such as <font-size>, <color>, <font- ... The availability of the aforementioned element categories can be flexibly configured as needed during the product design phase. For example, in the initial version of the document editing system, only text, text block, decoration, and layout elements can be available to meet basic document editing needs. In subsequent versions, based on user feedback and scenario requirements, more categories of elements, such as tables, lists, interactive elements, and custom-drawn elements, can be gradually added to support richer custom content block types. By configuring the phased availability of different element categories during the product design phase, flexible evolution and refined management of the element whitelist can be achieved. The style blacklist is used to explicitly prohibit the use of style attributes and / or style attribute values. The design of the style blacklist can adopt the "maximum invisibility principle," that is, style attributes that may pose a risk are prohibited by default. Subsequently, based on actual operation, style attributes that have been verified to be safe are gradually removed from the blacklist, making them allowed. Optionally, the style blacklist includes, but is not limited to, the following categories of style properties: Security Risk: Style properties that may be used to execute malicious code or steal data, such as `background-image: url()` (may reference a malicious address), `content: attr()` (may leak sensitive information in DOM properties), and `url(javascript:)` (may execute malicious scripts). Rendering Performance Risk: Style properties that may significantly degrade page rendering performance, such as `box-shadow` (excessive shadow stacking may cause repaint performance issues), and complex animations and transitions (excessive animation frames may cause page stuttering). Layout Disruption: Style properties that may cause elements to be removed from the normal document flow and disrupt the overall layout structure of the document, such as `position:absolute`, `position:fixed`, and `float`.Hiding and Overriding: Style attributes that may make content invisible or override system styles, such as `display:none`, `visibility:hidden` (may hide content), `!important` declarations (may override system styles, breaking style consistency), `accent-color` (may change system color consistency), etc. Global Pollution: Style characteristics that may have uncontrollable impacts, such as wildcard selectors (*, may affect the main document's global styles), CSS variables (--var, may cause style pollution), etc. Through the above blacklist mechanism, the document editing system effectively controls high-risk styles at both the security and rendering performance levels. During the product design phase, the blacklist can be configured to include all the above categories of style attributes. In subsequent versions, based on actual operation and security verification results, style attributes proven to be safe and controllable will be gradually removed from the blacklist, progressively expanding the user's style customization space while ensuring a bottom line of security. Optionally, the program interface whitelist includes a global object whitelist, an API whitelist, and a JSAPI whitelist exposed by the document system, used to limit the scope of allowed program interfaces. The global object and API whitelist is used to restrict access to global objects, methods, and properties. Optionally, the global object and API whitelist includes, but is not limited to: read-only properties (such as devicePixelRatio) and safe methods (such as getComputedStyle, requestAnimationFrame, requestIdleCallback, parseInt, parseFloat, isNaN, hasOwnProperty, etc.) in the window object; query methods (such as querySelector, getElementById, getElementsByClassName, getElementsByTagName, but limited to elements within the DOM tree of the target content block itself) and event listener methods (such as addEventListener, removeEventListener) in the document object; event-related methods (such as addEventListener, removeEventListener, dispatchEvent) and keyboard events in Node and Element objects. Global objects, methods, or properties not in the global object and API whitelist will be prohibited from access or invocation. The document system's exposed JSAPI whitelist is used to restrict the allowed calls to JSAPI interfaces used for communication and data exchange with the main document.Optionally, the JSAPI whitelist includes, but is not limited to: communication interfaces actively triggered by custom content blocks (such as CUSTOM_SNIPET_UPDATE, used to notify the main document to complete data persistence when the target content block content is updated; CUSTOM_SNIPET_SUBMIT, used to transfer the input data submitted by the target content block to the main document for storage; CUSTOM_SNIPET_QUERY, used to query the data most recently submitted by the target content block) and event interfaces sent by the main document to custom content blocks (such as HOST_RESIZE, used to notify the target content block when the main document's page width changes; HOST_SCALE, used to notify the target content block when the main document's scaling ratio changes). JSAPI interfaces not on the JSAPI whitelist will be prohibited from being called. Through the dual restriction of the above global object and API whitelist and JSAPI whitelist, interactive program code can only access authorized global objects, methods, and JSAPI interfaces, thereby ensuring the necessary data communication and interaction capabilities between the target content block and the main document while effectively preventing malicious code from harming system security. In one embodiment, the combined use of whitelists and blacklists is as follows: First, it is determined whether the element, style attribute, or program interface to be detected (i.e., the corresponding information item in the content block definition information entered by the user) is in the corresponding whitelist. If it is in the whitelist, the compliance check is passed directly; if it is not in the whitelist, it is further determined whether it is in the corresponding blacklist. If it is in the blacklist, the pass is explicitly rejected and the reason for non-compliance is recorded; if it is neither in the whitelist nor the blacklist, it can be processed according to the default policy. Optionally, the default policy is to reject the pass and prompt the user that the item to be detected is not within the allowed range. In addition, for animation and transformation styles, the number of animations and / or transformation frequency are further limited to avoid rendering performance degradation due to excessive animations. For DOM hierarchical nesting structures, the nesting depth is further limited to ensure that it complies with MDN specifications and is efficient. In other words, the whitelist defines the allowed range of the "security boundary" and is the basis for users' free operation; the blacklist is used to identify high-risk items that need to be explicitly prohibited outside the whitelist range (such as styles with the risk of deviating from the document flow, such as position:absolute), as a supplement and emphasis to the whitelist. This combined compliance check approach ensures clear security boundaries while providing differentiated feedback for different types of non-compliant content, improving the precision of compliance checks and user experience. Furthermore, in one embodiment, the compliance check also includes a security audit step, used to perform a security scan on the interactive program code within the content block definition information.Security audits have a veto power. If any of the following situations are detected, the content block definition information is deemed to have failed the compliance check and will be refused storage and rendering: (I) Code style check: Check whether there are code quality issues such as syntax errors, undefined variable references, spelling errors, unused variables or functions in the interactive program code; check whether there are unsafe code patterns, such as eval(), Function() constructors, and code patterns that are prone to cross-site scripting attacks by directly inserting user input through innerHTML; check whether there are type and logic defects, such as the mixed use of == and ===, unvalidated null values, array out-of-bounds, infinite loops, etc. (II) Vulnerability detection: Check whether there are common security vulnerabilities such as cross-site scripting attack vulnerabilities, cross-site request forgery vulnerabilities, and code injection vulnerabilities in the interactive program code. (III) Sensitive Behavior Detection: Interactive program code is prohibited from obtaining cookies, reporting data, downloading resources, etc.; unauthorized extensions of global objects such as window and Object.prototype are prohibited; access to browser storage or sensitive APIs such as localStorage, sessionStorage, indexDB, and navigator is prohibited; insecure DOM operations are prohibited, such as high-risk operations like document.write(), setTimeout(string), and location.href = userInput; hard-coded sensitive information (such as keys, passwords, tokens, etc.) is prohibited. (IV) Resource and External Link Detection: The interactive program code is checked for external links such as images, videos, and audio. If such links are found, they must be transferred to the document system's internal cloud storage space and approved for content security before use; sensitive text, images, and videos are checked for; external JavaScript files are prohibited from being included in any form, including but not limited to. <script src="xxx.js">< / script> (v) DOM access scope restriction: The interactive program code in the target content block can only operate on elements within its own DOM tree scope, and access to the DOM tree of the main document is prohibited through DOM query methods such as document.querySelector, document.getElementById, and document.getElementsByClassName, so as to prevent malicious code from interfering with the normal function and style of the main document. In the above embodiment, the compliance check includes two levels: one is the boundary check based on the set of security constraint rules, which is used to limit the scope of elements, styles and APIs allowed in the content block definition information; the other is the security audit, which is used to scan the interactive program code for code standardization and malicious behavior. The two levels cooperate with each other to jointly ensure system security. Step 103: In response to the compliance check passing, the content block definition information is associated with the target document for storage. When the compliance check passes, the document editing system associates the content block definition information submitted by the user with the target document for storage. Here, "association storage" means establishing a correspondence between the content block definition information and the target document, so that when the target document is opened later, the corresponding content block definition information can be located and loaded according to the correspondence. Step 103 ensures that user-defined content blocks are not lost due to page refresh or document closure, achieving persistent storage of custom content blocks. In one embodiment, the specific implementation of associating content block definition information with the target document includes: firstly, compressing the content block definition information to remove redundant data and reduce storage space usage; then, encoding the compressed data (e.g., Base64 encoding) to ensure it can be securely written into the document's storage structure; finally, writing the encoded data to a specified location in the target document's storage structure. Through compression and encoding, not only is storage space saved, but the integrity and security of data during storage and transmission are also guaranteed. Step 104: Using a method isolated from the target document's Document Object Model (DOM), the content block definition information is rendered into the target document to present the target content block; wherein, the interactive program code of the target content block runs in the target document's global runtime environment. The document editing system renders the content block definition information, which has undergone compliance checks and is stored, in a rendering environment isolated from the target document's Document Object Model (DOM), ultimately presenting the user-defined target content block in the target document. The "Document Object Model" is the programming interface for documents. It represents documents as a tree structure, allowing scripting languages ​​such as JavaScript to manipulate page content."Isolation from the target document's Document Object Model" refers to creating an independent DOM subtree for the target content block. The style and structure of this subtree are isolated from the main document's DOM tree. The style of the target content block will not affect the main document, and the style of the main document will not permeate the target content block, thus avoiding style pollution and naming conflicts. In the embodiments of this application, the rendering method of isolating from the target document's Document Object Model differs from the existing technology of embedding external web pages through iframes. iframes create nested browsing contexts (i.e., inline frames), carving out an independent area in the page to load another document. When the origin is the same, the parent page can directly access the DOM and global objects inside the iframe through APIs such as contentWindow and contentDocument. When the origin is cross-domain, it is limited by the browser's same-origin policy, but the parent page and the iframe can still communicate in a controlled manner through postMessage. In terms of content loading methods, iframes can not only load external web page addresses by specifying the src attribute, but also directly load HTML string content through the srcdoc attribute, or inject content into the iframe through dynamic writing. However, regardless of the method used, an iframe essentially loads a complete, independent document—a single piece of content—and cannot share the global JavaScript runtime environment with its parent page. Even if the parent page can communicate with the iframe via `postMessage`, this communication is based on an asynchronous message-passing mechanism, requiring both sides to write separate logic for sending and receiving messages. This communication model is suitable for data exchange between two independent documents, but not for scenarios where interactive code needs to share the same global runtime environment as the main document. In other words, the interactive code needs to directly call global methods and read global variables from the main document to achieve seamless interaction. Therefore, in application scenarios requiring deep interaction between the content block and the main document, direct manipulation of main document data, or sharing of main document capabilities, the cross-document communication mechanism of iframes has inherent limitations. In contrast, the isolated rendering method used in this application creates a rendering container within the same page that is isolated from the document object model of the main document. The target content block shares the global JavaScript execution environment with the main document; that is, the interactive code of the target content block runs in the global runtime environment of the target document, enabling direct calls to top-level global methods and reading of global variables, thereby achieving seamless interaction with the main document and true editability. Because sharing the global runtime environment while isolating rendering brings security risks, this application needs to strictly limit the range of APIs that can be called by the interactive program code through the set of security constraint rules in step 102, so as to ensure system security while ensuring editability.Through the above methods, this application achieves both isolation of content blocks from the main document in terms of style and DOM structure, and retains the ability of interactive program code to share the global runtime environment with the main document, thus balancing security and editability. In one embodiment, the content block definition information is rendered into the target document to present the target content block by isolating it from the target document's document object model. This includes: creating a rendering container isolated from the target document's document object model, which is independent of the main document's DOM tree and has an independent style scope; then, rendering the content block definition information in the rendering container to generate the target content block isolated from the document object model. DOM operations and style applications of the target content block within the rendering container are restricted to this container and do not affect the main document. Preferably, the rendering container is a Shadow DOM node, created by calling the attachShadow method on the element, thereby utilizing the browser's natively supported Shadow DOM features to achieve DOM isolation and style isolation. It should be noted that the rendering container is not limited to Shadow DOM nodes, but can also be other containers capable of achieving DOM isolation. When rendering content block definition information in the rendering container, the structural information (such as HTML tag structure) and style information (such as CSS style rules) in the content block definition information are injected into the rendering container, and interactive program code is executed, so that the target content block is fully presented in the isolated environment and has interactive responsiveness. Since the interactive program code of the target content block runs in the global runtime environment of the target document, it can directly call the global methods of the main document and access global variables, without relying on cross-document message passing mechanisms (such as postMessage) for asynchronous communication as in the iframe solution. Based on this, the target content block can use the browser's native editing capabilities (such as setting the contenteditable attribute) to achieve direct editing of the content, or it can synchronize the edited content to the main document through the JSAPI exposed by the document editing system (such as CUSTOM_SNIPET_UPDATE), and it can also implement a custom editor (such as floating toolbars, editing controls, etc.) inside the content block to meet the needs of more complex editing scenarios. The above mechanism makes the target content block a truly editable and interactive part of the document, rather than requiring cross-document communication mechanisms to interact with the main document as in the iframe solution, thus achieving an editing experience that is integrated with the main document. "Rendering" refers to the process of converting content block definition information (including structure, style, and interactive program code) into page elements that are visible and interactive to the user in the browser.In one embodiment, the rendering timing of the target content block includes at least one of the following: rendering is performed immediately after the target content block is inserted into the target document, allowing the user to instantly see the presentation effect of the custom content block; rendering is performed when the target document is opened, allowing the stored target content block to be restored during document loading; or rendering is performed when the target content block enters the visible area of ​​the target document, that is, rendering is triggered only when the user scrolls the document and the target content block enters the browser viewport, and target content blocks that have not entered the visible area are not rendered temporarily. Through the above rendering timing control, the document editing system can perform rendering operations on demand, especially when the document contains a large number of custom content blocks, avoiding the performance overhead caused by rendering all content blocks at once, and improving the document loading speed and the smoothness of scrolling. In one embodiment, the target content block is presented in the target document at a position corresponding to the user's preset operation. For example, if the user clicks the insert menu after a paragraph in the document, the document editing system will render the target content block at the position after that paragraph, maintaining consistency between the document's editing logic and the user's operation intention. In another embodiment, the target content block is presented at a position determined by a set adaptive layout method. For example, the document editing system determines the presentation position of the target content block based on at least one of the following factors: determining the presentation position based on the screen size of the current rendering device, for example, presenting the content block in the side area on devices with a larger screen width, and presenting the content block at the end of the main body of the document on mobile devices with a smaller screen width; determining the presentation position based on changes in the page width of the target document, dynamically adjusting the position of the content block to adapt to the new page size when the user adjusts the window size or switches devices; dynamically calculating the presentation position based on the number and / or arrangement of existing content blocks in the target document, for example, automatically arranging newly inserted content blocks in appropriate positions to avoid overlap or layout errors when multiple custom content blocks already exist in the document; matching the corresponding presentation position based on the content type of the target content block, for example, presenting interactive content blocks (such as voting forms) in the document sidebar, and presenting static content blocks in the document body area. Through the above adaptive layout method, the target content block can obtain a reasonable presentation position on different terminal devices and in different document environments, improving the overall layout quality of the document and the user experience. Based on the above description, this is a schematic diagram of an application scenario of the custom content block provided in the embodiments of this application. As shown, the user has created a content block with a floating toolbar in the document by using a custom content block. When the mouse hovers over the target content block, a floating toolbar appears above or to the side of the content block. This toolbar contains multiple function buttons, such as "Edit," "Delete," and "Share," each with its own custom interaction logic. When the mouse leaves the target content block, the floating toolbar automatically hides to maintain a clean document interface and uninterrupted browsing.Users can make the buttons and their layout in the toolbar editable within the document by setting the `contenteditable="true"` attribute of the top-level container. They can also write independent JavaScript interactive code for the toolbar to implement personalized behaviors such as hovering, collapsing, and dragging. The following is a schematic diagram of another application scenario of the custom content block provided in this application embodiment. As shown, the user implements a custom right-click menu in the document using a custom content block. When the user right-clicks in the document, the custom menu pops up, with menu items including but not limited to "Refresh," "Edit," and "Delete" options for the content block. This custom right-click menu is implemented through the interactive program code in the content block definition information. When a right-click event is detected on the target content block, the default browser right-click menu is blocked, and the custom menu is displayed instead, executing the corresponding operation logic based on the menu item selected by the user. The following is a schematic diagram of yet another application scenario of the custom content block provided in this application embodiment. As shown, the user implements a voting block in the document using a custom content block. The voting block includes a voting option area and a voting result display area. The voting option area displays the voting options (such as "Option 1", "Option 2", "Option 3") and their corresponding voting buttons. The voting result display area displays the real-time voting results for each option (such as vote count, percentage, etc.), and can optionally be presented in the form of a bar chart or progress bar. When a user clicks the voting button in the voting option area and submits their vote, the document editing system obtains the submitted voting data, associates and stores the voting data as additional data associated with the target content block, and updates the display content of the voting result display area based on the updated additional data. During this process, the structural and style information of the target content block remains unchanged; only the displayed content changes with the update of the voting data. Furthermore, different users will see different content when viewing the same voting block: users who have not voted will see an interactive voting interface, while users who have voted will see the voting result display interface, i.e., the result view shown on the right. The detailed implementation methods for storing additional data in the voting block, access control, and differentiated display for different users will be further described in the specific embodiments below, and will not be repeated here. This is a schematic diagram illustrating another application scenario of the custom content block provided in this application embodiment. As shown, a user implements an electronic signature block in a document using a custom content block. The signature block includes a signature drawing area and a signature confirmation area. The signature drawing area provides a drawing interface based on HTML5 Canvas, where the user can handwrite their signature using a mouse or stylus. The signature confirmation area includes a "Save" button and a "Clear" button.After the user completes the signature drawing and clicks the "Save" button, the document editing system retrieves the signature image data from the Canvas, associates and stores the signature image data with the target content block, and updates the display content of the signature block to show the signed status. This signature drawing interaction is implemented through the interactive program code in the content block definition information. The Canvas drawing operation only uses the standard Canvas API, thus passing the compliance check of the security constraint rule set. The signed content is stored as additional data of the target content block in the document system, and the user can still view the signature when opening the document again. It should be noted that the application scenario shown is only an illustrative example and should not constitute any limitation on the embodiments of this application. Based on the technical solution provided by the embodiments of this application, users can also implement more types of custom content blocks, including but not limited to information collection forms, task progress tracking, data chart displays, embedded maps, calendar events, comment message boards, etc. These custom content blocks do not depend on the predefined block types of the document editing system, but are defined by the user within the boundaries defined by the security constraint rule set. That is, the user can define whatever type they want, as long as it falls within the security boundary, the system does not impose any restrictions. The technical solution provided in this application, by acquiring user-inputted content block definition information, allows users to freely define the structure, style, and interaction logic of content blocks according to their own needs. Since the content block definition information does not have predefined business type restrictions, users are not limited to the fixed content block types preset by the document editing system, thus satisfying diverse personalized editing needs. By performing compliance checks on the content block definition information according to a preset set of security constraint rules, and by using the security constraint rule set to limit the scope of elements, attributes, and / or program interfaces allowed in the content block definition information, a clear security boundary is defined for the content block definition information. Within the boundary, users can freely define and create; outside the boundary, the system intercepts, ensuring both the user's creative freedom and isolating all unsafe and non-compliant elements and code, thereby ensuring the system's security and stability. By associating and storing the content block definition information with the target document after the compliance check is passed, persistent storage of custom content blocks is achieved, allowing users' customization results to be continuously reused throughout the document's lifecycle and not lost due to page refreshes or closing.By rendering content block definition information into the target document in a way that isolates it from the target document's document object model, the target content block is isolated from the main document in terms of style and DOM structure, avoiding style pollution and naming conflicts between multiple custom content blocks and between custom content blocks and the main document. Simultaneously, the interactive program code of the target content block runs in the global runtime environment of the target document, allowing the target content block to directly call global methods and access global variables of the main document. This achieves seamless interaction and true editability with the main document, fundamentally different from existing technologies that embed external web pages via iframes (which rely on cross-document communication mechanisms for interaction and have inherent limitations in scenarios requiring deep interaction with the main document). In summary, this application's technical solution, while ensuring the security of the document editing system, empowers users to freely define content blocks of any type within the document. This satisfies diverse and personalized editing needs while ensuring the security and stability of the document editing system. Furthermore, isolated rendering balances document consistency and editability even with multiple content blocks coexisting. In one embodiment, before rendering content block definition information in the rendering container, a compliance check is performed again on the content block definition information according to the set of security constraint rules. In one possible implementation, performing the compliance check again on the content block definition information according to the set of security constraint rules includes: responding to an update of the cloud-configured set of security constraint rules, performing a compliance check again on the content block definition information according to the updated set of security constraint rules. In this embodiment, before rendering content block definition information in the rendering container, the document editing system performs a compliance check again on the content block definition information according to the set of security constraint rules. Exemplarily, this re-execution of the compliance check is triggered when an update to the cloud-configured set of security constraint rules is detected. The reason for performing the compliance check again before rendering in this embodiment is that there may be a time lag between the user's initial submission of the content block definition information and its passing of the compliance check, and the actual rendering of the content block. During this time lag, the cloud-configured set of security constraint rules may have been updated, for example, the system administrator may have added a blacklist rule or removed a whitelist rule. If stored content block definitions are still rendered according to the old rules, the content block may no longer comply with the new rules but will still be displayed, thus posing a security risk. Therefore, when any rendering event is triggered, the system first checks whether the cloud configuration has been updated. If it has, a compliance check is performed again on the content block definition information based on the updated set of security constraint rules. If the check passes, normal rendering is allowed; if the check fails, rendering is blocked and the user is notified that the content block no longer complies with the current security specifications, or downgraded content is displayed.Degraded content refers to the following: when the content block definition information fails the re-check of the updated security constraint rule set, the document editing system does not directly render the content block definition information. Instead, it renders an alternative, safe, and simplified content to replace the original content block. For example, a placeholder area can be rendered, displaying a prompt text such as "This content block does not comply with the current security specifications and cannot be displayed temporarily," or displaying metadata such as the content block's creator information and creation time, but without executing any interactive program code or rendering any potentially non-compliant structures or styles. By degrading the display, the user is informed of the reason why the content block is unavailable, while avoiding security risks or page anomalies caused by rendering non-compliant content. Simultaneously, the integrity of the overall document layout is maintained (the user can still see that a content block exists at that location, but the content has been replaced with a security prompt). In this embodiment, the security constraint rule set includes cloud configuration and local configuration. The cloud configuration is uniformly managed and distributed by the server, while the local configuration is the previously successfully distributed cloud configuration, serving as a fallback solution for offline or network anomalies. The cloud configuration has higher priority than the local configuration. When the cloud configuration is updated, the update is pushed or synchronized to the document editing system. After detecting the update, the document editing system performs a compliance check on the content block definition information again according to the updated set of security constraint rules when the target content block is triggered for rendering. Through the above method, this embodiment achieves dynamic security control over the stored content block definition information. Even if the content block passes the compliance check at the time of initial submission, it is still subject to the latest security rules during subsequent rendering, effectively addressing the need for dynamic evolution of security rules and avoiding security vulnerabilities caused by rule lag. Simultaneously, the dual configuration mechanism of prioritizing cloud configuration and providing local configuration as a fallback ensures that the system can still perform compliance checks based on locally cached rules when there are network anomalies or the cloud is unavailable, guaranteeing availability and reliability. The flowchart of another document editing method provided in this application embodiment is shown. Based on the illustrated flowchart, the process includes the following steps: Step 701: Obtain the content block definition information input by the user. Step 702: Perform a compliance check on the content block definition information according to a preset set of security constraint rules. Step 703: In response to the compliance check passing, associate and store the content block definition information with the target document. Step 704: Render the content block definition information into the target document using a method isolated from the target document's document object model to present the target content block; wherein, the interactive program code of the target content block runs in the global runtime environment of the target document. For detailed descriptions of steps 701 to 704, please refer to the relevant descriptions in the above embodiments, which will not be repeated here. Step 705: Obtain additional data generated during the interaction of the target content block; associate and store the additional data with the target content block; update the display content of the target content block according to the additional data, while keeping the structural and style information of the target content block unchanged.Step 705 describes the processing flow of additional data generated during the interaction with the target content block. This additional data refers to the data generated during user interaction with the target content block (such as voting in the voting block, filling out and submitting information in the form block, or completing a signature in the signature block). This data is independent of the content block definition itself (i.e., independent of the content block's structural information, style information, and interaction program code), and is dynamically generated business data during the content block's operation. Step 705 specifically includes three sub-steps: Sub-step 1: Obtaining additional data generated during the interaction with the target content block. When a user performs an interaction operation in the target content block (e.g., clicking a voting button, submitting a form, or completing a signature drawing), the interaction program code responds to the user's operation by generating corresponding additional data (e.g., the user-selected voting option, the filled-in form field values, the drawn signature image data, etc.). The document editing system obtains this data through the open JSAPI. Sub-step 2: Associating and storing the additional data with the target content block. The document editing system establishes an association between the obtained additional data and the corresponding target content block and persists it for storage. Associative storage refers to establishing a correspondence between additional data and target content blocks at the data level, enabling subsequent queries or updates to locate the associated additional data based on the target content block. In this embodiment, the additional data and content block definition information are stored separately. The content block definition information (structure, style, interaction code) is stored in the document structure, while the additional data (user-submitted business data) is independently accessed and managed by the document editing system. Since the two use heterogeneous data structures, changes to either one will not affect the storage structure and integrity of the other. Sub-step 3 updates the display content of the target content block based on the additional data, while the structural and style information of the target content block remains unchanged. After the additional data storage is completed, the document editing system refreshes the display content of the target content block based on the updated additional data. For example, in the voting block, after a user votes, the voting result display area is re-rendered based on the updated voting data (including the current user's new vote and the cumulative voting results of all users), so that the area displays the latest vote count and percentage; in the signature block, after the user completes the signature and confirms, the system updates the display based on the stored signature image data, switching the signature drawing area to the signed signature display. It is important to note that this update process only involves changes to the displayed content; that is, refreshing the information displayed in the content block based on additional data, without altering the content block's structural information (such as the DOM tree structure) or style information (such as font, color, layout, and other appearance styles). By keeping the structural and style information unchanged and only updating the displayed content, this embodiment achieves a rapid refresh of the content block's presentation without re-executing the entire rendering process and compliance checks, thus balancing interactive response speed and system performance.The process shown, based on the previous process, achieves decoupled storage and independent updating of content block definition information and interaction data through step 705. Based on this, since the structural and style information of the target content block remains unchanged, updating the displayed content only involves refreshing the display information based on additional data, without needing to re-execute the complete rendering process such as structural parsing, style calculation, and compliance checks. This significantly reduces rendering overhead and improves interaction response speed and system performance. Simultaneously, by associating the additional data generated by the interaction with the target content block for storage, the target content block has the ability to record the user's operation state and can present different display content based on the current interaction state, such as switching from a non-voted state to a voted state. This makes the content block a stateful interactive unit, enriching the interaction dimensions and application scenarios of custom content blocks. This is a flowchart of another embodiment of a document editing method provided by this application. The process shown, based on the previous process, includes the following steps: Step 801: Obtain the content block definition information input by the user. Step 802: Perform a compliance check on the content block definition information according to a preset set of security constraint rules; if the compliance check passes, execute step 803; if the compliance check fails, execute step 810. Step 803: Associate and store the content block definition information with the target document. Step 804: Render the content block definition information into the target document using a method isolated from the target document's document object model to present the target content block; wherein, the interactive program code of the target content block runs in the global runtime environment of the target document. For detailed descriptions of steps 801 to 804, please refer to the relevant descriptions in the above embodiments, which will not be repeated here. Step 805: In response to an editing operation on the target content block, obtain the edited content block definition information. Step 806: Determine whether the editing operation involves interactive result data associated with the target content block; if yes, proceed to step 807; if no, proceed to step 808. Step 807: Process the interactive result data accordingly based on the type of editing operation; then proceed to step 808. Step 808: Perform a compliance check on the edited content block definition information according to the set of security constraint rules; in response to a successful compliance check, proceed to step 809; in response to a failed compliance check, proceed to step 811. Step 809: Associate the edited content block definition information with the target document and store it to overwrite the target content block; end the process. Step 810: Reject the association of the content block definition information with the target document and output the corresponding prompt message; end the process. Step 810 is the processing branch for compliance check failure in step 802: if the content block definition information submitted by the user fails the compliance check, the association of the content block definition information with the target document is rejected, and the corresponding prompt message is output. For example, the prompt message is used to provide feedback to the user on the specific reasons for the compliance check failure, to help the user locate the problem and make corrections.Specifically, the prompt message includes at least one of the following: the specific location of the non-compliant content, such as prompting the user "used in row 15, column 3".

Claims

1. A document editing method, characterized in that, The method includes: Get the content block definition information input by the user; The content block definition information is subjected to compliance checks based on a preset set of security constraint rules; the set of security constraint rules is used to limit the scope of elements, attributes and / or program interfaces that are allowed to be used in the content block definition information. In response to the compliance check being passed, the content block definition information is associated with and stored in the target document; The content block definition information is rendered into the target document in a manner isolated from the document object model of the target document to present the target content block; wherein, the interactive program code of the target content block runs in the global runtime environment of the target document.

2. The method according to claim 1, characterized in that, The method further includes: In response to the failure of the compliance check, the content block definition information is refused to be associated with the target document for storage, and a corresponding prompt message is output.

3. The method according to claim 1, characterized in that, The method of obtaining the content block definition information input by the user includes one of the following: Obtain the source code entered by the user in the content block editing interface, and use the source code as the content block definition information; Obtain the webpage address specified by the user, and download the webpage source code corresponding to the webpage address as the content block definition information.

4. The method according to claim 3, characterized in that, The content block editing interface includes at least one of the following: The source code editing area is used for users to input and edit the source code defining the content blocks; The preview area is used to preview the rendering effect corresponding to the content block definition information in real time. The verification area is used to display the results of the compliance check.

5. The method according to claim 1, characterized in that, The target content block is displayed in the target document at the position corresponding to the preset operation; Alternatively, the target content block may be presented at a position determined by a set adaptive layout method.

6. The method according to claim 1, characterized in that, The step of associating and storing the content block definition information with the target document includes: The content block definition information is compressed. The compressed data is then encoded. The encoded data is written into the storage structure of the target document.

7. The method according to claim 1, characterized in that, The method of rendering the content block definition information into the target document in a way that isolates it from the document object model of the target document to present the target content block includes: Create a rendering container isolated from the document object model of the target document; The content block definition information is rendered in the rendering container to generate a target content block isolated from the document object model.

8. The method according to claim 7, characterized in that, Before rendering the content block definition information in the rendering container, the method further includes: Based on the set of security constraint rules, a compliance check is performed again on the content block definition information.

9. The method according to claim 8, characterized in that, The step of performing a compliance check on the content block definition information again based on the set of security constraint rules includes: In response to an update to the set of security constraint rules configured in the cloud, a compliance check is performed again on the content block definition information based on the updated set of security constraint rules.

10. The method according to claim 1, characterized in that, The method further includes: In response to the editing operation on the target content block, the edited content block definition information is obtained; Based on the set of security constraint rules, a compliance check is performed on the edited content block definition information; In response to the compliance check being passed, the edited content block definition information is associated with the target document and stored to overwrite the target content block.

11. The method according to claim 10, characterized in that, After obtaining the edited content block definition information in response to the editing operation on the target content block, the method further includes: In response to the interaction result data associated with the target content block involved in the editing operation, the interaction result data is processed accordingly based on the type of the editing operation.

12. The method according to claim 10, characterized in that, The method further includes: In response to the failure of the compliance check, the original content block definition information of the target content block is retained, and a message is displayed indicating that the edited content block definition information is non-compliant.

13. The method according to claim 1, characterized in that, The method further includes: Set the creator of the target content block as the owner of the target content block; The owner of the target content block has the authority to set editing and / or deletion permissions for the target content block.

14. The method according to claim 1, characterized in that, The content block definition information of the target content block has a heterogeneous data structure with other content in the target document, and the permission management and user data management of the target content block are uniformly executed by the target document.

15. The method according to claim 1, characterized in that, The displayed content of the target content block is determined based on the identity information of the user viewing the target content block; when different users view the same target content block, the displayed content and / or interaction status are different.

16. The method according to claim 1, characterized in that, The displayed content of the target content block is determined based on the current interaction state of the target content block; in response to different operations performed by the same user on the target content block, the target content block presents different display states and / or interaction options.

17. The method according to claim 1, characterized in that, The method further includes: Acquire additional data generated during the interaction with the target content block; The additional data is associated with and stored in relation to the target content block; The display content of the target content block is updated based on the additional data, while the structural and style information of the target content block remains unchanged.

18. A document editing device, characterized in that, The device includes: The content block definition acquisition module is used to acquire content block definition information input by the user; The compliance check module is used to perform compliance checks on the content block definition information according to a preset set of security constraint rules; the set of security constraint rules is used to limit the scope of elements, attributes and / or program interfaces that are allowed to be used in the content block definition information. The storage module is used to associate and store the content block definition information with the target document in response to the compliance check being passed; The rendering module is used to render the content block definition information into the target document in a manner isolated from the document object model of the target document, so as to present the target content block; wherein, the interactive program code of the target content block runs in the global runtime environment of the target document.

19. An electronic device, characterized in that, include: A processor and a memory, the processor being configured to execute a document editing program stored in the memory to implement the document editing method according to any one of claims 1-17.

20. A storage medium, characterized in that, The storage medium stores one or more programs, which can be executed by one or more processors to implement the document editing method according to any one of claims 1-17.