Code editor implementation method, apparatus, and device

By setting up core packages in the code editor, and responsive event triggers to obtain and generate display update status, the complexity and storage usage of existing code editors are solved, and the lightweight code editor function is realized.

WO2024227413A1PCT designated stage expired Publication Date: 2024-11-07BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/089536
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-05-04
Filing Date
2024-04-24
Publication Date
2024-11-07

AI Technical Summary

Technical Problem

Existing code editors have high complexity and high storage usage, resulting in insufficient lightweight implementation.

Method used

By setting up the core package of the code editor, including status components, display components and command components, obtaining event status in response to event triggers, generating and displaying update status, thereby realizing display updates of the code editor.

Benefits of technology

It realizes simple and lightweight code editor functions, reduces storage usage and complexity, and improves the editor's efficiency and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024089536_07112024_PF_FP_ABST
    Figure CN2024089536_07112024_PF_FP_ABST
Patent Text Reader

Abstract

Provided are a code editor implementation method, apparatus, and device. A lightweight code editor is implemented, and the implementation method comprises: in response to triggering of an event in a code editor, obtaining the state of the event; generating a display update state of the code editor according to the state of the event; and displaying the display update state in an editing page of the code editor.
Need to check novelty before this filing date? Find Prior Art

Description

Code editor implementation method, device and equipment

[0001] This application claims priority to Chinese Patent Application No. 202310491309.4 filed on May 4, 2023, and the contents of the above-mentioned Chinese patent application disclosure are hereby incorporated by reference in their entirety as a part of this application. Technical Field

[0002] The present disclosure relates to a method, apparatus, and device for implementing a code editor. Background Art

[0003] Programmers and engineers can use code editors to edit code. Code editors are containers for code input. There are many types of code editors, such as HTML (Hyper Text Markup Language) code editors, which can add and edit web page DOM (Document Object Model) elements. In the application scenario of AB experiments, when generating AB pages for visual experiments, the code editor can be used to realize the combination of any web page elements and web page scenarios. In this application scenario, the code editor can be used as a supplement to the visual editor, and the code editor can be used to implement functions that are more difficult to achieve with the visual editor.

[0004] Currently, some code editors, such as VSCode, are integrated editors with powerful features and rich plugins. However, these code editors are complex, require a lot of storage, and are not lightweight enough.

[0005] Summary of the Invention

[0006] Embodiments of the present disclosure provide a method, apparatus, and device for implementing a code editor to implement a relatively lightweight code editor.

[0007] To solve the above problems, the embodiments of the present disclosure provide the following technical solutions:

[0008] In a first aspect, an embodiment of the present disclosure provides a method for implementing a code editor, the method comprising:

[0009] In response to triggering of an event in the code editor, obtaining a status of the event;

[0010] Generate a display update state of the code editor according to the state of the event;

[0011] The display update status is displayed in an editing page of the code editor.

[0012] In a second aspect, an embodiment of the present disclosure further provides a device for implementing a code editor, the device comprising:

[0013] A first acquiring unit is configured to acquire a state of an event in response to triggering of the event in the code editor;

[0014] a generating unit configured to generate a display update state of the code editor according to a state of the event; and

[0015] The display unit is configured to display the display update status in the editing page of the code editor.

[0016] In a third aspect, an embodiment of the present disclosure further provides an implementation device for a code editor, characterized in that it includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the implementation method of the code editor as described above is implemented.

[0017] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, characterized in that instructions are stored in the computer-readable storage medium, and when the instructions are executed on a terminal device, the terminal device executes the implementation method of the code editor as described above. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] FIG1 is a schematic diagram of an exemplary application scenario provided by at least one embodiment of the present disclosure;

[0019] FIG2 is a flowchart of a method for implementing a code editor provided by at least one embodiment of the present disclosure;

[0020] FIG3 is a flowchart of another method for implementing a code editor provided by at least one embodiment of the present disclosure;

[0021] FIG4 is a schematic diagram of an editing page of a code completion extension function of a code editor in at least one embodiment of the present disclosure;

[0022] FIG5 is a flowchart of another method for implementing a code editor provided by at least one embodiment of the present disclosure;

[0023] FIG6 is a schematic diagram of an editing page of a code formatting command of a code editor in at least one embodiment of the present disclosure;

[0024] FIG7 is a schematic diagram of an editing page for a line break command of a code editor in at least one embodiment of the present disclosure;

[0025] FIG8 is a schematic diagram of an editing page of a code verification command of a code editor in at least one embodiment of the present disclosure;

[0026] FIG9 is a schematic diagram of an editing page style of a code editor in at least one embodiment of the present disclosure;

[0027] FIG10 is a schematic diagram of an implementation device of a code editor provided by at least one embodiment of the present disclosure; and

[0028] FIG11 is a schematic diagram of a device provided by at least one embodiment of the present disclosure. DETAILED DESCRIPTION

[0029] In order to make the above-mentioned objects, features and advantages of the present disclosure more obvious and easy to understand, the embodiments of the present disclosure are further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0030] In order to facilitate understanding and explanation of the technical solutions provided by the embodiments of the present disclosure, the background technology of the embodiments of the present disclosure will be described below.

