Rich text format setting method and device, rich text format clearing method and device, storage medium and electronic equipment

By capturing and caching format data in the rich text editor and applying that data in the target text, inter-browser compatibility issues are solved and the efficiency of rich text editing and format control is improved.

CN118708541APending Publication Date: 2024-09-27AIJI MICRO CONSULTING (XIAMEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410751620.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-12
Publication Date
2024-09-27

AI Technical Summary

Technical Problem

Existing rich text editors have compatibility issues between different browsers, resulting in inconsistent execution results of formatting operations, seriously affecting the editing efficiency of rich text.

Method used

By implementing the format capture and caching mechanism in the rich text editor, the format data of the reference rich text is captured and stored in the cache structure, and then the data is applied in the target rich text, using chained calls to organize the formatting and clearing methods. To improve the efficiency of format control.

Benefits of technology

It improves the compatibility and portability of rich text formats between different platforms, reduces the complexity of format control, and improves the efficiency of rich text editing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118708541A
    Figure CN118708541A
Patent Text Reader

Abstract

The invention discloses a rich text format setting method and device, a rich text format clearing method and device, a storage medium and electronic device.The rich text format setting method comprises the steps that a reference rich text is opened through a rich text editor; according to a capture instruction initiated by a user, performing format capture on the reference rich text to obtain reference format data; storing the reference format data into a cache structure of a rich text editor; opening the target rich text by utilizing a rich text editor; and calling the reference format data from the cache structure according to an application instruction initiated by a user, and applying the reference format data to the target rich text. According to the scheme, the rich text editing efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of text processing, and in particular to a rich text formatting method, clearing method, device, storage medium and electronic device. Background Art

[0002] In Web applications, rich text editing often requires a high degree of format control to meet the publishing needs of different content such as news information, public opinion reports, etc.

[0003] However, the existing implementation method of rich text editors mainly relies on document.execCommand API. Although this method is widely used, it has compatibility issues between different browsers, resulting in inconsistent execution results of format operations, making the format control of rich text more complicated, and seriously affecting the editing efficiency of rich text. Summary of the invention

[0004] The embodiments of the present application provide a rich text formatting method, a clearing method, a device, a storage medium, and an electronic device, which can improve the editing efficiency of rich text.

[0005] In a first aspect, an embodiment of the present application provides a method for setting a rich text format, comprising:

[0006] Use the rich text editor to open the reference rich text;

[0007] According to the capture instruction initiated by the user, the reference rich text is formatted and captured to obtain reference format data;

[0008] Storing the reference format data in a cache structure of the rich text editor;

[0009] Open the target rich text using the rich text editor;

[0010] According to an application instruction initiated by a user, the reference format data is called from the cache structure, and the reference format data is applied to the target rich text.

[0011] In the rich text format setting method provided in the embodiment of the present application, the format of the reference rich text is captured according to the capture instruction initiated by the user to obtain the reference format data, including:

[0012] Determining, according to a capture instruction initiated by the user, a reference node selected by the user in the reference rich text;

[0013] The deep traversal mechanism of the rich text editor is called to traverse the reference node to obtain the format type and format attribute of the reference node.

[0014] In the rich text format setting method provided in the embodiment of the present application, calling the reference format data from the cache structure according to the application instruction initiated by the user and applying the reference format data to the target rich text includes:

[0015] Determine, according to the application instruction initiated by the user, the target node selected by the user in the target rich text;

[0016] Recalling the format type and format attributes of the reference node from the cache structure;

[0017] The format type and the format attributes are applied to the target node.

[0018] In the rich text format setting method provided in the embodiment of the present application, after calling the format type and format attributes of the reference node from the cache structure and before applying the format type and the format attributes to the target node, it also includes:

[0019] Traversing the format type and the format attribute to obtain several format setting methods;

[0020] Organizing the plurality of formatting methods through chain calls to generate a chained formatting method;

[0021] The applying the format type and the format attribute to the target node includes:

[0022] The format type and the format attributes are applied to the target node based on the chained formatting method.

[0023] In the rich text format setting method provided in the embodiment of the present application, after applying the reference format data to the target rich text, it also includes:

[0024] Generating a text preview window in the rich text editor to display the target rich text to which the reference format data is applied;

[0025] Perform corresponding operations based on the confirmation or cancellation instructions initiated by the user.

[0026] In a second aspect, an embodiment of the present application provides a method for clearing a rich text format, comprising:

[0027] Use the rich text editor to open the target rich text;

[0028] According to the capture instruction initiated by the user, the target rich text is captured in a format to obtain target format data;

[0029] Traversing the target format data to obtain several format clearing methods;

[0030] Organizing the plurality of format clearing methods through chain calls to generate a chain format clearing method;

[0031] The target rich text is formatted based on the chain formatting clearing method.

[0032] In a third aspect, an embodiment of the present application provides a rich text format setting device, including:

[0033] A first opening unit is used to open the reference rich text using a rich text editor;

[0034] A first capturing unit, configured to capture the reference rich text in a format according to a capturing instruction initiated by a user, to obtain reference format data;

[0035] A format storage unit, used for storing the reference format data in a cache structure of the rich text editor;

[0036] A second opening unit, used for opening a target rich text using the rich text editor;

[0037] A format application unit is used to call the reference format data from the cache structure according to an application instruction initiated by a user, and apply the reference format data to the target rich text.

[0038] In a fourth aspect, an embodiment of the present application provides a rich text format clearing device, including:

[0039] The third opening unit is used to open the target rich text using a rich text editor;

[0040] A second capturing unit is used to capture the target rich text in a format according to a capturing instruction initiated by a user to obtain target format data;

[0041] A format traversal unit, used for traversing the target format data to obtain a number of format clearing methods;

[0042] A chain organization unit, used for organizing a plurality of the format clearing methods through chain calls to generate a chain format clearing method;

[0043] A format clearing unit is used to clear the format of the target rich text based on the chain format clearing method.

[0044] In a fifth aspect, the present application provides a storage medium storing a plurality of instructions, wherein the instructions are suitable for loading by a processor to execute any of the methods described above.

[0045] In a sixth aspect, the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the methods described above when executing the computer program.

[0046] In summary, the rich text format setting method provided in the embodiment of the present application is to open a reference rich text by using a rich text editor; according to a capture instruction initiated by a user, the reference rich text is formatted to obtain reference format data; the reference format data is stored in a cache structure of the rich text editor; the target rich text is opened by using the rich text editor; according to an application instruction initiated by a user, the reference format data is called from the cache structure, and the reference format data is applied to the target rich text. This solution reduces the complexity of rich text format control and improves the editing efficiency of rich text by storing the reference format data of the reference rich text in a cache structure, then calling the reference format data from the cache structure, and applying the reference format data to the target rich text. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0048] Figure 1 It is a structural diagram of a rich text format setting / clearing system provided in an embodiment of the present application.

