lakelib 0.4.0 → 0.4.2

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/lib/lake.d.ts CHANGED
@@ -2264,4 +2264,4 @@ declare class Dropdown {
2264
2264
  }
2265
2265
 
2266
2266
  export { Box, Button, Dropdown, Editor, Fragment, HTMLParser, Nodes, Range$1 as Range, TextParser, Toolbar, addMark, createIframeBox, deleteContents, getBox, getContentRules, icons, insertBlock, insertBookmark, insertBox, insertContents, query, removeBox, removeMark, setBlocks, splitBlock, splitMarks, template, toBookmark, toHex };
2267
- export type { ActiveItem, BoxComponent, BoxValue, CommandItem, ContentRules, DropdownItem, DropdownMenuItem, InitializePlugin, KeyValue, MentionItem, NodePath, SelectionState, SlashButtonItem, SlashItem, SlashUploadItem, ToolbarButtonItem, ToolbarDropdownItem, ToolbarItem, ToolbarUploadItem, UnmountPlugin };
2267
+ export type { ActiveItem, BoxComponent, BoxValue, CommandItem, ContentRules, DropdownItem, DropdownMenuItem, EditorConfig, InitializePlugin, KeyValue, MentionItem, NodePath, SelectionState, SlashButtonItem, SlashItem, SlashUploadItem, ToolbarButtonItem, ToolbarConfig, ToolbarDropdownItem, ToolbarItem, ToolbarUploadItem, UnmountPlugin };
package/lib/lake.js CHANGED
@@ -6611,7 +6611,7 @@ function removeBox(range) {
6611
6611
  return box;
6612
6612
  }
6613
6613
 
6614
- var version = "0.4.0";
6614
+ var version = "0.4.2";
6615
6615
 
6616
6616
  // Converts the custom HTML tags to the special tags that can not be parsed by browser.
6617
6617
  function denormalizeValue(value) {
@@ -8345,11 +8345,21 @@ class Editor {
8345
8345
  }
8346
8346
  else if (children.length === 1) {
8347
8347
  const child = children[0];
8348
- if (child.isVoid) {
8348
+ if (child.isVoid || child.isText) {
8349
+ const startNode = range.startNode;
8350
+ const startOffset = range.startOffset;
8351
+ const endNode = range.endNode;
8352
+ const endOffset = range.endOffset;
8349
8353
  const paragraph = query('<p />');
8350
8354
  child.before(paragraph);
8351
8355
  paragraph.append(child);
8352
- range.shrinkAfter(paragraph);
8356
+ if (startNode.isText || endNode.isText) {
8357
+ range.setStart(startNode, startOffset);
8358
+ range.setEnd(endNode, endOffset);
8359
+ }
8360
+ else {
8361
+ range.shrinkAfter(paragraph);
8362
+ }
8353
8363
  changed = true;
8354
8364
  debug(`Content fixed: void element "${child.name}" was wrapped in paragraph`);
8355
8365
  }
@@ -11552,21 +11562,23 @@ function renderDone(box) {
11552
11562
  });
11553
11563
  const captionNode = renderCaption(box);
11554
11564
  renderFloatingToolbar(box);
11555
- new Resizer({
11556
- root: rootNode,
11557
- target: rootNode,
11558
- onResize: newWidth => {
11559
- boxContainer.css('width', `${newWidth}px`);
11560
- updateBoxMarginBottom(box, captionNode);
11561
- },
11562
- onStop: (newWidth, newHeight) => {
11563
- box.updateValue({
11564
- width: newWidth,
11565
- height: newHeight,
11566
- });
11567
- editor.history.save();
11568
- },
11569
- }).render();
11565
+ if (!editor.readonly) {
11566
+ new Resizer({
11567
+ root: rootNode,
11568
+ target: rootNode,
11569
+ onResize: newWidth => {
11570
+ boxContainer.css('width', `${newWidth}px`);
11571
+ updateBoxMarginBottom(box, captionNode);
11572
+ },
11573
+ onStop: (newWidth, newHeight) => {
11574
+ box.updateValue({
11575
+ width: newWidth,
11576
+ height: newHeight,
11577
+ });
11578
+ editor.history.save();
11579
+ },
11580
+ }).render();
11581
+ }
11570
11582
  });
11571
11583
  }
11572
11584
  var imageBox = {