Rich text image-text pasting method and device, electronic equipment and readable storage medium

Through DOM parsing and server resource address replacement, the problem of rich text pictures and text pasting in the browser displaying local pictures is solved, which improves the reliability and compatibility of pasting and reduces server resource usage.

CN118886401APending Publication Date: 2024-11-01CHINA UNITED NETWORK COMM GRP CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410904908.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2024-11-01

AI Technical Summary

Technical Problem

The existing rich text image pasting methods have poor reliability and compatibility, especially the fact that local image information in the document cannot be directly displayed under browser security restrictions.

Method used

By listening to the rich text paste event, get the HTML text to be pasted, perform DOM parsing, extract image information, and upload it to the server, replace it with the network resource address, convert the updated rich text DOM into HTML text and paste it to rich text editing in the tool.

Benefits of technology

It effectively improves the reliability and compatibility of rich text pasting, avoids compatibility problems caused by browser errors and different platforms or file formats, and reduces server resource usage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118886401A_ABST
    Figure CN118886401A_ABST
Patent Text Reader

Abstract

The invention provides a rich text image-text pasting method and device, electronic equipment and a readable storage medium, and can be applied to the technical field of data processing. The method comprises the steps that a rich text pasting event is monitored, and when it is monitored that a user executes pasting operation in a rich text editor, a first HTML text to be pasted is obtained from a system pasting board; performing DOM (Document Object Model) analysis on the first HTML text, and converting the first HTML text into a rich text DOM; obtaining a picture container in the rich text DOM, and extracting first picture information from the picture container; wherein the first picture information comprises a picture name and a local resource address; uploading a picture file corresponding to the first picture information to a server, and obtaining a network resource address of the picture file on the server; and replacing a local resource address of the picture container with a network resource address, converting the updated rich text DOM into a second HTML text, and pasting the second HTML text into a rich text editor. According to the method provided by the invention, the reliability and compatibility of rich text image-text pasting are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method, device, electronic device and readable storage medium for pasting rich text and images. Background Art

[0002] With the development of Internet technology, various types of WEB projects generally use rich text editors to publish graphic information, which mostly comes from other edited documents, such as WORD, PPT, etc. Maintenance personnel can directly copy and paste graphic information from the document into the rich text editor, but due to the security restrictions of the browser, the local image information in the document cannot be displayed in the rich text editor.

[0003] To this end, currently rich text can be pasted into document images by listening to the rich text paste event, obtaining the text content in the rich text format (RTF) to be pasted, using regular expressions to obtain the hexadecimal information of the image in the RTF content, converting the image into BASE64 format and uploading it to the server, thereby realizing the pasting and display of the document image.

[0004] However, in the above method for pasting rich text and images, there is a problem of poor reliability and compatibility of pasting rich text and images. Summary of the invention

[0005] The present application provides a rich text image pasting method, device, electronic device and readable storage medium, which are used to solve the technical problem of poor reliability and compatibility of rich text image pasting in existing rich text image pasting.

[0006] According to the first aspect disclosed in the present application, the present application provides a rich text image pasting method, comprising:

[0007] Listen for rich text paste events, and when the user is detected to perform a paste operation in the rich text editor, obtain the first HTML text to be pasted from the system clipboard;

[0008] Performing DOM parsing on the first HTML text, and converting the first HTML text into a rich text DOM;

[0009] Based on the DOM operation method, obtain the image container in the rich text DOM, and extract the first image information from the image container; wherein the first image information includes the image name and the local resource address;

[0010] Uploading the image file corresponding to the first image information to the server, and obtaining the network resource address of the image file on the server;

[0011] The local resource address of the image in the image container is replaced with the network resource address, and the updated rich text DOM is converted into a second HTML text and pasted into the rich text editor.

[0012] In a feasible implementation manner, the DOM operation method is based on obtaining the image container in the rich text DOM, and extracting the first image information from the image container, including:

[0013] Traverse the nodes of the rich text DOM to obtain the image container in the rich text DOM;

[0014] Based on the node attributes of the picture container, obtaining the local resource address of the picture in the picture container;

