qzhuli-markdown-wysiwyg 0.1.21 → 0.1.22

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.cjs CHANGED
@@ -4622,25 +4622,6 @@
4622
4622
  }
4623
4623
  }
4624
4624
 
4625
- function logSourceDebug(stage, extra) {
4626
- const textarea = typeof window.sourceEditor === 'function' ? window.sourceEditor() : document.getElementById('markdown-source-editor')
4627
- const scrollEl = getEditorScrollElement()
4628
- const activeEl = document.activeElement
4629
- console.debug('[source-debug]', stage, {
4630
- sourceMode: !!sourceMode,
4631
- scrollTop: scrollEl ? scrollEl.scrollTop : null,
4632
- textareaScrollTop: textarea ? textarea.scrollTop : null,
4633
- selectionStart: textarea ? textarea.selectionStart : null,
4634
- selectionEnd: textarea ? textarea.selectionEnd : null,
4635
- valueLength: textarea ? (textarea.value || '').length : null,
4636
- activeTag: activeEl ? activeEl.tagName : null,
4637
- activeId: activeEl ? activeEl.id || null : null,
4638
- sourceHistoryIndex,
4639
- sourceHistoryLength: sourceHistory.length,
4640
- ...(extra || {}),
4641
- })
4642
- }
4643
-
4644
4625
  function recordSourceHistory() {
4645
4626
  if (sourceHistorySuppress || window._loadingContent || editorReadOnly) return
4646
4627
 
@@ -4663,9 +4644,6 @@
4663
4644
  const snapshot = captureSourceSnapshot()
4664
4645
  sourceHistory = snapshot ? [snapshot] : []
4665
4646
  sourceHistoryIndex = snapshot ? 0 : -1
4666
- logSourceDebug('resetSourceHistory', {
4667
- snapshotValueLength: snapshot ? snapshot.value.length : null,
4668
- })
4669
4647
  }
4670
4648
 