[0031] Programmers and engineers can edit code using a code editor, which is a container for code input. Code editors come in many different types. For example, an HTML code editor can generate web pages and specifically add and edit DOM elements. In the application scenario of AB experiments, when generating AB pages for visual experiments, a code editor can be used to combine any web page elements and scenarios. In this application scenario, a code editor can serve as a supplement to a visual editor, enabling functionality that is difficult to achieve with a visual editor.

[0032] Currently, existing code editors, such as VSCode, are integrated editors with powerful features and rich plugins. However, these code editors are complex, require a lot of storage, and are not lightweight enough.

[0033] Based on this, the embodiments of the present disclosure provide a method, apparatus and device for implementing a code editor, which implements the code editor by setting a core program package of the code editor. The core program package may include a states component, which is used to represent the state of the code editor and the data structure of the change to the state; a views component, which is used to display the state of the code editor to the user through the page, and convert the operation trigger of the code editor into the state update of the page; a commands component, which is used to define the implementation logic of the command or extended function, and the binding of the command or extended function to the key (such as command button, shortcut key, etc.). Through the operation and mutual calling of each core program package, it is possible to obtain the status of the event when an event is triggered in the code editor, and generate the display update status of the code editor according to the status of the event. The display update status can be considered as the new state that the code editor should display, so that the display update status is displayed in the editing page of the code editor. The above method is used to implement a relatively simple code editor function and achieve a relatively lightweight implementation.

[0034] To facilitate understanding of the implementation method of the code editor provided by the embodiment of the present disclosure, the following description is made with reference to the scenario example shown in Figure 1. Referring to Figure 1, this figure is a schematic diagram of an exemplary application scenario provided by the embodiment of the present disclosure.

[0035] In the disclosed embodiments, a code editor is implemented by providing a core program package for a code editor. This code editor can be an HTML code editor. The HTML code editor can generate HTML web pages. The code editor has an edit page for entering code text and may also have corresponding command buttons. Entering text or triggering a command on the code editor's edit page, such as by triggering a command button or a command shortcut, can cause the view component to monitor the triggering of the event and obtain the event's status. Based on the event's status, the code editor's display update state can be generated. During this process, command implementation logic in the command component may be invoked. The generated display update state can be considered the new state that the code editor should display, and the new state can be retrieved by the state component. The view component can then display the display update state on the edit page, thereby updating the edit page. The view component continues to monitor for event triggering, repeating the above process repeatedly. Thus, through the above process, text input or command execution can be triggered in the code editor, and the corresponding results can be displayed in the code editor, achieving a relatively simple and lightweight implementation of the code editor's functionality.

[0036] Those skilled in the art will appreciate that the framework diagram shown in FIG1 is merely an example in which the embodiments of the present disclosure may be implemented, and the scope of application of the embodiments of the present disclosure is not limited in any way by the framework.

[0037] To facilitate understanding of the embodiments of the present disclosure, an implementation method of a code editor provided by the embodiments of the present disclosure is described below with reference to the accompanying drawings.

[0038] Referring to FIG. 2 , which is a flow chart of a method for implementing a code editor provided by an embodiment of the present disclosure, as shown in FIG. 2 , the method may include S201 to S203:

[0039] S201: In response to triggering of an event in a code editor, obtaining a state of the event.

[0040] The disclosed embodiments can be applied to devices that implement a code editor. By setting the core package of the code editor, a minimal, feasible code editor is first constructed. The code editor has at least an editing page, which can be used to enter code text. The user can trigger events in the code editor, such as triggering a text input event and triggering a command event. When the code editor listens to the triggering of an event in the code editor, the state of the event can be obtained. The state of the event represents the basic information of the triggered event, such as the newly added text input of the text input event and the command type of the command event. In actual applications, the view component can listen to the event triggering to obtain the state of the event.

[0041] S202: Generate a display update state of the code editor according to the state of the event.

[0042] After obtaining the status of an event, the code editor's display update status can be generated based on the event status. The code editor's display update status corresponds to the new status that should be displayed within the code editor's editing page. In actual applications, generating the display update status can be implemented by different core packages calling each other, and the generated display update status can be obtained by the status component. The specific implementation of generating the display update status varies depending on the event. The specific implementation can be referenced in the subsequent embodiments and will not be repeated here.

[0043] S203: Displaying the update status in the editing page of the code editor.

[0044] After the display update status is generated, the code editor's edit page displays the display update status to implement the update of the edit page. For example, if a text input event inputs a new text A, the edit page also needs to add the new text A after the text already displayed on the edit page to implement the update of the edit page.

[0045] In practical applications, the view component can directly obtain the display update status from the state component and display it on the edit page. The view component does not need to convert the display update status, making the view component as transparent as possible to the view component. In addition, the view component can provide utility methods to display animations, such as flashing the mouse cursor.

[0046] Based on the description of S201-S203, the disclosed embodiment monitors the triggering of events in the code editor, obtains the event status, and generates the code editor's display update status based on the event status. This display update status can be considered the new status that the code editor should display, and the display update status is displayed on the code editor's editing page. This method achieves a relatively simple code editor function and is relatively lightweight.

