lexxy 0.8.6.beta → 0.9.1.beta

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8294fbf164b9b8fb87be2f8025cc8fd563e3fd5bb61daaf1415ff93f39a588bc
4
- data.tar.gz: f40f1aa544f74bf7e0c2fb5fdd7b6a0850426eeb30861d2631f08c4bfefe7ec9
3
+ metadata.gz: 857d629c986ab28555fc79821525be30888fdfa3083b900dfbc8a1b74f42b1db
4
+ data.tar.gz: 34c6e06b8a36438eaed68aaf9421a6388b85d1004bf1a8682e3d83bf0d29ed55
5
5
  SHA512:
6
- metadata.gz: 5d032f3f71e366385c22ce4cfbd0e5c48d3af49aa28001d6c7d13a931e62d9df57c9549728ccbd4bf105c1cb3d24e21e0693754726887f7c8db248677b2de23f
7
- data.tar.gz: 1877815c54a4436a398f471eb0277e7fc68526e0f24ad6680902fd2ebdde198cc450889d279d17bbea7811524ea9716eaea750f0560063f03ed1d50226e3510b
6
+ metadata.gz: 0c1ef0dfa8299890c9d165b9e76a254f465f107404fb2c281ad1f830d5f2c9f97641eae0070d88bf24a201f5358448793d00d2cea3f2131edd08bdc56358339f
7
+ data.tar.gz: c06d85591d104ca856ddcea2cfa5fe00d678eab8eed4455b88bfef8338535bd1d1de4299debb0c873d4790104433ad06f9be18ad964df365817fde8e7d1c6b3d
@@ -5266,13 +5266,13 @@ class LexicalToolbarElement extends HTMLElement {
5266
5266
 
5267
5267
  static get defaultTemplate() {
5268
5268
  return `
5269
- <button class="lexxy-editor__toolbar-button" type="button" name="image" data-command="uploadAttachments" data-prevent-overflow="true" title="Add images">
5270
- ${ToolbarIcons.image}
5271
- </button>
5269
+ <button class="lexxy-editor__toolbar-button" type="button" name="image" data-command="uploadImage" data-prevent-overflow="true" title="Add images and video">
5270
+ ${ToolbarIcons.image}
5271
+ </button>
5272
5272
 
5273
- <button class="lexxy-editor__toolbar-button lexxy-editor__toolbar-group-end" type="button" name="file" data-command="uploadAttachments" title="Upload files">
5274
- ${ToolbarIcons.attachment}
5275
- </button>
5273
+ <button class="lexxy-editor__toolbar-button lexxy-editor__toolbar-group-end" type="button" name="file" data-command="uploadFile" title="Upload files">
5274
+ ${ToolbarIcons.attachment}
5275
+ </button>
5276
5276
 
5277
5277
  <button class="lexxy-editor__toolbar-button" type="button" name="bold" data-command="bold" title="Bold">
5278
5278
  ${ToolbarIcons.bold}
@@ -5296,10 +5296,10 @@ class LexicalToolbarElement extends HTMLElement {
5296
5296
  <button type="button" name="heading-medium" data-command="setFormatHeadingMedium" title="Medium heading">
5297
5297
  ${ToolbarIcons.h3} <span>Medium Heading</span>
5298
5298
  </button>
5299
- <button type="button" name="heading-small" data-command="setFormatHeadingSmall" title="Small heading">
5299
+ <button class="lexxy-editor__toolbar-group-end" type="button" name="heading-small" data-command="setFormatHeadingSmall" title="Small heading">
5300
5300
  ${ToolbarIcons.h4} <span>Small Heading</span>
5301
5301
  </button>
5302
- <div class="separator" role="separator"></div>
5302
+ <div class="lexxy-editor__toolbar-separator" role="separator"></div>
5303
5303
  <button type="button" name="strikethrough" data-command="strikethrough" title="Strikethrough">
5304
5304
  ${ToolbarIcons.strikethrough} <span>Strikethrough</span>
5305
5305
  </button>
@@ -5309,21 +5309,6 @@ class LexicalToolbarElement extends HTMLElement {
5309
5309
  </div>
5310
5310
  </details>
5311
5311
 
5312
-
5313
- <details class="lexxy-editor__toolbar-dropdown lexxy-editor__toolbar-dropdown--chevron" name="lexxy-dropdown">
5314
- <summary class="lexxy-editor__toolbar-button" name="lists" title="Lists">
5315
- ${ToolbarIcons.ul}
5316
- </summary>
5317
- <div class="lexxy-editor__toolbar-dropdown-list">
5318
- <button type="button" name="unordered-list" data-command="insertUnorderedList" title="Bullet list">
5319
- ${ToolbarIcons.ul} <span>Bullets</span>
5320
- </button>
5321
- <button type="button" name="ordered-list" data-command="insertOrderedList" title="Numbered list">
5322
- ${ToolbarIcons.ol} <span>Numbers</span>
5323
- </button>
5324
- </div>
5325
- </details>
5326
-
5327
5312
  <details class="lexxy-editor__toolbar-dropdown lexxy-editor__toolbar-dropdown--chevron" name="lexxy-dropdown">
5328
5313
  <summary class="lexxy-editor__toolbar-button" name="highlight" title="Color highlight">
5329
5314
  ${ToolbarIcons.highlight}
@@ -5335,7 +5320,7 @@ class LexicalToolbarElement extends HTMLElement {
5335
5320
  </details>
5336
5321
 
5337
5322
  <details class="lexxy-editor__toolbar-dropdown" name="lexxy-dropdown">
5338
- <summary class="lexxy-editor__toolbar-button" name="link" title="Link" data-hotkey="cmd+k ctrl+k">
5323
+ <summary class="lexxy-editor__toolbar-button lexxy-editor__toolbar-group-end" name="link" title="Link" data-hotkey="cmd+k ctrl+k">
5339
5324
  ${ToolbarIcons.link}
5340
5325
  </summary>
5341
5326
  <lexxy-link-dropdown class="lexxy-editor__toolbar-dropdown-content">
@@ -5353,10 +5338,17 @@ class LexicalToolbarElement extends HTMLElement {
5353
5338
  ${ToolbarIcons.quote}
5354
5339
  </button>
5355
5340
 
5356
- <button class="lexxy-editor__toolbar-button lexxy-editor__toolbar-group-end" type="button" name="code" data-command="insertCodeBlock" title="Code">
5341
+ <button class="lexxy-editor__toolbar-button" type="button" name="code" data-command="insertCodeBlock" title="Code">
5357
5342
  ${ToolbarIcons.code}
5358
5343
  </button>
5359
5344
 
5345
+ <button class="lexxy-editor__toolbar-button" type="button" name="unordered-list" data-command="insertUnorderedList" title="Bullet list">
5346
+ ${ToolbarIcons.ul}
5347
+ </button>
5348
+ <button class="lexxy-editor__toolbar-button lexxy-editor__toolbar-group-end" type="button" name="ordered-list" data-command="insertOrderedList" title="Numbered list">
5349
+ ${ToolbarIcons.ol}
5350
+ </button>
5351
+
5360
5352
  <button class="lexxy-editor__toolbar-button" type="button" name="table" data-command="insertTable" title="Insert a table">
5361
5353
  ${ToolbarIcons.table}
5362
5354
  </button>
@@ -8240,7 +8232,8 @@ const COMMANDS = [
8240
8232
  "insertQuoteBlock",
8241
8233
  "insertCodeBlock",
8242
8234
  "insertHorizontalDivider",
8243
- "uploadAttachments",
8235
+ "uploadImage",
8236
+ "uploadFile",
8244
8237
 
8245
8238
  "insertTable",
8246
8239
 
@@ -8424,15 +8417,27 @@ class CommandDispatcher {
8424
8417
  this.contents.applyParagraphFormat();
8425
8418
  }
8426
8419
 
8427
- dispatchUploadAttachments() {
8428
- const input = createElement("input", {
8420
+ dispatchUploadImage() {
8421
+ this.#dispatchUploadAttachment("image/*,video/*");
8422
+ }
8423
+
8424
+ dispatchUploadFile() {
8425
+ this.#dispatchUploadAttachment();
8426
+ }
8427
+
8428
+ #dispatchUploadAttachment(accept = null) {
8429
+ const attributes = {
8429
8430
  type: "file",
8430
8431
  multiple: true,
8431
8432
  style: "display: none;",
8432
8433
  onchange: ({ target: { files } }) => {
8433
8434
  this.contents.uploadFiles(files, { selectLast: true });
8434
8435
  }
8435
- });
8436
+ };
8437
+
8438
+ if (accept) attributes.accept = accept;
8439
+
8440
+ const input = createElement("input", attributes);
8436
8441
 
8437
8442
  // Append and remove to make testable
8438
8443
  this.editorElement.appendChild(input);
@@ -10711,7 +10716,8 @@ class Contents {
10711
10716
  }
10712
10717
 
10713
10718
  #splitParagraphsAtLineBreaks(selection) {
10714
- const selectedNodeKeys = new Set(selection.getNodes().map(n => n.getKey()));
10719
+ const anchorKey = selection.anchor.getNode().getKey();
10720
+ const focusKey = selection.focus.getNode().getKey();
10715
10721
  const topLevelElements = this.#topLevelElementsInSelection(selection);
10716
10722
 
10717
10723
  for (const element of topLevelElements) {
@@ -10720,6 +10726,14 @@ class Contents {
10720
10726
  const children = element.getChildren();
10721
10727
  if (!children.some(Zn)) continue
10722
10728
 
10729
+ // Check whether this paragraph needs splitting: skip only if neither
10730
+ // selection endpoint is inside it (meaning it's a middle paragraph
10731
+ // fully between anchor and focus with no partial lines to split off).
10732
+ const hasEndpoint = children.some(child =>
10733
+ child.getKey() === anchorKey || child.getKey() === focusKey
10734
+ );
10735
+ if (!hasEndpoint) continue
10736
+
10723
10737
  const groups = [ [] ];
10724
10738
  for (const child of children) {
10725
10739
  if (Zn(child)) {
@@ -10730,8 +10744,6 @@ class Contents {
10730
10744
  }
10731
10745
  }
10732
10746
 
10733
- if (groups.every(group => group.some(child => selectedNodeKeys.has(child.getKey())))) continue
10734
-
10735
10747
  for (const group of groups) {
10736
10748
  if (group.length === 0) continue
10737
10749
  const paragraph = Vi();
@@ -11019,7 +11031,9 @@ class Clipboard {
11019
11031
  return true
11020
11032
  }
11021
11033
 
11022
- return this.#handlePastedFiles(clipboardData)
11034
+ const handled = this.#handlePastedFiles(clipboardData);
11035
+ if (handled) event.preventDefault();
11036
+ return handled
11023
11037
  }
11024
11038
 
11025
11039
  #isPlainTextOrURLPasted(clipboardData) {
@@ -11117,14 +11131,21 @@ class Clipboard {
11117
11131
  return true
11118
11132
  }
11119
11133
 
11120
- if (html) {
11134
+ if (html && !this.#isLexicalClipboardData(clipboardData)) {
11121
11135
  this.contents.insertHtml(html, { tag: Jn });
11122
11136
  return true
11123
11137
  }
11124
11138
 
11125
- this.#uploadFilesPreservingScroll(files);
11139
+ if (files.length) {
11140
+ this.#uploadFilesPreservingScroll(files);
11141
+ return true
11142
+ }
11143
+
11144
+ return false
11145
+ }
11126
11146
 
11127
- return true
11147
+ #isLexicalClipboardData(clipboardData) {
11148
+ return Array.from(clipboardData.types).includes("application/x-lexical-editor")
11128
11149
  }
11129
11150
 
11130
11151
  #isCopiedImageHTML(html) {
Binary file
Binary file