[0049] Figure 2 It is a flowchart of the rich text format setting method provided in an embodiment of the present application.

[0050] Figure 3 It is a flowchart of the rich text format clearing method provided in an embodiment of the present application.

[0051] Figure 4 It is a structural diagram of a rich text format setting device provided in an embodiment of the present application.

[0052] Figure 5 It is a structural schematic diagram of a rich text format clearing device provided in an embodiment of the present application.

[0053] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0055] It should be noted that, in this article, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element. In addition, components, features, and elements with the same name in different embodiments of the present application may have the same meaning or different meanings, and their specific meanings need to be determined by their explanation in the specific embodiment or further combined with the context of the specific embodiment.

[0056] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0057] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present application, and have no specific meanings. Therefore, "module", "component" or "unit" can be used in a mixed manner.

[0058] In the description of the present application, it should be noted that the terms "upper", "lower", "left", "right", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present application. In addition, terms such as "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.

[0059] The existing implementation method of rich text editors mainly relies on document.execCommand API. Although this method is widely used, it has compatibility issues between different browsers, resulting in inconsistent execution results of format operations, making the format control of rich text more complicated, and seriously affecting the editing efficiency of rich text.

[0060] Based on this, the embodiments of the present application provide a rich text format setting method, a clearing method, a device, a storage medium and an electronic device. Specifically, the rich text format setting device and the clearing device can be integrated in an electronic device, and the electronic device can be a server or a terminal or other device; wherein the terminal can include a mobile phone, a wearable smart device, a tablet computer, a laptop computer, and a personal computer (PC), etc.; the server can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.

