@tmagic/utils 1.5.23 → 1.6.0-beta.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 +1 -1
- package/dist/tmagic-utils.js +4 -4
- package/dist/tmagic-utils.umd.cjs +4 -3
- package/package.json +2 -2
- package/src/index.ts +5 -5
- package/types/index.d.ts +2 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
2
2
|
|
|
3
|
-
Copyright (C)
|
|
3
|
+
Copyright (C) 2025 Tencent. All rights reserved.
|
|
4
4
|
|
|
5
5
|
TMagicEditor is licensed under the Apache License Version 2.0 except for the third-party components listed below.
|
|
6
6
|
|
package/dist/tmagic-utils.js
CHANGED
|
@@ -294,11 +294,10 @@ const getNodes = (ids, data = []) => {
|
|
|
294
294
|
if (!Array.isArray(data2)) {
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
|
-
for (
|
|
298
|
-
const item = data2[i];
|
|
297
|
+
for (const item of data2) {
|
|
299
298
|
const index = ids2.findIndex((id) => `${id}` === `${item.id}`);
|
|
300
299
|
if (index > -1) {
|
|
301
|
-
ids2.
|
|
300
|
+
ids2.splice(index, 1);
|
|
302
301
|
nodes.push(item);
|
|
303
302
|
}
|
|
304
303
|
if (item.items) {
|
|
@@ -337,6 +336,7 @@ const replaceChildNode = (newNode, data, parentId) => {
|
|
|
337
336
|
};
|
|
338
337
|
const DSL_NODE_KEY_COPY_PREFIX = "__tmagic__";
|
|
339
338
|
const IS_DSL_NODE_KEY = "__tmagic__dslNode";
|
|
339
|
+
const PAGE_FRAGMENT_CONTAINER_ID_KEY = "tmagic-page-fragment-container-id";
|
|
340
340
|
const compiledNode = (compile, node, dataSourceDeps = {}, sourceId) => {
|
|
341
341
|
let keys = [];
|
|
342
342
|
if (!sourceId) {
|
|
@@ -515,4 +515,4 @@ const isValueIncludeDataSource = (value) => {
|
|
|
515
515
|
return false;
|
|
516
516
|
};
|
|
517
517
|
|
|
518
|
-
export { DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, DSL_NODE_KEY_COPY_PREFIX, IS_DSL_NODE_KEY, addClassName, addParamToUrl, asyncLoadCss, asyncLoadJs, calcValueByFontsize, calculatePercentage, compiledCond, compiledNode, convertToNumber, createDiv, dataSourceTemplateRegExp, delQueStr, emptyFn, filterXSS, getDefaultValueFromFields, getDepKeys, getDepNodeIds, getDocument, getElById, getGlobalThis, getHost, getIdFromEl, getKeys, getKeysArray, getNodeInfo, getNodePath, getNodes, getSearchObj, getUrlParam, getValueByKeyPath, guid, injectStyle, isDslNode, isNumber, isObject, isPage, isPageFragment, isPercentage, isPop, isSameDomain, isValueIncludeDataSource, removeClassName, removeClassNameByClassName, replaceChildNode, setDslDomRelateConfig, setIdToEl, setUrlParam, setValueByKeyPath, sleep, toHump, toLine, traverseNode };
|
|
518
|
+
export { DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, DSL_NODE_KEY_COPY_PREFIX, IS_DSL_NODE_KEY, PAGE_FRAGMENT_CONTAINER_ID_KEY, addClassName, addParamToUrl, asyncLoadCss, asyncLoadJs, calcValueByFontsize, calculatePercentage, compiledCond, compiledNode, convertToNumber, createDiv, dataSourceTemplateRegExp, delQueStr, emptyFn, filterXSS, getDefaultValueFromFields, getDepKeys, getDepNodeIds, getDocument, getElById, getGlobalThis, getHost, getIdFromEl, getKeys, getKeysArray, getNodeInfo, getNodePath, getNodes, getSearchObj, getUrlParam, getValueByKeyPath, guid, injectStyle, isDslNode, isNumber, isObject, isPage, isPageFragment, isPercentage, isPop, isSameDomain, isValueIncludeDataSource, removeClassName, removeClassNameByClassName, replaceChildNode, setDslDomRelateConfig, setIdToEl, setUrlParam, setValueByKeyPath, sleep, toHump, toLine, traverseNode };
|
|
@@ -2667,11 +2667,10 @@
|
|
|
2667
2667
|
if (!Array.isArray(data2)) {
|
|
2668
2668
|
return;
|
|
2669
2669
|
}
|
|
2670
|
-
for (
|
|
2671
|
-
const item = data2[i];
|
|
2670
|
+
for (const item of data2) {
|
|
2672
2671
|
const index = ids2.findIndex((id) => `${id}` === `${item.id}`);
|
|
2673
2672
|
if (index > -1) {
|
|
2674
|
-
ids2.
|
|
2673
|
+
ids2.splice(index, 1);
|
|
2675
2674
|
nodes.push(item);
|
|
2676
2675
|
}
|
|
2677
2676
|
if (item.items) {
|
|
@@ -2710,6 +2709,7 @@
|
|
|
2710
2709
|
};
|
|
2711
2710
|
const DSL_NODE_KEY_COPY_PREFIX = "__tmagic__";
|
|
2712
2711
|
const IS_DSL_NODE_KEY = "__tmagic__dslNode";
|
|
2712
|
+
const PAGE_FRAGMENT_CONTAINER_ID_KEY = "tmagic-page-fragment-container-id";
|
|
2713
2713
|
const compiledNode = (compile, node, dataSourceDeps = {}, sourceId) => {
|
|
2714
2714
|
let keys = [];
|
|
2715
2715
|
if (!sourceId) {
|
|
@@ -2892,6 +2892,7 @@
|
|
|
2892
2892
|
exports.DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX = DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX;
|
|
2893
2893
|
exports.DSL_NODE_KEY_COPY_PREFIX = DSL_NODE_KEY_COPY_PREFIX;
|
|
2894
2894
|
exports.IS_DSL_NODE_KEY = IS_DSL_NODE_KEY;
|
|
2895
|
+
exports.PAGE_FRAGMENT_CONTAINER_ID_KEY = PAGE_FRAGMENT_CONTAINER_ID_KEY;
|
|
2895
2896
|
exports.addClassName = addClassName;
|
|
2896
2897
|
exports.addParamToUrl = addParamToUrl;
|
|
2897
2898
|
exports.asyncLoadCss = asyncLoadCss;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.6.0-beta.0",
|
|
3
3
|
"name": "@tmagic/utils",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/tmagic-utils.umd.cjs",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"typescript": "^5.8.3",
|
|
37
|
-
"@tmagic/schema": "1.
|
|
37
|
+
"@tmagic/schema": "1.6.0-beta.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"typescript": {
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
4
4
|
*
|
|
5
|
-
* Copyright (C)
|
|
5
|
+
* Copyright (C) 2025 Tencent. All rights reserved.
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
8
|
* you may not use this file except in compliance with the License.
|
|
@@ -328,12 +328,11 @@ export const getNodes = (ids: Id[], data: MNode[] = []): MNode[] => {
|
|
|
328
328
|
return;
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
for (
|
|
332
|
-
const item = data[i];
|
|
331
|
+
for (const item of data) {
|
|
333
332
|
const index = ids.findIndex((id: Id) => `${id}` === `${item.id}`);
|
|
334
333
|
|
|
335
334
|
if (index > -1) {
|
|
336
|
-
ids.
|
|
335
|
+
ids.splice(index, 1);
|
|
337
336
|
nodes.push(item);
|
|
338
337
|
}
|
|
339
338
|
|
|
@@ -372,7 +371,7 @@ export const getDepNodeIds = (dataSourceDeps: DataSourceDeps = {}) =>
|
|
|
372
371
|
* @param data 需要修改的数据
|
|
373
372
|
* @param parentId 父节点 id
|
|
374
373
|
*/
|
|
375
|
-
export const replaceChildNode = (newNode: MNode, data?: MNode[], parentId?: Id) => {
|
|
374
|
+
export const replaceChildNode = (newNode: MNode, data?: MNode[], parentId?: Id): void => {
|
|
376
375
|
const path = getNodePath(newNode.id, data);
|
|
377
376
|
const node = path.pop();
|
|
378
377
|
let parent = path.pop();
|
|
@@ -390,6 +389,7 @@ export const replaceChildNode = (newNode: MNode, data?: MNode[], parentId?: Id)
|
|
|
390
389
|
|
|
391
390
|
export const DSL_NODE_KEY_COPY_PREFIX = '__tmagic__';
|
|
392
391
|
export const IS_DSL_NODE_KEY = '__tmagic__dslNode';
|
|
392
|
+
export const PAGE_FRAGMENT_CONTAINER_ID_KEY = 'tmagic-page-fragment-container-id';
|
|
393
393
|
|
|
394
394
|
export const compiledNode = (
|
|
395
395
|
compile: (value: any) => any,
|
package/types/index.d.ts
CHANGED
|
@@ -86,6 +86,7 @@ declare const getDepNodeIds: (dataSourceDeps?: DataSourceDeps) => string[];
|
|
|
86
86
|
declare const replaceChildNode: (newNode: MNode$1, data?: MNode$1[], parentId?: Id) => void;
|
|
87
87
|
declare const DSL_NODE_KEY_COPY_PREFIX = "__tmagic__";
|
|
88
88
|
declare const IS_DSL_NODE_KEY = "__tmagic__dslNode";
|
|
89
|
+
declare const PAGE_FRAGMENT_CONTAINER_ID_KEY = "tmagic-page-fragment-container-id";
|
|
89
90
|
declare const compiledNode: (compile: (value: any) => any, node: MNode$1, dataSourceDeps?: DataSourceDeps, sourceId?: Id) => MNode$1;
|
|
90
91
|
declare const compiledCond: (op: string, fieldValue: any, inputValue: any, range?: number[]) => boolean;
|
|
91
92
|
declare const getDefaultValueFromFields: (fields: DataSchema[]) => Record<string, any>;
|
|
@@ -111,5 +112,5 @@ interface NodeItem {
|
|
|
111
112
|
declare const traverseNode: <T extends NodeItem = NodeItem>(node: T, cb: (node: T, parents: T[]) => void, parents?: T[], evalCbAfter?: boolean) => void;
|
|
112
113
|
declare const isValueIncludeDataSource: (value: any) => boolean;
|
|
113
114
|
|
|
114
|
-
export { DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, DSL_NODE_KEY_COPY_PREFIX, IS_DSL_NODE_KEY, addClassName, addParamToUrl, asyncLoadCss, asyncLoadJs, calcValueByFontsize, calculatePercentage, compiledCond, compiledNode, convertToNumber, createDiv, dataSourceTemplateRegExp, delQueStr, emptyFn, filterXSS, getDefaultValueFromFields, getDepKeys, getDepNodeIds, getDocument, getElById, getGlobalThis, getHost, getIdFromEl, getKeys, getKeysArray, getNodeInfo, getNodePath, getNodes, getSearchObj, getUrlParam, getValueByKeyPath, guid, injectStyle, isDslNode, isNumber, isObject, isPage, isPageFragment, isPercentage, isPop, isSameDomain, isValueIncludeDataSource, removeClassName, removeClassNameByClassName, replaceChildNode, setDslDomRelateConfig, setIdToEl, setUrlParam, setValueByKeyPath, sleep, toHump, toLine, traverseNode };
|
|
115
|
+
export { DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, DSL_NODE_KEY_COPY_PREFIX, IS_DSL_NODE_KEY, PAGE_FRAGMENT_CONTAINER_ID_KEY, addClassName, addParamToUrl, asyncLoadCss, asyncLoadJs, calcValueByFontsize, calculatePercentage, compiledCond, compiledNode, convertToNumber, createDiv, dataSourceTemplateRegExp, delQueStr, emptyFn, filterXSS, getDefaultValueFromFields, getDepKeys, getDepNodeIds, getDocument, getElById, getGlobalThis, getHost, getIdFromEl, getKeys, getKeysArray, getNodeInfo, getNodePath, getNodes, getSearchObj, getUrlParam, getValueByKeyPath, guid, injectStyle, isDslNode, isNumber, isObject, isPage, isPageFragment, isPercentage, isPop, isSameDomain, isValueIncludeDataSource, removeClassName, removeClassNameByClassName, replaceChildNode, setDslDomRelateConfig, setIdToEl, setUrlParam, setValueByKeyPath, sleep, toHump, toLine, traverseNode };
|
|
115
116
|
export type { NodeItem };
|