@flexiui/svelte-rich-text 0.0.63 → 0.0.64

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.
@@ -56,8 +56,7 @@ export const MediaGridExtension = Node.create({
56
56
  insertGrid: (options) => ({ tr, state, dispatch }) => {
57
57
  const { schema } = state;
58
58
  const cols = options?.cols || 2;
59
- const items = Array.from({ length: cols }, () => schema.nodes.gridItem.create() // 👈 sin contenido
60
- );
59
+ const items = Array.from({ length: cols }, () => schema.nodes.gridItem.create());
61
60
  const grid = this.type.create({ cols }, items);
62
61
  if (dispatch) {
63
62
  tr.replaceSelectionWith(grid).scrollIntoView();
@@ -84,6 +83,31 @@ export const MediaGridExtension = Node.create({
84
83
  },
85
84
  };
86
85
  },
86
+ addKeyboardShortcuts() {
87
+ return {
88
+ Enter: () => {
89
+ const { state } = this.editor;
90
+ const { $from } = state.selection;
91
+ let gridPos = null;
92
+ let gridNode = null;
93
+ for (let depth = $from.depth; depth > 0; depth--) {
94
+ if ($from.node(depth).type === this.type) {
95
+ gridPos = $from.before(depth);
96
+ gridNode = $from.node(depth);
97
+ break;
98
+ }
99
+ }
100
+ if (gridPos === null || !gridNode)
101
+ return false;
102
+ const insertPos = gridPos + gridNode.nodeSize;
103
+ this.editor.chain()
104
+ .insertContentAt(insertPos, { type: 'paragraph' })
105
+ .setTextSelection(insertPos + 1)
106
+ .run();
107
+ return true;
108
+ },
109
+ };
110
+ },
87
111
  addNodeView() {
88
112
  return SvelteNodeViewRenderer(MediaGridComponent);
89
113
  },
@@ -37,7 +37,7 @@ export function getRichTextExtensions(options) {
37
37
  // fontSize: false
38
38
  }),
39
39
  StarterKit.configure({
40
- trailingNode: trailingNode ? undefined : false,
40
+ ...(!trailingNode && { trailingNode: false }),
41
41
  link: false,
42
42
  bulletList: false,
43
43
  listItem: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flexiui/svelte-rich-text",
3
- "version": "0.0.63",
3
+ "version": "0.0.64",
4
4
  "description": "A lightweight and flexible rich text editor component for Svelte",
5
5
  "keywords": [
6
6
  "svelte",