CN110874523A - Internal and external interaction method and device for rich text editor, processor and storage medium - Google Patents
Internal and external interaction method and device for rich text editor, processor and storage medium Download PDFInfo
- Publication number
- CN110874523A CN110874523A CN201811000414.9A CN201811000414A CN110874523A CN 110874523 A CN110874523 A CN 110874523A CN 201811000414 A CN201811000414 A CN 201811000414A CN 110874523 A CN110874523 A CN 110874523A
- Authority
- CN
- China
- Prior art keywords
- rich text
- text editor
- hook element
- software module
- content data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 72
- 230000003993 interaction Effects 0.000 title claims abstract description 53
- 230000004044 response Effects 0.000 claims abstract description 82
- 230000001960 triggered effect Effects 0.000 claims abstract description 20
- 238000012544 monitoring process Methods 0.000 claims description 33
- 230000008569 process Effects 0.000 claims description 27
- 230000008859 change Effects 0.000 claims description 17
- 230000006870 function Effects 0.000 description 39
- 238000004590 computer program Methods 0.000 description 10
- 238000010586 diagram Methods 0.000 description 10
- 230000008901 benefit Effects 0.000 description 3
- 230000000694 effects Effects 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Images
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Document Processing Apparatus (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses an internal and external interaction method and device of a rich text editor, a processor and a storage medium, wherein the method is applied to electronic equipment, and a software module corresponding to the rich text editor is also deployed in the electronic equipment; the method comprises the steps of adding hook elements to software modules corresponding to the rich text editors; binding a trigger event and an external response event for the hook element; wherein the external response event occurs outside the software module corresponding to the rich text editor; and if the hook element is triggered by the bound trigger event, executing the external response event bound by the hook element. According to the method and the device, the hook element is used as a link for the internal and external interaction of the rich text editor, so that the interaction between a designated area inside the rich text editor and an external response event outside the rich text editor is realized, and the internal and external interaction of the rich text editor is also realized.
Description
Technical Field
The invention relates to the technical field of web pages, in particular to a rich text editor internal and external interaction method and device, a processor and a storage medium.
Background
A Rich Text Editor (RTE) is also a what-you-see-is-what-you-get Text Editor. The rich text editor may be embedded in a browser (or other application) to facilitate a user editing information into the rich text editor, unlike a text editor.
In the electronic devices currently deployed with rich text editors, the rich text editors are usually used as independent software modules, so the rich text editors can only realize internal operations within the software modules.
With the generalization of the application scenarios of the rich text editor, the requirement of data interaction between the inside of the rich text editor and the outside of the rich text editor can be met, but the current rich text editor does not support the data interaction between the inside and the outside, so the requirement cannot be met.
Disclosure of Invention
In view of the above, the present invention has been made to provide a rich text editor internal and external interaction method and apparatus, a processor, and a storage medium that overcome or at least partially solve the above-mentioned problems.
In order to realize the scheme, the following technical characteristics are adopted:
an internal and external interaction method of a rich text editor is applied to electronic equipment, and a software module corresponding to the rich text editor is also deployed in the electronic equipment; the internal and external interaction method of the rich text editor comprises the following steps:
adding a hook element to a software module corresponding to the rich text editor;
binding a trigger event and an external response event for the hook element; wherein the external response event occurs outside the software module corresponding to the rich text editor;
and if the hook element is triggered by the bound trigger event, executing the external response event bound by the hook element.
Optionally, the adding a hook element to a software module corresponding to the rich text editor includes:
determining a designated area for binding a trigger event in an editing area of the rich text editor;
and in the process of initializing the content of the editing area of the rich text editor, adding a hook element into a code block corresponding to the specified area in the software module.
Optionally, the binding a trigger event and an external response event for the hook element includes:
monitoring whether content initialization is completed in an editing area of the rich text editor;
after the fact that content initialization of an editing area of a rich text editor is monitored, searching the hook element in a software module corresponding to the rich text editor;
binding a trigger event and the external response event to the hook element.
Optionally, a temporary storage variable is set;
the temporary storage variable is used for storing content data containing the hook element in a software module corresponding to the rich text editor.
Optionally, the temporary storage variable is used to store content data containing the hook element in a software module corresponding to the rich text editor, and includes:
after a trigger event and an external response event are bound for the hook element, calling an acquisition content interface in the rich text editor to acquire current content data of an editing area in a software module corresponding to the rich text editor;
and storing the current content data into the temporary storage variable.
Optionally, the temporary storage variable is used to store content data containing the hook element in a software module corresponding to the rich text editor, and includes:
calling a content change monitoring interface in the rich text editor, and monitoring whether the content data of an editing area in a software module corresponding to the rich text editor changes;
under the condition that the change of the content data of the editing area in the software module corresponding to the rich text editor is monitored, calling an interface for acquiring the content in the rich text editor to acquire the current content data of the editing area in the software module corresponding to the rich text editor;
judging whether the current content data of the rich text editor contains the hook element;
and if the current content data of the rich text editor contains the hook element, updating the current content data into the temporary storage variable, calling a content change monitoring interface in the rich text editor, and monitoring whether the content changes in the using process of the rich text editor.
Optionally, the method further includes:
if the current content data of the rich text editor does not contain the hook element, obtaining the existing content data in the temporary storage variable, and replacing the current content data in the software module corresponding to the rich text editor with the existing content data;
searching the hook element in a software module corresponding to the rich text editor;
and rebinding the trigger event and the external response event for the hook element.
An internal and external interaction device of a rich text editor is integrated in electronic equipment, and a software module corresponding to the rich text editor is also deployed in the electronic equipment; the internal and external interaction device of the rich text editor comprises:
the adding unit is used for adding hook elements to the software modules corresponding to the rich text editors;
a binding unit, configured to bind a trigger event and an external response event for the hook element; wherein the external response event occurs outside the software module corresponding to the rich text editor;
and the execution unit is used for executing the external response event bound by the hook element if the hook element is triggered by the bound trigger event.
A processor for running a program, wherein the program is run to perform a rich text editor in-and-out interaction method.
A storage medium having stored thereon a program which, when executed by a processor, implements a rich text editor in-and-out interaction method.
By means of the technical scheme, the internal and external interaction method of the rich text editor provided by the invention has the following beneficial effects:
according to the method, hook elements are added in software modules corresponding to rich text editors, and then trigger events and external response events are bound for the hook elements; therefore, the purpose of executing the hook element bound external response event is achieved after the hook element is triggered by the bound trigger event.
The hook element is used as a link for the internal and external interaction of the rich text editor, so that the interaction between a designated area inside the rich text editor and an external response event outside the rich text editor is realized, namely the internal and external interaction of the rich text editor is realized.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 illustrates a display interface of a rich text editor;
FIGS. 2a-2b show schematic structural diagrams of an electronic device;
FIG. 3 is a flow chart of a first embodiment of a rich text editor in-out interaction method;
FIG. 4 is a flow chart of a second embodiment of a rich text editor in-out interaction method;
fig. 5 shows a schematic structural diagram of the internal and external interaction device of the rich text editor.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Interpretation of terms:
hook elements: according to the method and the device, the hook element is added in the code block corresponding to the designated area, the hook element is a special identifier, and the hook element is identified by searching the special identifier.
Referring to fig. 1, the display interface of the rich text editor includes two parts: one part is a functional area for providing functions such as font format and font color, and the other part is an editing area for editing data such as characters and pictures. The functional area is usually fixed, and the editing area can be used for performing editing operations such as writing, deleting, adding effects and the like.
The present application provides an electronic device, see fig. 2a, having an executing software module 100 integrated therein. Referring to fig. 2b, the software module 200 corresponding to the rich text editor is integrated into the electronic device; the software module 200 corresponding to the rich text editor is a stand-alone software module.
The present application provides a first embodiment of an internal and external interaction method for a rich text editor, which is applied to the executing software module 100 of the electronic device shown in fig. 2.
Referring to fig. 3, the rich text editor in-out interaction method may include the steps of:
step S301: the executing software module deploys a container within the electronic device and generates a rich text editor within the container.
In practical applications, the software execution module 100 deploys a container (Docker) in the electronic device and initializes the rich text editor in the container, and the electronic device may generate the rich text editor in the container by using the following instructions: < div id ═ authenticator "> < div >.
The rich text editor configures some event listening functions, such as a ready function, to listen whether the rich text editor generates. Software execution module 100 calls the ready function interface to determine whether a rich text editor is generated.
And after the rich text editor is generated, the container is the rich text editor. Inside the container is the inside of the rich text editor, and outside the container is the outside of the rich text editor. The container, that is, the software module 200 corresponding to the rich text editor, and the electronic device to which the software module 200 is added can be seen in fig. 2 b.
Adding hook elements to the software module corresponding to the rich text editor can be realized by adopting the following steps S302-S303.
Step S302: the software executing module 100 determines a designated area in the edit section of the rich text editor for binding the trigger event.
The editing area of the rich text editor comprises a plurality of areas, and a user can determine one area in the plurality of areas in advance to use the area as a specified area of a subsequent binding trigger event.
Each region in the software module corresponding to the rich text editor is implemented by using one code block, for example, a region is used for displaying a picture, and the code block corresponding to the region is composed of multiple lines of codes for displaying the picture.
To distinguish between different regions, region identifiers may be used to represent the different regions. The software executing module 100 saves the area identification of the designated area to determine the designated area for binding the trigger event by the area identification.
Step S303: and in the process of initializing the content of the editing area of the rich text editor, adding a hook element into a code block corresponding to the specified area in the software module. The hook element can be a hook function or a mark, and the specific implementation can be determined according to the actual situation.
The software executing module 100 controls the editing area of the rich text editor to perform content initialization. In the process of controlling the rich text editor to initialize, a code block corresponding to a specified area for binding the trigger event is determined in a software module corresponding to the rich text editor through an area identifier.
Then, in the software module corresponding to the rich text editor, a hook element (english paraphrase hook) is added to the code block corresponding to the specified region, for example, the hook element id is added to the code block as "signature".
For the hook element binding trigger event and external response event, the process can be implemented by using the following steps S304 to S306.
Step S304: and the execution software module monitors whether the content initialization of the editing area of the rich text editor is finished.
After the content initialization of the editing area of the rich text editor is completed, the execution software module 100 receives the feedback message, so as to know that the content initialization of the editing area of the rich text editor is completed.
Step S305: and after monitoring that the content initialization of the editing area of the rich text editor is completed, the executing software module searches the hook element in the software module corresponding to the rich text editor.
And the executing software module searches the hook elements in the software module corresponding to the rich text editor through the pre-written script file. For example, the executing software module searches the hook element "signature" in the software module of the rich text editor by means of pre-written js script code.
Step S306: and the executing software module binds the trigger event and the external response event to the hook element.
After finding the hook element, the executing software module binds the trigger event and binds the external response event to the hook element in the software module corresponding to the rich text editor, so that the external response event bound by the hook element is executed after the hook element is triggered by the trigger event, and internal and external interaction of the rich text editor is realized.
The external response event here is the execution of a function implemented by a software module. Since the executing software module is located outside the software module corresponding to the rich text editor, the function in the executing software module is equivalent to the external response event corresponding to the rich text editor.
Wherein the triggering event may include: mouse clicks, hovers, double clicks, triple clicks, etc. trigger hook element events, it being understood that trigger events may also include events, not to be enumerated herein.
For example, after the "signature" is found, the hook element "signature" is bound with a click event, and the rich text editor corresponds to a function () outside the software module.
An example of native js code for this step is given below to facilitate understanding.
Function initEvent()
{
var iframe
=document.querySelector('#ueditor').querySelector('iframe').contentWindow iframe.document.getElementById('signature').addEventListener(event,function() {// here rich text editor corresponds to software code that needs to be executed outside the software module })
}
The underlined signature in the above example is the found hook element, and the addEventListener function underlined later is a function for binding the trigger event and the external response event to the hook element.
The addEventListener function includes two parts event and function () {// here software code that needs to be executed outside the corresponding software module of the rich text editor }. An Event is a trigger Event that needs to bind to a hook element, such as a click (click), a mouse slide (mouseover), and so on.
function () {// here rich text editor corresponds to software code that needs to be executed outside the software module } is an external response event.
And if the hook element is triggered by the bound trigger event, executing the external response event bound by the hook element. This process can be implemented by steps S307 to S308.
Step S307: and the executing software module monitors whether the hook element in the corresponding software module of the rich text editor is triggered by a trigger event.
Step S308: and if the hook element is triggered by the bound trigger event, executing the external response event bound by the hook element.
For example, in the process of using the rich text editor, after a user executes a trigger event for a specified area of a hook element "signature" in an editing area of the rich text editor, an external response event for binding the hook element is triggeredfunction(){// here the rich text editor corresponds to software code that needs to be executed outside the software module }, so as to enable the rich text editor to interact inside and outside.
By the above embodiment, the following advantageous effects can be obtained:
in the embodiment, a hook element is added in a software module corresponding to a rich text editor, and then a trigger event and an external response event are bound for the hook element; therefore, the purpose of executing the hook element bound external response event is achieved after the hook element is triggered by the bound trigger event.
The hook element is used as a link for the internal and external interaction of the rich text editor, so that the interaction between a designated area inside the rich text editor and an external response event outside the rich text editor is realized, namely the internal and external interaction of the rich text editor is realized.
It is understood that all contents of the editing area in the rich text editor can be edited, and the user may mistakenly delete the designated area to which the hook element is added during the use of the rich text editor. After the hook element for internal and external interaction is deleted, the internal and external interaction of the rich text editor cannot be realized.
In order to optimize the first embodiment, a second embodiment of the internal and external interaction method of the rich text editor is provided, and a temporary storage variable is added on the basis of the first embodiment, and the temporary storage variable is used for storing content data containing the hook element in a software module corresponding to the rich text editor.
Referring to fig. 4, the method for internal and external interaction of the rich text editor may include steps S402, steps S408 to S409, and steps S412 to S417, which are different from those of the first embodiment, and the remaining steps are the same as those of the first embodiment.
Step S401: a container is deployed within an electronic device, and a rich text editor is generated within the container.
In practical applications, the software execution module 100 deploys a container (Docker) in the electronic device and initializes the rich text editor in the container, and the electronic device may generate the rich text editor in the container by using the following instructions: < div id ═ authenticator "> < div >.
The rich text editor configures some event listening functions, such as a ready function, to listen whether the rich text editor generates. Software execution module 100 calls the ready function interface to determine whether a rich text editor is generated.
And the container is the rich text editor after the rich text editor is generated. Inside the container is the inside of the rich text editor, and outside the container is the outside of the rich text editor. The container, that is, the software module 200 corresponding to the rich text editor, and the electronic device to which the software module 200 is added can be seen in fig. 2 b.
Step S402: a global scratch variable is set.
Adding hook elements to the software module corresponding to the rich text editor can be realized by adopting the following steps S403 to S404.
Step S403: the software executing module 100 determines a designated area in the edit section of the rich text editor for binding the trigger event.
The editing area of the rich text editor comprises a plurality of areas, and a user can determine one area in the plurality of areas in advance to use the area as a specified area of a subsequent binding trigger event.
Each region in the software module corresponding to the rich text editor is implemented by using one code block, for example, a region is used for displaying a picture, and the code block corresponding to the region is composed of multiple lines of codes for displaying the picture.
To distinguish between different regions, region identifiers may be used to represent the different regions. The software executing module 100 saves the area identification of the designated area to determine the designated area for binding the trigger event by the area identification.
Step S404: and in the process of initializing the content of the editing area of the rich text editor, adding a hook element into a code block corresponding to the specified area in the software module.
The software executing module 100 controls the editing area of the rich text editor to perform content initialization. In the process of controlling the rich text editor to initialize, a code block corresponding to a specified area for binding the trigger event is determined in a software module corresponding to the rich text editor through an area identifier.
Then, in the software module corresponding to the rich text editor, a hook element (english paraphrase hook) is added to the code block corresponding to the specified region, for example, the hook element id is added to the code block as "signature".
For the hook element binding trigger event and external response event, the process can be implemented by the following steps S405 to S407.
Step S405: and the execution software module monitors whether the content initialization of the editing area of the rich text editor is finished.
After the content initialization of the editing area of the rich text editor is completed, the execution software module 100 receives the feedback message, so as to know that the content initialization of the editing area of the rich text editor is completed.
Step S406: and after monitoring that the content initialization of the editing area of the rich text editor is completed, the executing software module searches the hook element in the software module corresponding to the rich text editor.
And the executing software module searches the hook elements in the software module corresponding to the rich text editor through the pre-written script file. For example, the executing software module searches the hook element "signature" in the software module of the rich text editor by means of pre-written js script code.
Step S407: and the executing software module binds the trigger event and the external response event to the hook element.
After finding the hook element, the executing software module binds the trigger event and binds the external response event to the hook element in the software module corresponding to the rich text editor, so that the external response event bound by the hook element is executed after the hook element is triggered by the trigger event, and internal and external interaction of the rich text editor is realized.
The external response event here is the execution of a function implemented by a software module. Since the executing software module is located outside the software module corresponding to the rich text editor, the function in the executing software module is equivalent to the external response event corresponding to the rich text editor.
Wherein the triggering event may include: mouse clicks, hovers, double clicks, triple clicks, etc. trigger hook element events, it being understood that trigger events may also include events, not to be enumerated herein.
For example, after the "signature" is found, the hook element "signature" is bound with a click event, and the rich text editor corresponds to a function () outside the software module.
An example of native js code for this step is given below to facilitate understanding.
Function initEvent()
{
var iframe
=document.querySelector('#ueditor').querySelector('iframe').contentWindow iframe.document.getElementById('signature').addEventListener(event,function(){// here rich text editor corresponds to software code that needs to be executed outside the software module })
}
The underlined signature in the above example is the found hook element, followed by the underlined signatureaddEventListenerThe function is a function that binds trigger events and external response events to the hook element.
addEventListenerThe function comprises two partseventAndfunction(){// here is the software code that needs to be executed outside the corresponding software module of the rich text editor }。event needs to bind hook elementsCertain triggering events (e.g., click, mouse swipe, etc.).function(){// here rich text editor corresponds to software code that needs to be executed outside the software module } is an external response event.
After a trigger event and an external response event are bound for the hook element, calling an acquisition content interface in the rich text editor to acquire current content data of an editing area in a software module corresponding to the rich text editor; and storing the current content data into the temporary storage variable. This process can be implemented by steps S408 to S409.
Step S408: after the executing software module binds the trigger event and the external response event for the hook element, the executing software module calls an interface for acquiring content in the rich text editor to acquire the current content data of the editing area in the software module corresponding to the rich text editor.
The rich text editor is provided with event monitoring functions, such as a Contentchange function, for monitoring whether the content data of the editing area of the rich text editor changes; the getContent function is used to obtain content data of an edit section of a rich text editor, and so on.
And the execution software module calls a getContent function in the software module corresponding to the rich text editor to acquire the current content data of the editing area of the rich text editor.
Step S409: and the execution software module stores the current content data into the temporary storage variable.
It will be appreciated that immediately after the hook element is added, the current content data must contain the hook element, so the current content data is saved first for use when the hook element is deleted.
And if the hook element is triggered by the bound trigger event, executing the external response event bound by the hook element. The present process can be implemented using steps S410 to S411.
Step S410: and the executing software module monitors whether the hook element in the corresponding software module of the rich text editor is triggered by a trigger event.
Step S411: and if the hook element is triggered by the bound trigger event, executing the external response event bound by the hook element.
For example, in the process of using the rich text editor, after a user executes a trigger event for a specified area of a hook element "signature" in an editing area of the rich text editor, an external response event for binding the hook element is triggeredfunction(){// here the rich text editor corresponds to software code that needs to be executed outside the software module }, so as to enable the rich text editor to interact inside and outside.
Steps S412 to S417 executed in parallel with step S410 and step S411 to prevent the hook element of the edit area from being deleted.
Step S412: and calling a content change monitoring interface in the rich text editor, and monitoring whether the content data of an editing area in a software module corresponding to the rich text editor changes.
The software code corresponding to the rich text editor comprises a Contentchange function which is used for monitoring whether the content data of the editing area of the rich text editor changes. The electronic equipment calls a Contentchange function interface to monitor whether the content data of the editing area of the rich text editor changes.
Step S413: and under the condition that the execution software module monitors that the content data of the editing area in the software module corresponding to the rich text editor changes, calling an acquisition content interface in the rich text editor to acquire the current content data of the editing area in the software module corresponding to the rich text editor.
And the execution software module calls a getContent function in the software module corresponding to the rich text editor to acquire the current content data of the editing area of the rich text editor under the condition that the change of the content data of the editing area in the software module corresponding to the rich text editor is monitored.
Step S414: and judging whether the current content data of the rich text editor contains the hook element. If so, the process proceeds to step S415, otherwise, the process proceeds to step S416.
Step S415: if the current content data of the rich text editor includes the hook element, the current content data is updated to the temporary storage variable, and the process proceeds to step S412.
If the current content data of the rich text editor contains the hook element, it is indicated that although the current content data of the editing area changes, the hook element is not deleted, so that the internal and external interaction of the rich text editor can be still realized, that is, the current content data is legal data.
Then, the current content data is updated to the temporary storage variable, that is, the existing content data of the temporary storage variable is updated by using the existing content data in the temporary storage variable of the current content data.
Step S416: and if the current content data of the rich text editor does not contain the hook element, acquiring the existing content data in the temporary storage variable, and replacing the current content data in the software module corresponding to the rich text editor with the existing content data.
And if the current content data of the rich text editor does not contain the hook element, the hook element is deleted. And in order to ensure that the inside and outside interaction of the rich text editor is realized, the value is assigned to the editing area of the rich text editor again.
Because the existing content data in the temporary storage variable contains the hook element, the current content data in the software module corresponding to the rich text editor is replaced by the existing content data, so that the content data of the rich text editor has the hook element.
Step S417: and the executing software module searches the hook element in the software module corresponding to the rich text editor, and binds the trigger event and the external response event for the hook element again.
And after the edit area of the rich text editor is re-assigned, the bound trigger event and the external response event are lost, and the trigger event and the external response event need to be bound for the hook element again, so that the hook element can still be triggered by the bound trigger event, and the external response event bound by the hook element is executed.
By the above embodiment, the following advantageous effects can be obtained:
in the embodiment, a hook element is added in a software module corresponding to a rich text editor, and then a trigger event and an external response event are bound for the hook element; therefore, the purpose of executing the hook element bound external response event is achieved after the hook element is triggered by the bound trigger event.
The hook element is used as a link for the internal and external interaction of the rich text editor, so that the interaction between a designated area inside the rich text editor and an external response event outside the rich text editor is realized, namely the internal and external interaction of the rich text editor is realized.
In addition, a temporary storage variable is added in the embodiment, so that the hook element can be recovered after the hook element in the rich text editor is deleted by mistake, and the trigger event and the external response event are bound for the hook element again, so that the internal and external interaction of the rich text editor can be ensured.
Corresponding to the internal and external interaction method of the rich text editor shown in fig. 4, the present application further provides an internal and external interaction apparatus of the rich text editor, which is integrated in an execution software module integrated in an electronic device, where a software module corresponding to the rich text editor is also deployed in the electronic device.
Referring to fig. 5, the rich text editor internal-external interaction device includes:
an adding unit 51, configured to add a hook element to a software module corresponding to the rich text editor;
a binding unit 52, configured to bind a trigger event and an external response event for the hook element; wherein the external response event occurs outside the software module corresponding to the rich text editor;
an executing unit 53, configured to execute the external response event bound by the hook element if the hook element is triggered by a trigger event bound by the hook element.
The adding unit 51 specifically includes:
a determining area unit 511, configured to determine a specified area for binding a trigger event in an editing area of the rich text editor;
an add hook unit 512, configured to add a hook element to a code block corresponding to the specified area in the software module in a process of initializing content of the editing area of the rich text editor.
The binding unit 52 specifically includes:
a monitoring unit 521, configured to monitor whether content initialization of an editing area of the rich text editor is completed;
the searching unit 522 is configured to search the hook element in a software module corresponding to the rich text editor after monitoring that content initialization is completed in an editing area of the rich text editor;
a binding event unit 523, configured to bind the trigger event and the external response event to the hook element.
A setting unit 53 for setting a temporary storage variable; the temporary storage variable is used for storing content data containing the hook element in a software module corresponding to the rich text editor.
The setting unit 53 uses a temporary storage variable to store the content data containing the hook element in the software module corresponding to the rich text editor, and specifically includes:
an obtaining unit 531, configured to call an obtaining content interface in the rich text editor after a trigger event and an external response event are bound for the hook element, and obtain current content data of an editing area in a software module corresponding to the rich text editor;
a storage unit 532, configured to store the current content data into the temporary storage variable.
A calling and monitoring unit 54, configured to call a content change monitoring interface in the rich text editor, and monitor whether content data in an editing area in a software module corresponding to the rich text editor changes;
the acquiring unit 55 is further configured to, when it is monitored that content data of an editing area in the software module corresponding to the rich text editor changes, invoke an acquiring content interface in the rich text editor to acquire current content data of the editing area in the software module corresponding to the rich text editor;
a judging unit 56, configured to judge whether the current content data of the rich text editor contains the hook element;
an updating unit 57, configured to update the current content data of the rich text editor to the temporary storage variable if the current content data of the rich text editor includes the hook element, and enter a step of calling a content change monitoring interface in the rich text editor to monitor whether the content changes during the use of the rich text editor.
A replacing unit 58, configured to, if the current content data of the rich text editor does not include the hook element, obtain existing content data in the temporary storage variable, and replace the current content data in the software module corresponding to the rich text editor with the existing content data;
a searching unit 522, configured to search the hook element in the software module corresponding to the rich text editor;
a binding event unit 523, configured to re-bind the trigger event and the external response event for the hook element.
The rich text editor internal and external interaction device comprises a processor and a memory, wherein the adding unit 51, the binding unit 52, the executing unit 53, the calling and monitoring unit 54, the obtaining unit 55, the judging unit 56, the updating unit 57, the replacing unit 58 and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to one or more than one, and the internal and external interaction purposes of the rich text editor are achieved by adjusting the kernel parameters.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
An embodiment of the present invention provides a storage medium on which a program is stored, the program implementing the rich text editor internal and external interaction method when executed by a processor.
The embodiment of the invention provides a processor, which is used for running a program, wherein the program executes an internal and external interaction method of a rich text editor during running.
The embodiment of the invention provides equipment, which comprises a processor, a memory and a program which is stored on the memory and can run on the processor, wherein the processor executes the program and realizes the following steps:
adding a hook element to a software module corresponding to the rich text editor;
binding a trigger event and an external response event for the hook element; wherein the external response event occurs outside the software module corresponding to the rich text editor;
and if the hook element is triggered by the bound trigger event, executing the external response event bound by the hook element.
Optionally, the adding a hook element to a software module corresponding to the rich text editor includes:
determining a designated area for binding a trigger event in an editing area of the rich text editor;
and in the process of initializing the content of the editing area of the rich text editor, adding a hook element into a code block corresponding to the specified area in the software module.
Optionally, the binding a trigger event and an external response event for the hook element includes:
monitoring whether content initialization is completed in an editing area of the rich text editor;
after the fact that content initialization of an editing area of a rich text editor is monitored, searching the hook element in a software module corresponding to the rich text editor;
binding a trigger event and the external response event to the hook element.
Optionally, a temporary storage variable is set;
the temporary storage variable is used for storing content data containing the hook element in a software module corresponding to the rich text editor.
Optionally, the temporary storage variable is used to store content data containing the hook element in a software module corresponding to the rich text editor, and includes:
after a trigger event and an external response event are bound for the hook element, calling an acquisition content interface in the rich text editor to acquire current content data of an editing area in a software module corresponding to the rich text editor;
and storing the current content data into the temporary storage variable.
Optionally, the temporary storage variable is used to store content data containing the hook element in a software module corresponding to the rich text editor, and includes:
calling a content change monitoring interface in the rich text editor, and monitoring whether the content data of an editing area in a software module corresponding to the rich text editor changes;
under the condition that the change of the content data of the editing area in the software module corresponding to the rich text editor is monitored, calling an interface for acquiring the content in the rich text editor to acquire the current content data of the editing area in the software module corresponding to the rich text editor;
judging whether the current content data of the rich text editor contains the hook element;
and if the current content data of the rich text editor contains the hook element, updating the current content data into the temporary storage variable, calling a content change monitoring interface in the rich text editor, and monitoring whether the content changes in the using process of the rich text editor.
Optionally, the method further includes:
if the current content data of the rich text editor does not contain the hook element, obtaining the existing content data in the temporary storage variable, and replacing the current content data in the software module corresponding to the rich text editor with the existing content data;
searching the hook element in a software module corresponding to the rich text editor;
and rebinding the trigger event and the external response event for the hook element.
The device herein may be a server, a PC, a PAD, a mobile phone, etc.
The present application further provides a computer program product adapted to perform a program for initializing the following method steps when executed on a data processing device:
adding a hook element to a software module corresponding to the rich text editor;
binding a trigger event and an external response event for the hook element; wherein the external response event occurs outside the software module corresponding to the rich text editor;
and if the hook element is triggered by the bound trigger event, executing the external response event bound by the hook element.
Optionally, the adding a hook element to a software module corresponding to the rich text editor includes:
determining a designated area for binding a trigger event in an editing area of the rich text editor;
and in the process of initializing the content of the editing area of the rich text editor, adding a hook element into a code block corresponding to the specified area in the software module.
Optionally, the binding a trigger event and an external response event for the hook element includes:
monitoring whether content initialization is completed in an editing area of the rich text editor;
after the fact that content initialization of an editing area of a rich text editor is monitored, searching the hook element in a software module corresponding to the rich text editor;
binding a trigger event and the external response event to the hook element.
Optionally, a temporary storage variable is set;
the temporary storage variable is used for storing content data containing the hook element in a software module corresponding to the rich text editor.
Optionally, the temporary storage variable is used to store content data containing the hook element in a software module corresponding to the rich text editor, and includes:
after a trigger event and an external response event are bound for the hook element, calling an acquisition content interface in the rich text editor to acquire current content data of an editing area in a software module corresponding to the rich text editor;
and storing the current content data into the temporary storage variable.
Optionally, the temporary storage variable is used to store content data containing the hook element in a software module corresponding to the rich text editor, and includes:
calling a content change monitoring interface in the rich text editor, and monitoring whether the content data of an editing area in a software module corresponding to the rich text editor changes;
under the condition that the change of the content data of the editing area in the software module corresponding to the rich text editor is monitored, calling an interface for acquiring the content in the rich text editor to acquire the current content data of the editing area in the software module corresponding to the rich text editor;
judging whether the current content data of the rich text editor contains the hook element;
and if the current content data of the rich text editor contains the hook element, updating the current content data into the temporary storage variable, calling a content change monitoring interface in the rich text editor, and monitoring whether the content changes in the using process of the rich text editor.
Optionally, the method further includes:
if the current content data of the rich text editor does not contain the hook element, obtaining the existing content data in the temporary storage variable, and replacing the current content data in the software module corresponding to the rich text editor with the existing content data;
searching the hook element in a software module corresponding to the rich text editor;
and rebinding the trigger event and the external response event for the hook element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims (10)
1. An internal and external interaction method of a rich text editor is characterized by being applied to electronic equipment, wherein a software module corresponding to the rich text editor is also deployed in the electronic equipment; the internal and external interaction method of the rich text editor comprises the following steps:
adding a hook element to a software module corresponding to the rich text editor;
binding a trigger event and an external response event for the hook element; wherein the external response event occurs outside the software module corresponding to the rich text editor;
and if the hook element is triggered by the bound trigger event, executing the external response event bound by the hook element.
2. The method of claim 1, wherein adding a hook element to a software module corresponding to the rich text editor comprises:
determining a designated area for binding a trigger event in an editing area of the rich text editor;
and in the process of initializing the content of the editing area of the rich text editor, adding a hook element into a code block corresponding to the specified area in the software module.
3. The method of claim 2, wherein the binding a trigger event and an external response event for the hook element comprises:
monitoring whether content initialization is completed in an editing area of the rich text editor;
after the fact that content initialization of an editing area of a rich text editor is monitored, searching the hook element in a software module corresponding to the rich text editor;
binding a trigger event and the external response event to the hook element.
4. The method of claim 1, further comprising setting a scratch variable;
the temporary storage variable is used for storing content data containing the hook element in a software module corresponding to the rich text editor.
5. The method of claim 4, wherein the scratch variable is used for storing content data containing the hook element in the corresponding software module of the rich text editor, and comprises:
after a trigger event and an external response event are bound for the hook element, calling an acquisition content interface in the rich text editor to acquire current content data of an editing area in a software module corresponding to the rich text editor;
and storing the current content data into the temporary storage variable.
6. The method of claim 4 or 5, wherein the scratch variable is used for storing content data containing the hook element in the corresponding software module of the rich text editor, and comprises the following steps:
calling a content change monitoring interface in the rich text editor, and monitoring whether the content data of an editing area in a software module corresponding to the rich text editor changes;
under the condition that the change of the content data of the editing area in the software module corresponding to the rich text editor is monitored, calling an interface for acquiring the content in the rich text editor to acquire the current content data of the editing area in the software module corresponding to the rich text editor;
judging whether the current content data of the rich text editor contains the hook element;
and if the current content data of the rich text editor contains the hook element, updating the current content data into the temporary storage variable, calling a content change monitoring interface in the rich text editor, and monitoring whether the content changes in the using process of the rich text editor.
7. The method of claim 6, further comprising:
if the current content data of the rich text editor does not contain the hook element, obtaining the existing content data in the temporary storage variable, and replacing the current content data in the software module corresponding to the rich text editor with the existing content data;
searching the hook element in a software module corresponding to the rich text editor;
and rebinding the trigger event and the external response event for the hook element.
8. An internal and external interaction device of a rich text editor is characterized by being integrated in electronic equipment, wherein a software module corresponding to the rich text editor is also deployed in the electronic equipment; the internal and external interaction device of the rich text editor comprises:
the adding unit is used for adding hook elements to the software modules corresponding to the rich text editors;
a binding unit, configured to bind a trigger event and an external response event for the hook element; wherein the external response event occurs outside the software module corresponding to the rich text editor;
and the execution unit is used for executing the external response event bound by the hook element if the hook element is triggered by the bound trigger event.
9. A processor, characterized in that the processor is configured to run a program, wherein the program when running performs the rich text editor in-out interaction method of any one of claims 1-7.
10. A storage medium having stored thereon a program which, when executed by a processor, implements the rich text editor in-and-out interaction method as claimed in any one of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811000414.9A CN110874523B (en) | 2018-08-30 | 2018-08-30 | Internal and external interaction method and device for rich text editor, processor and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811000414.9A CN110874523B (en) | 2018-08-30 | 2018-08-30 | Internal and external interaction method and device for rich text editor, processor and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110874523A true CN110874523A (en) | 2020-03-10 |
CN110874523B CN110874523B (en) | 2024-02-13 |
Family
ID=69714419
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811000414.9A Active CN110874523B (en) | 2018-08-30 | 2018-08-30 | Internal and external interaction method and device for rich text editor, processor and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110874523B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101410798A (en) * | 2006-04-27 | 2009-04-15 | 国际商业机器公司 | A method and system for generating application data editors |
US20090259949A1 (en) * | 2008-04-15 | 2009-10-15 | Microsoft Corporation | Cross-browser rich text editing via a hybrid client-side model |
CN103577427A (en) * | 2012-07-25 | 2014-02-12 | 中国移动通信集团公司 | Browser kernel based web page crawling method and device and browser containing device |
CN108089847A (en) * | 2017-12-14 | 2018-05-29 | 易知成都数据服务有限公司 | A kind of Components Development method based on ElementUI and UEditor rich texts |
-
2018
- 2018-08-30 CN CN201811000414.9A patent/CN110874523B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101410798A (en) * | 2006-04-27 | 2009-04-15 | 国际商业机器公司 | A method and system for generating application data editors |
US20090259949A1 (en) * | 2008-04-15 | 2009-10-15 | Microsoft Corporation | Cross-browser rich text editing via a hybrid client-side model |
CN103577427A (en) * | 2012-07-25 | 2014-02-12 | 中国移动通信集团公司 | Browser kernel based web page crawling method and device and browser containing device |
CN108089847A (en) * | 2017-12-14 | 2018-05-29 | 易知成都数据服务有限公司 | A kind of Components Development method based on ElementUI and UEditor rich texts |
Also Published As
Publication number | Publication date |
---|---|
CN110874523B (en) | 2024-02-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110058856B (en) | Page configuration method and device | |
US10699061B2 (en) | Application page quick access | |
CN106933887B (en) | Data visualization method and device | |
KR20160128940A (en) | Method and system of automated generation of user form interface | |
CN108268609B (en) | File path establishing and accessing method and device | |
CN108874379B (en) | Page processing method and device | |
CN106919620B (en) | Single page processing method and device | |
CN113536174A (en) | Interface loading method, device and equipment | |
CN113885935A (en) | Resource packaging method and device, electronic equipment and computer readable storage medium | |
CN109857964B (en) | Thermodynamic diagram drawing method and device for page operation, storage medium and processor | |
CN109977317B (en) | Data query method and device | |
CN106648567B (en) | Data acquisition method and device | |
CN111538667A (en) | Page testing method and device | |
CN112346761B (en) | Front-end resource online method, device, system and storage medium | |
CN110020370B (en) | Method and device for realizing animation in client application and framework of animation script | |
CN111142990A (en) | WeChat applet page display method and device and storage medium | |
CN112667934A (en) | Dynamic simulation diagram display method and device, electronic equipment and computer readable medium | |
CN110955813A (en) | Data crawling method and device | |
CN112560403A (en) | Text processing method and device and electronic equipment | |
CN112579066A (en) | Chart display method and device, storage medium and equipment | |
CN113485746B (en) | Method and device for generating application program interface document | |
CN110874523B (en) | Internal and external interaction method and device for rich text editor, processor and storage medium | |
CN115712794A (en) | Page management method and device, processor and electronic equipment | |
CN110968500A (en) | Test case execution method and device | |
CN114676372A (en) | Data processing method and device for web game, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |