Text editing method, device and equipment and readable storage medium

By obtaining and storing the target size parameters of images in rich text editing, the problem of image size mismatch is solved, ensuring that the image size is displayed correctly during the display process, improving editing efficiency and reducing power consumption.

CN118535068APending Publication Date: 2024-08-23GREAT WALL MOTOR CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410665085.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-27
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

During rich text editing, the actual size of the image does not match the adjusted size, causing the image's size to be lost during display.

Method used

When receiving the image resizing operation, obtain the adjusted target size parameters, and replace the original size parameters stored at the target location with the target size parameters when saving the rich text to ensure that the correct size parameters are provided during the display process, preventing Size parameters are missing.

Benefits of technology

It effectively prevents the loss of target size parameters during the editing and display process, ensures that the actual size of the picture matches the adjusted target size parameters, improves editing efficiency and reduces power consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535068A
    Figure CN118535068A
Patent Text Reader

Abstract

The invention provides a text editing method, device and equipment and a readable storage medium, and is applied to the technical field of data processing. The method comprises the steps of monitoring whether a size adjustment operation on a picture is received or not under the condition that a rich text comprises the picture, and if the size adjustment operation is received, obtaining a target size parameter of the adjusted picture, and when an instruction for indicating to store the rich text is received, replacing the original size parameter of the picture stored at the target position with the target size parameter, and storing the rich text. According to the method provided by the invention, in the process of displaying the rich text, the picture can be displayed based on the target size parameter stored in the target position, so that the actual size of the picture is matched with the target size parameter obtained by adjustment in the editing process.
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 more specifically, to a text editing method, apparatus, device and readable storage medium in the field of data processing technology. Background Art

[0002] Rich text is a text representation method that supports multiple text formats and elements. Different from traditional plain text, rich text allows users to embed different font styles, colors, sizes, and insert elements such as pictures, links, tables, lists, etc. into the text. This text format can make the text content more vivid, intuitive and easy to understand.

[0003] During the rich text editing process, after inserting an image into the rich text, the user can manually adjust the image size to make the image size meet the actual needs. In actual applications, the adjusted image size may be lost, which may cause the rich text to display the image at its original size during actual use, resulting in a mismatch between the actual image size and the adjusted size. Summary of the invention

[0004] The present application provides a text editing method, apparatus, device and readable storage medium, which can solve the problem that the actual size of an image in a rich text does not match the adjusted size.

[0005] In a first aspect, a text editing method is provided, comprising:

[0006] In the case where the rich text includes a picture, monitoring whether a resizing operation on the picture is received;

[0007] If the size adjustment operation is received, obtaining target size parameters of the image after adjustment;

[0008] When receiving an instruction to save the rich text, the original size parameters of the image stored in the target position are replaced with the target size parameters, and the rich text is saved; wherein the target position is a position used to provide the size parameters of the image to the rich text during display.

[0009] In an embodiment of the present application, when a picture is included in a rich text, it is monitored whether a resizing operation on the picture is received. If a resizing operation is received, the target size parameters of the adjusted picture are obtained, and when an instruction to save the rich text is received, the original size parameters of the picture stored in the target position are replaced with the target size parameters, and the rich text is saved. In the text editing method provided in the present application, when the target size parameters of the picture are not saved during the editing process of the rich text, the target size parameters can be stored in the target position when the rich text is saved. In this way, not only can the target size parameters be prevented from being lost during the editing process of the rich text, but also because the target size parameters of the target position can be directly provided to the rich text during the display process of the rich text, it is possible to prevent the target size parameters from being lost during the display process of the rich text, thereby enabling the rich text to display the picture based on the target size parameters during the display process, ensuring that the actual size of the picture matches the adjusted target size parameters.

[0010] In combination with the first aspect, in some possible implementations, replacing the original size parameters of the image stored at the target location with the target size parameters includes: determining whether the rich text includes an inline image; if the inline image is included, replacing the original size parameters of the inline image stored at the target location with the target size parameters.

[0011] In an embodiment of the present application, in the process of replacing the original size parameters with the target size parameters of the picture, the target size parameters are used to replace the original size parameters only for the pictures in the row with a higher probability of losing the target size parameters, which can reduce the number of pictures in the replacement process, thereby improving efficiency and reducing power consumption.

[0012] In combination with the first aspect, in some possible implementations, if the resizing operation is received, obtaining the target size parameters of the adjusted image includes: if the resizing operation for the in-row image is received, obtaining the target size parameters of the in-row image after the adjustment.

