@jvs-milkdown/crepe 1.2.7 → 1.2.9

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.
Files changed (32) hide show
  1. package/lib/cjs/builder.js.map +1 -1
  2. package/lib/cjs/feature/block-edit/index.js.map +1 -1
  3. package/lib/cjs/feature/code-mirror/index.js.map +1 -1
  4. package/lib/cjs/feature/cursor/index.js.map +1 -1
  5. package/lib/cjs/feature/image-block/index.js.map +1 -1
  6. package/lib/cjs/feature/latex/index.js.map +1 -1
  7. package/lib/cjs/feature/link-tooltip/index.js.map +1 -1
  8. package/lib/cjs/feature/list-item/index.js.map +1 -1
  9. package/lib/cjs/feature/placeholder/index.js.map +1 -1
  10. package/lib/cjs/feature/table/index.js.map +1 -1
  11. package/lib/cjs/feature/toolbar/index.js.map +1 -1
  12. package/lib/cjs/index.js +47 -30
  13. package/lib/cjs/index.js.map +1 -1
  14. package/lib/esm/builder.js.map +1 -1
  15. package/lib/esm/feature/block-edit/index.js.map +1 -1
  16. package/lib/esm/feature/code-mirror/index.js.map +1 -1
  17. package/lib/esm/feature/cursor/index.js.map +1 -1
  18. package/lib/esm/feature/image-block/index.js.map +1 -1
  19. package/lib/esm/feature/latex/index.js.map +1 -1
  20. package/lib/esm/feature/link-tooltip/index.js.map +1 -1
  21. package/lib/esm/feature/list-item/index.js.map +1 -1
  22. package/lib/esm/feature/placeholder/index.js.map +1 -1
  23. package/lib/esm/feature/table/index.js.map +1 -1
  24. package/lib/esm/feature/toolbar/index.js.map +1 -1
  25. package/lib/esm/index.js +47 -30
  26. package/lib/esm/index.js.map +1 -1
  27. package/lib/tsconfig.tsbuildinfo +1 -1
  28. package/lib/types/feature/fixed-toolbar/config.d.ts.map +1 -1
  29. package/package.json +4 -4
  30. package/src/feature/fixed-toolbar/config.ts +32 -29
  31. package/src/feature/fixed-toolbar/document-header.tsx +19 -0
  32. package/src/feature/index.ts +1 -1
package/lib/esm/index.js CHANGED
@@ -69,7 +69,7 @@ const defaultFeatures = {
69
69
  ["block-edit" /* BlockEdit */]: true,
70
70
  ["placeholder" /* Placeholder */]: true,
71
71
  ["toolbar" /* Toolbar */]: true,
72
- ["fixed-toolbar" /* FixedToolbar */]: false,
72
+ ["fixed-toolbar" /* FixedToolbar */]: true,
73
73
  ["code-mirror" /* CodeMirror */]: true,
74
74
  ["table" /* Table */]: true,
75
75
  ["latex" /* Latex */]: true,
@@ -8579,6 +8579,35 @@ function buildDefaultFixedToolbar(builder, _config, ctx) {
8579
8579
  }
8580
8580
  });
8581
8581
  const blockGroup = builder.addGroup("block", "Block");
