paas-component-library 1.1.2 → 1.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "paas-component-library",
3
3
  "private": false,
4
- "version": "1.1.2",
4
+ "version": "1.1.3",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -434,7 +434,7 @@ export default {
434
434
  }
435
435
 
436
436
  // 创建完整的路径值和标签
437
- const fullValue = this.SAVE_SYMBOL + this.currentPathValues.join('.');
437
+ const fullValue = '${' + this.currentPathValues.join('.') + '}';
438
438
  const fullLabel = this.currentPathLabels.join('/');
439
439
 
440
440
  // 在当前位置插入标签(只在后方添加空格)
@@ -487,8 +487,8 @@ export default {
487
487
  const spaceAfter = document.createTextNode(' ');
488
488
  mentionEl.parentNode?.insertBefore(spaceAfter, mentionEl.nextSibling);
489
489
 
490
- // 在标签后插入零宽字符作为光标位置
491
- const cursorMarker = document.createTextNode('\u200B');
490
+ // 在标签后插入空格作为光标位置
491
+ const cursorMarker = document.createTextNode(' ');
492
492
  mentionEl.parentNode?.insertBefore(cursorMarker, spaceAfter.nextSibling);
493
493
 
494
494
  // 设置光标位置
@@ -505,8 +505,8 @@ export default {
505
505
  // 如果出现索引错误,使用替代方案
506
506
  console.error("Error inserting mention tag:", e);
507
507
 
508
- // 创建零宽字符用于光标定位
509
- const cursorMarker = document.createTextNode('\u200B');
508
+ // 创建空格用于光标定位
509
+ const cursorMarker = document.createTextNode(' ');
510
510
 
511
511
  // 直接在光标位置插入整个HTML片段
512
512
  const fragment = document.createDocumentFragment();
@@ -516,7 +516,7 @@ export default {
516
516
  range.deleteContents();
517
517
  range.insertNode(fragment);
518
518
 
519
- // 设置光标到零宽字符位置
519
+ // 设置光标到空格位置
520
520
  const selection = window.getSelection();
521
521
  if (selection) {
522
522
  const cursorRange = document.createRange();
@@ -574,7 +574,7 @@ export default {
574
574
  const text = textNode.textContent || '';
575
575
  if (startOffset <= text.length) {
576
576
  const prevChar = text[startOffset - 1];
577
- if (prevChar === '\u200B') { // 零宽字符,通常在标签后
577
+ if (prevChar === ' ') { // 空格字符,光标位置标记
578
578
  // 检查前一个节点是否是标签
579
579
  const prevNode = textNode.previousSibling;
580
580
  if (prevNode && prevNode.classList && prevNode.classList.contains('mention-tag')) {
@@ -798,7 +798,7 @@ export default {
798
798
  }
799
799
  } else if (target.classList.contains('mention-tag')) {
800
800
  // 如果点击标签本身,将光标移到标签后
801
- const cursorMarker = document.createTextNode('\u200B');
801
+ const cursorMarker = document.createTextNode(' ');
802
802
  target.parentNode?.insertBefore(cursorMarker, target.nextSibling);
803
803
 
804
804
  const newRange = document.createRange();
@@ -825,11 +825,8 @@ export default {
825
825
  let remainingText = value;
826
826
  let lastIndex = 0;
827
827
 
828
- // 匹配 自定义符号后跟着标识符格式
829
- // 表达式以 $ 开头,以空格或字符串结尾
830
- // 支持格式:$aaa, $aaa.bbb, $xxx-bbb, $aaa_bb, $user_name.first-name 等
831
- // 支持任意非空白字符(包括字母、数字、符号、中文、-、_ 等)
832
- const mentionRegex = new RegExp(`\\${this.SAVE_SYMBOL}[^\\s]+(?=\\s|$)`, 'g');
828
+ // 匹配 ${xxx.xxx.xxx} 格式
829
+ const mentionRegex = /\$\{[^\}]+\}/g;
833
830
  let match;
834
831
 
835
832
  while ((match = mentionRegex.exec(remainingText)) !== null) {
@@ -841,7 +838,7 @@ export default {
841
838
 
842
839
  // 创建标签
843
840
  const fullMatch = match[0];
844
- const pathWithoutPrefix = fullMatch.substring(this.SAVE_SYMBOL.length); // 移除保存符号
841
+ const pathWithoutPrefix = fullMatch.substring(2, fullMatch.length - 1); // 移除 ${ 和 }
845
842
 
846
843
  // 从路径到名称的映射中获取标签名称
847
844
  let label = this.pathToNameMap.get(pathWithoutPrefix) || pathWithoutPrefix;
@@ -861,8 +858,8 @@ export default {
861
858
  htmlContent += this.convertTextToHtml(remaining);
862
859
  }
863
860
 
864
- // 在末尾添加零宽字符作为光标位置
865
- htmlContent += '\u200B';
861
+ // 在末尾添加空格作为光标位置
862
+ htmlContent += ' ';
866
863
 
867
864
  // 将换行符转换为 <br> 标签以便在 contenteditable 中正确显示
868
865
  this.inputRef.innerHTML = htmlContent.replace(/\n/g, '<br>');