[0013] In an embodiment of the present application, in the process of obtaining target size parameters, only the target size parameters of the pictures in the row with a higher probability of target size parameter loss are obtained, which can reduce the number of pictures in the process of obtaining target size parameters, thereby improving efficiency and reducing power consumption.

[0014] In combination with the first aspect, in some possible implementations, obtaining the adjusted target size parameters of the in-line image includes: obtaining the target size parameters of each in-line image included in the rich text, and saving the target size parameters of the in-line image according to the image tag corresponding to each in-line image, to obtain at least one target size parameter; replacing the original size parameters of the in-line image stored in the target position with the target size parameters includes: determining the target size parameters of the in-line image from the at least one target size parameter according to the image tag corresponding to the in-line image; and replacing the original size parameters stored in the target position corresponding to the in-line image with the target size parameters of the in-line image.

[0015] In an embodiment of the present application, target size parameters of the in-line pictures are saved based on picture tags corresponding to the in-line pictures. When replacing the original size parameters of the in-line pictures, the target size parameters of the in-line pictures are determined from at least one saved target size parameter based on the picture tags corresponding to the pictures. This can reduce the error probability and improve replacement efficiency when there are many pictures in the line.

[0016] In combination with the first aspect, in some possible implementations, the target position is a picture tag corresponding to the picture; replacing the original size parameters of the picture stored in the target position with the target size parameters and saving the rich text includes: determining the picture tag from a hypertext markup language document constructed based on the rich text; replacing the original size parameters of the picture included in the picture tag with the target size parameters of the picture, and saving the hypertext markup language document.

[0017] In combination with the first aspect, in some possible implementations, the method further includes: constructing a document attachment based on the target size parameters of the image; saving the document attachment; wherein the document attachment is used to provide the target size parameters of the image to the hypertext markup language document when the size parameters of the image included in the hypertext markup language document are inconsistent with the target size parameters.

[0018] In an embodiment of the present application, an attachment document is constructed based on the target size parameters of the image, and the attachment document provides the target size parameters of the image to the rich text during the display of the rich text, which can reduce the probability of losing the target size parameters.

[0019] In combination with the first aspect, in some possible implementations, replacing the original size parameters of the image stored in the target location with the target size parameters includes: generating a replacement image for the image based on the image; wherein the size parameters of the replacement image are the target size parameters of the image; and replacing the image included in the rich text with the replacement image.

[0020] In an embodiment of the present application, when the target size parameters of an image are used to replace the original size parameters, a replacement image is directly generated based on the target size parameters, and then the replacement image is used to replace the original image, so that the actual size of the image included in the rich text matches the adjusted target size parameters, thereby reducing the probability of losing the target size parameters.

[0021] In a second aspect, a text editing device is provided, comprising:

[0022] A monitoring module, used for monitoring whether a size adjustment operation of a picture is received when the rich text includes the picture;

[0023] An acquisition module, configured to acquire target size parameters of the image after the size adjustment operation is received;

[0024] A saving module is used to replace the original size parameters of the image stored in the target position with the target size parameters and save the rich text when receiving an instruction to save the rich text; wherein the target position is a position used to provide the size parameters of the image to the rich text during display.

[0025] According to a third aspect, an electronic device is provided, the electronic device comprising:

[0026] A memory for storing executable program codes;

[0027] A processor is used to call and run the executable program code from the memory, so that the electronic device executes the method in any possible implementation manner of the first aspect above.

[0028] In a fourth aspect, a computer program product is provided, the computer program product comprising: a computer program code, when the computer program code is run on a computer, the computer executes the method in any possible implementation manner of the above-mentioned first aspect.

[0029] In a fifth aspect, a readable storage medium is provided, which stores a computer program code. When the computer program code runs on a computer, the computer executes the method in any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 is a flowchart of the steps of a text editing method provided by an embodiment of the present application;

[0031] Figure 2 is a flowchart of a text editing method provided by an embodiment of the present application;

[0032] Figure 3 is a structural schematic diagram of a text editing device provided in an embodiment of the present application;

[0033] Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0034] The technical solution in the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B: "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0035] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features.

[0036] At present, rich text editing is mainly performed through a rich text editor (RTE). In the process of editing rich text through a rich text editor, users can enter text in the rich text editor, insert other elements such as pictures, links, tables, lists, and set the properties of each element to obtain rich text composed of text and other elements. The rich text editor can convert the text entered by the user, other elements inserted, and properties set into corresponding Hypertext Markup Language (HTML) tags and attributes, and generate an HTML document based on the HTML tags and attributes. The HTML document will be embedded in the web page to present the rich text on the web page.

