Search

CN-121979419-A - Text editing method, text editing device and storage medium

CN121979419ACN 121979419 ACN121979419 ACN 121979419ACN-121979419-A

Abstract

The application relates to a text editing method, a text editing device and a storage medium, wherein the text editing method comprises the steps of responding to a first trigger operation of a user on a text editor, displaying a simulated cursor in the text editor, responding to a selection operation of a preset editing component in the text editor by the user, displaying a visual element block corresponding to the selection operation at the current display position of the simulated cursor, moving the current display position of the simulated cursor along with a moving operation of the simulated cursor by the user, and generating structured data based on a data object corresponding to the visual element block, wherein a display sequence of the visual element block in the text editor and a data object sequence in the structured data form a bidirectional binding relation. By the application, the text editor has difficulty in considering the problems of simple operation and output structuring.

Inventors

  • LI HAIHONG
  • ZHAO XIAOFAN

Assignees

  • 浙江极氪智能科技有限公司
  • 浙江吉利控股集团有限公司

Dates

Publication Date
20260505
Application Date
20260126

Claims (10)

  1. 1. A method of text editing, the method comprising: responding to a first triggering operation of a user on a text editor, and displaying a simulated cursor in the text editor; responding to the selection operation of the user on a preset editing component in the text editor, and displaying a visual element block corresponding to the selection operation at the current display position of the simulated cursor; Generating structured data based on the data object corresponding to the visual element block; and the display sequence of the visual element block in the text editor and the data object sequence in the structured data form a bidirectional binding relation.
  2. 2. The text editing method of claim 1, wherein the text editor has an initial state and an activated state, the inserting a simulated cursor in the text editor in response to a first trigger operation within the text editor comprising: And in the initial state of the text editor, responding to the first trigger operation, dynamically creating an input box element, inserting the input box element to a position corresponding to the first trigger operation, and displaying the simulated cursor by controlling the input box element to focus so as to enable the text editor to enter the activated state from the initial state.
  3. 3. The text editing method of claim 2, wherein the method further comprises: And in response to a second trigger operation of the user outside the editing area of the text editor, removing the simulated cursor so as to enable the text editor to return to the initial state from the activated state.
  4. 4. The text editing method of claim 1, wherein the displaying a simulated cursor in the text editor in response to a first trigger operation of the text editor by a user comprises: Under the condition that the existing visual element block is displayed in the text editor, acquiring the position coordinate of the first trigger operation, and calculating a logic position index into which the simulated cursor is to be inserted based on the position relation between the position coordinate and the existing visual element block; And inserting and displaying the simulated cursor according to the logic position index.
  5. 5. The text editing method of claim 4, wherein after inserting and displaying the simulated cursor according to the logical position index, the method further comprises: detecting keyboard operation of the simulated cursor; When the keyboard operation is detected to be a deleting operation, deleting a previous visual element block and a data object corresponding to the visual element block according to the current display position of the simulated cursor, and reactivating the cursor; When the keyboard operation is detected to be the direction key moving operation, deleting the current simulated cursor, and inserting a new simulated cursor at the adjacent position of the current display position according to the moving direction obtained by analyzing the direction key moving operation.
  6. 6. The text editing method of claim 4, wherein the acquiring the position coordinates of the first trigger operation includes: If the object of the first triggering operation is the existing visual element block or a preset simulation placeholder prompting element, judging that the first triggering operation is invalid operation, otherwise, judging that the first triggering operation is valid operation; And under the condition that the first trigger operation is detected to be an effective operation, acquiring the position coordinates of the first trigger operation.
  7. 7. The text editing method according to claim 1, wherein the generating structured data based on the data object corresponding to the visual element block includes: Based on the display sequence of the visual element block in the text editor, combining the data object corresponding to the visual element block into a data object sequence with a preset structure, generating the structured data, and storing the structured data into a database; And responding to the display operation of the text editor, extracting corresponding structured data from the database, and restoring the structured data into a visual element block sequence for display based on the data object sequence.
  8. 8. The text editing method according to any one of claims 1 to 7, wherein the preset editing component includes a parameter editing component and an operator editing component, and wherein the displaying, in response to a selection operation of the preset editing component in the text editor, a visual element block corresponding to the selection operation at a current display position of the simulated cursor includes: responding to the selection operation of the parameter editing component, and inserting a corresponding parameter visual element block in the current display position of the simulated cursor; And in response to the selection operation of the operator editing component, inserting a corresponding operator visual element block in the current display position of the simulated cursor.
  9. 9. A text editing apparatus, comprising: The simulated cursor module is used for responding to a first triggering operation of a user in the text editor, and inserting a simulated cursor in the text editor; The insertion module is used for responding to the selection operation of the user on a preset editing component in the text editor and inserting a visual element block corresponding to the selection operation at the current display position of the simulated cursor; And the generation module is used for generating structured data based on the data object corresponding to the visual element block, wherein a display sequence of the visual element block in the text editor and the data object sequence in the structured data form a bidirectional binding relation.
  10. 10. A storage medium having a computer program stored therein, wherein the computer program is arranged to perform the text editing method of any of claims 1 to 8 at run-time.