8582
+ if (isTableEnabled) {
8583
+ blockGroup.addItem("table", {
8584
+ label: ctx ? i18n(ctx, "menu.item.table") : "Table",
8585
+ icon: tableIcon,
8586
+ active: () => false,
8587
+ onRun: (ctx2) => {
8588
+ const commands = ctx2.get(commandsCtx);
8589
+ const view = ctx2.get(editorViewCtx);
8590
+ const { from } = view.state.selection;
8591
+ commands.call(addBlockTypeCommand.key, {
8592
+ nodeType: createTable(ctx2, 3, 3)
8593
+ });
8594
+ commands.call(selectTextNearPosCommand.key, { pos: from });
8595
+ }
8596
+ });
8597
+ }
8598
+ if (isImageBlockEnabled) {
8599
+ blockGroup.addItem("image", {
8600
+ label: ctx ? i18n(ctx, "menu.item.image") : "Image",
8601
+ icon: imageIcon,
8602
+ active: () => false,
8603
+ onRun: (ctx2) => {
8604
+ const commands = ctx2.get(commandsCtx);
8605
+ commands.call(addBlockTypeCommand.key, {
8606
+ nodeType: imageBlockSchema.type(ctx2)
8607
+ });
8608
+ }
8609
+ });
8610
+ }
8582
8611
  blockGroup.addItem("quote", {
8583
8612
  label: ctx ? i18n(ctx, "menu.item.quote") : "Quote",
8584
8613
  icon: quoteIcon,
@@ -8645,19 +8674,6 @@ function buildDefaultFixedToolbar(builder, _config, ctx) {
8645
8674
  commands.call(toggleLinkCommand.key);
8646
8675
  }
8647
8676
  });
8648
- if (isImageBlockEnabled) {
8649
- blockGroup.addItem("image", {
8650
- label: ctx ? i18n(ctx, "menu.item.image") : "Image",
8651
- icon: imageIcon,
8652
- active: () => false,
8653
- onRun: (ctx2) => {
8654
- const commands = ctx2.get(commandsCtx);
8655
- commands.call(addBlockTypeCommand.key, {
8656
- nodeType: imageBlockSchema.type(ctx2)
8657
- });
8658
- }
8659
- });
8660
- }
8661
8677
  if (isAttachmentEnabled) {
8662
8678
  blockGroup.addItem("attachment", {
8663
8679
  label: ctx ? i18n(ctx, "menu.item.attachment") : "Video or File",
@@ -8710,22 +8726,6 @@ function buildDefaultFixedToolbar(builder, _config, ctx) {
8710
8726
  });
8711
8727
  }
8712
8728
  });
8713
- if (isTableEnabled) {
8714
- blockGroup.addItem("table", {
8715
- label: ctx ? i18n(ctx, "menu.item.table") : "Table",
8716
- icon: tableIcon,
8717
- active: () => false,
8718
- onRun: (ctx2) => {
8719
- const commands = ctx2.get(commandsCtx);
8720
- const view = ctx2.get(editorViewCtx);
8721
- const { from } = view.state.selection;
8722
- commands.call(addBlockTypeCommand.key, {
8723
- nodeType: createTable(ctx2, 3, 3)
8724
- });
8725
- commands.call(selectTextNearPosCommand.key, { pos: from });
8726
- }
8727
- });
8728
- }
8729
8729
  if (isLatexEnabled) {
8730
8730
  blockGroup.addItem("math-block", {
8731
8731
  label: ctx ? i18n(ctx, "menu.item.math") : "Math Block",
@@ -9001,6 +9001,23 @@ const DocumentHeader = defineComponent({
9001
9001
  title.value = e.target.value;
9002
9002
  adjustTitleHeight();
9003
9003
  },
9004
+ onKeydown: (e) => {
9005
+ if (e.key !== "Enter") return;
9006
+ e.preventDefault();
9007
+ if (e.ctrlKey || e.metaKey) {
9008
+ const target = e.target;
9009
+ const start = target.selectionStart;
9010
+ const end = target.selectionEnd;
9011
+ title.value = title.value.slice(0, start) + "\n" + title.value.slice(end);
9012
+ requestAnimationFrame(() => {
9013
+ target.selectionStart = target.selectionEnd = start + 1;
9014
+ adjustTitleHeight();
9015
+ });
9016
+ } else {
9017
+ const view = props.ctx.get(editorViewCtx);
9018
+ view == null ? void 0 : view.focus();
9019
+ }
9020
+ },
9004
9021
  rows: 1,
9005
9022
  style: {
9006
9023
  width: "100%",