MCPcopy
hub / github.com/zxlie/FeHelper / _getSelectionInfo

Function _getSelectionInfo

apps/json-format/format-lib.js:1091–1128  ·  view source on GitHub ↗
(el)

Source from the content-addressed store, hash-verified

1089 };
1090
1091 let _getSelectionInfo = function (el) {
1092 let selected = (el !== undefined && el !== null) ? el : _getSelectedJsonElement();
1093 if (!selected.length) {
1094 return {
1095 selected: false,
1096 path: '',
1097 type: '',
1098 preview: '',
1099 text: ''
1100 };
1101 }
1102
1103 let path = _getJsonPathForElement(selected, 'javascript');
1104 let text = '';
1105 try {
1106 text = _stringifyJsonNodeValue(selected);
1107 } catch (e) {
1108 try {
1109 text = getJsonText(selected);
1110 } catch (err) {
1111 text = selected.text() || '';
1112 }
1113 }
1114
1115 let preview = _getDirectNodeText(selected) || text;
1116 preview = String(preview || '').replace(/\s+/g, ' ').trim();
1117 if (preview.length > 140) {
1118 preview = preview.slice(0, 137) + '...';
1119 }
1120
1121 return {
1122 selected: true,
1123 path: path,
1124 type: _getJsonNodeType(selected, text),
1125 preview: preview,
1126 text: text
1127 };
1128 };
1129
1130 let _emitSelectionChange = function (el) {
1131 try {

Callers 8

_emitSelectionChangeFunction · 0.85
_emitFormatReadyFunction · 0.85
_selectJsonElementFunction · 0.85
_clearSelectionFunction · 0.85
_copySelectedPathFunction · 0.85
_copySelectedValueFunction · 0.85
format-lib.jsFile · 0.85

Calls 6

_getSelectedJsonElementFunction · 0.85
_getJsonPathForElementFunction · 0.85
_stringifyJsonNodeValueFunction · 0.85
getJsonTextFunction · 0.85
_getDirectNodeTextFunction · 0.85
_getJsonNodeTypeFunction · 0.85

Tested by

no test coverage detected