@seyamali/aurelia-editor 0.1.1 → 0.1.3
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/dist/aurelia-editor.js +1 -1
- package/dist/aurelia-editor.umd.cjs +184 -151
- package/dist/code-block-popover-ui-u3iuYqYp.js +79 -0
- package/dist/core/engine.d.ts +5 -0
- package/dist/{horizontal-rule-plugin-DdpCd1us.js → horizontal-rule-plugin-Ct8iq55t.js} +1 -1
- package/dist/{index-C9G087KG.js → index-BrE44rnx.js} +8427 -8199
- package/dist/plugins/advanced/raw-html-node.d.ts +20 -0
- package/dist/state-logic-DmJ5y08x.js +103 -0
- package/dist/table-popover-ui-BoxmjrtM.js +161 -0
- package/package.json +1 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { $getSelection as s, $isRangeSelection as r, $getNodeByKey as g } from "lexical";
|
|
2
|
+
import { a as p, S as u, b as h } from "./index-BrE44rnx.js";
|
|
3
|
+
function k(e) {
|
|
4
|
+
const t = w();
|
|
5
|
+
document.body.appendChild(t), e.registerUpdateListener(({ editorState: i }) => {
|
|
6
|
+
i.read(() => {
|
|
7
|
+
const c = s();
|
|
8
|
+
if (!r(c)) {
|
|
9
|
+
a(t);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const o = c.anchor.getNode().getParent();
|
|
13
|
+
if (p(o)) {
|
|
14
|
+
const n = o.getLanguage();
|
|
15
|
+
b(t, o.getKey(), n, e);
|
|
16
|
+
} else
|
|
17
|
+
a(t);
|
|
18
|
+
});
|
|
19
|
+
}), document.addEventListener("click", (i) => {
|
|
20
|
+
const c = i.target;
|
|
21
|
+
!t.contains(c) && !c.closest(".code-block-wrapper") && a(t);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function w() {
|
|
25
|
+
const e = document.createElement("div");
|
|
26
|
+
return e.id = "code-block-popover", e.className = "code-block-popover hidden", e.innerHTML = `
|
|
27
|
+
<div class="code-block-popover-content">
|
|
28
|
+
<label class="code-block-label">
|
|
29
|
+
<span>Language:</span>
|
|
30
|
+
<select id="code-language-select" class="code-language-select">
|
|
31
|
+
${u.map(
|
|
32
|
+
(t) => `<option value="${t.value}">${t.label}</option>`
|
|
33
|
+
).join("")}
|
|
34
|
+
</select>
|
|
35
|
+
</label>
|
|
36
|
+
<button id="code-block-delete-btn" class="code-block-delete-btn" title="Delete Code Block">
|
|
37
|
+
🗑️ Delete
|
|
38
|
+
</button>
|
|
39
|
+
</div>
|
|
40
|
+
`, e;
|
|
41
|
+
}
|
|
42
|
+
function b(e, t, i, c) {
|
|
43
|
+
e.classList.remove("hidden");
|
|
44
|
+
const l = e.querySelector("#code-language-select");
|
|
45
|
+
if (l) {
|
|
46
|
+
const n = l.cloneNode(!0);
|
|
47
|
+
l.parentNode?.replaceChild(n, l), n.value = i || "plaintext", n.addEventListener("change", () => {
|
|
48
|
+
const d = n.value;
|
|
49
|
+
c.dispatchCommand(h, {
|
|
50
|
+
nodeKey: t,
|
|
51
|
+
language: d
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const o = e.querySelector("#code-block-delete-btn");
|
|
56
|
+
if (o) {
|
|
57
|
+
const n = o.cloneNode(!0);
|
|
58
|
+
o.parentNode?.replaceChild(n, o), n.addEventListener("click", () => {
|
|
59
|
+
c.update(() => {
|
|
60
|
+
const d = g(t);
|
|
61
|
+
d && d.remove();
|
|
62
|
+
}), a(e);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
f(e, t, c);
|
|
66
|
+
}
|
|
67
|
+
function a(e) {
|
|
68
|
+
e.classList.add("hidden");
|
|
69
|
+
}
|
|
70
|
+
function f(e, t, i) {
|
|
71
|
+
const c = i.getElementByKey(t);
|
|
72
|
+
if (!c) return;
|
|
73
|
+
const l = c.getBoundingClientRect(), o = e.getBoundingClientRect();
|
|
74
|
+
let n = l.bottom + window.scrollY + 8, d = l.left + window.scrollX;
|
|
75
|
+
d + o.width > window.innerWidth && (d = window.innerWidth - o.width - 20), n + o.height > window.innerHeight + window.scrollY && (n = l.top + window.scrollY - o.height - 8), e.style.top = `${n}px`, e.style.left = `${d}px`;
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
k as setupCodeBlockPopover
|
|
79
|
+
};
|
package/dist/core/engine.d.ts
CHANGED
|
@@ -3,6 +3,11 @@ import { EditorPlugin } from './registry';
|
|
|
3
3
|
export declare class AureliaEditor {
|
|
4
4
|
private editor;
|
|
5
5
|
private registry;
|
|
6
|
+
/**
|
|
7
|
+
* Static factory method to create a full-featured editor with toolbar and UI.
|
|
8
|
+
* This is the recommended way to initialize the editor in frameworks like Angular/React.
|
|
9
|
+
*/
|
|
10
|
+
static create(container: HTMLElement): Promise<AureliaEditor>;
|
|
6
11
|
constructor(element: HTMLDivElement);
|
|
7
12
|
use(plugin: EditorPlugin): void;
|
|
8
13
|
execute(command: any, payload?: any): void;
|