[0061] See also Figure 1 , Figure 1 A schematic diagram of the structure of a rich text format setting / clearing system provided in an embodiment of the present application. The system may include at least one electronic device 1000, at least one server or personal computer 2000. The electronic device 1000 held by the user can be connected to different servers or personal computers through a network. The electronic device 1000 may be an electronic device with computing hardware that can support and execute software products corresponding to multimedia. In addition, the electronic device 1000 may also have one or more multi-touch screens for sensing and obtaining the input of a user through a touch or sliding operation performed at multiple points on one or more touch-sensitive display screens. In addition, the electronic device 1000 can be interconnected with a server or personal computer 2000 through a network. The network may be a wireless network or a wired network, such as a wireless network such as a wireless local area network (WLAN), a local area network (LAN), a cellular network, a 2G network, a 3G network, a 4G network, a 5G network, etc. In addition, different electronic devices 1000 may also use their own Bluetooth network or hotspot network to connect to other embedded platforms or to servers and personal computers, etc.

[0062] Among them, the electronic device includes a touch display screen and a processor, and the touch display screen is used to present a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. When the user operates the graphical user interface through the touch display screen, the graphical user interface can control the local content of the electronic device by responding to the received operation instructions, and can also control the content of the server side by responding to the received operation instructions. For example, the operation instructions generated by the user acting on the graphical user interface include instructions for processing the initial audio signal, and the processor is configured to start the corresponding application after receiving the instructions provided by the user. In addition, the processor is configured to render and draw a graphical user interface associated with the application on the touch display screen. The touch display screen is a multi-touch sensitive screen that can sense touch or sliding operations performed simultaneously at multiple points on the screen. The user uses a finger to perform a touch operation on the graphical user interface, and when the graphical user interface detects the touch operation, the corresponding operation is displayed in the graphical user interface of the control application.

[0063] The technical solutions shown in the present application will be described in detail below through specific embodiments. It should be noted that the description order of the following embodiments is not intended to limit the priority order of the embodiments.

[0064] See also Figure 2 , Figure 2 : is a flow chart of a rich text format setting method provided in an embodiment of the present application. The specific flow of the rich text format setting method can be as follows:

[0065] 101. Use the rich text editor to open the reference rich text.

[0066] Among them, the rich text editor is a text editor that can be embedded in a browser and what you see is what you get. Users can download the rich text editor on the Internet and embed it in the website or program used to facilitate users to edit text. Specifically, after the user embeds the rich text editor in the web page used, the user can open the reference rich text through the rich text editor.

[0067] In an embodiment of the present application, the rich text editor is a rich text editor based on ProseMirror.

[0068] 102. According to the capture instruction initiated by the user, the reference rich text is formatted and captured to obtain reference format data.

[0069] Specifically, the reference node selected by the user in the reference rich text can be determined according to the capture instruction initiated by the user; the deep traversal mechanism of the rich text editor is called to traverse the reference node to obtain the format type and format attributes of the reference node.

[0070] In some embodiments, a capture instruction initiated by a user may be called

[0071] getFirstNodeMarksAndAttrs method to determine the capture range for formatting capture of the reference rich text.

[0072] In the embodiment of the present application, the format type refers to the Mark of ProseMirror, and the format attribute refers to the Attribute of ProseMirror.

[0073] Among them, Mark is an object used to represent text styles, such as bold, italic, underline, link, etc. Different text styles correspond to different Marks. For example, bold text corresponds to Bold Mark. Italic text corresponds to Italic Mark.

[0074] Attribute refers to the properties of a node, which can be align, src, href, etc., and are usually applied to more complex nodes such as image or link nodes. These attributes can be any custom key-value pairs that are used to define specific behaviors or performances of a node. For example, for an image node, you can add a src attribute to specify the source link of the image. For a link node, you can add an href attribute to specify the target address of the link.

