mechanica 1.0.7 → 1.0.9-a
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/editor.js +42 -24
- package/dist/editor.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/plugin.js +11 -2
- package/dist/plugin.js.map +1 -1
- package/dist/{schemaAliases-jUlXWmB3.js → schemaAliases-CX3SQvLF.js} +4 -1
- package/dist/{schemaAliases-jUlXWmB3.js.map → schemaAliases-CX3SQvLF.js.map} +1 -1
- package/package.json +2 -3
package/dist/editor.js
CHANGED
|
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { defineComponent, ref, watch, createElementBlock, openBlock, normalizeStyle, createElementVNode, reactive, computed, shallowRef, onMounted, onBeforeUnmount, triggerRef, inject, normalizeClass, createCommentVNode, renderSlot, createVNode, createTextVNode, toDisplayString, Transition, withCtx, getCurrentScope, onScopeDispose, toRef as toRef$1, readonly, customRef, toValue as toValue$1, getCurrentInstance, nextTick, unref, createBlock, createSlots, withDirectives, vModelText, vModelDynamic, Fragment, renderList, h, TransitionGroup, useSlots, Teleport, mergeProps, withModifiers, mergeModels, useModel, createStaticVNode, resolveDynamicComponent, isRef, vShow, shallowReactive, vModelCheckbox, isProxy, toRaw, resolveComponent, normalizeProps, guardReactiveProps, provide, createApp } from "vue";
|
|
5
|
-
import {
|
|
5
|
+
import { p as passDefaultValue, d as defaultImageSrc, g as getDefaultValue, r as registerAliases } from "./schemaAliases-CX3SQvLF.js";
|
|
6
6
|
import { blocksList as blocksList$1, addUpdateListener } from "virtual:builder-blocks";
|
|
7
7
|
import { unfoldSchema } from "compact-json-schema";
|
|
8
8
|
const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
@@ -1365,11 +1365,7 @@ const processBlock = (contentBlock, schema) => {
|
|
|
1365
1365
|
}
|
|
1366
1366
|
contentBlock.data["data-block-id"] = contentBlock.id;
|
|
1367
1367
|
if (schema) {
|
|
1368
|
-
|
|
1369
|
-
if (key && isRequired && !schema2.nullable && (value === null || value === void 0)) {
|
|
1370
|
-
parent[key] = getDefaultValue(schema2);
|
|
1371
|
-
}
|
|
1372
|
-
});
|
|
1368
|
+
passDefaultValue(contentBlock.data, schema.props);
|
|
1373
1369
|
if (schema.slots) {
|
|
1374
1370
|
if (Object.keys(schema.slots).join() === "default") {
|
|
1375
1371
|
contentBlock.children = [];
|
|
@@ -1433,7 +1429,7 @@ const walkTree = (blocks, callback) => {
|
|
|
1433
1429
|
}
|
|
1434
1430
|
};
|
|
1435
1431
|
const walkSchema = (obj, schema, callback) => {
|
|
1436
|
-
if (schema.type === "object") {
|
|
1432
|
+
if (schema.type === "object" && schema.properties) {
|
|
1437
1433
|
if (!obj) {
|
|
1438
1434
|
return;
|
|
1439
1435
|
}
|
|
@@ -3235,6 +3231,17 @@ class TextEditorStore {
|
|
|
3235
3231
|
get currentBlock() {
|
|
3236
3232
|
return this._currentBlock.value;
|
|
3237
3233
|
}
|
|
3234
|
+
*getCurrentBlocks() {
|
|
3235
|
+
const blockAnchorIndex = this.blocks.findIndex((item) => item.id === this.selection.anchor.blockId);
|
|
3236
|
+
const focusAnchorIndex = this.blocks.findIndex((item) => item.id === this.selection.focus.blockId);
|
|
3237
|
+
if (blockAnchorIndex === -1 || focusAnchorIndex === -1)
|
|
3238
|
+
return;
|
|
3239
|
+
const start = Math.min(blockAnchorIndex, focusAnchorIndex);
|
|
3240
|
+
const end = Math.max(blockAnchorIndex, focusAnchorIndex);
|
|
3241
|
+
for (let i = start; i <= end; i++) {
|
|
3242
|
+
yield this.blocks[i];
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3238
3245
|
get selectedText() {
|
|
3239
3246
|
return this._selectedText.value;
|
|
3240
3247
|
}
|
|
@@ -3852,13 +3859,11 @@ const _sfc_main$1$1 = /* @__PURE__ */ defineComponent({
|
|
|
3852
3859
|
return;
|
|
3853
3860
|
} else {
|
|
3854
3861
|
for (let i = store.blocks.length; i < newValue.length; i++) {
|
|
3855
|
-
store.blocks.push({ id: uid(), text: ""
|
|
3862
|
+
store.blocks.push({ id: uid(), text: "" });
|
|
3856
3863
|
}
|
|
3857
3864
|
store.blocks.length = newValue.length;
|
|
3858
3865
|
for (let i = 0; i < newValue.length; i++) {
|
|
3859
|
-
store.blocks[i]
|
|
3860
|
-
store.blocks[i].type = newValue[i].type;
|
|
3861
|
-
store.blocks[i].styles = newValue[i].styles;
|
|
3866
|
+
store.blocks[i] = { ...newValue[i], id: uid() };
|
|
3862
3867
|
}
|
|
3863
3868
|
}
|
|
3864
3869
|
}, { immediate: true });
|
|
@@ -3879,6 +3884,7 @@ const _sfc_main$1$1 = /* @__PURE__ */ defineComponent({
|
|
|
3879
3884
|
emit("update:styles", styles);
|
|
3880
3885
|
emit("update:modelValue", modelValue);
|
|
3881
3886
|
} else {
|
|
3887
|
+
modelValue = store.blocks;
|
|
3882
3888
|
emit("update:modelValue", store.blocks);
|
|
3883
3889
|
}
|
|
3884
3890
|
}, { deep: true });
|
|
@@ -4005,6 +4011,7 @@ const _sfc_main$1$1 = /* @__PURE__ */ defineComponent({
|
|
|
4005
4011
|
isCollapsed: store._isCollapsed,
|
|
4006
4012
|
selection: store.selection,
|
|
4007
4013
|
isFocused: store.isFocused,
|
|
4014
|
+
getCurrentBlocks: store.getCurrentBlocks.bind(store),
|
|
4008
4015
|
toggleStyle: store.toggleStyle.bind(store),
|
|
4009
4016
|
applyStyle: store.applyStyle.bind(store),
|
|
4010
4017
|
removeStyle: store.removeStyle.bind(store),
|
|
@@ -4355,21 +4362,32 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
4355
4362
|
const textEditorRef = shallowRef();
|
|
4356
4363
|
const blockType = computed({
|
|
4357
4364
|
get() {
|
|
4358
|
-
|
|
4359
|
-
|
|
4365
|
+
if (!textEditorRef.value) return "default";
|
|
4366
|
+
let type = null;
|
|
4367
|
+
for (let block of textEditorRef.value.getCurrentBlocks()) {
|
|
4368
|
+
if (type === null) {
|
|
4369
|
+
type = block.type;
|
|
4370
|
+
} else if (type !== block.type) {
|
|
4371
|
+
type = "mixed";
|
|
4372
|
+
break;
|
|
4373
|
+
}
|
|
4374
|
+
}
|
|
4375
|
+
return type;
|
|
4360
4376
|
},
|
|
4361
4377
|
set(type) {
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4378
|
+
if (!model.value || !textEditorRef.value) return;
|
|
4379
|
+
console.log(textEditorRef.value);
|
|
4380
|
+
for (let block of textEditorRef.value.getCurrentBlocks()) {
|
|
4381
|
+
if (type === "default") {
|
|
4382
|
+
delete block.type;
|
|
4383
|
+
} else {
|
|
4384
|
+
block.type = type ?? void 0;
|
|
4385
|
+
}
|
|
4386
|
+
if (type === "code") {
|
|
4387
|
+
block.editable = false;
|
|
4388
|
+
} else {
|
|
4389
|
+
delete block.editable;
|
|
4390
|
+
}
|
|
4373
4391
|
}
|
|
4374
4392
|
}
|
|
4375
4393
|
});
|