4671
4649
  function applySourceHistorySnapshot(snapshot) {
@@ -4676,30 +4654,17 @@
4676
4654
  sourceHistorySuppress = true
4677
4655
  try {
4678
4656
  const currentScrollTop = scrollEl ? scrollEl.scrollTop : 0
4679
- logSourceDebug('applySourceHistorySnapshot:start', {
4680
- targetValueLength: (snapshot.value || '').length,
4681
- currentScrollTop,
4682
- })
4683
4657
  textarea.value = snapshot.value || ''
4684
4658
  syncSourceModeDirtyState(textarea.value || '')
4685
4659
  const nextLength = textarea.value.length
4686
4660
  textarea.setSelectionRange(nextLength, nextLength)
4687
- logSourceDebug('applySourceHistorySnapshot:afterSelection', {
4688
- currentScrollTop,
4689
- })
4690
4661
  if (typeof window.syncSourceEditorHeight === 'function') {
4691
4662
  window.syncSourceEditorHeight()
4692
4663
  }
4693
- logSourceDebug('applySourceHistorySnapshot:afterHeightSync', {
4694
- currentScrollTop,
4695
- })
4696
4664
  if (scrollEl) {
4697
4665
  scrollEl.scrollTop = currentScrollTop
4698
4666
  requestAnimationFrame(() => {
4699
4667
  scrollEl.scrollTop = currentScrollTop
4700
- logSourceDebug('applySourceHistorySnapshot:rafRestore', {
4701
- currentScrollTop,
4702
- })
4703
4668
  })
4704
4669
  }
4705
4670
  if (document.activeElement === textarea) {
@@ -4720,16 +4685,9 @@
4720
4685
  const snapshot = sourceHistory[targetIndex]
4721
4686
  if (!snapshot) return false
4722
4687
 
4723
- logSourceDebug('undoSourceHistory:before', {
4724
- targetIndex,
4725
- targetValueLength: (snapshot.value || '').length,
4726
- })
4727
4688
  clearPendingAutoSave()
4728
4689
  if (!applySourceHistorySnapshot(snapshot)) return false
4729
4690
  sourceHistoryIndex = targetIndex
4730
- logSourceDebug('undoSourceHistory:after', {
4731
- targetIndex,
4732
- })
4733
4691
  scheduleAutoSave(true)
4734
4692
  return true
4735
4693
  }
@@ -4742,16 +4700,9 @@
4742
4700
  const snapshot = sourceHistory[targetIndex]
4743
4701
  if (!snapshot) return false
4744
4702
 
4745
- logSourceDebug('redoSourceHistory:before', {
4746
- targetIndex,
4747
- targetValueLength: (snapshot.value || '').length,
4748
- })
4749
4703
  clearPendingAutoSave()
4750
4704
  if (!applySourceHistorySnapshot(snapshot)) return false
4751
4705
  sourceHistoryIndex = targetIndex
4752
- logSourceDebug('redoSourceHistory:after', {
4753
- targetIndex,
4754
- })
4755
4706
  scheduleAutoSave(true)
4756
4707
  return true
4757
4708
  }
@@ -4764,9 +4715,6 @@
4764
4715
  if (key === 'z') {
4765
4716
  e.preventDefault()
4766
4717
  e.stopPropagation()
4767
- logSourceDebug('handleSourceKeydown:z', {
4768
- shiftKey: !!e.shiftKey,
4769
- })
4770
4718
  if (e.shiftKey) {
4771
4719
  redoSourceHistory()
4772
4720
  } else {
@@ -4777,7 +4725,6 @@
4777
4725
  if (key === 'y') {
4778
4726
  e.preventDefault()
4779
4727
  e.stopPropagation()
4780
- logSourceDebug('handleSourceKeydown:y')
4781
4728
  redoSourceHistory()
4782
4729
  return
4783
4730
  }
@@ -12266,21 +12213,12 @@
12266
12213
  sourceModeDirty = false
12267
12214
  resetSourceHistory()
12268
12215
  textarea.setSelectionRange(0, 0)
12269
- logSourceDebug('loadContent:afterTextareaReset', {
12270
- restoreView,
12271
- targetScrollTop,
12272
- markdownLength: markdown.length,
12273
- })
12274
12216
  if (sourceMode) {
12275
12217
  requestAnimationFrame(function () {
12276
12218
  syncSourceEditorHeight()
12277
12219
  if (scrollEl && targetScrollTop !== null) {
12278
12220
  scrollEl.scrollTop = targetScrollTop
12279
12221
  }
12280
- logSourceDebug('loadContent:sourceModeRaf', {
12281
- restoreView,
12282
- targetScrollTop,
12283
- })
12284
12222
  })
12285
12223
  }
12286
12224
  }
@@ -12303,10 +12241,6 @@
12303
12241
  if (scrollEl && targetScrollTop !== null) {
12304
12242
  scrollEl.scrollTop = targetScrollTop
12305
12243
  }
12306
- logSourceDebug('loadContent:finalRaf', {
12307
- restoreView,
12308
- targetScrollTop,
12309
- })
12310
12244
  loadingFromHost = false
12311
12245
  window._loadingContent = false
12312
12246
  })
@@ -12388,10 +12322,6 @@
12388
12322
  revealToolbarForSourceMode()
12389
12323
  })
12390
12324
  textarea.addEventListener('keydown', handleSourceKeydown)