[0075] The deep traversal mechanism identifies all Marks applied to the selected node and its child nodes.

[0076] ProseMirror allows Marks to span multiple nodes, so starting from the outermost node, all inherited and directly applied Marks are collected and recorded. This includes basic styles such as bold, italic, links, etc., as well as more complex Marks that may contain additional properties (such as textStyle with style information).

[0077] Unlike Mark, Attribute is usually directly bound to a specific node. The deep traversal mechanism not only checks the Attribute directly bound to the selected node, but also takes into account inherited properties. For example, if the fontSize property of a text node is not directly set, the deep traversal mechanism will detect and apply the corresponding attributes extracted from the upper inheritance or child nodes. This intelligent processing ensures the coherence and consistency of the format. For nodes like paragraphs, it may be necessary to check properties such as alignment and list style. If the node is a more complex object, such as an image or video, it is also necessary to extract information such as src, alt text, width and height.

[0078] It should be noted that special Marks (such as textStyle) may require additional processing because they may not only affect the direct display of text (such as font size and color), but may also involve more complex behaviors (such as font type). When capturing these Marks, the deep traversal mechanism can pay special attention to whether these Marks have already set related properties at a higher level to avoid redundancy and potential conflicts.

[0079] 103. Store reference format data in the cache structure of the rich text editor.

[0080] It is understandable that a rich text editor is a tool that allows users to create and edit text on a web page, and it provides a wealth of formatting options, such as font, color, size, etc. In the embodiment of the present application, in order to allow users to easily implement these formatting, a cache structure is added to the rich text editor.

[0081] This cache structure is used to store reference format data, making it easier to achieve cross-platform migration of text formats. Since the cache structure stores the text format information, when migrating from one platform to another, we only need to migrate the data in the cache structure to ensure that the text format is preserved on the target platform. This greatly improves the compatibility and portability of text formats between different platforms.

[0082] It should be noted that the cache structure cache can not only store the format type and attributes of the reference node, but also process the information of the child nodes to ensure the accuracy and completeness of the format replication.

[0083] 104. Use a rich text editor to open the target rich text.

[0084] Specifically, after the user embeds the rich text editor into the web page being used, the user can open the target rich text through the rich text editor.

[0085] 105. According to the application instruction initiated by the user, call the reference format data from the cache structure, and apply the reference format data to the target rich text.

[0086] Specifically, the target node selected by the user in the target rich text may be determined according to the application instruction initiated by the user; the format type and format attributes of the reference node may be called from the cache structure; and the format type and format attributes may be applied to the target node.

[0087] It should be noted that after the step of "calling the format type and format attributes of the reference node from the cache structure" and before the step of "applying the format type and format attributes to the target node", the following steps are also included:

[0088] Traverse the format types and format attributes to obtain several format setting methods;

[0089] Organize several formatting methods through chain calls to generate a chained formatting method.

[0090] In the specific implementation process, the Marks and Attributes in the cache structure will be traversed to determine all the marks and attributes that should be set. Different marks and attributes correspond to different setting methods. Bold Mark corresponds to the setBoldMark function. Italic Mark corresponds to the setItalicMark function.

[0091] That is, in the specific implementation process, you can use ProseMirror's setMark function to add these Marks one by one to the target node. For example, if the captured format includes bold and italic, these two Marks will be applied to the target node. And for each captured Attribute, if a new value is set on the target node, these attributes will be applied using ProseMirror's setAttribute function. This includes modifying node attributes such as alignment, list type, etc.

[0092] In addition, the embodiment of the present application organizes several formatting methods into a chained formatting method through chained calls, so that the entire formatting process can be clear and efficient. Moreover, the chained operation reduces the complexity of the code and improves the execution efficiency.

[0093] At this time, the step of "applying the format type and format attributes to the target node" may specifically be: applying the format type and format attributes to the target node based on the chain formatting method.

[0094] In one embodiment, multiple commands such as getFormatPainter, setFormatPainter, and unsetFormatPainter can be extended and defined in the rich text editor, allowing the user to start the format brush function, apply the format, or clear the format application in the editor. This series of commands provides a concise application programming interface and is independent of the UI layer, which can ensure the usability under different front-end technology frameworks.

