@liferay-editor-custom-fields/framework 7.4.7 → 74.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +6 -24
- package/build/static/index.js +1 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lawrence Behar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,37 +1,19 @@
|
|
|
1
1
|
# Liferay Custom Fields Framework
|
|
2
2
|
|
|
3
|
-
The engine behind Liferay Editor Custom Fields.
|
|
3
|
+
The engine behind Liferay Editor Custom Fields.
|
|
4
|
+
|
|
5
|
+
You only need this if you are creating a new Liferay Editor Custom Fields package, otherwise it is provided as a dependency on existing ones.
|
|
4
6
|
|
|
5
7
|
## Before You Start
|
|
6
8
|
|
|
7
9
|
Any client extension using this framework should not run on a production or pre-prod staging environment. It is only intended for the fragment and web content editors. Any JS that will end up on the page should be elsewhere, either in a separate client extension or in the fragment/web content template.
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
If you are creating/appending DOM elements, make sure that you check for an existing element to avoid infinite MutationObserver loops.
|
|
10
12
|
|
|
11
13
|
## Getting Started
|
|
12
14
|
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
- For example `yarn add @liferay-editor-custom-fields/framework@~7.4.0` for Liferay 7.4.
|
|
16
|
-
- In the index.ts of your app:
|
|
17
|
-
- Declare the Liferay global object
|
|
18
|
-
- Import the default exported function from @liferay-editor-custom-fields/framework. You can call it something short like initFramework();
|
|
19
|
-
- Create a default exported function of your own and call that function
|
|
20
|
-
- Write a Liferay.on event subscriber for each event that your app will be using. See the Events section of this document for a list of events.
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
declare const Liferay;
|
|
24
|
-
|
|
25
|
-
import initFramework from '@liferay-editor-custom-fields/framework';
|
|
26
|
-
|
|
27
|
-
const initImageTools: () => void = () => {
|
|
28
|
-
initFramework();
|
|
29
|
-
Liferay.on('EditorCustomFields_WebContentFields_OnLoad', ()=>{});
|
|
30
|
-
Liferay.on('EditorCustomFields_FragmenConfig_OnLoad', ()=>{});
|
|
31
|
-
Liferay.on('EditorCustomFields_Image_OnChange', ()=>{});
|
|
32
|
-
}
|
|
33
|
-
export default initImageTools;
|
|
34
|
-
```
|
|
15
|
+
- Download the boilerplate starter at https://github.com/lbeharxtivia/liferay-editor-custom-fields-sample
|
|
16
|
+
- See below for available events and helper functions
|
|
35
17
|
|
|
36
18
|
## Events
|
|
37
19
|
|
package/build/static/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{Cu:()=>r,cp:()=>d,s9:()=>n,qC:()=>l,Un:()=>i,S6:()=>u});const r=(e,t)=>{let r=null;return(...o)=>{window.clearTimeout(r),r=window.setTimeout(()=>{e(...o)},t)}},o=()=>{Liferay.fire("EditorCustomFields_Image_OnChange")},i=()=>{const e=document?.querySelector("#portlet_com_liferay_journal_web_portlet_JournalPortlet, .page-editor__topper.active"),t=e?.querySelector(".page-editor__topper.active img.page-editor__editable, .image-picker-preview>img");return t},n=()=>document.querySelector('input[name^="_com_liferay_journal_web_portlet_JournalPortlet_ddm$$Image"]'),s=e=>{Liferay.editorCustomFields.imageObserver&&Liferay.editorCustomFields.imageObserver.disconnect?.();const t="fragment"===e?i():n();if(e&&t&&!Liferay.editorCustomFields.imageObserver){const e=r(()=>o(),500);Liferay.editorCustomFields.imageObserver=new MutationObserver(e);const i={attributes:!0,childList:!1,subtree:!1};Liferay.editorCustomFields.imageObserver.observe(t,i)}o()},a=()=>{const e=document.querySelector(".page-editor__item-configuration-sidebar");if(e){Liferay.editorCustomFields.fragmentObserver&&Liferay.editorCustomFields.fragmentObserver.disconnect?.();const t=r(()=>{s("fragment"),Liferay.fire("EditorCustomFields_FragmenConfig_OnLoad")},500);Liferay.editorCustomFields.fragmentObserver=new MutationObserver(t);const o={attributes:!1,childList:!0,subtree:!1};Liferay.editorCustomFields.fragmentObserver.observe(e,o)}},l=e=>{
|
|
1
|
+
var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{Cu:()=>r,cp:()=>d,s9:()=>n,qC:()=>l,Un:()=>i,S6:()=>u});const r=(e,t)=>{let r=null;return(...o)=>{window.clearTimeout(r),r=window.setTimeout(()=>{e(...o)},t)}},o=()=>{Liferay.fire("EditorCustomFields_Image_OnChange")},i=()=>{const e=document?.querySelector("#portlet_com_liferay_journal_web_portlet_JournalPortlet, .page-editor__topper.active"),t=e?.querySelector(".page-editor__topper.active img.page-editor__editable, .image-picker-preview>img");return t},n=()=>document.querySelector('input[name^="_com_liferay_journal_web_portlet_JournalPortlet_ddm$$Image"]'),s=e=>{Liferay.editorCustomFields.imageObserver&&Liferay.editorCustomFields.imageObserver.disconnect?.();const t="fragment"===e?i():n();if(e&&t&&!Liferay.editorCustomFields.imageObserver){const e=r(()=>o(),500);Liferay.editorCustomFields.imageObserver=new MutationObserver(e);const i={attributes:!0,childList:!1,subtree:!1};Liferay.editorCustomFields.imageObserver.observe(t,i)}o()},a=()=>{const e=document.querySelector(".page-editor__item-configuration-sidebar");if(e){Liferay.editorCustomFields.fragmentObserver&&Liferay.editorCustomFields.fragmentObserver.disconnect?.();const t=r(()=>{s("fragment"),Liferay.fire("EditorCustomFields_FragmenConfig_OnLoad")},500);Liferay.editorCustomFields.fragmentObserver=new MutationObserver(t);const o={attributes:!1,childList:!0,subtree:!1};Liferay.editorCustomFields.fragmentObserver.observe(e,o)}},l=e=>{let t=null;const r=document.querySelector("#portlet_com_liferay_journal_web_portlet_JournalPortlet, .page-editor__item-configuration-sidebar");if(r){const o=document.evaluate(`//label[text()='${e}']`,r,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null)?.singleNodeValue;t=o?.closest(".form-group, .field-wrapper")?.querySelector("input")||o?.nextElementSibling?.querySelector("input")||o?.nextSibling}return t},u=(e,t)=>{e.focus(),Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),document.body.focus(),e.dispatchEvent(new Event("blur",{bubbles:!0}))},d=()=>{const e=()=>{(()=>{const e=document.querySelector("#_com_liferay_journal_web_portlet_JournalPortlet_fieldsContent");if(e){Liferay.editorCustomFields.webContentObserver&&Liferay.editorCustomFields.webContentObserver.disconnect?.();const t=r(()=>{s("content"),Liferay.fire("EditorCustomFields_WebContentFields_OnLoad")},500);Liferay.editorCustomFields.webContentObserver=new MutationObserver(t);const o={attributes:!1,childList:!0,subtree:!0};Liferay.editorCustomFields.webContentObserver.observe(e,o)}})(),setTimeout(a,500)};Liferay&&!Liferay?.editorCustomFields&&(Liferay.editorCustomFields={},Liferay.on("allPortletsReady",()=>{e()}),Liferay.on("endNavigate",()=>{e()}))};var c=t.Cu,m=t.cp,b=t.s9,f=t.qC,_=t.Un,p=t.S6;export{c as debounce,m as default,b as getContentImageInput,f as getFieldByLabel,_ as getPreviewImage,p as setReactDomInputValue};
|
package/package.json
CHANGED