[0037] Specifically, in the process of editing rich text through the rich text editor, when the user inserts a picture in the rich text, the rich text editor will generate a picture tag (img) corresponding to the picture, and add the storage path of the picture in the path (src) attribute of the img tag, add the original width parameter of the picture in the width (width) attribute of the img tag, and add the original height parameter of the picture in the height (height) attribute of the img tag. The original height parameter and the original width parameter are the original size parameters of the picture. When the original size parameters do not meet the actual needs of the user, the user can adjust the size of the picture through the size adjustment operation to make the size of the picture meet the requirements, and the height parameter (hereinafter referred to as the target height parameter) and width parameter (hereinafter referred to as the target width parameter) of the picture obtained by adjustment are the target size parameters of the picture.

[0038] Among them, the size adjustment operation includes, but is not limited to, a dragging operation of dragging the picture after selecting the picture, a pressing operation of pressing the size adjustment control after selecting the picture, a rolling operation of rolling the mouse wheel forward or backward after selecting the picture, etc.

[0039] In some cases, after the user adjusts the size of the image, the target size parameters may not be saved in the height and width attributes of the img tag, but saved in other locations in the HTML document. For example, HTML supports the width tag (span) to wrap the img tag. The span tag is used to combine inline elements in rich text. Text, images, and other elements can be combined in a row of rich text through the span tag. Images combined through the span tag are generally displayed on the left side of the page and are called inline images.

[0040] When inserting an inline image, the original height parameter and original width parameter of the inline image are added to the height attribute and width attribute of the img tag. After adjusting the size of the inline image, since the size of the inline element is mainly controlled by the style attribute of the span tag, the target size parameter is added to the style attribute of the span tag, and the original size parameter in the img tag does not change. When presenting rich text on a web page through an HTML document, the style attribute of the span tag may be filtered out, resulting in the loss of the target size parameter of the inline image. At this time, the inline image is displayed with the original size parameter in the img tag, which will cause the actual size of the inline image to not match the target size parameter.

[0041] The above are only illustrative examples. The images whose actual sizes do not match the target size parameters include not only inline images but also other images.

[0042] In order to solve the above technical problems, an embodiment of the present application provides a text editing method. During the editing process in the rich text, when the user's size adjustment operation on the image is received, the target size parameters of the adjusted image are obtained, and when the rich text is saved, the original size parameters of the image are replaced with the target size parameters, and then the rich text is saved. In the text editing method provided by the present application, when the target size parameters of the image are not saved during the editing process of the rich text, the target size parameters can be stored in the target position when the rich text is saved. In this way, not only can the target size parameters be prevented from being lost during the editing process of the rich text, but also because the target size parameters of the target position can be directly provided to the rich text during the display process of the rich text, it is possible to prevent the target size parameters from being lost during the display process of the rich text, thereby enabling the rich text to display the image based on the target size parameters during the display process, ensuring that the actual size of the image matches the adjusted target size parameters.

[0043] See also Figure 1 , Figure 1 1 is a flowchart of the steps of a text editing method provided by an embodiment of the present application. The execution subject of the method may be an electronic device, specifically a rich text editor in an electronic device, such as a computer and a tablet computer, but not limited thereto. Figure 1 As shown, the method may include the following steps:

[0044] Step 101: When a rich text includes a picture, monitor whether a size adjustment operation for the picture is received.

[0045] Step 102: If a size adjustment operation is received, obtain target size parameters of the adjusted image.

[0046] Exemplarily, a rich text editor is installed in an electronic device, and a user can start the rich text editor, enter text in the text editing area of ​​the rich text editor, and change the text's attributes such as font style, color, and size. At the same time, the user can insert other elements such as pictures, links, tables, lists, etc. in the text editing area, and set the attributes of other elements to obtain rich text composed of text and other elements.

[0047] After the rich text editor is started, it monitors whether the user inserts a picture into the text editing area. If a picture is inserted into the text editing area, it starts to monitor whether the user's resizing operation on the picture is received. For example, after the user enters text in the text editing area and inserts other elements, the rich text editor can convert the rich text in the text editing area into an HTML document. In the case of inserting a picture, the rich text editor can add an img tag corresponding to the picture in the HTML document. When the rich text editor detects the presence of an img tag in the HTML document, it determines that the rich text includes the picture.

[0048] After determining that the rich text includes an image, the rich text editor monitors whether the user's resizing operation on the image is received. After receiving the user's resizing operation on the image, the target height parameter and the target width parameter of the adjusted image are obtained to obtain the target size parameter of the image. For example, when the img tag corresponding to the image is wrapped in a span tag, the rich text editor can add the target size parameter of the image in the style attribute of the span tag. At this time, the rich text editor can obtain the target size parameter of the image and save the target size parameter in a location other than the style attribute.