[0095] In some embodiments, the addStorage method can be used to store the state of the format setting (format brush), so that it can track whether the format has been saved and the current state of the format application. The key attributes of the available data source and related data structure are provided for the context of subsequent command operations.

[0096] In the actual application process, before applying any formatting changes, users can see an instant preview in the editor. This preview shows how the text will look after the new format is applied, allowing users to make adjustments before finally submitting the changes. That is, after applying the reference formatting data to the target rich text, it can also include:

[0097] Generate a text preview window in the rich text editor to display the target rich text to which the reference format data is applied;

[0098] Perform corresponding operations based on the confirmation or cancellation instructions initiated by the user.

[0099] It is understandable that if the target rich text after the format is applied is different from the user's expectations, the user can initiate an undo command to return the target rich text to an unset state. If the target rich text after the format is applied is consistent with the user's expectations, the user can confirm the format change by initiating a confirm command. This interactive feedback mechanism enhances the user's control over the editing process, improves user satisfaction and the usability of the editor.

[0100] In summary, the rich text formatting method of the embodiment of the present application opens a reference rich text by using a rich text editor; according to a capture instruction initiated by a user, the reference rich text is formatted to obtain reference format data; the reference format data is stored in the cache structure of the rich text editor; the target rich text is opened by using the rich text editor; according to an application instruction initiated by a user, the reference format data is called from the cache structure, and the reference format data is applied to the target rich text. This solution improves the compatibility and portability of the text format between different platforms by storing the reference format data of the reference rich text in a cache structure, and then calling the reference format data from the cache structure, and applying the reference format data to the target rich text, thereby reducing the complexity of rich text format control and improving the editing efficiency of rich text. Especially for industry news and information, such as semiconductor industry news and information, by improving the editing efficiency of rich text, the timeliness of content release can be achieved and the overall user experience can be improved.

[0101] See also Figure 3 , Figure 3 : is a flow chart of a rich text format clearing method provided in an embodiment of the present application. The specific flow of the rich text format clearing method can be as follows:

[0102] 201. Use a rich text editor to open the target rich text.

[0103] 202. According to the capture instruction initiated by the user, the target rich text is formatted and captured to obtain target format data.

[0104] 203. Traverse the target format data to obtain several format clearing methods.

[0105] 204. Organize several format clearing methods through chain calls to generate a chain format clearing method.

[0106] 205. Clear the format of the target rich text based on the chain format clearing method.

[0107] The specific implementation of each of the above steps can be found in the above-mentioned embodiment of the rich text format setting method, which will not be described one by one here.

[0108] In summary, the embodiment of the present application organizes several format clearing methods into a chain format clearing method through chain calls, so that the entire format clearing process can be clear and efficient. In addition, the chain operation reduces the complexity of the code and improves the execution efficiency.

[0109] In order to better implement the rich text formatting method provided in the embodiment of the present application, the embodiment of the present application also provides a rich text formatting device, wherein the meanings of the nouns are the same as those in the above-mentioned rich text formatting method, and the specific implementation details can refer to the description in the method embodiment.

[0110] See also Figure 4 , Figure 4 30 is a schematic diagram of the structure of the rich text format setting device provided in an embodiment of the present application. The rich text format setting device may include a first opening unit 301, a first capturing unit 302, a format storage unit 303, a second opening unit 304 and a format application unit 305.

[0111] The first opening unit 301 is used to open the reference rich text using a rich text editor;

[0112] The first capturing unit 302 is used to capture the reference rich text in a format according to a capturing instruction initiated by the user to obtain reference format data;

[0113] A format storage unit 303, used to store the reference format data in a cache structure of the rich text editor;

[0114] The second opening unit 304 is used to open the target rich text using a rich text editor;

[0115] The format application unit 305 is used to call the reference format data from the cache structure according to the application instruction initiated by the user, and apply the reference format data to the target rich text.

[0116] The specific implementation of each of the above units can refer to the above-mentioned embodiment of the rich text format setting method, which will not be described one by one here.