[0047] In a possible implementation, after generating the display update status of the code editor according to the status of the event in S202, the implementation method of the code editor provided by the embodiment of the present disclosure may further include:

[0048] The display update status is sent to the browser, so that the browser parses the display update status and then displays the target page of the browser.

[0049] In the embodiment of the present disclosure, after obtaining the display update status, on the one hand, it is necessary to update the editing page of the code editor, and on the other hand, it is also necessary to display the generated target page in the browser according to the display update status so that the user can view the target page to determine the validity of the event triggered in the code editor.

[0050] After obtaining the display update status, the display update status is sent to the browser. The browser parses the display update status and generates the target page for display. Specifically, the browser parses the display update status to generate the page DOM of the target page. In a specific implementation, the display update status can be sent as JS encapsulated data to parse and generate the page DOM, rather than using the browser's contentEditable attribute.

[0051] In addition, the display update status displayed on the edit page of the code editor may be the same as or different from the display on the target page after the display update status is parsed. For example, if the display update status of the edit page is "newly added display text A", the display on the target page after the display update status is parsed will also be "newly added display text A"; while the display update status of the edit page is "newly added display text , and after the browser parses the display update status, the target page is displayed as blank, that is, the browser The result of the analysis is blank.

[0052] In this way, after the code editor is triggered by an event, the embodiment of the present disclosure can also promptly preview the display effect of the generated browser target page.

[0053] The core function of the code editor provided by the embodiment of the present disclosure is relatively lightweight, and the function can be expanded to achieve other functions.

[0054] In a possible implementation, the method for implementing the code editor provided by the embodiment of the present disclosure may further include:

[0055] In response to a request to enable an extended function, a corresponding extended function is added in the code editor.

[0056] First, you can configure some options and set up a selection interface in the code editor, allowing the user to decide whether to enable extended features. In response to the user's request to enable extended features, the corresponding extended features are added to the code editor, such as code completion extended features and code folding extended features. In specific implementations, extended features can be implemented through command components.

[0057] In a possible implementation, the method for implementing the code editor provided by the embodiment of the present disclosure may further include:

[0058] In response to a request to start a command, a corresponding command button is displayed in the code editor and / or a corresponding command shortcut key is set in the code editor.

[0059] Similarly, some options can be configured to set up a selection interface in the code editor, and the user can decide whether to enable the command through selection. In response to the user's request to enable the command, the code editor needs to be styled to establish a connection between the command component and the view component. This will display the corresponding command button in the code editor and / or set the corresponding command shortcut key in the code editor. For example, command buttons such as line break and code formatting can be added to the code editor. When the user triggers the command button and / or command shortcut key, the corresponding command event can be triggered. In a specific implementation, these commands can be implemented through the command component.

[0060] In addition, it is allowed to enable a command or an extended function multiple times. If the same command or extended function is enabled multiple times, the last one will prevail.

[0061] The following uses the triggering of a text input event as an example to further illustrate a method for implementing a code editor provided by an embodiment of the present disclosure. Referring to FIG3 , which is a flowchart of another method for implementing a code editor provided by an embodiment of the present disclosure, as shown in FIG3 , the method may include S301-S303:

[0062] S301: In response to triggering of a text input event in a code editor, obtaining newly added text input by the text input event.

[0063] S301 is a specific implementation of S201, which obtains the state of an event in response to the triggering of an event in the code editor. When a user enters code text in the editing page of the code editor, a text input event may be triggered. In this case, the triggering of the event is the triggering of a text input event. When the code editor monitors the text input event, it obtains the newly added text entered in the text input event.

[0064] S302: Generate a display update text state of the code editor according to the text displayed in the editing page of the code editor and the newly added text input by the text input event.

[0065] S302 is a specific implementation of S202, which generates a code editor's display update state based on the state of an event. The code editor's edit page may already contain displayed text. Based on the new text inputted by the text input event, the code editor's display update text state can be generated. The display update text state represents the new text state that should be displayed on the edit page. In practical applications, the display update text state can also include any number of comments, i.e., comments about functions or commands involved in generating the display update text state can also be included as part of the display update text state.

[0066] In a possible implementation, S302 may include generating a display updated text state of the code editor based on the displayed text in the editing page of the code editor and the newly added text input by the text input event:

[0067] When the code editor is added with a code completion extension function, the newly added text is automatically completed based on the text displayed in the editing page of the code editor and the newly added text entered by the text input event, generating a display update text state of the code editor.

[0068] In the embodiment of the present disclosure, corresponding extended functions can be added to the code editor. When the code editor is added with the code completion extended function, the newly added text can be automatically completed according to the text displayed in the editing page of the code editor and the newly added text input by the text input event, thereby generating the display update text state of the code editor. For example, in HTML code, Need to appear in pairs. When the new text is When you use This effectively reduces the amount of text that users actually enter in the code editor and can reduce input errors.

[0069] In a possible implementation, S302 may include generating a display updated text state of the code editor based on the displayed text in the editing page of the code editor and the newly added text input by the text input event:

[0070] When the code editor is added with a code folding extension function, based on the displayed text in the editing page of the code editor and the new text input by the text input event, the target text in the displayed text and the new text is converted into an ellipsis mark to generate the display update text state of the code editor.