[0015] Based on the local resource address, the picture name of the picture in the picture container is extracted.

[0016] In a feasible implementation manner, before uploading the picture file corresponding to the first picture information to the server based on the first picture information, the method further includes:

[0017] Initialize the first picture information array; wherein the initial state of the first picture information array is empty;

[0018] Storing each piece of first picture information into the first picture information array;

[0019] Determine whether the first picture information array is empty. If the first picture information array is not empty, perform a step of uploading a picture file corresponding to the first picture information to a server based on the first picture information.

[0020] In a feasible implementation manner, the method further includes:

[0021] If the first picture information array is empty, the first HTML text is pasted into the rich text editor.

[0022] In a feasible implementation manner, uploading the picture file corresponding to the first picture information to the server includes:

[0023] Create a file upload control;

[0024] Triggering a click event of the file upload control to open a file selector;

[0025] Acquire the second picture information of the picture file selected by the user, and upload the picture file corresponding to the second picture information matching the first picture information to the server; wherein the second picture information includes the picture name and the local resource address.

[0026] In a feasible implementation manner, uploading the image file corresponding to the second image information matching the first image information to the server includes:

[0027] Initialize the second picture information array; wherein the initial state of the second picture information data is empty;

[0028] For each piece of second picture information, the second picture information is matched with the first picture information in the first picture information array, and if the match is successful, the second picture information is stored in the array of picture information to be uploaded;

[0029] Based on the file upload control, the picture files corresponding to the respective second picture information in the second picture information array are uploaded to the server in batches.

[0030] In a feasible implementation manner, replacing the local resource address of the picture in the picture container with the network resource address includes:

[0031] For each picture container, marking the picture container based on the picture name of the first picture information corresponding to the picture container;

[0032] For each picture file stored in the server, the picture name of the picture file is matched with the picture name marked in each picture container, and the local resource address of the picture in the successfully matched picture container is replaced with the network resource address of the picture file.

[0033] According to the second aspect disclosed in the present application, the present application provides a rich text image pasting method, comprising:

[0034] The text acquisition module is used to monitor the rich text paste event, and when it monitors that the user performs a paste operation in the rich text editor, it obtains the first HTML text to be pasted from the system clipboard;

[0035] A DOM parsing module, used for performing DOM parsing on the first HTML text, and converting the first HTML text into a rich text DOM;

[0036] An information extraction module, used to obtain the image container in the rich text DOM based on a DOM operation method, and extract the first image information from the image container; wherein the first image information includes the image name and the local resource address;

[0037] A file uploading module, used to upload the image file corresponding to the first image information to the server, and obtain the network resource address of the image file on the server;

[0038] The text pasting module is used to replace the local resource address of the image in the image container with the network resource address, and convert the updated rich text DOM into a second HTML text and paste it into the rich text editor.

[0039] According to a third aspect disclosed in the present application, there is provided an electronic device, comprising a processor, and a memory communicatively connected to the processor;

[0040] The memory stores computer-executable instructions;

[0041] The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of the first aspects.

[0042] According to a fourth aspect disclosed in the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement any one of the methods described in the first aspect.

[0043] According to a fifth aspect disclosed in the present application, a computer program product is provided, including a computer program, wherein the computer program is used to implement any one of the methods in the first aspect when executed by a processor.

[0044] Compared with the prior art, this application has the following beneficial effects:

[0045] The present application provides a method, device, electronic device and readable storage medium for pasting rich text and images. When a rich text editor copies text and image content from other documents for pasting, the method converts the HTML text to be pasted into a rich text DOM, uses a DOM operation method to obtain a picture container and picture information in the rich text DOM, and then uploads the file of the picture corresponding to the picture information to a server. Finally, the local resource address of the picture container in the rich text DOM is replaced with the network resource address of the picture file on the server, and the updated rich text DOM is converted into HTML text and pasted into the rich text editor, so that the picture in the pasted text and image content can be displayed normally in the rich text editor.