[0117] In summary, the rich text format setting device provided in the embodiment of the present application can open the reference rich text by using the rich text editor through the first opening unit 301; the first capture unit 302 performs format capture on the reference rich text according to the capture instruction initiated by the user to obtain the reference format data; the format storage unit 303 stores the reference format data in the cache structure of the rich text editor; the second opening unit 304 opens the target rich text by using the rich text editor; the format application unit 305 calls the reference format data from the cache structure according to the application instruction initiated by the user, and applies the reference format data to the target rich text. This solution can improve the compatibility and portability of the text format between different platforms by storing the reference format data of the reference rich text in the cache structure, and then calling the reference format data from the cache structure, and applying the reference format data to the target rich text, thereby reducing the complexity of rich text format control and improving the editing efficiency of rich text.

[0118] See also Figure 5 , Figure 5 404 is a schematic diagram of the structure of the rich text format setting device provided by the embodiment of the present application. The rich text format clearing device may include a third opening unit 401, a second capturing unit 402, a format traversal unit 403, a chain organization unit 404 and a format clearing unit 405.

[0119] The third opening unit 401 is used to open the target rich text using a rich text editor;

[0120] The second capturing unit 402 is used to capture the target rich text in a format according to the capturing instruction initiated by the user, and obtain the target format data;

[0121] The format traversal unit 403 is used to traverse the target format data and obtain several format clearing methods;

[0122] The chain organization unit 404 is used to organize a plurality of format clearing methods through chain calls to generate a chain format clearing method;

[0123] The format clearing unit 405 is used to clear the format of the target rich text based on the chain format clearing method.

[0124] The specific implementation of each of the above units can refer to the above-mentioned embodiment of the rich text format clearing method, which will not be described one by one here.

[0125] In summary, the embodiment of the present application organizes several format clearing methods into a chain format clearing method through chain calls, so that the entire format clearing process can be clear and efficient. In addition, the chain operation reduces the complexity of the code and improves the execution efficiency.

[0126] The present application also provides an electronic device, in which the rich text format setting device of the present application can be integrated, such as Figure 6 As shown, it shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application, specifically:

[0127] The electronic device may include components such as a radio frequency (RF) circuit 601, a memory 602 including one or more computer-readable storage media, an input unit 603, a display unit 604, a sensor 605, an audio circuit 606, a wireless fidelity (WiFi) module 607, a processor 608 including one or more processing cores, and a power supply 609. Those skilled in the art will appreciate that Figure 6 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0128] in:

[0129] The RF circuit 601 can be used for receiving and sending signals during the process of sending and receiving information or making calls. In particular, after receiving the downlink information of the base station, it is handed over to one or more processors 608 for processing; in addition, the data related to the uplink is sent to the base station. Generally, the RF circuit 601 includes but is not limited to an antenna, at least one amplifier, a tuner, one or more oscillators, a subscriber identity module (Subscriber Identity Module, SIM) card, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the RF circuit 601 can also communicate with the network and other devices through wireless communication. Wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (Global System of Mobile communication, GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE), email, Short Messaging Service (SMS), etc.

[0130] The memory 602 can be used to store software programs and modules, and the processor 608 executes various functional applications and information processing by running the software programs and modules stored in the memory 602. The memory 602 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device (such as audio data, a phone book, etc.), etc. In addition, the memory 602 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 602 may also include a memory controller to provide the processor 608 and the input unit 603 with access to the memory 602.

[0131] The input unit 603 can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control. Specifically, in a specific embodiment, the input unit 603 may include a touch-sensitive surface and other input devices. The touch-sensitive surface, also known as a touch display screen or a touch pad, can collect the user's touch operations on or near it (such as the user's operation on or near the touch-sensitive surface using any suitable object or accessory such as a finger, a stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch-sensitive surface may include a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 608, and can receive and execute the command sent by the processor 608. In addition, the touch-sensitive surface can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch-sensitive surface, the input unit 603 may also include other input devices. Specifically, other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.

