@flexiui/svelte-rich-text 0.0.62 → 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.
@@ -91,9 +91,10 @@
91
91
  docTextColor?: string;
92
92
  buttonStyle?: "accent-soft" | "accent-solid";
93
93
  };
94
- contentWrapperAs?: T;
95
- inlineNodeMode?: boolean;
96
- }
94
+ contentWrapperAs?: T;
95
+ inlineNodeMode?: boolean;
96
+ trailingNode?: boolean;
97
+ }
97
98
 
98
99
  type ToolbarButton =
99
100
  | string
@@ -147,9 +148,10 @@
147
148
  onPaste: () => {},
148
149
  },
149
150
  config,
150
- contentWrapperAs = "div" as T,
151
- inlineNodeMode = false,
152
- }: Props = $props();
151
+ contentWrapperAs = "div" as T,
152
+ inlineNodeMode = false,
153
+ trailingNode = true,
154
+ }: Props = $props();
153
155
 
154
156
  let editor = $state() as Readable<Editor>;
155
157
 
@@ -276,9 +278,10 @@
276
278
  "rgb(255, 102, 142)",
277
279
  ];
278
280
 
279
- const extensions = getRichTextExtensions({
280
- editable: true,
281
- customExtensions: [
281
+ const extensions = getRichTextExtensions({
282
+ editable: true,
283
+ trailingNode,
284
+ customExtensions: [
282
285
  Mathematics.configure({
283
286
  inlineOptions: {
284
287
  onClick: (node, pos) => {
@@ -712,7 +715,7 @@
712
715
  </header>
713
716
  {/if}
714
717
 
715
- <EditorContent as={contentWrapperAs} editor={$editor} class="fl-rich-text-content a" data-fl-editable="true" />
718
+ <EditorContent as={contentWrapperAs} editor={$editor} class="fl-rich-text-content" data-fl-editable="true" />
716
719
 
717
720
  <!-- Warning message for node limit -->
718
721
  {#if showLimitWarning && nodesLimit}
@@ -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
  },
@@ -7,5 +7,6 @@ declare module '@tiptap/core' {
7
7
  }
8
8
  export declare function getRichTextExtensions(options?: {
9
9
  editable?: boolean;
10
+ trailingNode?: boolean;
10
11
  customExtensions?: any[];
11
12
  }): any[];
@@ -28,7 +28,7 @@ const DocHeading = Heading.extend({
28
28
  },
29
29
  }).configure({ levels: [1] });
30
30
  export function getRichTextExtensions(options) {
31
- const { editable = false, customExtensions = [] } = options ?? {};
31
+ const { editable = false, trailingNode = true, customExtensions = [] } = options ?? {};
32
32
  return [
33
33
  DocHeading,
34
34
  Heading.configure({ levels: [2, 3, 4, 5, 6] }),
@@ -37,7 +37,7 @@ export function getRichTextExtensions(options) {
37
37
  // fontSize: false
38
38
  }),
39
39
  StarterKit.configure({
40
- trailingNode: false,
40
+ ...(!trailingNode && { trailingNode: false }),
41
41
  link: false,
42
42
  bulletList: false,
43
43
  listItem: false,
package/dist/styles.css CHANGED
@@ -127,7 +127,8 @@
127
127
  display: flex;
128
128
  gap: 5px;
129
129
  position: relative;
130
- z-index: 9;
130
+ z-index: var(--fl-toolbar-sticky-position, 10);
131
+
131
132
 
132
133
  .fl-bubble-menu-mark-button {
133
134
  border-radius: 9px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flexiui/svelte-rich-text",
3
- "version": "0.0.62",
3
+ "version": "0.0.64",
4
4
  "description": "A lightweight and flexible rich text editor component for Svelte",
5
5
  "keywords": [
6
6
  "svelte",