autoblogger 0.2.27 → 0.2.29

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/dist/ui.js CHANGED
@@ -1031,6 +1031,9 @@ function getAttributesFromExtensions(extensions) {
1031
1031
  keepOnSplit: true,
1032
1032
  isRequired: false
1033
1033
  };
1034
+ const nodeExtensionTypes = nodeExtensions.filter((ext) => ext.name !== "text").map((ext) => ext.name);
1035
+ const markExtensionTypes = markExtensions.map((ext) => ext.name);
1036
+ const allExtensionTypes = [...nodeExtensionTypes, ...markExtensionTypes];
1034
1037
  extensions.forEach((extension) => {
1035
1038
  const context = {
1036
1039
  name: extension.name,
@@ -1048,7 +1051,19 @@ function getAttributesFromExtensions(extensions) {
1048
1051
  }
1049
1052
  const globalAttributes = addGlobalAttributes();
1050
1053
  globalAttributes.forEach((globalAttribute) => {
1051
- globalAttribute.types.forEach((type) => {
1054
+ let resolvedTypes;
1055
+ if (Array.isArray(globalAttribute.types)) {
1056
+ resolvedTypes = globalAttribute.types;
1057
+ } else if (globalAttribute.types === "*") {
1058
+ resolvedTypes = allExtensionTypes;
1059
+ } else if (globalAttribute.types === "nodes") {
1060
+ resolvedTypes = nodeExtensionTypes;
1061
+ } else if (globalAttribute.types === "marks") {
1062
+ resolvedTypes = markExtensionTypes;
1063
+ } else {
1064
+ resolvedTypes = [];
1065
+ }
1066
+ resolvedTypes.forEach((type) => {
1052
1067
  Object.entries(globalAttribute.attributes).forEach(([name, attribute]) => {
1053
1068
  extensionAttributes.push({
1054
1069
  type,
@@ -1484,6 +1499,9 @@ function isMarkActive(state, typeOrName, attributes = {}) {
1484
1499
  const from = $from.pos;
1485
1500
  const to = $to.pos;
1486
1501
  state.doc.nodesBetween(from, to, (node, pos) => {
1502
+ if (type && node.inlineContent && !node.type.allowsMarkType(type)) {
1503
+ return false;
1504
+ }
1487
1505
  if (!node.isText && !node.marks.length) {
1488
1506
  return;
1489
1507
  }
@@ -3050,8 +3068,12 @@ var init_dist = __esm({
3050
3068
  }
3051
3069
  });
3052
3070
  };
3053
- if (view.hasFocus() && position === null || position === false) {
3054
- return true;
3071
+ try {
3072
+ if (view.hasFocus() && position === null || position === false) {
3073
+ return true;
3074
+ }
3075
+ } catch {
3076
+ return false;
3055
3077
  }
3056
3078
  if (dispatch && position === null && !isTextSelection(editor.state.selection)) {
3057
3079
  delayedFocus();
@@ -4327,6 +4349,39 @@ var init_dist = __esm({
4327
4349
  };
4328
4350
  }, baseDispatch);
4329
4351
  }
4352
+ /**
4353
+ * Get the composed transformPastedHTML function from all extensions.
4354
+ * @param baseTransform The base transform function (e.g. from the editor props)
4355
+ * @returns A composed transform function that chains all extension transforms
4356
+ */
4357
+ transformPastedHTML(baseTransform) {
4358
+ const { editor } = this;
4359
+ const extensions = sortExtensions([...this.extensions]);
4360
+ return extensions.reduce(
4361
+ (transform, extension) => {
4362
+ const context = {
4363
+ name: extension.name,
4364
+ options: extension.options,
4365
+ storage: this.editor.extensionStorage[extension.name],
4366
+ editor,
4367
+ type: getSchemaTypeByName(extension.name, this.schema)
4368
+ };
4369
+ const extensionTransform = getExtensionField(
4370
+ extension,
4371
+ "transformPastedHTML",
4372
+ context
4373
+ );
4374
+ if (!extensionTransform) {
4375
+ return transform;
4376
+ }
4377
+ return (html, view) => {
4378
+ const transformedHtml = transform(html, view);
4379
+ return extensionTransform.call(context, transformedHtml);
4380
+ };
4381
+ },
4382
+ baseTransform || ((html) => html)
4383
+ );
4384
+ }
4330
4385
  get markViews() {
4331
4386
  const { editor } = this;
4332
4387
  const { markExtensions } = splitExtensions(this.extensions);
@@ -5482,11 +5537,13 @@ var init_dist2 = __esm({
5482
5537
  });
5483
5538
 
5484
5539
  // node_modules/@tiptap/extension-paragraph/dist/index.js
5485
- var Paragraph, index_default2;
5540
+ var EMPTY_PARAGRAPH_MARKDOWN, NBSP_CHAR, Paragraph, index_default2;
5486
5541
  var init_dist3 = __esm({
5487
5542
  "node_modules/@tiptap/extension-paragraph/dist/index.js"() {
5488
5543
  "use strict";
5489
5544
  init_dist();
5545
+ EMPTY_PARAGRAPH_MARKDOWN = " ";
5546
+ NBSP_CHAR = "\xA0";
5490
5547
  Paragraph = Node3.create({
5491
5548
  name: "paragraph",
5492
5549
  priority: 1e3,
@@ -5508,18 +5565,21 @@ var init_dist3 = __esm({
5508
5565
  if (tokens.length === 1 && tokens[0].type === "image") {
5509
5566
  return helpers.parseChildren([tokens[0]]);
5510
5567
  }
5511
- return helpers.createNode(
5512
- "paragraph",
5513
- void 0,
5514
- // no attributes for paragraph
5515
- helpers.parseInline(tokens)
5516
- );
5568
+ const content = helpers.parseInline(tokens);
5569
+ if (content.length === 1 && content[0].type === "text" && (content[0].text === EMPTY_PARAGRAPH_MARKDOWN || content[0].text === NBSP_CHAR)) {
5570
+ return helpers.createNode("paragraph", void 0, []);
5571
+ }
5572
+ return helpers.createNode("paragraph", void 0, content);
5517
5573
  },
5518
5574
  renderMarkdown: (node, h2) => {
5519
- if (!node || !Array.isArray(node.content)) {
5575
+ if (!node) {
5520
5576
  return "";
5521
5577
  }
5522
- return h2.renderChildren(node.content);
5578
+ const content = Array.isArray(node.content) ? node.content : [];
5579
+ if (content.length === 0) {
5580
+ return EMPTY_PARAGRAPH_MARKDOWN;
5581
+ }
5582
+ return h2.renderChildren(content);
5523
5583
  },
5524
5584
  addCommands() {
5525
5585
  return {
@@ -5832,11 +5892,13 @@ var init_dist4 = __esm({
5832
5892
  node,
5833
5893
  h2,
5834
5894
  (context) => {
5895
+ var _a, _b;
5835
5896
  if (context.parentType === "bulletList") {
5836
5897
  return "- ";
5837
5898
  }
5838
5899
  if (context.parentType === "orderedList") {
5839
- return `${context.index + 1}. `;
5900
+ const start = ((_b = (_a = context.meta) == null ? void 0 : _a.parentAttrs) == null ? void 0 : _b.start) || 1;
5901
+ return `${start + context.index}. `;
5840
5902
  }
5841
5903
  return "- ";
5842
5904
  },
@@ -14185,20 +14247,7 @@ function AutobloggerDashboard({
14185
14247
  }) {
14186
14248
  const resolvedChatApiPath = chatApiPath || `${apiBasePath}/ai/chat`;
14187
14249
  const resolvedHistoryApiPath = historyApiPath || `${apiBasePath}/chat/history`;
14188
- (0, import_react35.useEffect)(() => {
14189
- const viewportMeta = document.querySelector('meta[name="viewport"]');
14190
- if (viewportMeta) {
14191
- const originalContent = viewportMeta.getAttribute("content") || "";
14192
- if (!originalContent.includes("user-scalable")) {
14193
- const newContent = originalContent + ", user-scalable=no, maximum-scale=1";
14194
- viewportMeta.setAttribute("content", newContent);
14195
- return () => {
14196
- viewportMeta.setAttribute("content", originalContent);
14197
- };
14198
- }
14199
- }
14200
- }, []);
14201
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ThemeProvider, { className: "h-dvh bg-background text-foreground flex flex-col overscroll-none touch-manipulation", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
14250
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ThemeProvider, { className: "h-dvh bg-background text-foreground flex flex-col overscroll-none", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
14202
14251
  ChatProvider,
14203
14252
  {
14204
14253
  apiBasePath,