[0046] By using a general DOM operation method to obtain image information, compared with the existing method of using regular expressions to obtain image information in rich text format, using the DOM operation method to obtain image information can effectively avoid browser errors and affect page operation. At the same time, using the DOM operation method to obtain image information can also avoid compatibility issues caused by uncertain formats of pasted content obtained from different platforms or file formats. In addition, by replacing the local resource address with the network resource address returned by the server, compared with the existing method of converting the image into BASE64 format, it also avoids excessive or excessive BASE64 image information, thereby avoiding the rich text content to be pasted from being too large, and effectively reducing the server's resource usage. Therefore, compared with the existing rich text image and text pasting method, the present application effectively improves the reliability and compatibility of rich text image and text pasting. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0048] Figure 1 A schematic diagram of a process for pasting rich text images provided in an embodiment of the present application;

[0049] Figure 2 A schematic diagram of another rich text image pasting method provided in an embodiment of the present application;

[0050] Figure 3 A schematic diagram of the structure of a rich text image pasting device provided in an embodiment of the present application;

[0051] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0052] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0053] 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.

[0054] Rich text editor is a WYSIWYG text editor that can be embedded in the browser. It allows users to perform rich text editing, including but not limited to text editing, formatting, typesetting, media file editing and uploading, hyperlinks, text export, printing and other functions.

[0055] With the development of Internet technology, various types of WEB projects generally use rich text editors to publish graphic information, which mostly comes from other edited documents, such as WORD, PPT, etc. Maintenance personnel can directly copy and paste graphic information from the document into the rich text editor, but due to the security restrictions of the browser, the local image information in the document cannot be displayed in the rich text editor.

[0056] To this end, currently rich text can be pasted into document images by listening to the rich text paste event, obtaining the text content in the rich text format (RTF) to be pasted, using regular expressions to obtain the hexadecimal information of the image in the RTF content, converting the image into BASE64 format and uploading it to the server, thereby realizing the pasting and display of the document image.

[0057] However, in the above method of pasting rich text images, since regular expressions are used to obtain image information, if the image information is too long, it will exceed the limit of the JavaScript engine, which will affect the operation of the page and reduce the reliability of pasting rich text images. In addition, due to the uncertainty of the format of the pasted content obtained by different platforms (Mac, Windows, etc.) or file formats (WORD, PPT, etc.), RTF may be empty, resulting in poor compatibility. In addition, after the image is converted into BASE64 and submitted to the server as content, if the image is too large or too many, it will cause the rich text content to be too large, occupying too many server resources, and also affecting the reliability of pasting rich text images.

[0058] In response to the above technical problems, this application proposes a rich text image pasting method, which converts the HTML text to be pasted into a rich text editor into a rich text DOM, and uses a general DOM operation method to complete the rich text image pasting operation, effectively improving the reliability and compatibility of rich text image pasting.

[0059] The technical solution of the rich text image pasting method provided by the present application is described in detail below through specific embodiments. It should be noted that the following embodiments can exist alone or in combination with each other, and the same or similar content may not be repeatedly described in different embodiments.

[0060] Figure 1 A flowchart of a rich text image pasting method provided in an embodiment of the present application is shown in FIG. Figure 1In some embodiments, the process of the rich text image pasting method includes the following steps:

[0061] S101, monitoring a rich text paste event, and when monitoring that a user performs a paste operation in a rich text editor, obtaining a first HTML text to be pasted from a system clipboard.

[0062] Among them, the implementation of monitoring rich text paste events can choose to register the monitoring event on the browser side, or it can be implemented by installing a special client on the user's local device. Specifically, when the user opens the editing page of the rich text editor to edit the content, the client can immediately use WebSocket and other methods to establish a communication relationship with the locally established monitoring service after monitoring the user opening the current editing page. If the connection is successful, the user's installed client is prompted to enter the monitoring state. In addition, in addition to monitoring rich text paste events, this client can also be used to implement the subsequent processes of the rich text image and text paste method, such as DOM parsing, rich text DOM operations, image upload server, etc.