[0071] Similarly, when a code editor has added the code folding extension, if there is target text to be folded in the text already displayed on the code editor's editing page or in the newly added text entered in the text input event, the target text can be converted to ellipsis marks, thereby generating the code editor's display updated text state. This allows you to fold unimportant code text in the code editor, reducing the length of the code and making it easier to view the code.

[0072] S303: Displaying the updated text status in the editing page of the code editor.

[0073] S303 is a specific implementation of S203 in which the display update status is displayed on the editing page of the code editor. The display update text status is displayed on the editing page of the code editor to implement the update of the editing page.

[0074] 4, which shows a schematic diagram of the editing page of the code editor. 401 represents the editing page of the code editor. When the text is added to the 4th line of the editing page of the code editor When , a pairing can be automatically generated in line 6 , so that these display contents constitute the display update text status and are displayed on the edit page.

[0075] Based on the description of S301-S303, the embodiment of the present disclosure can realize the text input function of the code editor, and by setting the extended function of the code editor, the text input of the code editor can be made more convenient and the display more concise.

[0076] The following uses the triggering of a command event as an example to further illustrate a method for implementing a code editor provided by an embodiment of the present disclosure. Referring to FIG5 , which is a flowchart of another method for implementing a code editor provided by an embodiment of the present disclosure, as shown in FIG5 , the method may include S501-S503:

[0077] S501: In response to the triggering of a command event in the code editor, the command type of the command event is obtained. When the user triggers a command button in the code editor, and the triggering of the event is the triggering of a command event, S501 is the specific implementation of S201 in response to the triggering of the event in the code editor to obtain the state of the event. When the user triggers a command button or triggers a command shortcut key in the code editor, a command event can be triggered. At this time, the triggering of the event is the triggering of a command event. When the code editor listens to a command event, it obtains the command type corresponding to the triggered command button or the triggered command shortcut key. Command types include code formatting commands, line break commands, code verification commands, etc.

[0078] S502: Generate a display update text state of the code editor according to the displayed text in the editing page of the code editor and the implementation logic corresponding to the command type.

[0079] S502 is a specific implementation of S202, which generates the display update state of the code editor based on the state of the event. There may be displayed text in the editing page of the code editor. The implementation logic corresponding to the command type can process the displayed text to generate the display update text state of the code editor. The display update text state is the new text state that should be displayed in the editing page. In actual applications, the command component can store the implementation logic corresponding to each command type, and the display update text state of the code editor can be generated by calling the implementation logic corresponding to the command type in the command component.

[0080] In a possible implementation, S502 may include generating a display update text state of the code editor based on the displayed text in the editing page of the code editor and the implementation logic corresponding to the command type. The specific implementation may include:

[0081] When the command type is a code formatting command, the code formatting is performed on the displayed text in the editing page of the code editor, and the display update text state of the code editor is generated;

[0082] When the command type is a line break command, the text displayed in the editing page of the code editor is wrapped according to the preset length, generating a display update text state of the code editor;

[0083] When the command type is a code verification command, the displayed text in the editing page of the code editor is verified. If there is incorrect verification text in the displayed text, the incorrect verification text is marked and the display update text status of the code editor is generated.

[0084] In an embodiment of the present disclosure, when the command type is a code formatting command, the implementation logic corresponding to the code formatting command can be obtained to perform code formatting on the text displayed in the editing page, such as starting each code segment on a new line, adjusting the indentation position of the code, etc., to generate a display update text status of the code editor.

[0085] When the command type is a line break command, the implementation logic corresponding to the line break command can be obtained to wrap the displayed text in the editing page according to the preset length to generate the display update text state of the code editor.

[0086] When the command type is a code verification command, you can get the implementation logic corresponding to the code verification command to verify the text displayed in the editing page. If there is incorrectly verified text in the displayed text, the incorrectly verified text will be marked. At the same time, the marked position needs to be displayed in the current page to generate the code editor's display update text status.

[0087] S503: Displaying the updated text status in the editing page of the code editor.

[0088] S503 is a specific implementation of S203, wherein the display update status is displayed on the editing page of the code editor. The editing page of the code editor displays the display update text status to implement the update of the editing page.

[0089] 6 to 8 , schematic diagrams of the editing page of the code editor are shown.

[0090] In Figure 6, 601 represents a command button for code formatting. When the user triggers the command button, a code formatting command event is triggered. According to the text displayed in the editing page in the left figure of Figure 6 and the implementation logic corresponding to the code formatting command, the code editor in the right figure of Figure 6 is generated and displayed. The effect of code formatting is to update the text state of the inner layer of lines 4-6 in the editing page. The code text between and is indented to make the display hierarchy clearer.

[0091] In Figure 7 , 701 represents a line break command button. When the user triggers this command button, a line break command event is triggered. Based on the text displayed on the edit page in the left figure of Figure 7 and the corresponding implementation logic of the line break command, the code editor in the right figure of Figure 7 is generated and displayed. The line break effect updates the code text displayed on line 3 of the edit page to display the same code text on lines 3-4, making the display more in line with the user's needs.

[0092] In Figure 8, the user can trigger the code verification command event through the command shortcut key to verify the text displayed in the editing page and mark the incorrect text, as shown in 801, thereby automatically identifying and marking the incorrect code in the code text to facilitate user viewing.