[0049] When the rich text includes multiple pictures, for each picture, after receiving the user's operation of adjusting the size of the picture, the rich text editor obtains and saves the target size parameters of the picture, so that the target size parameters of each picture can be obtained.

[0050] In actual applications, for each image, the user can perform one or more resizing operations on the image. After the first resizing operation, the rich text editor obtains and saves the target size parameters of the image. Thereafter, after each resizing operation on the image, the rich text editor deletes the previously stored target size parameters, obtains and stores the target size parameters of the image after the current resizing operation. In this way, the latest target size parameters of the image during the rich text editing process can be obtained.

[0051] Optionally, the rich text editor has a monitoring function, which can monitor various data during the operation of the rich text editor. The rich text editor can monitor the rich text during the editing process through the monitoring function, and when it is detected that the rich text includes a picture, monitor whether the user's resizing operation on the picture is received, and after the user's resizing operation on the picture is detected, obtain the adjusted target size parameters.

[0052] Step 103: When receiving an instruction to save the rich text, the original size parameters of the image stored at the target location are replaced with the target size parameters, and the rich text is saved.

[0053] The target position is a position used to provide size parameters of the image to the rich text during display. The target position is, for example, an img tag corresponding to the image.

[0054] Exemplarily, after the user completes the editing of the rich text in the rich text editor, the user can input a save instruction to the rich text editor. Upon receiving the save instruction, the rich text editor can respond to the save instruction, first obtain the target size parameter of the saved image, then determine the img tag corresponding to the image from the HTML document, and then replace the original width parameter in the width attribute of the img tag with the target width parameter in the target size parameter, and replace the original height parameter in the height attribute of the img tag with the target height parameter in the target size parameter, and at the same time, the style attribute of the img tag can be modified according to the target size parameter of the image, so that the style attribute of the img tag matches the target size parameter. Afterwards, the rich text editor can save the current HTML document to obtain the final HTML document, thereby realizing the saving of the rich text.

[0055] After replacing the original size parameters stored in the target location with the target size parameters of the image, when the HTML document is embedded in a web page and rich text is presented on the web page, the image can be displayed based on the target size parameters in the img tag so that the actual size of the image matches the target size parameters.

[0056] Among them, during the rich text editing process, the original size parameters of some pictures may have been added to the corresponding img tags. For each picture, in the process of replacing the original size parameters with the target size parameters, the rich text editor first determines whether the size parameters in the img tag corresponding to the picture are consistent with the target size parameters. If they are inconsistent with the target size parameters, the size parameters in the img tag are determined to be the original size parameters, and the target size parameters can be used to replace the original size parameters. On the contrary, if the size parameters in the img tag are consistent with the target size parameters, the size parameters in the img tag remain unchanged.

[0057] It should be noted that when a rich text includes multiple pictures, for each picture, in the process of saving the rich text, the original size parameter in the img tag corresponding to the picture can be replaced with the target size parameter of the picture.

[0058] It should be understood that the target location can be an img tag corresponding to the image, or other locations used to provide the size parameters of the image to the rich text during display. When the target size parameters are stored in locations other than the img tag, the target size parameters can be obtained from other locations during the display of the rich text to display the image based on the target size parameters.

[0059] In an embodiment of the present application, when a picture is included in a rich text, it is monitored whether a resizing operation on the picture is received. If a resizing operation is received, the target size parameters of the adjusted picture are obtained, and when an instruction to save the rich text is received, the original size parameters of the picture stored in the target position are replaced with the target size parameters, and the rich text is saved. In the text editing method provided in the present application, when the target size parameters of the picture are not saved during the editing process of the rich text, the target size parameters can be stored in the target position when the rich text is saved. In this way, not only can the target size parameters be prevented from being lost during the editing process of the rich text, but also because the target size parameters of the target position can be directly provided to the rich text during the display process of the rich text, it is possible to prevent the target size parameters from being lost during the display process of the rich text, thereby enabling the rich text to display the picture based on the target size parameters during the display process, ensuring that the actual size of the picture matches the adjusted target size parameters.

[0060] In some embodiments, after receiving a user's resizing operation on a picture, it can be determined whether the resizing operation is a preset operation. When the resizing operation is a preset operation, the target size parameters of the picture are saved, and before saving the rich text, the original size parameters of the picture are replaced by the target size parameters.