[0063] Since the rich text editor is embedded in the browser, when copying and pasting rich text content containing images in a local document file into a WEB application, the paste content information in the paste event obtained in the system clipboard is generally in HTML format. Therefore, the first HTML text to be pasted can be obtained from the system clipboard.

[0064] Specifically, the copy source of the rich text content can be a local WORD, PPT or other file, or a web page content, and there is no restriction on this.

[0065] S102: Perform DOM parsing on the first HTML text, and convert the first HTML text into a rich text DOM.

[0066] Among them, HTML (Hyper Text Markup Language) is a standard markup language for creating web pages. First, HTML text is mainly composed of HTML tags, which define the content and structure of the web page. DOM (Document Object Model) is a programming interface for HTML documents. It presents HTML documents as a tree structure, in which each HTML element is a node in this tree. Through DOM, WEB developers can use programming languages ​​such as JavaScript to access, modify and delete HTML elements, thereby realizing the development of dynamic web pages and interactive applications. The relationship between HTML and DOM is complementary. HTML defines the structure and content of web pages, while DOM provides a way to interact with these structures and contents. Through HTML parsing and the construction of the DOM tree, the browser can convert the HTML document into an operable DOM tree, thereby realizing the development of dynamic web pages and interactive applications.

[0067] Therefore, the HTML parsing API (such as DOMParser, etc.) of the browser may be called to convert the first HTML text to be pasted into a rich text DOM.

[0068] S103, based on the DOM operation method, obtain the image container in the rich text DOM, and extract the first image information from the image container; wherein the first image information includes the image name and the local resource address.

[0069] After the first HTML text is converted into a rich text DOM, the corresponding DOM operation methods can be used to extract information, modify information, etc. on the rich text DOM. Specifically, the DOM operation method refers to operations such as accessing, modifying, and deleting elements in the HTML document. For example, JavaScript defines many DOM operation methods, which can easily access, modify, and delete the DOM.

[0070] In DOM, HTML documents are parsed into a structure consisting of nodes and objects. The label indicates that The tag also contains the attribute src, which is used to specify the source (URL) of the image.

[0071] Therefore, by Tags can be searched to find all image containers. The first picture information including the picture name and the local resource address can be further extracted by accessing the src attribute in the tag.

[0072] Specifically, for a picture, a temporary file is generally generated when it is copied and recorded as a local protocol file address. The local resource address refers to the specific storage path of the picture file on the local storage device. For example, the specific path example of the local resource address is C:\Users\Username\Documents\image.png.

[0073] S104: Upload the picture file corresponding to the first picture information to the server, and obtain the network resource address of the picture file on the server.

[0074] The first image information is used to upload the corresponding local image file stored locally to the server, and the network resource address of the image file on the server is obtained. Specifically, the network resource path refers to the specific storage path of the image file on the server. For example, the specific path example of the network resource path is https: / / www.example.com / Documents / image.png.

[0075] S105: Replace the local resource address of the image in the image container with the network resource address, and convert the updated rich text DOM into a second HTML text and paste it into the rich text editor.

[0076] Among them, the originally copied local image files have been uploaded to the server in the previous step, so the network resource addresses of these image files can be used to replace the local resource addresses in the original system clipboard, and the text content parsed by the updated rich text DOM can be reorganized into a second HTML text, and the updated second HTML text can be pasted into the rich text editor. Since the resource address of the image file in the updated second HTML text is a network resource address, the rich text editor embedded in the browser can display the image file normally, thereby realizing the copy and paste of the image and text content of the rich text editor.

[0077] In this embodiment, when the rich text editor copies graphic content from other documents for pasting, the HTML text to be pasted is converted into a rich text DOM, and the DOM operation method is used to obtain the image container and image information in the rich text DOM, and then the file of the image corresponding to the image information is uploaded to the server, and finally the local resource address of the image container in the rich text DOM is replaced with the network resource address of the image file on the server, and the updated rich text DOM is converted into HTML text and pasted into the rich text editor, so that the image in the pasted graphic content can be displayed normally in the rich text editor.