12391
- textarea.addEventListener('select', function () {
12392
- if (!sourceMode) return
12393
- logSourceDebug('textarea:select')
12394
- })
12395
12325
  textarea.addEventListener('input', function () {
12396
12326
  if (editorReadOnly) return
12397
12327
  syncSourceModeDirtyState(textarea.value || '')
@@ -12407,9 +12337,6 @@
12407
12337
  if (scrollEl) {
12408
12338
  var scrollTimer = null
12409
12339
  scrollEl.addEventListener('scroll', function () {
12410
- if (sourceMode) {
12411
- logSourceDebug('editorScroll:scroll')
12412
- }
12413
12340
  clearTimeout(scrollTimer)
12414
12341
  scrollTimer = setTimeout(notifyScrollPosition, 100)
12415
12342
  })
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineComponent as q, ref as s, getCurrentInstance as X, computed as u, watch as h, onMounted as _, onUpdated as $, onBeforeUnmount as AA, openBlock as eA, createElementBlock as nA } from "vue";
1
+ import { defineComponent as q, ref as s, getCurrentInstance as X, computed as B, watch as h, onMounted as _, onUpdated as $, onBeforeUnmount as AA, openBlock as eA, createElementBlock as nA } from "vue";
2
2
  const k = `<!doctype html>\r
3
3
  <html lang="zh-CN" class="light">\r
4
4
  <head>\r
@@ -4623,25 +4623,6 @@ const k = `<!doctype html>\r
4623
4623
  }
4624
4624
  }
4625
4625
 