[0093] Based on the description of S501-S503, the embodiment of the present disclosure can implement the execution and display of command events in the code editor after they are triggered, thereby also implementing the execution of commands in the code editor according to user needs in a relatively simple manner.

[0094] In a possible implementation, the method for implementing the code editor provided by the embodiment of the present disclosure may further include:

[0095] Get the style information of the code editor;

[0096] The editing page of the code editor and / or the display content in the editing page of the code editor are displayed according to the style information.

[0097] In the disclosed embodiments, the style of the code editor can be customized, pre-set style information of the code editor can be obtained, and the editing page of the code editor can be displayed according to the style information. For example, the editing page of the code editor can have a vertical slider or a horizontal slider. The display content of the editing page can also be displayed according to the style information, for example, the display content of the editing page can be displayed in a certain font or color.

[0098] 9 , which shows a schematic diagram of an editing page of a code editor, wherein 901 represents a horizontal slide bar in the editing page, and 902 represents a vertical slide bar in the editing page.

[0099] In addition, the code editor provided by the embodiment of the present disclosure can treat the input text as a flat string and store it in a tree-like data structure, so that the editing page can be updated quickly and efficiently, and can also be efficiently searched by code line number.

[0100] Based on the implementation method of a code editor provided by the above method embodiment, the embodiment of the present disclosure further provides an implementation device of a code editor, which will be described below with reference to the accompanying drawings.

[0101] See Figure 10, which is a schematic diagram of a structure of a device for implementing a code editor provided by an embodiment of the present disclosure. As shown in Figure 10, the device for implementing the code editor includes:

[0102] A first acquiring unit 1001 is configured to acquire a state of an event in response to triggering of the event in the code editor;

[0103] A generating unit 1002 is configured to generate a display update state of the code editor according to a state of the event;

[0104] The display unit 1003 is configured to display the display update status in the editing page of the code editor.

[0105] In some possible implementations, the apparatus further includes:

[0106] The sending unit is used to send the display update status to the browser, so that the browser analyzes the display update status and then displays the target page of the browser.

[0107] In some possible implementations, the first acquiring unit is specifically configured to:

[0108] In response to triggering of a text input event in a code editor, obtaining newly added text input by the text input event;

[0109] The generating unit is specifically configured to:

[0110] Generate a display updated text state of the code editor according to the text displayed in the editing page of the code editor and the newly added text input by the text input event;

[0111] The display unit is specifically used for:

[0112] The display update text status is displayed in the editing page of the code editor.

[0113] In a possible implementation, the generating unit is specifically configured to:

[0114] When the code editor is added with a code completion extension function, the newly added text is automatically completed according to the text displayed in the editing page of the code editor and the newly added text input by the text input event, and the display updated text state of the code editor is generated.

[0115] In a possible implementation, the generating unit is specifically configured to:

[0116] When the code editor is added with a code folding extension function, the target text in the displayed text and the newly added text is converted into an ellipsis mark based on the displayed text in the editing page of the code editor and the newly added text input by the text input event, thereby generating a display update text state of the code editor.

[0117] In a possible implementation, the first acquiring unit is specifically configured to:

[0118] The step of obtaining a status of an event in response to triggering the event in the code editor includes:

[0119] In response to triggering of a command event in the code editor, obtaining a command type of the command event;

[0120] The generating unit is specifically configured to:

[0121] Generate a display update text state of the code editor according to the text displayed in the editing page of the code editor and the implementation logic corresponding to the command type;

[0122] The display unit is specifically used for:

[0123] The display update text status is displayed in the editing page of the code editor.

[0124] In a possible implementation, the generating unit is specifically configured to:

[0125] When the command type is a code formatting command, code formatting is performed on the text displayed in the editing page of the code editor to generate a display updated text state of the code editor;

[0126] When the command type is a line break command, the text displayed in the editing page of the code editor is wrapped according to a preset length, and a display updated text state of the code editor is generated;

[0127] When the command type is a code verification command, the text displayed in the editing page of the code editor is verified. If there is incorrectly verified text in the displayed text, the incorrectly verified text is marked to generate a display update text status of the code editor.

[0128] In a possible implementation, the apparatus further includes:

[0129] The adding unit is configured to add a corresponding extended function in the code editor in response to a request to enable the extended function.

[0130] In a possible implementation, the apparatus further includes:

[0131] In response to a request to start a command, a corresponding command button is displayed in the code editor and / or a corresponding command shortcut key is set in the code editor.

[0132] In a possible implementation, the apparatus further includes:

[0133] A second acquiring unit, configured to acquire style information of the code editor;

[0134] The display unit is further configured to display the editing page of the code editor and / or the display content in the editing page of the code editor according to the style information.

[0135] Based on the implementation method of a code editor provided in the above method embodiment, the present disclosure also provides an electronic device, including: one or more processors; a storage device on which one or more programs are stored, when the one or more programs are executed by the one or more processors, the one or more processors implement the implementation method of the code editor described in any of the above embodiments.

