lexxy-realtime 0.4.0 → 0.7.0

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: 1ca9f7e8da5b292e73222ff67b6f49f6abe35825faf45af947157d4442fa37ce
4
- data.tar.gz: a5aa12d0c2835df82d5eefa99e884b1920af507e824eb7ee3ee032d8b1c06a41
3
+ metadata.gz: 3350b78c757d67751e698066907ab2242baed38f5eabdf49aea0cb096c62c89d
4
+ data.tar.gz: 33f803cbfee003e7fcf067c03625b3e7451bbbeb3c9b7602edc3da51bf8d378e
5
5
  SHA512:
6
- metadata.gz: 2eb4bbdc5584615480b1b8cde54df071b1a38cce8c84cd6eaca8e14dbce7a57617f3f5c758d9b3c9dbc226a2c69c15d2f1a84ef69b5aa986824c7182498fb420
7
- data.tar.gz: a9ec33bca8104051993e0d4a2fc6233afb459bf9e8a6cd63d72b1801f316244d5ef161d38e33d1ca7c325446f87d16622eb8bd7ce3cb20952eaf13d146d0f0ed
6
+ metadata.gz: 93640c137ef447f2dcb730a3902e0774c972523e02087779ceec54b4d73232e14cba4a180a922889f295ac2e9749337aae080b4c4237d62fe2c3885c91a46698
7
+ data.tar.gz: 5a0dd91c3d419aa2ae34428d484fd6a513e7354abd75e290b3a4345b001ffe284a72451e7a72190ad5eda4101210a20a1dc5713a3d55a0286b074ce54aac9132
@@ -1,4 +1,4 @@
1
- import { $addUpdateTag, $caretFromPoint, $caretRangeFromSelection, $cloneWithProperties as $cloneWithProperties$1, $cloneWithPropertiesEphemeral, $createChildrenArray, $createParagraphNode, $createRangeSelection, $createTextNode, $extendCaretToRange, $findMatchingParent, $getCharacterOffsets, $getEditor, $getNodeByKey, $getNodeByKeyOrThrow, $getPreviousSelection, $getRoot, $getSelection, $getState, $getWritableNodeState, $hasAncestor, $isChildCaret, $isDecoratorNode, $isElementNode, $isExtendableTextPointCaret, $isLeafNode, $isLineBreakNode, $isRangeSelection, $isRootNode, $isRootOrShadowRoot, $isTextNode, $isTokenOrSegmented, $nodesOfType, $selectAll as $selectAll$1, $setSelection, COLLABORATION_TAG, ElementNode, HISTORIC_TAG, HISTORY_MERGE_TAG, INTERNAL_$isBlock, RootNode, SKIP_SCROLL_INTO_VIEW_TAG, TextNode, createCommand, createEditor, createState, getStyleObjectFromCSS, removeFromParent, setDOMStyleObject } from "lexical";
1
+ import { Lexical } from "@37signals/lexxy";
2
2
  //#region \0rolldown/runtime.js
3
3
  var __defProp = Object.defineProperty;