[0132] The display unit 604 can be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, which can be composed of graphics, text, icons, videos and any combination thereof. The display unit 604 may include a display panel. Optionally, the display panel may be configured in the form of a liquid crystal display (Liquid Crystal Display, LCD), an organic light-emitting diode (Organic Light-Emitting Diode, OLED), etc. Further, the touch-sensitive surface may cover the display panel, and when the touch-sensitive surface detects a touch operation on or near it, it is transmitted to the processor 608 to determine the type of touch event, and then the processor 608 provides a corresponding visual output on the display panel according to the type of touch event. Although in Figure 6 In the embodiment, the touch-sensitive surface and the display panel are used as two independent components to realize input and output functions, but in some embodiments, the touch-sensitive surface and the display panel can be integrated to realize input and output functions.

[0133] The electronic device may also include at least one sensor 605, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel according to the brightness of the ambient light, and the proximity sensor may turn off the display panel and / or backlight when the electronic device is moved to the ear. As a type of motion sensor, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in the electronic device, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.

[0134] The audio circuit 606, the speaker, and the microphone can provide an audio interface between the user and the electronic device. The audio circuit 606 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 606 and converted into audio data, and then the audio data is output to the processor 608 for processing, and then sent to another electronic device through the RF circuit 601, or the audio data is output to the memory 602 for further processing. The audio circuit 606 may also include an earplug jack to provide communication between an external headset and the electronic device.

[0135] WiFi is a short-range wireless transmission technology. Electronic devices can help users send and receive emails, browse web pages, and access streaming media through WiFi module 607. It provides users with wireless broadband Internet access. Figure 6 , a WiFi module 607 is shown, but it is understandable that it is not a necessary component of the electronic device and can be omitted as needed without changing the essence of the invention.

[0136] The processor 608 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire mobile phone. By running or executing software programs and / or modules stored in the memory 602, and calling data stored in the memory 602, it executes various functions of the electronic device and processes data, thereby monitoring the mobile phone as a whole. Optionally, the processor 608 may include one or more processing cores; preferably, the processor 608 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 608.

[0137] The electronic device also includes a power supply 609 (such as a battery) for supplying power to each component. Preferably, the power supply can be logically connected to the processor 608 through a power management system, so that the power management system can manage charging, discharging, and power consumption management. The power supply 609 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0138] Although not shown, the electronic device may also include a camera, a Bluetooth module, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 608 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 602 according to the following instructions, and the processor 608 will run the application programs stored in the memory 602, thereby realizing various functions, such as:

[0139] Use the rich text editor to open the reference rich text;

[0140] According to the capture instruction initiated by the user, the reference rich text is formatted and captured to obtain reference format data;

[0141] Storing the reference format data in a cache structure of the rich text editor;

[0142] Open the target rich text using the rich text editor;

[0143] According to an application instruction initiated by a user, the reference format data is called from the cache structure, and the reference format data is applied to the target rich text.

[0144] or,

[0145] Use the rich text editor to open the target rich text;

[0146] According to the capture instruction initiated by the user, the target rich text is captured in a format to obtain target format data;

[0147] Traversing the target format data to obtain several format clearing methods;

[0148] Organizing the plurality of format clearing methods through chain calls to generate a chain format clearing method;

[0149] The target rich text is formatted based on the chain formatting clearing method.

[0150] In summary, the electronic device provided by the embodiment of the present application can improve the compatibility and portability of text formats between different platforms by storing the reference format data of the reference rich text in a cache structure, then calling the reference format data from the cache structure, and applying the reference format data to the target rich text, thereby reducing the complexity of rich text format control and improving the editing efficiency of rich text. In addition, by organizing several format clearing methods into a chained format clearing method through chained calls, the entire format clearing process can be made clear and efficient. In addition, chain operations reduce the complexity of the code and improve the efficiency of execution.

[0151] In the above embodiments, the description of each embodiment has its own focus. For the parts that are not described in detail in a certain embodiment, please refer to the detailed description of the rich text format setting method and clearing method above, which will not be repeated here.