[0061] Exemplarily, the preset operation is, for example, a drag operation. After receiving the image resizing operation, the electronic device first determines whether the resizing operation is a drag operation. If it is a drag operation, the target size parameters of the image after the drag operation is completed are obtained. In actual applications, the probability of losing the target size parameters obtained by some resizing operations is low. For preset operations that may cause the loss of target size parameters, the target size parameters are obtained, and the target size parameters are used to replace the original size parameters, which can reduce the amount of data in the replacement process, thereby improving efficiency and reducing power consumption.

[0062] Optionally, the step of replacing the original size parameter of the picture stored at the target location with the target size parameter may include:

[0063] Determine whether to include inline images in rich text;

[0064] If an inline image is included, the original size parameters of the inline image stored at the target location are replaced with the target size parameters.

[0065] In some embodiments, in the process of saving rich text, the rich text editor can only replace the original size parameters with the target size parameters of the inline pictures for inline pictures. Exemplarily, after receiving the save instruction, the rich text editor can first traverse the HTML document and determine the img tag of each picture from the HTML document. Then, for the img tag of each picture, determine whether the img tag is wrapped in a span tag. If the img tag is wrapped in a span, it is determined that the picture is an inline picture. For each inline picture, the rich text editor can obtain the target size parameters saved separately, and then replace the original size parameters included in the img tag corresponding to the inline picture with the target size parameters. After replacing the original size parameters of each inline picture with the target size parameters, save the HTML document to achieve the saving of the rich text.

[0066] In actual applications, the probability of losing the target size parameters of pictures in a row is relatively high, while the probability of losing the target size parameters of other types of pictures is relatively low. In the embodiment of the present application, in the process of replacing the original size parameters with the target size parameters of the pictures, only the original size parameters are replaced with the target size parameters for the pictures in the row with a high probability of losing the target size parameters, which can reduce the number of pictures in the replacement process, thereby improving efficiency and reducing power consumption.

[0067] Optionally, step 102 may include:

[0068] If a size adjustment operation for an inline image is received, a target size parameter of the adjusted inline image is obtained.

[0069] In some embodiments, in the process of obtaining the target size parameters of the image, the rich text editor may only obtain the target size parameters of the inline image. Exemplarily, in the process of editing the rich text, the rich text editor may monitor the generated HTML to determine whether an img tag wrapped in a span tag appears in the HTML, and after detecting the presence of the img tag wrapped in the span tag, determine that the rich text includes inline images. Afterwards, the rich text editor monitors the inline images corresponding to each img tag located in the span tag to determine whether the user has performed a size adjustment operation on the inline image. For each inline image, after detecting the user's size adjustment operation on the inline image, the target size parameters of the adjusted inline image are determined, and the target size parameters of the inline image are saved separately. In this way, after the rich text editing is completed, the rich text editor can obtain the target size parameters of each inline image.

[0070] Correspondingly, after receiving the save instruction, for each inline image, the rich text editor obtains the temporarily stored target size parameters of each inline image, and uses the target size parameters of the inline image to replace the original size parameters in the img tag corresponding to the inline image.

[0071] In an embodiment of the present application, in the process of obtaining target size parameters, only the target size parameters of the pictures in the row with a higher probability of target size parameter loss are obtained, which can reduce the number of pictures in the process of obtaining target size parameters, thereby improving efficiency and reducing power consumption.

[0072] Optionally, the step of obtaining the target size parameters of the adjusted inline image may include: obtaining the target size parameters of each inline image included in the rich text, and saving the target size parameters of the inline image according to the image tag corresponding to each inline image, to obtain at least one target size parameter.

[0073] Correspondingly, the step of replacing the original size parameters of the in-line image stored at the target position with the target size parameters may include: determining the target size parameters of the in-line image from at least one target size parameter according to the image tag corresponding to the in-line image; and replacing the original size parameters stored at the target position corresponding to the in-line image with the target size parameters of the in-line image.

[0074] Exemplarily, in the process of obtaining the target size parameter, an array object for storing the target size parameter of each inline image can be pre-established. After obtaining the target size parameter of each inline image, the src attribute of the img tag corresponding to the inline image can be obtained from the HTML document, and the src attribute corresponding to each inline image is different. Afterwards, the target size parameter and the corresponding src attribute of the inline image can be stored in the data object according to the src attribute of the inline image.