4
4
  var __exportAll = (all, no_symbols) => {
@@ -11,6 +11,242 @@ var __exportAll = (all, no_symbols) => {
11
11
  return target;
12
12
  };
13
13
  //#endregion
14
+ //#region scripts/importmap/lexical_shim.js
15
+ const $addUpdateTag = Lexical.$addUpdateTag;
16
+ Lexical.$applyNodeReplacement;
17
+ const $caretFromPoint = Lexical.$caretFromPoint;
18
+ const $caretRangeFromSelection = Lexical.$caretRangeFromSelection;
19
+ const $cloneWithProperties$1 = Lexical.$cloneWithProperties;
20
+ const $cloneWithPropertiesEphemeral = Lexical.$cloneWithPropertiesEphemeral;
21
+ Lexical.$comparePointCaretNext;
22
+ Lexical.$copyNode;
23
+ Lexical.$create;
24
+ const $createChildrenArray = Lexical.$createChildrenArray;
25
+ Lexical.$createLineBreakNode;
26
+ Lexical.$createNodeSelection;
27
+ const $createParagraphNode = Lexical.$createParagraphNode;
28
+ Lexical.$createPoint;
29
+ const $createRangeSelection = Lexical.$createRangeSelection;
30
+ Lexical.$createRangeSelectionFromDom;
31
+ Lexical.$createTabNode;
32
+ const $createTextNode = Lexical.$createTextNode;
33
+ const $extendCaretToRange = Lexical.$extendCaretToRange;
34
+ const $findMatchingParent = Lexical.$findMatchingParent;
35
+ Lexical.$getAdjacentChildCaret;
36
+ Lexical.$getAdjacentNode;
37
+ Lexical.$getAdjacentSiblingOrParentSiblingCaret;
38
+ Lexical.$getCaretInDirection;
39
+ Lexical.$getCaretRange;
40
+ Lexical.$getCaretRangeInDirection;
41
+ const $getCharacterOffsets = Lexical.$getCharacterOffsets;
42
+ Lexical.$getChildCaret;
43
+ Lexical.$getChildCaretAtIndex;
44
+ Lexical.$getChildCaretOrSelf;
45
+ Lexical.$getCollapsedCaretRange;
46
+ Lexical.$getCommonAncestor;
47
+ Lexical.$getCommonAncestorResultBranchOrder;
48
+ const $getEditor = Lexical.$getEditor;
49
+ Lexical.$getEditorDOMRenderConfig;
50
+ Lexical.$getNearestNodeFromDOMNode;
51
+ Lexical.$getNearestRootOrShadowRoot;
52
+ const $getNodeByKey = Lexical.$getNodeByKey;
53
+ const $getNodeByKeyOrThrow = Lexical.$getNodeByKeyOrThrow;
54
+ Lexical.$getNodeFromDOMNode;
55
+ const $getPreviousSelection = Lexical.$getPreviousSelection;
56
+ const $getRoot = Lexical.$getRoot;
57
+ const $getSelection = Lexical.$getSelection;
58
+ Lexical.$getSiblingCaret;
59
+ const $getState = Lexical.$getState;
60
+ Lexical.$getStateChange;
61
+ Lexical.$getTextContent;
62
+ Lexical.$getTextNodeOffset;
63
+ Lexical.$getTextPointCaret;
64
+ Lexical.$getTextPointCaretSlice;
65
+ const $getWritableNodeState = Lexical.$getWritableNodeState;
66
+ const $hasAncestor = Lexical.$hasAncestor;
67
+ Lexical.$hasUpdateTag;
68
+ Lexical.$insertNodes;
69
+ Lexical.$isBlockElementNode;
70
+ const $isChildCaret = Lexical.$isChildCaret;
71
+ const $isDecoratorNode = Lexical.$isDecoratorNode;
72
+ Lexical.$isEditorState;
73
+ const $isElementNode = Lexical.$isElementNode;
74
+ const $isExtendableTextPointCaret = Lexical.$isExtendableTextPointCaret;
75
+ Lexical.$isInlineElementOrDecoratorNode;
76
+ const $isLeafNode = Lexical.$isLeafNode;
77
+ Lexical.$isLexicalNode;
78
+ const $isLineBreakNode = Lexical.$isLineBreakNode;
79
+ Lexical.$isNodeCaret;
80
+ Lexical.$isNodeSelection;
81
+ Lexical.$isParagraphNode;
82
+ const $isRangeSelection = Lexical.$isRangeSelection;
83
+ const $isRootNode = Lexical.$isRootNode;
84
+ const $isRootOrShadowRoot = Lexical.$isRootOrShadowRoot;
85
+ Lexical.$isSiblingCaret;
86
+ Lexical.$isTabNode;
87
+ const $isTextNode = Lexical.$isTextNode;
88
+ Lexical.$isTextPointCaret;
89
+ Lexical.$isTextPointCaretSlice;
90
+ const $isTokenOrSegmented = Lexical.$isTokenOrSegmented;
91
+ Lexical.$isTokenOrTab;
92
+ const $nodesOfType = Lexical.$nodesOfType;
93
+ Lexical.$normalizeCaret;
94
+ Lexical.$normalizeSelection__EXPERIMENTAL;
95
+ Lexical.$onUpdate;
96
+ Lexical.$parseSerializedNode;
97
+ Lexical.$removeTextFromCaretRange;
98
+ Lexical.$rewindSiblingCaret;
99
+ const $selectAll$1 = Lexical.$selectAll;
100
+ Lexical.$setCompositionKey;
101
+ Lexical.$setPointFromCaret;
102
+ const $setSelection = Lexical.$setSelection;
103
+ Lexical.$setSelectionFromCaretRange;
104
+ Lexical.$setState;
105
+ Lexical.$splitAtPointCaretNext;
106
+ Lexical.$splitNode;
107
+ Lexical.$updateRangeSelectionFromCaretRange;
108
+ Lexical.ArtificialNode__DO_NOT_USE;
109
+ Lexical.BEFORE_INPUT_COMMAND;
110
+ Lexical.BLUR_COMMAND;
111
+ Lexical.CAN_REDO_COMMAND;
112
+ Lexical.CAN_UNDO_COMMAND;
113
+ Lexical.CLEAR_EDITOR_COMMAND;
114
+ Lexical.CLEAR_HISTORY_COMMAND;
115
+ Lexical.CLICK_COMMAND;
116
+ const COLLABORATION_TAG = Lexical.COLLABORATION_TAG;
117
+ Lexical.COMMAND_PRIORITY_BEFORE_CRITICAL;
118
+ Lexical.COMMAND_PRIORITY_BEFORE_EDITOR;
119
+ Lexical.COMMAND_PRIORITY_BEFORE_HIGH;
120
+ Lexical.COMMAND_PRIORITY_BEFORE_LOW;
121
+ Lexical.COMMAND_PRIORITY_BEFORE_NORMAL;
122
+ Lexical.COMMAND_PRIORITY_CRITICAL;
123
+ Lexical.COMMAND_PRIORITY_EDITOR;
124
+ Lexical.COMMAND_PRIORITY_HIGH;
125
+ Lexical.COMMAND_PRIORITY_LOW;
126
+ Lexical.COMMAND_PRIORITY_NORMAL;
127
+ Lexical.COMPOSITION_END_COMMAND;
128
+ Lexical.COMPOSITION_END_TAG;
129
+ Lexical.COMPOSITION_START_COMMAND;
130
+ Lexical.COMPOSITION_START_TAG;
131
+ Lexical.CONTROLLED_TEXT_INSERTION_COMMAND;
132
+ Lexical.COPY_COMMAND;
133
+ Lexical.CUT_COMMAND;
134
+ Lexical.DEFAULT_EDITOR_DOM_CONFIG;
135
+ Lexical.DELETE_CHARACTER_COMMAND;
136
+ Lexical.DELETE_LINE_COMMAND;
137
+ Lexical.DELETE_WORD_COMMAND;
138
+ Lexical.DRAGEND_COMMAND;
139
+ Lexical.DRAGOVER_COMMAND;
140
+ Lexical.DRAGSTART_COMMAND;
141
+ Lexical.DROP_COMMAND;
142
+ Lexical.DecoratorNode;
143
+ const ElementNode = Lexical.ElementNode;
144
+ Lexical.FOCUS_COMMAND;
145
+ Lexical.FORMAT_ELEMENT_COMMAND;
146
+ Lexical.FORMAT_TEXT_COMMAND;
147
+ const HISTORIC_TAG = Lexical.HISTORIC_TAG;
148
+ const HISTORY_MERGE_TAG = Lexical.HISTORY_MERGE_TAG;
149
+ Lexical.HISTORY_PUSH_TAG;
150
+ Lexical.INDENT_CONTENT_COMMAND;
151
+ Lexical.INPUT_COMMAND;
152
+ Lexical.INSERT_LINE_BREAK_COMMAND;
153
+ Lexical.INSERT_PARAGRAPH_COMMAND;
154
+ Lexical.INSERT_TAB_COMMAND;
155
+ const INTERNAL_$isBlock = Lexical.INTERNAL_$isBlock;
156
+ Lexical.IS_ALL_FORMATTING;
157
+ Lexical.IS_BOLD;
158
+ Lexical.IS_CODE;
159
+ Lexical.IS_HIGHLIGHT;
160
+ Lexical.IS_ITALIC;
161
+ Lexical.IS_STRIKETHROUGH;
162
+ Lexical.IS_SUBSCRIPT;
163
+ Lexical.IS_SUPERSCRIPT;
164
+ Lexical.IS_UNDERLINE;
165
+ Lexical.KEY_ARROW_DOWN_COMMAND;
166
+ Lexical.KEY_ARROW_LEFT_COMMAND;
167
+ Lexical.KEY_ARROW_RIGHT_COMMAND;
168
+ Lexical.KEY_ARROW_UP_COMMAND;
169
+ Lexical.KEY_BACKSPACE_COMMAND;
170
+ Lexical.KEY_DELETE_COMMAND;
171
+ Lexical.KEY_DOWN_COMMAND;
172
+ Lexical.KEY_ENTER_COMMAND;
173
+ Lexical.KEY_ESCAPE_COMMAND;
174
+ Lexical.KEY_MODIFIER_COMMAND;
175
+ Lexical.KEY_SPACE_COMMAND;
176
+ Lexical.KEY_TAB_COMMAND;
177
+ Lexical.LineBreakNode;
178
+ Lexical.MOVE_TO_END;
179
+ Lexical.MOVE_TO_START;
180
+ Lexical.NODE_STATE_KEY;
181
+ Lexical.OUTDENT_CONTENT_COMMAND;
182
+ Lexical.PASTE_COMMAND;
183
+ Lexical.PASTE_TAG;
184
+ Lexical.ParagraphNode;
185
+ Lexical.REDO_COMMAND;
186
+ Lexical.REMOVE_TEXT_COMMAND;
187
+ const RootNode = Lexical.RootNode;
188
+ Lexical.SELECTION_CHANGE_COMMAND;
189
+ Lexical.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND;
190
+ Lexical.SELECT_ALL_COMMAND;
191
+ Lexical.SKIP_COLLAB_TAG;
192
+ Lexical.SKIP_DOM_SELECTION_TAG;
193
+ const SKIP_SCROLL_INTO_VIEW_TAG = Lexical.SKIP_SCROLL_INTO_VIEW_TAG;
194
+ Lexical.SKIP_SELECTION_FOCUS_TAG;
195
+ Lexical.TEXT_TYPE_TO_FORMAT;
196
+ Lexical.TabNode;
197
+ const TextNode = Lexical.TextNode;
198
+ Lexical.UNDO_COMMAND;
199
+ Lexical.addClassNamesToElement;
200
+ Lexical.buildImportMap;
201
+ Lexical.configExtension;
202
+ const createCommand = Lexical.createCommand;
203
+ const createEditor = Lexical.createEditor;
204
+ Lexical.createSharedNodeState;
205
+ const createState = Lexical.createState;
206
+ Lexical.declarePeerDependency;
207
+ Lexical.defineExtension;
208
+ Lexical.flipDirection;
209
+ Lexical.getDOMOwnerDocument;
210
+ Lexical.getDOMSelection;
211
+ Lexical.getDOMSelectionFromTarget;
212
+ Lexical.getDOMTextNode;
213
+ Lexical.getEditorPropertyFromDOMNode;
214
+ Lexical.getNearestEditorFromDOMNode;
215
+ Lexical.getRegisteredNode;
216
+ Lexical.getRegisteredNodeOrThrow;
217
+ Lexical.getStaticNodeConfig;
218
+ const getStyleObjectFromCSS$2 = Lexical.getStyleObjectFromCSS;
219
+ Lexical.getTextDirection;
220
+ Lexical.getTransformSetFromKlass;
221
+ Lexical.isBlockDomNode;
222
+ Lexical.isCurrentlyReadOnlyMode;
223
+ Lexical.isDOMDocumentNode;
224
+ Lexical.isDOMNode;
225
+ Lexical.isDOMTextNode;
226
+ Lexical.isDOMUnmanaged;
227
+ Lexical.isDocumentFragment;
228
+ Lexical.isExactShortcutMatch;
229
+ Lexical.isHTMLAnchorElement;
230
+ Lexical.isHTMLElement;
231
+ Lexical.isInlineDomNode;
232
+ Lexical.isLexicalEditor;
233
+ Lexical.isModifierMatch;
234
+ Lexical.isSelectionCapturedInDecoratorInput;
235
+ Lexical.isSelectionWithinEditor;
236
+ Lexical.makeStepwiseIterator;
237
+ Lexical.mergeRegister;
238
+ Lexical.normalizeClassNames;
239
+ Lexical.removeClassNamesFromElement;
240
+ const removeFromParent = Lexical.removeFromParent;
241
+ Lexical.resetRandomKey;
242
+ Lexical.safeCast;
243
+ Lexical.setDOMStyleFromCSS;
244
+ const setDOMStyleObject = Lexical.setDOMStyleObject;
245
+ Lexical.setDOMUnmanaged;
246
+ Lexical.setNodeIndentFromDOM;
247
+ Lexical.shallowMergeConfig;
248
+ Lexical.toggleTextFormatType;
249
+ //#endregion
14
250
  //#region node_modules/lib0/map.js
15
251
  /**
16
252
  * Utility module to work with key-value stores.
@@ -11025,7 +11261,7 @@ var LexicalSelection_dev_exports = /* @__PURE__ */ __exportAll({
11025
11261
  createDOMRange: () => createDOMRange$1,
11026
11262
  createRectsFromDOMRange: () => createRectsFromDOMRange$1,
11027
11263
  getCSSFromStyleObject: () => getCSSFromStyleObject$1,
11028
- getStyleObjectFromCSS: () => getStyleObjectFromCSS$2,
11264
+ getStyleObjectFromCSS: () => getStyleObjectFromCSS$1,
11029
11265
  trimTextContentFromAnchor: () => trimTextContentFromAnchor$1
11030
11266
  });
11031
11267
  /**
@@ -11339,7 +11575,7 @@ const $addNodeStyle$1 = warnOnlyOnce("$addNodeStyle is a deprecated no-op and ca
11339
11575
  */
11340
11576
  function $patchStyle(target, patch) {
11341
11577
  if (!($isRangeSelection(target) ? target.isCollapsed() : $isTextNode(target) || $isElementNode(target))) formatDevErrorMessage$1(`$patchStyle must only be called with a TextNode, ElementNode, or collapsed RangeSelection`);
11342
- const prevStyles = getStyleObjectFromCSS($isRangeSelection(target) ? target.style : $isTextNode(target) ? target.getStyle() : target.getTextStyle());
11578
+ const prevStyles = getStyleObjectFromCSS$2($isRangeSelection(target) ? target.style : $isTextNode(target) ? target.getStyle() : target.getTextStyle());
11343
11579
  const newCSSText = getCSSFromStyleObject$1(Object.entries(patch).reduce((styles, [key, value]) => {
11344
11580
  if (typeof value === "function") styles[key] = value(prevStyles[key], target);
11345
11581
  else if (value === null) delete styles[key];
@@ -11688,7 +11924,7 @@ function $moveCharacter$1(selection, isHoldingShift, isBackward) {
11688
11924
  */
11689
11925
  function $getNodeStyleValueForProperty(node, styleProperty, defaultValue) {
11690
11926
  const css = node.getStyle();
11691
- const styleObject = getStyleObjectFromCSS(css);
11927
+ const styleObject = getStyleObjectFromCSS$2(css);
11692
11928
  if (styleObject !== null) return styleObject[styleProperty] || defaultValue;
11693
11929
  return defaultValue;
11694
11930
  }
@@ -11712,7 +11948,7 @@ function $getSelectionStyleValueForProperty$1(selection, styleProperty, defaultV
11712
11948
  const endOffset = isBackward ? anchor.offset : focus.offset;
11713
11949
  if ($isRangeSelection(selection) && selection.isCollapsed() && selection.style !== "") {
11714
11950
  const css = selection.style;
11715
- const styleObject = getStyleObjectFromCSS(css);
11951
+ const styleObject = getStyleObjectFromCSS$2(css);
11716
11952
  if (styleObject !== null && styleProperty in styleObject) return styleObject[styleProperty];
11717
11953
  }
11718
11954
  for (let i = 0; i < nodes.length; i++) {
@@ -11738,7 +11974,7 @@ function $getSelectionStyleValueForProperty$1(selection, styleProperty, defaultV
11738
11974
  *
11739
11975
  */
11740
11976
  /** @deprecated moved to the `lexical` package */
11741
- const getStyleObjectFromCSS$2 = getStyleObjectFromCSS;
11977
+ const getStyleObjectFromCSS$1 = getStyleObjectFromCSS$2;
11742
11978
  /** @deprecated renamed to {@link $trimTextContentFromAnchor} by @lexical/eslint-plugin rules-of-lexical */
11743
11979
  const trimTextContentFromAnchor$1 = $trimTextContentFromAnchor$1;
11744
11980
  //#endregion
@@ -15193,6 +15429,59 @@ function removePendingUploadNodes(editor) {
15193
15429
  });
15194
15430
  }
15195
15431
  //#endregion
15432
+ //#region src/cursor_theme.js
15433
+ const CURSOR_CSS = `
15434
+ .lexxy-collab-cursor {
15435
+ background-color: var(--lexical-cursor-color);
15436
+ width: 2px;
15437
+ border-radius: 1px;
15438
+ z-index: 10;
15439
+ }
15440
+
15441
+ .lexxy-collab-cursor__name {
15442
+ position: absolute;
15443
+ top: 0;
15444
+ left: -2px;
15445
+ transform: translateY(calc(-100% - 3px));
15446
+ background-color: var(--lexical-cursor-color);
15447
+ color: white;
15448
+ font-family: var(--lexxy-font-base, system-ui, sans-serif);
15449
+ font-size: 0.6875rem;
15450
+ font-weight: 600;
15451
+ line-height: 1;
15452
+ padding: 0.3em 0.7em;
15453
+ border-radius: calc(var(--lexxy-radius, 0.5ch) * 1.5);
15454
+ white-space: nowrap;
15455
+ box-shadow: 0 1px 3px oklch(0% 0 0 / 0.25);
15456
+ z-index: 11;
15457
+ }
15458
+
15459
+ .lexxy-collab-selection {
15460
+ z-index: 5;
15461
+ }
15462
+
15463
+ .lexxy-collab-selection__bg {
15464
+ background-color: var(--lexical-cursor-color);
15465
+ opacity: 0.2;
15466
+ border-radius: 2px;
15467
+ }
15468
+ `;
15469
+ function registerCursorTheme(editor) {
15470
+ const theme = editor._config.theme;
15471
+ if (theme.collaboration) return;
15472
+ theme.collaboration = {
15473
+ cursor: "lexxy-collab-cursor",
15474
+ cursorName: "lexxy-collab-cursor__name",
15475
+ selection: "lexxy-collab-selection",
15476
+ selectionBg: "lexxy-collab-selection__bg"
15477
+ };
15478
+ if (getComputedStyle(document.documentElement).getPropertyValue("--lexxy-realtime-cursor-styles").trim() !== "" || document.getElementById("lexxy-realtime-cursor-styles")) return;
15479
+ const style = document.createElement("style");
15480
+ style.id = "lexxy-realtime-cursor-styles";
15481
+ style.textContent = CURSOR_CSS;
15482
+ document.head.appendChild(style);
15483
+ }
15484
+ //#endregion
15196
15485
  //#region src/editor_collaboration.js
15197
15486
  let sharedConsumer;
15198
15487
  let configuredConsumer;
@@ -15252,6 +15541,7 @@ var Collaboration = class extends HTMLElement {
15252
15541
  patchCollabElementSplice(binding);
15253
15542
  const unsubscribeListeners = registerCollaborationListeners(this.editor, provider, binding);
15254
15543
  const cancelBootstrap = bootstrapWhenSynced(this.editor, provider, binding, initialEditorState);
15544
+ registerCursorTheme(this.editor);
15255
15545
  const cursorsContainer = this.#createCursorsContainer();
15256
15546
  binding.cursorsContainer = cursorsContainer;
15257
15547
  initLocalState(provider, name, color, true, {