4626
- function logSourceDebug(stage, extra) {
4627
- const textarea = typeof window.sourceEditor === 'function' ? window.sourceEditor() : document.getElementById('markdown-source-editor')
4628
- const scrollEl = getEditorScrollElement()
4629
- const activeEl = document.activeElement
4630
- console.debug('[source-debug]', stage, {
4631
- sourceMode: !!sourceMode,
4632
- scrollTop: scrollEl ? scrollEl.scrollTop : null,
4633
- textareaScrollTop: textarea ? textarea.scrollTop : null,
4634
- selectionStart: textarea ? textarea.selectionStart : null,
4635
- selectionEnd: textarea ? textarea.selectionEnd : null,
4636
- valueLength: textarea ? (textarea.value || '').length : null,
4637
- activeTag: activeEl ? activeEl.tagName : null,
4638
- activeId: activeEl ? activeEl.id || null : null,
4639
- sourceHistoryIndex,
4640
- sourceHistoryLength: sourceHistory.length,
4641
- ...(extra || {}),
4642
- })
4643
- }
4644
-
4645
4626
  function recordSourceHistory() {
4646
4627
  if (sourceHistorySuppress || window._loadingContent || editorReadOnly) return
4647
4628
 
@@ -4664,9 +4645,6 @@ const k = `<!doctype html>\r
4664
4645
  const snapshot = captureSourceSnapshot()
4665
4646
  sourceHistory = snapshot ? [snapshot] : []
4666
4647
  sourceHistoryIndex = snapshot ? 0 : -1
4667
- logSourceDebug('resetSourceHistory', {
4668
- snapshotValueLength: snapshot ? snapshot.value.length : null,
4669
- })
4670
4648
  }
4671
4649
 
4672
4650
  function applySourceHistorySnapshot(snapshot) {
@@ -4677,30 +4655,17 @@ const k = `<!doctype html>\r
4677
4655
  sourceHistorySuppress = true
4678
4656
  try {
4679
4657
  const currentScrollTop = scrollEl ? scrollEl.scrollTop : 0
4680
- logSourceDebug('applySourceHistorySnapshot:start', {
4681
- targetValueLength: (snapshot.value || '').length,
4682
- currentScrollTop,
4683
- })
4684
4658
  textarea.value = snapshot.value || ''
4685
4659
  syncSourceModeDirtyState(textarea.value || '')
4686
4660
  const nextLength = textarea.value.length
4687
4661
  textarea.setSelectionRange(nextLength, nextLength)
4688
- logSourceDebug('applySourceHistorySnapshot:afterSelection', {
4689
- currentScrollTop,
4690
- })
4691
4662
  if (typeof window.syncSourceEditorHeight === 'function') {
4692
4663
  window.syncSourceEditorHeight()
4693
4664
  }
4694
- logSourceDebug('applySourceHistorySnapshot:afterHeightSync', {
4695
- currentScrollTop,
4696
- })
4697
4665
  if (scrollEl) {
4698
4666
  scrollEl.scrollTop = currentScrollTop
4699
4667
  requestAnimationFrame(() => {
4700
4668
  scrollEl.scrollTop = currentScrollTop
4701
- logSourceDebug('applySourceHistorySnapshot:rafRestore', {
4702
- currentScrollTop,
4703
- })
4704
4669
  })
4705
4670
  }
4706
4671
  if (document.activeElement === textarea) {
@@ -4721,16 +4686,9 @@ const k = `<!doctype html>\r
4721
4686
  const snapshot = sourceHistory[targetIndex]
4722
4687
  if (!snapshot) return false
4723
4688
 
4724
- logSourceDebug('undoSourceHistory:before', {
4725
- targetIndex,
4726
- targetValueLength: (snapshot.value || '').length,
4727
- })
4728
4689
  clearPendingAutoSave()
4729
4690
  if (!applySourceHistorySnapshot(snapshot)) return false
4730
4691
  sourceHistoryIndex = targetIndex
4731
- logSourceDebug('undoSourceHistory:after', {
4732
- targetIndex,
4733
- })
4734
4692
  scheduleAutoSave(true)
4735
4693
  return true
4736
4694
  }
@@ -4743,16 +4701,9 @@ const k = `<!doctype html>\r
4743
4701
  const snapshot = sourceHistory[targetIndex]
4744
4702
  if (!snapshot) return false
4745
4703
 
4746
- logSourceDebug('redoSourceHistory:before', {
4747
- targetIndex,
4748
- targetValueLength: (snapshot.value || '').length,
4749
- })
4750
4704
  clearPendingAutoSave()
4751
4705
  if (!applySourceHistorySnapshot(snapshot)) return false
4752
4706
  sourceHistoryIndex = targetIndex
4753
- logSourceDebug('redoSourceHistory:after', {
4754
- targetIndex,
4755
- })
4756
4707
  scheduleAutoSave(true)
4757
4708
  return true
4758
4709
  }
@@ -4765,9 +4716,6 @@ const k = `<!doctype html>\r
4765
4716
  if (key === 'z') {
4766
4717
  e.preventDefault()
4767
4718
  e.stopPropagation()
4768
- logSourceDebug('handleSourceKeydown:z', {
4769
- shiftKey: !!e.shiftKey,
4770
- })
4771
4719
  if (e.shiftKey) {
4772
4720
  redoSourceHistory()
4773
4721
  } else {
@@ -4778,7 +4726,6 @@ const k = `<!doctype html>\r
4778
4726
  if (key === 'y') {
4779
4727
  e.preventDefault()
4780
4728
  e.stopPropagation()
4781
- logSourceDebug('handleSourceKeydown:y')
4782
4729
  redoSourceHistory()
4783
4730
  return
4784
4731
  }
@@ -12267,21 +12214,12 @@ const k = `<!doctype html>\r
12267
12214
  sourceModeDirty = false
12268
12215
  resetSourceHistory()
12269
12216
  textarea.setSelectionRange(0, 0)
12270
- logSourceDebug('loadContent:afterTextareaReset', {
12271
- restoreView,
12272
- targetScrollTop,
12273
- markdownLength: markdown.length,
12274
- })
12275
12217
  if (sourceMode) {
12276
12218
  requestAnimationFrame(function () {
12277
12219
  syncSourceEditorHeight()
12278
12220
  if (scrollEl && targetScrollTop !== null) {
12279
12221
  scrollEl.scrollTop = targetScrollTop
12280
12222
  }
12281
- logSourceDebug('loadContent:sourceModeRaf', {
12282
- restoreView,
12283
- targetScrollTop,
12284
- })
12285
12223
  })
12286
12224
  }
12287
12225
  }
@@ -12304,10 +12242,6 @@ const k = `<!doctype html>\r
12304
12242
  if (scrollEl && targetScrollTop !== null) {
12305
12243
  scrollEl.scrollTop = targetScrollTop
12306
12244
  }
12307
- logSourceDebug('loadContent:finalRaf', {
12308
- restoreView,
12309
- targetScrollTop,
12310
- })
12311
12245
  loadingFromHost = false
12312
12246
  window._loadingContent = false
12313
12247
  })