[0075] In the process of saving rich text, the rich text editor can traverse the HTML document and determine each inline image from the HTML document. For each inline image, the src attribute is obtained from the img tag corresponding to the inline image, and then the target size parameter corresponding to the src attribute is obtained from the data object according to the obtained src attribute, and the target size parameter is used to replace the original size parameter in the img tag, so that the original size parameter of the inline image can be replaced with the target size parameter. After replacing the original size parameter of each inline image, the obtained HTML document can be saved, thereby realizing the saving of rich text.

[0076] In an embodiment of the present application, target size parameters of the in-line pictures are saved based on picture tags corresponding to the in-line pictures. When replacing the original size parameters of the in-line pictures, the target size parameters of the in-line pictures are determined from at least one saved target size parameter based on the picture tags corresponding to the pictures. This can reduce the error probability and improve replacement efficiency when there are many pictures in the line.

[0077] Optionally, the target location is a picture tag corresponding to the picture; the original size parameter of the picture stored in the target location is replaced with the target size parameter, and the rich text is saved, including:

[0078] Determining image tags from an HTML document constructed based on the rich text;

[0079] The original size parameters of the image included in the image tag are replaced with the target size parameters of the image, and the HTML document is saved.

[0080] Exemplarily, when rich text is saved through an HTML document, in the process of replacing the original size of the image, the img tag corresponding to the image can be determined from the HTML document, and the img tag is the target position corresponding to the image. In the process of replacing the original size parameters, the original size parameters in the img tag are replaced with the target size parameters of the image, that is, the original width parameter included in the width attribute of the img tag is replaced with the target width parameter in the target size parameter, and the original height parameter included in the height attribute of the img tag is replaced with the target height parameter in the target size parameter.

[0081] Optionally, the method may further include:

[0082] Build document attachments based on the target size parameters of the image;

[0083] The document attachment is saved; wherein the document attachment is used to provide the target size parameters of the image to the hypertext markup language document when the size parameters of the image included in the hypertext markup language document are inconsistent with the target size parameters.

[0084] Exemplarily, when only the target size parameters of the inline image are obtained and the original size parameters of the inline image are replaced, in the process of saving the HTML corresponding to the rich text, a document attachment of the HTML document can be constructed, and the target size parameters of each inline image can be stored in the document attachment, and the src attribute of the img tag corresponding to the inline image can be stored. When the HTML document is embedded in a web page to display rich text in the web page, before displaying the inline image, the size parameters of the image can be first obtained from the img tag corresponding to the image, and the corresponding target size parameters can be obtained from the attachment document according to the src attribute included in the img tag. Afterwards, the target size parameters and the size parameters obtained from the img tag can be compared. If the two are inconsistent, the target size parameters in the attachment document are used to display the image.

[0085] In an embodiment of the present application, an attachment document is constructed based on the target size parameters of the image, and the attachment document provides the target size parameters of the image to the rich text during the display of the rich text, which can reduce the probability of losing the target size parameters.

[0086] Optionally, the step of replacing the original size parameter of the picture stored at the target location with the target size parameter may include:

[0087] Generate a replacement image based on the image; wherein the size parameter of the replacement image is the target size parameter of the image;

[0088] Replace images included in rich text with alternative images.

[0089] Exemplarily, in the process of replacing the original size parameters of the picture, the rich text editor can first obtain the original size parameters of the picture from the img tag corresponding to the picture. In the case where the original size parameters in the img tag are different from the target size parameters, if the target height parameter in the target size parameter is different from the height parameter in the img tag, the height of the picture is adjusted to be consistent with the target height parameter, and if the target width parameter in the target size parameter is different from the width parameter in the img tag, the width of the picture is adjusted to be consistent with the target width parameter. After adjusting the height and / or width of the picture, a replacement picture of the picture can be obtained. Afterwards, the replacement picture can be used to replace the original picture included in the rich text. At the same time, the rich text editor can delete the img tag corresponding to the original picture in the HTML document, and generate the img tag corresponding to the replacement picture at the location of the original picture. The size parameter in the img tag corresponding to the replacement picture is the target size parameter, so that the original size parameter of the picture can be replaced with the target size parameter.

[0090] In an embodiment of the present application, when the target size parameters of an image are used to replace the original size parameters, a replacement image is directly generated based on the target size parameters, and then the replacement image is used to replace the original image, so that the actual size of the image included in the rich text matches the adjusted target size parameters, thereby reducing the probability of losing the target size parameters.

[0091] See also Figure 2 , Figure 2 1 is a flowchart of a text editing method provided by an embodiment of the present application. Figure 2 As shown, the method may include the following steps:

[0092] Step 201: Determine whether a resizing operation for an in-line picture is received.

[0093] Step 202: Obtain target size parameters of the inline image.