[0152] It should be noted that, for the rich text format setting method and clearing method in the embodiments of the present application, those skilled in the art can understand that all or part of the processes of the rich text format setting method and clearing method in the embodiments of the present application can be completed by controlling the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, such as stored in the memory of a terminal, and executed by at least one processor in the terminal. During the execution process, it may include the processes of the embodiments of the rich text format setting method and clearing method.

[0153] For the rich text format setting device and clearing device of the embodiment of the present application, each functional module can be integrated into a processing chip, or each module can exist physically separately, or two or more modules can be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware or in the form of software functional modules. If the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium.

[0154] To this end, an embodiment of the present application provides a storage medium in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any one of the rich text format setting methods and clearing methods provided in the embodiments of the present application. The storage medium may be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), etc.

[0155] The rich text format setting method, clearing method, device, storage medium and electronic device provided by the present application are respectively introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the core idea of ​​the present application; at the same time, for technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A rich text formatting method, characterized in that: include: Use the rich text editor to open the reference rich text; According to the capture instruction initiated by the user, the reference rich text is formatted and captured to obtain reference format data; Storing the reference format data in a cache structure of the rich text editor; Open the target rich text using the rich text editor; According to an application instruction initiated by a user, the reference format data is called from the cache structure, and the reference format data is applied to the target rich text.

2. The rich text format setting method according to claim 1, characterized in that: The step of capturing the reference rich text in a format according to the capture instruction initiated by the user to obtain reference format data includes: Determining, according to a capture instruction initiated by the user, a reference node selected by the user in the reference rich text; The deep traversal mechanism of the rich text editor is called to traverse the reference node to obtain the format type and format attribute of the reference node.

3. The rich text formatting method according to claim 2, wherein: The calling the reference format data from the cache structure according to the application instruction initiated by the user, and applying the reference format data to the target rich text, comprises: Determine, according to the application instruction initiated by the user, the target node selected by the user in the target rich text; Recalling the format type and format attributes of the reference node from the cache structure; The format type and the format attributes are applied to the target node.

4. The rich text format setting method according to claim 3, characterized in that: After calling the format type and format attributes of the reference node from the cache structure and before applying the format type and the format attributes to the target node, the method further includes: Traversing the format type and the format attribute to obtain several format setting methods; Organizing the plurality of formatting methods through chain calls to generate a chained formatting method; The applying the format type and the format attribute to the target node includes: The format type and the format attributes are applied to the target node based on the chained formatting method.

5. The rich text format setting method according to claim 1, characterized in that: After applying the reference format data to the target rich text, the method further includes: Generating a text preview window in the rich text editor to display the target rich text to which the reference format data is applied; Perform corresponding operations based on the confirmation or cancellation instructions initiated by the user.

6. A method for clearing rich text format, characterized in that: include: Use the rich text editor to open the target rich text; According to the capture instruction initiated by the user, the target rich text is captured in a format to obtain target format data; Traversing the target format data to obtain several format clearing methods; Organizing the plurality of format clearing methods through chain calls to generate a chain format clearing method; The target rich text is formatted based on the chain formatting clearing method.

7. A rich text format setting device, characterized in that: include: A first opening unit is used to open the reference rich text using a rich text editor; A first capturing unit, configured to capture the reference rich text in a format according to a capturing instruction initiated by a user, to obtain reference format data; A format storage unit, used for storing the reference format data in a cache structure of the rich text editor; A second opening unit, used for opening a target rich text using the rich text editor; A format application unit is used to call the reference format data from the cache structure according to an application instruction initiated by a user, and apply the reference format data to the target rich text.

8. A rich text format clearing device, characterized in that: include: The third opening unit is used to open the target rich text using a rich text editor; A second capturing unit is used to capture the target rich text in a format according to a capturing instruction initiated by a user to obtain target format data; A format traversal unit, used for traversing the target format data to obtain a number of format clearing methods; A chain organization unit, used for organizing a plurality of the format clearing methods through chain calls to generate a chain format clearing method; A format clearing unit is used to clear the format of the target rich text based on the chain format clearing method.

9. A storage medium, characterized in that: The storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the method according to any one of claims 1 to 5 or 6.

10. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 5 or 6 is implemented.