[0078] By using a general DOM operation method to obtain image information, compared with the existing method of using regular expressions to obtain image information in rich text format, using the DOM operation method to obtain image information can effectively avoid browser errors and affect page operation. At the same time, using the DOM operation method to obtain image information can also avoid compatibility issues caused by uncertain formats of pasted content obtained from different platforms or file formats. In addition, by replacing the local resource address with the network resource address returned by the server, compared with the existing method of converting the image into BASE64 format, it also avoids excessive or excessive BASE64 image information, thereby avoiding the rich text content to be pasted from being too large, and effectively reducing the server's resource usage. Therefore, compared with the existing rich text image and text pasting method, the present application effectively improves the reliability and compatibility of rich text image and text pasting.

[0079] exist Figure 1 Based on the embodiment shown, the following Figure 2 , the technical solution of the above-mentioned rich text image pasting method is further introduced.

[0080] Figure 2 A flowchart of another rich text image pasting method provided in an embodiment of the present application is shown in FIG. Figure 2 In some embodiments, the process of the rich text image pasting method includes the following steps.

[0081] S201, monitoring a rich text paste event, and when monitoring that a user performs a paste operation in a rich text editor, obtaining a first HTML text to be pasted from a system clipboard.

[0082] S202: Perform DOM parsing on the first HTML text, and convert the first HTML text into a rich text DOM.

[0083] S203, traverse the nodes of the rich text DOM to obtain the image container in the rich text DOM.

[0084] For example, since DOM presents HTML documents as a tree structure, each HTML element is a node in the tree. Therefore, by traversing the nodes of the rich text DOM, all nodes containing images in the rich text DOM can be obtained. , which is the image container.

[0085] S204: Based on the node attribute of the picture container, obtain the local resource address of the picture in the picture container.

[0086] In which, exemplary, after obtaining the image container, Access the src attribute in the node to obtain the local resource address of the image in the image container.

[0087] S205: extracting the picture name of the picture in the picture container based on the local resource address.

[0088] By obtaining the local resource address, the name of the image can be extracted from the local resource address. For example, assuming that the local resource address of the image file is C:\Users\Username\Documents\image.png, the image name image can be extracted from the string of the local resource address based on the JavaScript string method split().

[0089] S206, initializing a first picture information array; wherein the first picture information array is initially empty.

[0090] S207, storing each piece of first picture information into a first picture information array.

[0091] S208: Determine whether the first picture information array is empty.

[0092] Among them, by obtaining the length of the first picture information array, that is, the number of elements in the array, if the length of the picture information array is not 0, it means that the picture information array is not empty, that is, it indicates that there are picture files that need to be uploaded to the server. If the length of the picture information array is 0, it means that the picture information data is empty, that is, it indicates that there are no picture files that need to be uploaded to the server.

[0093] S209: If the first picture information array is not empty, create a file upload control.

[0094] Among them, the file upload control is an interface element used in web pages to allow users to select and upload files to the server. In the front end, usually using HTML <input type="file"> Tag to create a file upload control. In addition, in HTML, <input type="file"multiple> Allow users to select multiple files, so that they can select multiple image files at the same time for batch upload. On the server side, you need to write code to handle the logic of file upload, including receiving files, verifying file types, saving files to specified paths, etc.

[0095] Preferably, the file upload control is set to a hidden style, which can improve the aesthetics of the application.

[0096] S210, triggering a click event of the file upload control to open a file selector.

[0097] After the file upload control is constructed, the click event of the file upload control is automatically triggered to open the file selector, thereby facilitating the user to select the image file to be uploaded.

[0098] S211, obtaining second picture information of the picture file selected by the user, and uploading the picture file corresponding to the second picture information matching the first picture information to the server; wherein the second picture information includes a picture name and a local resource address.

[0099] Among them, for the file selector, after the user selects an image file, the local resource address of the image file selected by the user can also be obtained, and the image name can be extracted through the local resource address.

[0100] Preferably, after the user selects the image file to be uploaded, the second image information of the image file selected by the user is matched with the first image information extracted from the image container, so that the successfully matched image file is uploaded to the server. The specific process includes:

[0101] Step 1, initialize the second picture information array; wherein the initial state of the second picture information data is empty.

[0102] Step 2: For each piece of second picture information, match the second picture information with the first picture information in the first picture information array. If the match is successful, store the second picture information in the array of picture information to be uploaded.

[0103] Among them, if the image file selected by the user is the image file corresponding to the image container, the second image information of this image file should be consistent with the first image information, that is, the image name and local resource address contained in the second image information and the first image information are the same. If the first image information in the first image information array matches the second image information successfully, the second image information is stored in the image information array to be uploaded to facilitate the subsequent batch uploading of image files. If the match fails, the image file corresponding to the second image information will not be uploaded.

[0104] Step 3: Based on the file upload control, upload the picture files corresponding to each second picture information in the second picture information array to the server in batches.

[0105] Among them, through the file upload control, the image files corresponding to the second image information in the array of image information to be uploaded are uploaded to the server in batches to complete the batch uploading of image files. Using the upload control, users can select images to upload in batches, improve the efficiency of image and text pasting, and also avoid compatibility issues caused by uncertain pasting content formats obtained from different platforms or file formats.

[0106] S212: For each picture container, mark the picture container based on the picture name of the first picture information corresponding to the picture container.

[0107] The picture container is marked using the picture name of the first picture information corresponding to the picture container, so as to facilitate subsequent search for the picture container corresponding to the picture file uploaded to the server, thereby facilitating the replacement of the resource address.

[0108] S213, for each picture file stored in the server, match the picture name of the picture file with the picture name marked in each picture container, and replace the local resource address of the picture in the successfully matched picture container with the network resource address of the picture file.

[0109] The local resource address of the image in the image container corresponding to the image file stored in the server is replaced with the network resource address of the image file, so that the image in the image container can be normally displayed in the rich text editor.

[0110] S214, converting the updated rich text DOM into a second HTML text and pasting the second HTML text into the rich text editor.

[0111] S215: If the first picture information array is empty, paste the first HTML text into the rich text editor.

[0112] If the first picture information array is empty, indicating that there is no picture in the first HTML text to be pasted, there is no need to perform subsequent picture upload operations, and the first HTML text is directly pasted into the rich text editor.

[0113] Figure 3 is a structural schematic diagram of a rich text image pasting device provided in an embodiment of the present application, see Figure 3 The rich text image pasting device includes various functional modules for implementing the aforementioned rich text image pasting method, and any functional module can be implemented by software and / or hardware.

[0114] In some embodiments, the rich text image pasting device 300 includes a text acquisition module 301, a DOM parsing module 302, an information extraction module 303, a file upload module 304 and a text pasting module 305. Among them:

[0115] The text acquisition module 301 is used to monitor the rich text paste event, and when monitoring the user performing the paste operation in the rich text editor, obtain the first HTML text to be pasted from the system clipboard;

[0116] The DOM parsing module 302 is used to perform DOM parsing on the first HTML text and convert the first HTML text into a rich text DOM;

[0117] The information extraction module 303 is used to obtain the image container in the rich text DOM based on the DOM operation method, and extract the first image information from the image container; wherein the first image information includes the image name and the local resource address;

[0118] The file uploading module 304 is used to upload the picture file corresponding to the first picture information to the server, and obtain the network resource address of the picture file on the server;

[0119] The text pasting module is used to replace the local resource address of the image in the image container with the network resource address, and convert the updated rich text DOM into a second HTML text and paste it into the rich text editor.

[0120] In some embodiments, the DOM parsing module 302 is specifically used to:

[0121] Traverse the nodes of the rich text DOM and obtain the image container in the rich text DOM;

[0122] Based on the node attributes of the image container, obtain the local resource address of the image in the image container;

[0123] Extract the image name of the image in the image container based on the local resource address.

[0124] In some embodiments, the file upload module 304 is further configured to:

[0125] Initialize the first picture information array; wherein the initial state of the first picture information array is empty;

[0126] Storing each piece of first picture information into a first picture information array;