[0094] Step 203: Store the target size parameters of the in-row pictures into an array object.

[0095] In this embodiment, during the rich text editing process, when the rich text editor determines that the rich text includes inline images, it can execute steps 201 and 203 to determine whether a resizing operation for the inline image has been received. For each inline image, when a resizing operation for the inline image has been received, the target size parameters of the adjusted inline image are obtained, and the target size parameters of the inline image are stored in an array object according to the image tag corresponding to the inline image.

[0096] Step 204: Determine whether a save instruction is received.

[0097] Step 205: Replace the original size parameter with the target size parameter of the inline image.

[0098] Step 206: Save the rich text.

[0099] In this embodiment, during the rich text editing process, after obtaining and storing the target size parameters of the inline image, the rich text editor obtains the target size parameters of the inline image from the array object according to the image tag corresponding to the inline image after receiving the save instruction, and replaces the original size parameters with the target size parameters. After replacing the original size parameters with the target size parameters of each inline image, the HTML document corresponding to the rich text can be saved to achieve the saving of the rich text.

[0100] For some inline images, users may not adjust the size of the inline images. Accordingly, for such inline images, the rich text editor does not obtain and store the target size parameters of the inline images. During the process of saving the rich text, the original size parameters of such inline images can be kept unchanged because the target size parameters of such inline images are not stored in the array object.

[0101] It should be noted that, in the case where no resizing operation of the inline image is received or there is no inline image in the rich text, the rich text editor can directly save the rich text after receiving the save instruction.

[0102] See also Figure 3 , Figure 3 300 is a structural diagram of a text editing device provided in an embodiment of the present application. The text editing device 300 may be provided in an electronic device and may include:

[0103] A monitoring module 301 is used to monitor whether a size adjustment operation for a picture is received when the rich text includes the picture;

[0104] An acquisition module 302 is configured to acquire target size parameters of the image after the size adjustment operation is received;

[0105] The saving module 303 is used to replace the original size parameters of the image stored in the target position with the target size parameters and save the rich text when receiving an instruction to save the rich text; wherein the target position is the position used to provide the size parameters of the image to the rich text during the display process.

[0106] In combination with the first aspect, in some possible implementations, the saving module 303 is specifically used to determine whether the rich text includes an inline picture; if the inline picture is included, the original size parameters of the inline picture stored at the target position are replaced with the target size parameters.

[0107] In combination with the first aspect, in some possible implementations, the acquisition module 302 is specifically configured to, if a size adjustment operation on the in-row picture is received, obtain a target size parameter of the in-row picture after the adjustment.

[0108] In combination with the first aspect, in some possible implementations, the acquisition module 302 is specifically used to obtain the target size parameters of each in-line image included in the rich text, and save the target size parameters of the in-line image according to the image tag corresponding to each in-line image to obtain at least one target size parameter; the saving module 303 is specifically used to determine the target size parameter of the in-line image from the at least one target size parameter according to the image tag corresponding to the in-line image; and replace the original size parameter stored in the target position corresponding to the in-line image with the target size parameter of the in-line image.

[0109] In combination with the first aspect, in some possible implementations, the saving module 303 is specifically used to determine the image tag from a hypertext markup language document constructed based on the rich text; replace the original size parameters of the image included in the image tag with the target size parameters of the image, and save the hypertext markup language document.

[0110] In combination with the first aspect, in some possible implementations, the device also includes a saving module, which is used to construct a document attachment based on the target size parameters of the image; save the document attachment; wherein, when the size parameters of the image included in the hypertext markup language document are inconsistent with the target size parameters, the document attachment is used to provide the target size parameters of the image to the hypertext markup language document.

[0111] In combination with the first aspect, in some possible implementations, the saving module 303 is specifically used to generate a replacement image for the image based on the image; wherein a size parameter of the replacement image is a target size parameter of the image; and the replacement image is used to replace the image included in the rich text.

[0112] See also Figure 4 , Figure 4 Schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 4 As shown, the electronic device 400 includes: a memory 401 and a processor 402, wherein the memory 401 stores an executable program code 4011, and the processor 402 is used to call and execute the executable program code 4011 to perform a text editing method.

[0113] In addition, an embodiment of the present application also protects a text editing device, which may include a memory and a processor, wherein the memory stores executable program code, and the processor is used to call and execute the executable program code to execute a text editing method provided by an embodiment of the present application.

[0114] In this embodiment, the functional modules of the device can be divided according to the above method example. For example, each functional module can be corresponded, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0115] In the case of dividing each functional module according to each function, the device may also include a monitoring module, an acquisition module, a storage module, etc. It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module, which will not be repeated here.

