@editora/preview 1.0.1 → 1.0.2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let c=!1;const g=()=>{if(typeof document>"u")return;const r="rte-preview-plugin-styles";if(document.getElementById(r))return;const t=document.createElement("style");t.id=r,t.textContent=`
|
|
2
2
|
/* Preview Editor Dialog Styles */
|
|
3
3
|
.rte-preview-editor-overlay {
|
|
4
4
|
position: fixed !important;
|
|
@@ -217,7 +217,7 @@
|
|
|
217
217
|
font-size: 14px;
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
`,document.head.appendChild(t)},
|
|
220
|
+
`,document.head.appendChild(t)},v=()=>{const r=window.getSelection();if(r&&r.rangeCount>0){let e=r.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const o=e;if(o.getAttribute("contenteditable")==="true")return o}e=e.parentNode}}const t=document.activeElement;if(t){if(t.getAttribute("contenteditable")==="true")return t;const e=t.closest('[contenteditable="true"]');if(e)return e}return document.querySelector('[contenteditable="true"]')},h=()=>{const r=v();if(!r)return"";const t=r.cloneNode(!0);return[".rte-floating-toolbar",".rte-selection-marker",".rte-toolbar",".rte-resize-handle","[data-rte-internal]"].forEach(o=>{t.querySelectorAll(o).forEach(i=>i.remove())}),t.innerHTML},u=r=>{const t=document.createElement("div");return t.innerHTML=r,t.querySelectorAll('script, iframe[src^="javascript:"], object, embed, form[action^="javascript:"]').forEach(i=>i.remove()),t.querySelectorAll("*").forEach(i=>{Array.from(i.attributes).forEach(n=>{n.name.startsWith("on")&&i.removeAttribute(n.name),(n.name==="href"||n.name==="src")&&n.value.startsWith("javascript:")&&i.removeAttribute(n.name)})}),t.innerHTML},w=()=>{if(typeof window>"u"||c)return;c=!0,g();const r=h(),t=u(r),e=document.createElement("div");e.className="rte-preview-editor-overlay",e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e.setAttribute("aria-labelledby","preview-editor-title");const o=document.createElement("div");o.className="rte-preview-editor-modal";const i=document.createElement("div");i.className="rte-preview-editor-header",i.innerHTML=`
|
|
221
221
|
<h2 id="preview-editor-title">Preview Editor</h2>
|
|
222
222
|
<div class="rte-preview-editor-header-actions">
|
|
223
223
|
<button class="rte-preview-editor-close-btn" aria-label="Close preview editor">
|
|
@@ -227,4 +227,4 @@
|
|
|
227
227
|
</svg>
|
|
228
228
|
</button>
|
|
229
229
|
</div>
|
|
230
|
-
`;const n=document.createElement("div");n.className="rte-preview-editor-body";const
|
|
230
|
+
`;const n=document.createElement("div");n.className="rte-preview-editor-body";const a=document.createElement("div");a.className="rte-preview-editor-content";const l=document.createElement("div");l.className="rte-preview-editor-light-editor",l.innerHTML=t,a.appendChild(l),n.appendChild(a),o.appendChild(i),o.appendChild(n),e.appendChild(o);const p=()=>{e.parentNode&&e.parentNode.removeChild(e),c=!1,document.removeEventListener("keydown",s)},s=d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),p())},m=i.querySelector(".rte-preview-editor-close-btn");m&&m.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),p()}),e.addEventListener("click",d=>{d.target===e&&p()}),document.addEventListener("keydown",s),document.body.appendChild(e)},f=()=>({name:"preview",toolbar:[{label:"Preview",command:"togglePreview",icon:'<svg fill="#000000" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 92 92" enable-background="new 0 0 92 92" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path id="XMLID_1239_" d="M91.3,43.8C90.6,42.8,74.4,19,46,19C17.6,19,1.4,42.8,0.7,43.8c-0.9,1.3-0.9,3.1,0,4.5 C1.4,49.2,17.6,73,46,73c28.4,0,44.6-23.8,45.3-24.8C92.2,46.9,92.2,45.1,91.3,43.8z M46,65C26.7,65,13.5,51.4,9,46 c4.5-5.5,17.6-19,37-19c19.3,0,32.5,13.6,37,19C78.4,51.5,65.3,65,46,65z M48.3,29.6c-4.4-0.6-8.7,0.5-12.3,3.2c0,0,0,0,0,0 c-7.3,5.5-8.8,15.9-3.3,23.2c2.7,3.6,6.5,5.8,10.9,6.5c0.8,0.1,1.6,0.2,2.3,0.2c3.6,0,7-1.2,9.9-3.3c7.3-5.5,8.8-15.9,3.3-23.2 C56.6,32.5,52.7,30.2,48.3,29.6z M52.3,54.5c-2.2,1.7-5,2.4-7.8,2c-2.8-0.4-5.3-1.9-7-4.1C34.1,47.7,35,41,39.7,37.5 c2.2-1.7,5-2.4,7.8-2c2.8,0.4,5.3,1.9,7,4.1C57.9,44.3,57,51,52.3,54.5z M51.9,40c0.8,0.7,1.2,1.8,1.2,2.8c0,1-0.4,2.1-1.2,2.8 c-0.7,0.7-1.8,1.2-2.8,1.2c-1.1,0-2.1-0.4-2.8-1.2c-0.8-0.8-1.2-1.8-1.2-2.8c0-1.1,0.4-2.1,1.2-2.8c0.7-0.8,1.8-1.2,2.8-1.2 C50.2,38.9,51.2,39.3,51.9,40z"></path> </g></svg>'}],commands:{togglePreview:()=>(w(),!0)},keymap:{}});exports.PreviewPlugin=f;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editora/preview",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Preview plugin for Rich Text Editor",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Ajay Kumar <ajaykr089@gmail.com>"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"clean": "rm -rf dist"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@editora/core": "^1.0.
|
|
20
|
+
"@editora/core": "^1.0.6"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/react": "^18.0.0",
|
|
@@ -32,5 +32,13 @@
|
|
|
32
32
|
"html-editor"
|
|
33
33
|
],
|
|
34
34
|
"author": "",
|
|
35
|
-
"license": "MIT"
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"import": "./dist/index.esm.js",
|
|
40
|
+
"require": "./dist/index.cjs.js",
|
|
41
|
+
"default": "./dist/index.esm.js"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
36
44
|
}
|
|
File without changes
|