@burger-editor/client 4.0.0-alpha.46 → 4.0.0-alpha.48

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/client.js CHANGED
@@ -18770,6 +18770,11 @@ function isiOS() {
18770
18770
  navigator.userAgent.includes("Mac") && "ontouchend" in document;
18771
18771
  }
18772
18772
 
18773
+ // src/utilities/isSafari.ts
18774
+ function isSafari() {
18775
+ return typeof navigator !== "undefined" ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : false;
18776
+ }
18777
+
18773
18778
  // src/commands/focus.ts
18774
18779
  var focus = (position = null, options = {}) => ({ editor, view, tr, dispatch }) => {
18775
18780
  options = {
@@ -18780,6 +18785,9 @@ var focus = (position = null, options = {}) => ({ editor, view, tr, dispatch })
18780
18785
  if (isiOS() || isAndroid()) {
18781
18786
  view.dom.focus();
18782
18787
  }
18788
+ if (isSafari() && !isiOS() && !isAndroid()) {
18789
+ view.dom.focus({ preventScroll: true });
18790
+ }
18783
18791
  requestAnimationFrame(() => {
18784
18792
  if (!editor.isDestroyed) {
18785
18793
  view.focus();
@@ -27043,7 +27051,7 @@ function pasteHandler(options) {
27043
27051
  const link = find(textContent, { defaultProtocol: options.defaultProtocol }).find(
27044
27052
  (item) => item.isLink && item.value === textContent
27045
27053
  );
27046
- if (!textContent || !link || shouldAutoLink !== void 0 && !shouldAutoLink(link.href)) {
27054
+ if (!textContent || !link || shouldAutoLink !== void 0 && !shouldAutoLink(link.value)) {
27047
27055
  return false;
27048
27056
  }
27049
27057
  return options.editor.commands.setMark(options.type, {
@@ -27110,7 +27118,22 @@ var Link = Mark.create({
27110
27118
  },
27111
27119
  isAllowedUri: (url, ctx) => !!isAllowedUri(url, ctx.protocols),
27112
27120
  validate: (url) => !!url,
27113
- shouldAutoLink: (url) => !!url
27121
+ shouldAutoLink: (url) => {
27122
+ const hasProtocol = /^[a-z][a-z0-9+.-]*:\/\//i.test(url);
27123
+ const hasMaybeProtocol = /^[a-z][a-z0-9+.-]*:/i.test(url);
27124
+ if (hasProtocol || hasMaybeProtocol && !url.includes("@")) {
27125
+ return true;
27126
+ }
27127
+ const urlWithoutUserinfo = url.includes("@") ? url.split("@").pop() : url;
27128
+ const hostname = urlWithoutUserinfo.split(/[/?#:]/)[0];
27129
+ if (/^\d{1,3}(\.\d{1,3}){3}$/.test(hostname)) {
27130
+ return false;
27131
+ }
27132
+ if (!/\./.test(hostname)) {
27133
+ return false;
27134
+ }
27135
+ return true;
27136
+ }
27114
27137
  };
27115
27138
  },
27116
27139
  addAttributes() {
@@ -28120,6 +28143,7 @@ var TaskItem = Node3.create({
28120
28143
  Object.entries(HTMLAttributes).forEach(([key, value]) => {
28121
28144
  listItem.setAttribute(key, value);
28122
28145
  });
28146
+ let prevRenderedAttributeKeys = new Set(Object.keys(HTMLAttributes));
28123
28147
  return {
28124
28148
  dom: listItem,
28125
28149
  contentDOM: content,
@@ -28130,6 +28154,31 @@ var TaskItem = Node3.create({
28130
28154
  listItem.dataset.checked = updatedNode.attrs.checked;
28131
28155
  checkbox.checked = updatedNode.attrs.checked;
28132
28156
  updateA11Y(updatedNode);
28157
+ const extensionAttributes = editor.extensionManager.attributes;
28158
+ const newHTMLAttributes = getRenderedAttributes(updatedNode, extensionAttributes);
28159
+ const newKeys = new Set(Object.keys(newHTMLAttributes));
28160
+ const staticAttrs = this.options.HTMLAttributes;
28161
+ prevRenderedAttributeKeys.forEach((key) => {
28162
+ if (!newKeys.has(key)) {
28163
+ if (key in staticAttrs) {
28164
+ listItem.setAttribute(key, staticAttrs[key]);
28165
+ } else {
28166
+ listItem.removeAttribute(key);
28167
+ }
28168
+ }
28169
+ });
28170
+ Object.entries(newHTMLAttributes).forEach(([key, value]) => {
28171
+ if (value === null || value === void 0) {
28172
+ if (key in staticAttrs) {
28173
+ listItem.setAttribute(key, staticAttrs[key]);
28174
+ } else {
28175
+ listItem.removeAttribute(key);
28176
+ }
28177
+ } else {
28178
+ listItem.setAttribute(key, value);
28179
+ }
28180
+ });
28181
+ prevRenderedAttributeKeys = newKeys;
28133
28182
  return true;
28134
28183
  }
28135
28184
  };
@@ -42481,7 +42530,10 @@ function Block_options($$anchor, $$props) {
42481
42530
  var option_8_value = {};
42482
42531
 
42483
42532
  template_effect(() => {
42484
- set_selected(option_8, options.style?.[category().id] === propName() || data().isDefault);
42533
+ set_selected(option_8, options.style?.[category().id] == null
42534
+ ? data().isDefault
42535
+ : options.style[category().id] === propName());
42536
+
42485
42537
  set_text(text_7, `${propName()} (${data().value})`);
42486
42538
 
42487
42539
  if (option_8_value !== (option_8_value = data().isDefault ? '@@default' : propName())) {
@@ -44141,7 +44193,7 @@ function parseConfig(config) {
44141
44193
  }
44142
44194
  }
44143
44195
 
44144
- const version = "4.0.0-alpha.45";
44196
+ const version = "4.0.0-alpha.47";
44145
44197
  function attachDraftSwitcher(engine) {
44146
44198
  if (engine.hasDraft()) {
44147
44199
  const container = document.createElement("div");