[0127] It is determined whether the first picture information array is empty. If the first picture information array is not empty, a step of uploading a picture file corresponding to the first picture information to a server is performed based on the first picture information.

[0128] In some embodiments, the file upload module 304 is further configured to:

[0129] If the first picture information array is empty, the first HTML text is pasted into the rich text editor.

[0130] In some embodiments, the file upload module 304 is further configured to:

[0131] Create a file upload control;

[0132] Trigger the click event of the file upload control and open the file selector;

[0133] The second picture information of the picture file selected by the user is obtained, and the picture file corresponding to the second picture information matching the first picture information is uploaded to the server; wherein the second picture information includes a picture name and a local resource address.

[0134] In some embodiments, the file upload module 304 is further configured to:

[0135] Initialize the second picture information array; wherein the initial state of the second picture information data is empty;

[0136] For each piece of second picture information, the second picture information is matched with the first picture information in the first picture information array, and if the match is successful, the second picture information is stored in the array of picture information to be uploaded;

[0137] Based on the file upload control, the picture files corresponding to the second picture information in the second picture information array are uploaded to the server in batches.

[0138] In some embodiments, the text pasting module 305 is specifically used to:

[0139] For each picture container, marking the picture container based on the picture name of the first picture information corresponding to the picture container;

[0140] For each picture file stored in the server, the picture name of the picture file is matched with the picture name marked in each picture container, and the local resource address of the picture in the successfully matched picture container is replaced with the network resource address of the picture file.

[0141] The rich text image pasting device 300 provided in the embodiment of the present application is used to execute the technical solution provided in the aforementioned rich text image pasting method embodiment. Its implementation principle and technical effect are similar to those in the aforementioned method embodiment and will not be repeated here.

[0142] It should be noted that it should be understood that the division of the various modules of the above device is only a division of a logical function. When actually implemented, it can be fully or partially integrated into a physical entity, or it can be physically separated. And these modules can all be implemented in the form of software called by a processing element, or all in the form of hardware, or some modules can be implemented in the form of software called by a processing element, and some modules can be implemented in the form of hardware. For example, the text acquisition module 301 can be a processing element established separately, or it can be integrated in a certain chip of the above device to be implemented. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a certain processing element of the above device. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each of the above modules can be completed by the integrated logic circuit of the hardware in the processor element or the instruction in the form of software.

[0143] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, see Figure 4 , the electronic device 400 includes: a processor 401, and a memory 402 communicatively connected to the processor 401;

[0144] Memory 402 stores computer executable instructions;

[0145] The processor 401 executes the computer-executable instructions stored in the memory 402 to implement the technical solution of the aforementioned rich text image pasting method.

[0146] In the above-mentioned electronic device 400, the memory 402 and the processor 401 are electrically connected directly or indirectly to realize data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses or signal lines, such as through a bus connection. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus. The memory 402 stores computer execution instructions for implementing the above-mentioned rich text image pasting method, including at least one software function module that can be stored in the memory 402 in the form of software or firmware. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402.

[0147] The memory 402 includes at least one type of readable storage medium, including but not limited to random access memory (RAM), read only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), and electrically erasable read-only memory (EEPROM). The memory 402 is used to store programs, and the processor 401 executes the programs after receiving the execution instruction. Furthermore, the software programs and modules in the above-mentioned memory 402 may also include an operating system, which may include various software components and / or drivers for managing system tasks (such as memory management, storage device control, power management, etc.), and may communicate with various hardware or software components to provide an operating environment for other software components.

[0148] The processor 401 may be an integrated circuit chip having the ability to process signals. The processor 401 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), etc. The methods, steps, and logic diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor, or the processor 401 may be any conventional processor, etc.

[0149] The electronic device 400 is used to execute the technical solution provided by the aforementioned rich text image pasting method embodiment, and its implementation principle and technical effect are similar to those in the aforementioned method embodiment, which will not be repeated here.

[0150] The embodiment of the present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, a technical solution of the aforementioned rich text image pasting method is implemented.

[0151] The computer-readable storage medium may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The computer-readable storage medium may be any available medium that can be accessed by a general or special purpose computer.