@@ -12389,10 +12323,6 @@ const k = `<!doctype html>\r
12389
12323
  revealToolbarForSourceMode()
12390
12324
  })
12391
12325
  textarea.addEventListener('keydown', handleSourceKeydown)
12392
- textarea.addEventListener('select', function () {
12393
- if (!sourceMode) return
12394
- logSourceDebug('textarea:select')
12395
- })
12396
12326
  textarea.addEventListener('input', function () {
12397
12327
  if (editorReadOnly) return
12398
12328
  syncSourceModeDirtyState(textarea.value || '')
@@ -12408,9 +12338,6 @@ const k = `<!doctype html>\r
12408
12338
  if (scrollEl) {
12409
12339
  var scrollTimer = null
12410
12340
  scrollEl.addEventListener('scroll', function () {
12411
- if (sourceMode) {
12412
- logSourceDebug('editorScroll:scroll')
12413
- }
12414
12341
  clearTimeout(scrollTimer)
12415
12342
  scrollTimer = setTimeout(notifyScrollPosition, 100)
12416
12343
  })
@@ -14537,17 +14464,17 @@ const k = `<!doctype html>\r
14537
14464
  }, V = (r) => String(r || "").trim().length > 0, G = (r) => {
14538
14465
  const a = [];
14539
14466
  return g(a, r), a.length > 0 || (g(a, sA()), g(a, lA()), g(a, fA()), g(a, dA()), g(a, gA()), g(a, cA())), a;
14540
- }, uA = (r) => {
14467
+ }, BA = (r) => {
14541
14468
  if (typeof window > "u") return !1;
14542
14469
  try {
14543
14470
  return new URL(r, window.location.href).origin === window.location.origin;
14544
14471
  } catch {
14545
14472
  return !1;
14546
14473
  }
14547
- }, BA = async (r) => {
14474
+ }, uA = async (r) => {
14548
14475
  const a = String(r || "").trim();
14549
14476
  if (!a) return !1;
14550
- if (typeof window > "u" || typeof fetch != "function" || !uA(a)) return !0;
14477
+ if (typeof window > "u" || typeof fetch != "function" || !BA(a)) return !0;
14551
14478
  try {
14552
14479
  const i = await fetch(a, {
14553
14480
  method: "HEAD",
@@ -14587,13 +14514,13 @@ const k = `<!doctype html>\r
14587
14514
  var A;
14588
14515
  const e = (A = Q == null ? void 0 : Q.subTree) == null ? void 0 : A.el;
14589
14516
  C.value = e instanceof HTMLIFrameElement ? e : null;
14590
- }, c = s(!1), F = s(0), d = s(""), M = s(""), B = s(0), p = s(t.modelValue ?? ""), U = s(t.filename ?? ""), x = s(t.path ?? ""), w = s(0), y = u(() => P(t.atUserList)), j = u(() => k.trim().length > 0), z = u(() => !V(t.runtimeUrl) && j.value), W = u(() => t.viewMode ? t.viewMode : t.readOnly ? "readonly" : "default"), v = u(() => G(t.runtimeUrl)), T = u(() => t.viewMode ? t.viewMode : t.readOnly ? "readonly" : z.value ? "write" : W.value), I = async () => {
14517
+ }, c = s(!1), F = s(0), d = s(""), M = s(""), u = s(0), p = s(t.modelValue ?? ""), U = s(t.filename ?? ""), x = s(t.path ?? ""), w = s(0), y = B(() => P(t.atUserList)), j = B(() => k.trim().length > 0), z = B(() => !V(t.runtimeUrl) && j.value), W = B(() => t.viewMode ? t.viewMode : t.readOnly ? "readonly" : "default"), T = B(() => G(t.runtimeUrl)), v = B(() => t.viewMode ? t.viewMode : t.readOnly ? "readonly" : z.value ? "write" : W.value), I = async () => {
14591
14518
  const e = w.value + 1;
14592
14519
  if (w.value = e, z.value) {
14593
14520
  d.value = "", M.value = k;
14594
14521
  return;
14595
14522
  }
14596
- const A = v.value;
14523
+ const A = T.value;
14597
14524
  if (A.length === 0) {
14598
14525
  d.value = "", M.value = "";
14599
14526
  return;
@@ -14603,7 +14530,7 @@ const k = `<!doctype html>\r
14603
14530
  return;
14604
14531
  }
14605
14532
  for (const n of A) {
14606
- const o = await BA(n);
14533
+ const o = await uA(n);
14607
14534
  if (w.value !== e) return;
14608
14535
  if (o) {
14609
14536
  d.value = n;
@@ -14650,15 +14577,15 @@ const k = `<!doctype html>\r
14650
14577
  m({
14651
14578
  type: "apply-settings",
14652
14579
  theme: t.theme,
14653
- readOnly: T.value === "readonly",
14654
- viewMode: T.value
14580
+ readOnly: v.value === "readonly",
14581
+ viewMode: v.value
14655
14582
  });
14656
14583
  }, K = () => {
14657
14584
  m({
14658
14585
  type: "set-host-mode",
14659
14586
  mode: "external"
14660
14587
  });
14661
- }, R = (e = B.value) => {
14588
+ }, R = (e = u.value) => {
14662
14589
  m({
14663
14590
  type: "set-at-list",
14664
14591
  requestId: e,
@@ -14667,7 +14594,7 @@ const k = `<!doctype html>\r
14667
14594
  }, O = () => {
14668
14595
  c.value && (K(), N(), L(), R());
14669
14596
  }, Z = () => {
14670
- c.value = !1, B.value = 0, w.value += 1, F.value += 1, I();
14597
+ c.value = !1, u.value = 0, w.value += 1, F.value += 1, I();
14671
14598
  }, J = (e) => {
14672
14599
  if (C.value && e.source !== C.value.contentWindow || !e.data || typeof e.data != "object") return;
14673
14600
  const A = e.data;
@@ -14677,7 +14604,7 @@ const k = `<!doctype html>\r
14677
14604
  }
14678
14605
  if (A.type === "get-at-list") {
14679
14606
  const n = Number(A.requestId) || Date.now();
14680
- B.value = n;
14607
+ u.value = n;
14681
14608
  const o = {
14682
14609
  requestId: n,
14683
14610
  query: String(A.query || "")
@@ -14688,7 +14615,7 @@ const k = `<!doctype html>\r
14688
14615
  if (A.type === "at-who") {
14689
14616
  if (!A.user) return;
14690
14617
  const n = {
14691
- requestId: Number(A.requestId) || B.value || Date.now(),
14618
+ requestId: Number(A.requestId) || u.value || Date.now(),
14692
14619
  value: String(A.value || ""),
14693
14620
  user: E(A.user, 0)
14694
14621
  };
@@ -14721,9 +14648,9 @@ const k = `<!doctype html>\r
14721
14648
  A.type === "scroll-position" && l("scroll", Number(A.position) || 0);
14722
14649
  };
14723
14650
  return h(
14724
- v,
14651
+ T,
14725
14652
  () => {
14726
- c.value = !1, B.value = 0, I();
14653
+ c.value = !1, u.value = 0, I();
14727
14654
  },
14728
14655
  { deep: !0 }
14729
14656
  ), h(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qzhuli-markdown-wysiwyg",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "WYSIWYG Markdown editor packaged as a Vue-friendly JS library",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",