[0136] Reference is now made to FIG11 , which illustrates a schematic diagram of the structure of an electronic device 1300 suitable for implementing an embodiment of the present disclosure. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (portable Android devices), PMPs (Portable Media Players), vehicle-mounted terminals (e.g., vehicle-mounted navigation terminals), and fixed terminals such as digital televisions (TVs) and desktop computers. The electronic device illustrated in FIG11 is merely an example and should not limit the functionality and scope of use of the embodiments of the present disclosure.

[0137] As shown in FIG11 , the electronic device 1300 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 1301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1302 or a program loaded from a storage device 1306 into a random access memory (RAM) 1303. Various programs and data required for the operation of the electronic device 1300 are also stored in the RAM 1303. The processing device 1301, the ROM 1302, and the RAM 1303 are connected to each other via a bus 1304. An input / output (I / O) interface 1305 is also connected to the bus 1304.

[0138] Typically, the following devices may be connected to the I / O interface 1305: an input device 1306 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 1307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1306 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1309. The communication device 1309 may allow the electronic device 1300 to communicate with other devices wirelessly or by wire to exchange data. Although FIG11 illustrates the electronic device 1300 with various devices, it should be understood that not all of the illustrated devices are required to be implemented or present. More or fewer devices may alternatively be implemented or present.

[0139] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 1309, or installed from the storage device 1306, or installed from the ROM 1302. When the computer program is executed by the processing device 1301, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.

[0140] The electronic device provided by the embodiment of the present disclosure and the implementation method of a code editor provided by the above embodiment belong to the same inventive concept. For technical details not fully described in this embodiment, please refer to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0141] Based on the implementation method of a code editor provided in the above method embodiment, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the implementation method of the code editor as described in any of the above embodiments is implemented.

[0142] It should be noted that the computer-readable medium described above in the embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiments of the present disclosure, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device, or device. In the embodiments of the present disclosure, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.

[0143] In some embodiments, the client and server can communicate using any currently known or later developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or later developed network.

[0144] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0145] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the implementation method of the code editor.

[0146] Computer program code for performing the operations of the embodiments of the present disclosure may be written in one or more programming languages, or a combination thereof, including but not limited to object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0147] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0148] The units involved in the embodiments described in this disclosure may be implemented in software or hardware, wherein the name of a unit / module does not, in some cases, limit the unit itself.

[0149] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.

[0150] In the context of the embodiments of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0151] According to one or more embodiments of the present disclosure, Example 1 is a method for implementing a code editor provided by an embodiment of the present disclosure, the method comprising:

[0152] In response to triggering of an event in the code editor, obtaining a status of the event;

[0153] Generate a display update state of the code editor according to the state of the event;

[0154] The display update status is displayed in an editing page of the code editor.

[0155] According to one or more embodiments of the present disclosure, Example 2 is a method for implementing a code editor provided by an embodiment of the present disclosure, the method further comprising:

[0156] The display update status is sent to the browser, so that the browser parses the display update status and then displays the target page of the browser.

[0157] According to one or more embodiments of the present disclosure, Example 3 is a method for implementing a code editor provided in an embodiment of the present disclosure, wherein, in response to triggering an event in the code editor, obtaining the status of the event includes:

[0158] In response to triggering of a text input event in a code editor, obtaining newly added text input by the text input event;

[0159] Generating the display update status of the code editor according to the status of the event includes:

[0160] Generate a display updated text state of the code editor according to the text displayed in the editing page of the code editor and the newly added text input by the text input event;

[0161] The displaying of the update status in the editing page of the code editor includes:

[0162] The display update text status is displayed in the editing page of the code editor.

[0163] According to one or more embodiments of the present disclosure, Example 4 is a method for implementing a code editor provided in an embodiment of the present disclosure, wherein generating a display updated text state of the code editor based on displayed text in an editing page of the code editor and newly added text input by the text input event includes:

[0164] When the code editor is added with a code completion extension function, the newly added text is automatically completed according to the text displayed in the editing page of the code editor and the newly added text input by the text input event, and the display updated text state of the code editor is generated.

[0165] According to one or more embodiments of the present disclosure, Example 5 is a method for implementing a code editor provided in an embodiment of the present disclosure, wherein generating a display updated text state of the code editor based on displayed text in an editing page of the code editor and newly added text input by the text input event includes:

[0166] When the code editor is added with a code folding extension function, the target text in the displayed text and the newly added text is converted into an ellipsis mark based on the displayed text in the editing page of the code editor and the newly added text input by the text input event, thereby generating a display update text state of the code editor.

[0167] According to one or more embodiments of the present disclosure, Example 6 is a method for implementing a code editor provided in an embodiment of the present disclosure, wherein, in response to triggering an event in the code editor, obtaining the state of the event includes:

[0168] In response to triggering of a command event in the code editor, obtaining a command type of the command event;

[0169] Generating the display update status of the code editor according to the status of the event includes:

[0170] Generate a display update text state of the code editor according to the text displayed in the editing page of the code editor and the implementation logic corresponding to the command type;

[0171] The displaying of the update status in the editing page of the code editor includes:

[0172] The display update text status is displayed in the editing page of the code editor.

[0173] According to one or more embodiments of the present disclosure, Example 7 is a method for implementing a code editor provided in an embodiment of the present disclosure, wherein generating a display updated text state of the code editor based on displayed text in an editing page of the code editor and implementation logic corresponding to the command type includes:

