seatable-html-page-sdk 0.0.13-beta.2 → 0.0.13-beta.4

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/index.js CHANGED
@@ -4622,6 +4622,7 @@
4622
4622
  this.mouseEvents.forEach(eventType => {
4623
4623
  window.addEventListener(eventType, this._handleEvent, true);
4624
4624
  });
4625
+ this.addCommentModeStyle();
4625
4626
  }
4626
4627
  disable() {
4627
4628
  if (!this.isActive) return;
@@ -4629,6 +4630,20 @@
4629
4630
  this.mouseEvents.forEach(eventType => {
4630
4631
  window.removeEventListener(eventType, this._handleEvent, true);
4631
4632
  });
4633
+ this.removeCommentStyle();
4634
+ }
4635
+ addCommentModeStyle() {
4636
+ let style = document.getElementById('ai-comment-cursor-style');
4637
+ if (!style) {
4638
+ style = document.createElement('style');
4639
+ style.id = 'ai-comment-cursor-style';
4640
+ style.innerHTML = '* { cursor: crosshair !important; }';
4641
+ document.head.appendChild(style);
4642
+ }
4643
+ }
4644
+ removeCommentStyle() {
4645
+ const style = document.getElementById('ai-comment-cursor-style');
4646
+ if (style) style.remove();
4632
4647
  }
4633
4648
  _handleEvent(event) {
4634
4649
  if (!this.isActive) return;
@@ -4636,22 +4651,19 @@
4636
4651
  event.stopPropagation();
4637
4652
  event.stopImmediatePropagation();
4638
4653
  const target = event.target;
4654
+ const isBodyOrHtml = target === document.body || target === document.documentElement;
4639
4655
  if (event.type === 'mouseover') {
4640
- const data = this.buildElementData(target);
4641
- if (data) {
4642
- window.parent.postMessage({
4643
- type: POST_MESSAGE_TYPE.HTML_PAGE_COMMENT_MODE_ELEMENT_HOVER,
4644
- data
4645
- }, '*');
4646
- }
4656
+ const data = isBodyOrHtml ? null : this.buildElementData(target);
4657
+ window.parent.postMessage({
4658
+ type: POST_MESSAGE_TYPE.HTML_PAGE_COMMENT_MODE_ELEMENT_HOVER,
4659
+ data
4660
+ }, '*');
4647
4661
  } else if (event.type === 'click') {
4648
- const data = this.buildElementData(target);
4649
- if (data) {
4650
- window.parent.postMessage({
4651
- type: POST_MESSAGE_TYPE.HTML_PAGE_COMMENT_MODE_ELEMENT_SELECTED,
4652
- data
4653
- }, '*');
4654
- }
4662
+ const data = isBodyOrHtml ? null : this.buildElementData(target);
4663
+ window.parent.postMessage({
4664
+ type: POST_MESSAGE_TYPE.HTML_PAGE_COMMENT_MODE_ELEMENT_SELECTED,
4665
+ data
4666
+ }, '*');
4655
4667
  }
4656
4668
  }
4657
4669
  buildElementData(target) {
@@ -4876,6 +4888,9 @@
4876
4888
  eventType,
4877
4889
  payload
4878
4890
  } = event.data;
4891
+ if (type && type.includes('COMMENT')) {
4892
+ console.log('--- SDK handleMessage ---', type);
4893
+ }
4879
4894
  if (type === POST_MESSAGE_TYPE.HTML_PAGE_RESPONSE) {
4880
4895
  const pending = this.pendingRequests[requestId];
4881
4896
  if (pending) {
@@ -4891,12 +4906,10 @@
4891
4906
  this.emitEvent(eventType, payload);
4892
4907
  } else if (type === POST_MESSAGE_TYPE.HTML_PAGE_ENABLE_COMMENT_MODE) {
4893
4908
  this.isCommentMode = true;
4894
- document.body.style.cursor = 'crosshair';
4895
4909
  this.unbindInteractiveEvents();
4896
4910
  if (this.commentModeAdapter) this.commentModeAdapter.enable();
4897
4911
  } else if (type === POST_MESSAGE_TYPE.HTML_PAGE_DISABLE_COMMENT_MODE) {
4898
4912
  this.isCommentMode = false;
4899
- document.body.style.cursor = '';
4900
4913
  if (this.commentModeAdapter) this.commentModeAdapter.disable();
4901
4914
  this.bindInteractiveEvents();
4902
4915
  } else if (type === POST_MESSAGE_TYPE.WINDOW_EVENT) {