[0152] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist as discrete components in the control device of the rich text image pasting method.

[0153] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, is used to implement the technical solution of the aforementioned rich text image pasting method.

[0154] In the above embodiments, it will be appreciated by those skilled in the art that the above-mentioned various method embodiments can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loading and executing computer program instructions on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless network, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or a data center that contains one or more available media integrations. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (eg, a solid state disk (SSD)).

[0155] In the above embodiments, the description of each embodiment has its own emphasis. For the part not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0156] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0157] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A rich text image pasting method, characterized in that: include: Listen for rich text paste events, and when the user is detected to perform a paste operation in the rich text editor, obtain the first HTML text to be pasted from the system clipboard; Performing DOM parsing on the first HTML text, and converting the first HTML text into a rich text DOM; Based on the DOM operation method, obtain the image container in the rich text DOM, and extract the first image information from the image container; wherein the first image information includes the image name and the local resource address; Uploading the image file corresponding to the first image information to the server, and obtaining the network resource address of the image file on the server; The local resource address of the image in the image container is replaced with the network resource address, and the updated rich text DOM is converted into a second HTML text and pasted into the rich text editor.

2. The method according to claim 1, characterized in that The DOM operation method is based on obtaining a picture container in the rich text DOM, and extracting first picture information from the picture container, including: Traverse the nodes of the rich text DOM to obtain the image container in the rich text DOM; Based on the node attributes of the picture container, obtaining the local resource address of the picture in the picture container; Based on the local resource address, the picture name of the picture in the picture container is extracted.

3. The method according to claim 1, characterized in that Before uploading the picture file corresponding to the first picture information to the server based on the first picture information, the method further includes: Initialize the first picture information array; wherein the initial state of the first picture information array is empty; Storing each piece of first picture information into the first picture information array; Determine whether the first picture information array is empty. If the first picture information array is not empty, perform a step of uploading a picture file corresponding to the first picture information to a server based on the first picture information.

4. The method according to claim 3, characterized in that The method further comprises: If the first picture information array is empty, the first HTML text is pasted into the rich text editor.

5. The method according to claim 3, characterized in that: The step of uploading the image file corresponding to the first image information to the server includes: Create a file upload control; Triggering a click event of the file upload control to open a file selector; Acquire the second picture information of the picture file selected by the user, and upload the picture file corresponding to the second picture information matching the first picture information to the server; wherein the second picture information includes the picture name and the local resource address.

6. The method according to claim 5, characterized in that The uploading of the picture file corresponding to the second picture information matching the first picture information to the server includes: Initialize the second picture information array; wherein the initial state of the second picture information data is empty; For each piece of second picture information, the second picture information is matched with the first picture information in the first picture information array, and if the match is successful, the second picture information is stored in the array of picture information to be uploaded; Based on the file upload control, the picture files corresponding to the respective second picture information in the second picture information array are uploaded to the server in batches.

7. The method according to claim 1, characterized in that The replacing the local resource address of the picture in the picture container with the network resource address includes: For each picture container, marking the picture container based on the picture name of the first picture information corresponding to the picture container; For each picture file stored in the server, the picture name of the picture file is matched with the picture name marked in each picture container, and the local resource address of the picture in the successfully matched picture container is replaced with the network resource address of the picture file.

8. A rich text image pasting method, characterized in that: include: The text acquisition module is used to monitor the rich text paste event, and when it monitors that the user performs a paste operation in the rich text editor, it obtains the first HTML text to be pasted from the system clipboard; A DOM parsing module, used for performing DOM parsing on the first HTML text, and converting the first HTML text into a rich text DOM; An information extraction module, used to obtain the image container in the rich text DOM based on a DOM operation method, and extract the first image information from the image container; wherein the first image information includes the image name and the local resource address; A file uploading module, used to upload the image file corresponding to the first image information to the server, and obtain the network resource address of the image file on the server; The text pasting module is used to replace the local resource address of the image in the image container with the network resource address, and convert the updated rich text DOM into a second HTML text and paste it into the rich text editor.

9. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.