[0174] When the command type is a code formatting command, code formatting is performed on the text displayed in the editing page of the code editor to generate a display updated text state of the code editor;

[0175] When the command type is a line break command, the text displayed in the editing page of the code editor is wrapped according to a preset length, and a display updated text state of the code editor is generated;

[0176] When the command type is a code verification command, the text displayed in the editing page of the code editor is verified. If there is incorrectly verified text in the displayed text, the incorrectly verified text is marked to generate a display update text status of the code editor.

[0177] According to one or more embodiments of the present disclosure, Example 8 is a method for implementing a code editor provided by an embodiment of the present disclosure, the method further comprising:

[0178] In response to a request to enable an extended function, a corresponding extended function is added to the code editor.

[0179] According to one or more embodiments of the present disclosure, Example 9 is a method for implementing a code editor provided by an embodiment of the present disclosure, the method further comprising:

[0180] In response to a request to start a command, a corresponding command button is displayed in the code editor and / or a corresponding command shortcut key is set in the code editor.

[0181] According to one or more embodiments of the present disclosure, Example 10 is a method for implementing a code editor provided by an embodiment of the present disclosure, the method further comprising:

[0182] Obtaining style information of the code editor;

[0183] The editing page of the code editor and / or the display content in the editing page of the code editor are displayed according to the style information.

[0184] According to one or more embodiments of the present disclosure, Example 11 is a device for implementing a code editor provided in an embodiment of the present disclosure, the device including:

[0185] A first acquiring unit, configured to acquire a state of an event in response to triggering of the event in the code editor;

[0186] a generating unit, configured to generate a display update state of the code editor according to a state of the event;

[0187] The display unit is configured to display the display update status in the editing page of the code editor.

[0188] According to one or more embodiments of the present disclosure, Example 12 is a device for implementing a code editor provided by an embodiment of the present disclosure, the device further comprising:

[0189] The sending unit is used to send the display update status to the browser, so that the browser analyzes the display update status and then displays the target page of the browser.

[0190] According to one or more embodiments of the present disclosure, Example 13 is a device for implementing a code editor provided by an embodiment of the present disclosure, wherein the first acquisition unit is specifically configured to:

[0191] In response to triggering of a text input event in a code editor, obtaining newly added text input by the text input event;

[0192] The generating unit is specifically configured to:

[0193] Generate a display updated text state of the code editor according to the text displayed in the editing page of the code editor and the newly added text input by the text input event;

[0194] The display unit is specifically used for:

[0195] The display update text status is displayed in the editing page of the code editor.

[0196] According to one or more embodiments of the present disclosure, Example 14 is a device for implementing a code editor provided by an embodiment of the present disclosure, wherein the generating unit is specifically configured to:

[0197] When the code editor is added with a code completion extension function, the newly added text is automatically completed according to the text displayed in the editing page of the code editor and the newly added text input by the text input event, and the display updated text state of the code editor is generated.

[0198] According to one or more embodiments of the present disclosure, Example 15 is a device for implementing a code editor provided by an embodiment of the present disclosure, wherein the generating unit is specifically configured to:

[0199] When the code editor is added with a code folding extension function, the target text in the displayed text and the newly added text is converted into an ellipsis mark based on the displayed text in the editing page of the code editor and the newly added text input by the text input event, thereby generating a display update text state of the code editor.

[0200] According to one or more embodiments of the present disclosure, Example 16 is a device for implementing a code editor provided by an embodiment of the present disclosure, wherein the first acquisition unit is specifically configured to:

[0201] The step of obtaining a status of an event in response to triggering the event in the code editor includes:

[0202] In response to triggering of a command event in the code editor, obtaining a command type of the command event;

[0203] The generating unit is specifically configured to:

[0204] Generate a display update text state of the code editor according to the text displayed in the editing page of the code editor and the implementation logic corresponding to the command type;

[0205] The display unit is specifically used for:

[0206] The display update text status is displayed in the editing page of the code editor.

[0207] According to one or more embodiments of the present disclosure, Example 17 is a device for implementing a code editor provided by an embodiment of the present disclosure, wherein the generating unit is specifically configured to:

[0208] When the command type is a code formatting command, code formatting is performed on the text displayed in the editing page of the code editor to generate a display updated text state of the code editor;

[0209] When the command type is a line break command, the text displayed in the editing page of the code editor is wrapped according to a preset length, and a display updated text state of the code editor is generated;

[0210] When the command type is a code verification command, the text displayed in the editing page of the code editor is verified. If there is incorrectly verified text in the displayed text, the incorrectly verified text is marked to generate a display update text status of the code editor.

[0211] According to one or more embodiments of the present disclosure, Example 18 is a device for implementing a code editor provided by an embodiment of the present disclosure, the device further comprising:

[0212] The adding unit is configured to add a corresponding extended function in the code editor in response to a request to enable the extended function.

[0213] According to one or more embodiments of the present disclosure, Example 19 is a device for implementing a code editor provided by an embodiment of the present disclosure, the device further comprising:

[0214] In response to a request to start a command, a corresponding command button is displayed in the code editor and / or a corresponding command shortcut key is set in the code editor.

