@nuasite/cms 0.3.0 → 0.3.1

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/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "directory": "packages/astro-cms"
15
15
  },
16
16
  "license": "Apache-2.0",
17
- "version": "0.3.0",
17
+ "version": "0.3.1",
18
18
  "module": "src/index.ts",
19
19
  "types": "src/index.ts",
20
20
  "type": "module",
@@ -66,7 +66,7 @@ export function BlockEditor({
66
66
  setSelectedComponent(null)
67
67
  setInsertPosition('after')
68
68
  }
69
- }, [visible, componentId])
69
+ }, [visible])
70
70
 
71
71
  useEffect(() => {
72
72
  if (currentInstance) {
@@ -131,7 +131,7 @@ function extractElementBounds(
131
131
  ): ArrayElementBounds[] {
132
132
  const bounds: ArrayElementBounds[] = []
133
133
  for (const el of elements) {
134
- if (el && el.loc) {
134
+ if (el?.loc) {
135
135
  bounds.push({
136
136
  // Babel loc is 1-indexed; convert to 0-indexed file lines
137
137
  startLine: el.loc.start.line - 1 + frontmatterStartLine,
@@ -273,7 +273,7 @@ export async function handleRemoveArrayItem(
273
273
  const freshLines = freshContent.split('\n')
274
274
 
275
275
  const bounds = elementBounds[arrayIndex]!
276
- let removeStart = bounds.startLine
276
+ const removeStart = bounds.startLine
277
277
  let removeEnd = bounds.endLine
278
278
 
279
279
  // Clean up trailing comma on the line after the element, or leading comma
@@ -298,7 +298,7 @@ export async function handleRemoveArrayItem(
298
298
  if (removeStart > 0 && removeStart <= freshLines.length) {
299
299
  const prevLine = freshLines[removeStart - 1]!
300
300
  const nextLine = freshLines[removeStart]
301
- if (nextLine !== undefined && nextLine.trim().startsWith(']') && prevLine.trimEnd().endsWith(',')) {
301
+ if (nextLine?.trim().startsWith(']') && prevLine.trimEnd().endsWith(',')) {
302
302
  freshLines[removeStart - 1] = prevLine.replace(/,\s*$/, '')
303
303
  }
304
304
  }
@@ -397,7 +397,7 @@ export async function handleAddArrayItem(
397
397
  for (let i = freshLines.length - 1; i >= 0; i--) {
398
398
  if (freshLines[i]!.trim().startsWith(']')) {
399
399
  const prev = freshLines[i - 1]
400
- if (prev && prev.trimEnd().endsWith(',')) {
400
+ if (prev?.trimEnd().endsWith(',')) {
401
401
  // Check if this is the array we're editing by scanning backwards
402
402
  // to find the array variable
403
403
  freshLines[i - 1] = prev.replace(/,(\s*)$/, '$1')