Description

Text editing method, text editing device and storage medium Technical Field The present application relates to the field of computers, and more particularly, to a text editing method, a text editing apparatus, and a storage medium. Background Web editing refers to a man-machine interaction process implemented by a browser, and is characterized by allowing a user to create, modify or delete content and data in a Web page. The Web editing forms are various, the application scenes are multidimensional, the complexity is different, and the modes are different. In the related technology, web editing mainly has the following technical paths that firstly, a free input-based rich text editor is used for enabling a user to directly edit text patterns or insert simple media elements (such as pictures/video) and the like, and secondly, the Web editing mainly has the technical paths that firstly, the free input-based rich text editor finally generates text in the form of element labels, and secondly, the Web editing is usually divided into three functional areas of a material area, an editing view and an attribute panel by a visual drag editor based on drag and attribute configuration, and finally, JSON structural data which can be used for rendering is generated by dragging the material to canvas and configuring the attribute by the user. However, in the above manner, although the rich text editor provides intuitive editing experience, the unstructured text or HTML output by the rich text editor must be analyzed in a complex and error-prone manner, so that the unstructured text or HTML can be understood and executed by a computer, while the drag editor can directly generate structured data, but the interaction process is complex and incoherent, so that efficient editing of linear logic such as formulas is difficult to support. Therefore, in the related art of Web editing, there is always a lack of a linear editing paradigm of text that can achieve both ease of operation and output structuring. At present, an effective solution is not proposed for the problem that a text editor in the related art is difficult to achieve both simple operation and output structuring. Disclosure of Invention The embodiment of the application provides a text editing method, a text editing device and a storage medium, which at least solve the problem that a text editor in the related art is difficult to consider simple operation and output structuring. In a first aspect, an embodiment of the present application provides a text editing method, where the method includes: responding to a first triggering operation of a user on a text editor, and displaying a simulated cursor in the text editor; responding to the selection operation of the user on a preset editing component in the text editor, and displaying a visual element block corresponding to the selection operation at the current display position of the simulated cursor; Generating structured data based on the data object corresponding to the visual element block; and the display sequence of the visual element block in the text editor and the data object sequence in the structured data form a bidirectional binding relation. In some of these embodiments, the text editor has an initial state and an activated state, the inserting a simulated cursor in the text editor in response to a first trigger operation within the text editor comprising: And in the initial state of the text editor, responding to the first trigger operation, dynamically creating an input box element, inserting the input box element to a position corresponding to the first trigger operation, and displaying the simulated cursor by controlling the input box element to focus so as to enable the text editor to enter the activated state from the initial state. In some of these embodiments, the method further comprises: And in response to a second trigger operation of the user outside the editing area of the text editor, removing the simulated cursor so as to enable the text editor to return to the initial state from the activated state. In some embodiments, the responding to the first trigger operation of the user to the text editor displays a simulated cursor in the text editor, and the method comprises the following steps: Under the condition that the existing visual element block is displayed in the text editor, acquiring the position coordinate of the first trigger operation, and calculating a logic position index into which the simulated cursor is to be inserted based on the position relation between the position coordinate and the existing visual element block; And inserting and displaying the simulated cursor according to the logic position index. In some embodiments, after inserting and displaying the simulated cursor according to the logical position index, the method further comprises: detecting keyboard operation of the simulated cursor; When the keyboard operation is detected to be a deleting operation, deleting a p