@jxsuite/studio 0.14.0 → 0.15.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/dist/studio.js +40 -9
- package/dist/studio.js.map +5 -5
- package/package.json +1 -1
- package/src/editor/context-menu.js +47 -10
- package/src/tabs/transact.js +19 -1
- package/src/workspace/workspace.js +4 -0
package/dist/studio.js
CHANGED
|
@@ -1543,6 +1543,8 @@ var init_workspace = __esm(() => {
|
|
|
1543
1543
|
projectRoot: null,
|
|
1544
1544
|
projectConfig: null,
|
|
1545
1545
|
componentRegistry: [],
|
|
1546
|
+
clipboard: null,
|
|
1547
|
+
styleClipboard: null,
|
|
1546
1548
|
fileTree: {
|
|
1547
1549
|
dirs: new Map,
|
|
1548
1550
|
expanded: new Set,
|
|
@@ -42319,8 +42321,9 @@ init_reactivity();
|
|
|
42319
42321
|
var HISTORY_LIMIT = 100;
|
|
42320
42322
|
function transactDoc(tab, mutationFn, { skipHistory = false } = {}) {
|
|
42321
42323
|
mutationFn(tab);
|
|
42324
|
+
const raw = toRaw(tab.doc.document);
|
|
42325
|
+
tab.doc.document = { ...raw };
|
|
42322
42326
|
if (!skipHistory) {
|
|
42323
|
-
const raw = toRaw(tab.doc.document);
|
|
42324
42327
|
const snapshot = {
|
|
42325
42328
|
document: structuredClone(raw),
|
|
42326
42329
|
selection: tab.session.selection ? [...tab.session.selection] : null
|
|
@@ -42499,6 +42502,14 @@ function mutateUpdateMediaNestedStyle(tab, path, mediaName, selector, prop, valu
|
|
|
42499
42502
|
if (Object.keys(node.style).length === 0)
|
|
42500
42503
|
delete node.style;
|
|
42501
42504
|
}
|
|
42505
|
+
function mutateReplaceStyle(tab, path, style) {
|
|
42506
|
+
const node = getNodeAtPath(tab.doc.document, path);
|
|
42507
|
+
if (style && Object.keys(style).length > 0) {
|
|
42508
|
+
node.style = style;
|
|
42509
|
+
} else {
|
|
42510
|
+
delete node.style;
|
|
42511
|
+
}
|
|
42512
|
+
}
|
|
42502
42513
|
function mutateAddDef(tab, name, def2) {
|
|
42503
42514
|
const doc = tab.doc.document;
|
|
42504
42515
|
if (!doc.state)
|
|
@@ -178784,7 +178795,6 @@ init_workspace();
|
|
|
178784
178795
|
init_store();
|
|
178785
178796
|
init_workspace();
|
|
178786
178797
|
init_components();
|
|
178787
|
-
var clipboard = null;
|
|
178788
178798
|
function copyNode() {
|
|
178789
178799
|
const tab = activeTab.value;
|
|
178790
178800
|
if (!tab?.session.selection)
|
|
@@ -178792,7 +178802,7 @@ function copyNode() {
|
|
|
178792
178802
|
const node = getNodeAtPath(tab.doc.document, tab.session.selection);
|
|
178793
178803
|
if (!node)
|
|
178794
178804
|
return;
|
|
178795
|
-
clipboard = structuredClone(node);
|
|
178805
|
+
workspace.clipboard = structuredClone(node);
|
|
178796
178806
|
statusMessage("Copied");
|
|
178797
178807
|
}
|
|
178798
178808
|
function cutNode() {
|
|
@@ -178803,17 +178813,17 @@ function cutNode() {
|
|
|
178803
178813
|
const node = getNodeAtPath(tab.doc.document, sel);
|
|
178804
178814
|
if (!node)
|
|
178805
178815
|
return;
|
|
178806
|
-
clipboard = structuredClone(node);
|
|
178816
|
+
workspace.clipboard = structuredClone(node);
|
|
178807
178817
|
transactDoc(tab, (t) => mutateRemoveNode(t, sel));
|
|
178808
178818
|
statusMessage("Cut");
|
|
178809
178819
|
}
|
|
178810
178820
|
function pasteNode() {
|
|
178811
|
-
if (!clipboard)
|
|
178821
|
+
if (!workspace.clipboard)
|
|
178812
178822
|
return;
|
|
178813
178823
|
const tab = activeTab.value;
|
|
178814
178824
|
if (!tab)
|
|
178815
178825
|
return;
|
|
178816
|
-
const clip = clipboard;
|
|
178826
|
+
const clip = workspace.clipboard;
|
|
178817
178827
|
const pPath = tab.session.selection || [];
|
|
178818
178828
|
const parent = getNodeAtPath(tab.doc.document, pPath);
|
|
178819
178829
|
if (!parent)
|
|
@@ -178854,6 +178864,27 @@ function showContextMenu(e, path, opts = {}) {
|
|
|
178854
178864
|
label: "Duplicate",
|
|
178855
178865
|
action: () => transactDoc(activeTab.value, (t) => mutateDuplicateNode(t, path))
|
|
178856
178866
|
});
|
|
178867
|
+
if (node.style) {
|
|
178868
|
+
items.push({
|
|
178869
|
+
label: "Copy styles",
|
|
178870
|
+
action: () => {
|
|
178871
|
+
workspace.styleClipboard = JSON.parse(JSON.stringify(node.style));
|
|
178872
|
+
statusMessage("Styles copied");
|
|
178873
|
+
}
|
|
178874
|
+
});
|
|
178875
|
+
}
|
|
178876
|
+
if (workspace.styleClipboard) {
|
|
178877
|
+
items.push({
|
|
178878
|
+
label: "Paste styles",
|
|
178879
|
+
action: () => {
|
|
178880
|
+
if (!workspace.styleClipboard)
|
|
178881
|
+
return;
|
|
178882
|
+
const style = JSON.parse(JSON.stringify(workspace.styleClipboard));
|
|
178883
|
+
transactDoc(activeTab.value, (t) => mutateReplaceStyle(t, path, style));
|
|
178884
|
+
statusMessage("Styles pasted");
|
|
178885
|
+
}
|
|
178886
|
+
});
|
|
178887
|
+
}
|
|
178857
178888
|
items.push({ label: "—" });
|
|
178858
178889
|
items.push({
|
|
178859
178890
|
label: "Insert before",
|
|
@@ -178897,8 +178928,8 @@ function showContextMenu(e, path, opts = {}) {
|
|
|
178897
178928
|
danger: true
|
|
178898
178929
|
});
|
|
178899
178930
|
}
|
|
178900
|
-
if (clipboard) {
|
|
178901
|
-
const clip = clipboard;
|
|
178931
|
+
if (workspace.clipboard) {
|
|
178932
|
+
const clip = workspace.clipboard;
|
|
178902
178933
|
items.push({ label: "—" });
|
|
178903
178934
|
items.push({
|
|
178904
178935
|
label: "Paste inside",
|
|
@@ -217220,5 +217251,5 @@ effect(() => {
|
|
|
217220
217251
|
scheduleAutosave();
|
|
217221
217252
|
});
|
|
217222
217253
|
|
|
217223
|
-
//# debugId=
|
|
217254
|
+
//# debugId=CE5832A90C0FE77064756E2164756E21
|
|
217224
217255
|
//# sourceMappingURL=studio.js.map
|