[0116] It should be understood that the device provided in this embodiment is used to execute the above-mentioned text editing method, and thus can achieve the same effect as the above-mentioned implementation method.

[0117] In the case of an integrated unit, the device may include a processing module and a storage module. When the device is applied to an electronic device, the processing module may be used to control and manage the actions of the electronic device. The storage module may be used to support the electronic device in executing relevant program codes, etc.

[0118] The processing module may be a processor or a body control module, which may implement or execute various exemplary logic blocks, modules and circuits shown in combination with the contents disclosed in this application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module may be a memory.

[0119] In addition, the device provided in the embodiments of the present application may specifically be a chip, component or module, and the chip may include a connected processor and memory; wherein the memory is used to store instructions, and when the processor calls and executes the instructions, the chip can execute a text editing method provided in the above embodiments.

[0120] This embodiment also provides a readable storage medium, in which a computer program code is stored. When the computer program code is executed on a computer, the computer executes the above-mentioned related method steps to implement a text editing method provided by the above-mentioned embodiment.

[0121] This embodiment also provides a computer program product. When the computer program product runs on a computer, it enables the computer to execute the above-mentioned related steps to implement a text editing method provided by the above embodiment.

[0122] Among them, the device, readable storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.

[0123] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0124] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0125] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A text editing method, It is characterized in that include: In the case where the rich text includes a picture, monitoring whether a resizing operation on the picture is received; If the size adjustment operation is received, obtaining target size parameters of the image after adjustment; When receiving an instruction to save the rich text, the original size parameters of the image stored in the target position are replaced with the target size parameters, and the rich text is saved; wherein the target position is a position used to provide the size parameters of the image to the rich text during display.

2. The method according to claim 1, It is characterized in that The step of replacing the original size parameter of the picture stored at the target position with the target size parameter includes: Determine whether the rich text includes an inline image; If the in-line picture is included, the original size parameters of the in-line picture stored at the target position are replaced with the target size parameters.

3. The method according to claim 2, It is characterized in that If the size adjustment operation is received, obtaining the target size parameter of the adjusted image includes: If a size adjustment operation for the in-row picture is received, a target size parameter of the in-row picture after the adjustment is obtained.

4. The method according to claim 3, It is characterized in that The obtaining of the adjusted target size parameter of the inline image comprises: obtaining the target size parameter of each inline image included in the rich text, and saving the target size parameter of the inline image according to the image tag corresponding to each inline image, to obtain at least one target size parameter; The replacing the original size parameters of the in-line picture stored at the target position with the target size parameters includes: determining the target size parameters of the in-line picture from the at least one target size parameter according to the picture tag corresponding to the in-line picture; and replacing the original size parameters stored at the target position corresponding to the in-line picture with the target size parameters of the in-line picture.

5. The method according to any one of claims 1 to 4, It is characterized in that The target position is the image label corresponding to the image; The replacing the original size parameter of the picture stored at the target position with the target size parameter and saving the rich text includes: Determining the image tag from a hypertext markup language document constructed based on the rich text; The original size parameter of the image included in the image tag is replaced with the target size parameter of the image, and the hypertext markup language document is saved.

6. The method according to claim 5, It is characterized in that The method further comprises: constructing a document attachment based on a target size parameter of the image; The document attachment is saved; wherein the document attachment is used to provide the target size parameters of the image to the hypertext markup language document when the size parameters of the image included in the hypertext markup language document are inconsistent with the target size parameters.

7. The method according to any one of claims 1 to 4, It is characterized in that The step of replacing the original size parameter of the picture stored at the target position with the target size parameter includes: Generate a replacement image of the image based on the image; wherein a size parameter of the replacement image is a target size parameter of the image; The image included in the rich text is replaced with the alternative image.

8. A text editing device, It is characterized in that The device comprises: A monitoring module, used for monitoring whether a size adjustment operation of a picture is received when the rich text includes the picture; An acquisition module, configured to acquire target size parameters of the image after the size adjustment operation is received; A saving module is used to replace the original size parameters of the image stored in the target position with the target size parameters and save the rich text when receiving an instruction to save the rich text; wherein the target position is a position used to provide the size parameters of the image to the rich text during display.

9. An electronic device, It is characterized in that The electronic device comprises: A memory for storing executable program codes; A processor, configured to call and run the executable program code from the memory, so that the electronic device executes the method according to any one of claims 1 to 7.

10. A readable storage medium, It is characterized in that The readable storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 7 is implemented.