[0215] According to one or more embodiments of the present disclosure, Example 20 is a device for implementing a code editor provided by an embodiment of the present disclosure, the device further comprising:

[0216] A second acquiring unit, configured to acquire style information of the code editor;

[0217] The display unit is further configured to display the editing page of the code editor and / or the display content in the editing page of the code editor according to the style information.

[0218] According to one or more embodiments of the present disclosure, Example 21 is a code editor implementation device provided by an embodiment of the present disclosure, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the code editor implementation method described in any one of Examples 1 to 10.

[0219] According to one or more embodiments of the present disclosure, Example 22 is a computer-readable storage medium provided by an embodiment of the present disclosure, wherein instructions are stored in the computer-readable storage medium. When the instructions are executed on a terminal device, the terminal device executes the implementation method of the code editor as described in any one of Examples 1 to 10.

[0220] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the systems or devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.

[0221] It should be understood that in the present disclosure, "at least one (item)" means one or more, and "more" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or plural.

[0222] It should also be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprise," "include," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a set of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.

[0223] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0224] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present disclosure. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not limited to the embodiments shown herein, but is intended to be construed in the widest manner consistent with the principles and novel features disclosed herein.

Claims

1. A method for implementing a code editor, comprising: In response to triggering an event in the code editor, obtaining a state of the event; Generate a display update state of the code editor according to the state of the event; as well as The display update status is displayed in an editing page of the code editor.

2. The method according to claim 1, further comprising: The display update status is sent to the browser, so that the browser displays the target page of the browser after parsing the display update status.

3. The method according to claim 1, wherein: The step of obtaining the state of an event in response to triggering the event in the code editor includes: In response to triggering of a text input event in the code editor, obtaining newly added text input by the text input event; Generating the display update state of the code editor according to the state of the event includes: Generate a display update text state of the code editor according to the displayed text in the editing page of the code editor and the newly added text input by the text input event; The displaying of the update status in the editing page of the code editor includes: The display update text status is displayed in the editing page of the code editor.

4. The method according to claim 3, wherein: The step of generating a display update text state of the code editor according to the displayed text in the editing page of the code editor and the newly added text input by the text input event includes: When the code editor is added with a code completion extension function, the newly added text is automatically completed according to the displayed text in the editing page of the code editor and the newly added text input by the text input event, and the display update text state of the code editor is generated.

5. The method according to claim 3, wherein: The step of generating a display update text state of the code editor according to the displayed text in the editing page of the code editor and the newly added text input by the text input event includes: When the code editor is added with a code folding extension function, the displayed text in the editing page of the code editor and the newly added text input by the text input event are folded. The target text in the display text and the newly added text is converted into an ellipsis mark, and the display update text state of the code editor is generated.

6. The method according to claim 1, wherein: The step of obtaining the state of an event in response to triggering the event in the code editor includes: In response to triggering of a command event in the code editor, obtaining a command type of the command event; Generating the display update state of the code editor according to the state of the event includes: Generate a display update text state of the code editor according to the displayed text in the editing page of the code editor and the implementation logic corresponding to the command type; The displaying of the update status in the editing page of the code editor includes: The display update text status is displayed in the editing page of the code editor.

7. The method according to claim 6, wherein: The step of generating a display update text state of the code editor according to the displayed text in the editing page of the code editor and the implementation logic corresponding to the command type includes: When the command type is a code formatting command, code formatting is performed on the displayed text in the editing page of the code editor to generate a display update text state of the code editor; When the command type is a line break command, the displayed text in the editing page of the code editor is wrapped according to a preset length, and a display update text state of the code editor is generated; When the command type is a code verification command, the displayed text in the editing page of the code editor is verified. If the displayed text contains incorrectly verified text, the incorrectly verified text is marked to generate a display update text status of the code editor.

8. The method according to any one of claims 1 to 7, further comprising: In response to a request to enable an extended function, a corresponding extended function is added in the code editor.

9. The method according to any one of claims 1 to 7, further comprising: In response to a request to start a command, a corresponding command button is displayed in the code editor and / or a corresponding command shortcut key is set in the code editor.

10. The method according to any one of claims 1 to 7, further comprising: Obtaining style information of the code editor; The editing page of the code editor and / or the display content in the editing page of the code editor are displayed according to the style information.

11. A device for implementing a code editor, comprising: A first acquisition unit, configured to acquire a state of an event in response to triggering of the event in the code editor; a generating unit, configured to generate a display update state of the code editor according to a state of the event; as well as The display unit is configured to display the display update status in the editing page of the code editor.

12. A device for implementing a code editor, comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, When the processor executes the computer program, the implementation method of the code editor according to any one of claims 1 to 10 is implemented.

13. A computer-readable storage medium, wherein: The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device executes the implementation method of the code editor according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Code processing method and device, electronic equipment and storage medium

    CN111273899A

  • Webpage editing method and device, equipment and storage medium

    CN113343156A

  • Code editor implementation method, device and equipment

    CN116521152A

  • Extensible Mechanism for Providing Suggestions in a Source Code Editor

    US20130263086A1

  • Visual code editor for visually developing features in applications

    US20180143809A1