Skip to content

Commit

Permalink
fix: wysiwyg editor
Browse files Browse the repository at this point in the history
  • Loading branch information
hayedewit committed Oct 20, 2023
1 parent 4848d9f commit 1109d14
Show file tree
Hide file tree
Showing 6 changed files with 1,651 additions and 693 deletions.
5 changes: 4 additions & 1 deletion config/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default ({ env }) => {
config: {
environment: 'test',
pageBuilder: {
enabled: true
enabled: false
},
domains: {
default: {
Expand All @@ -16,6 +16,9 @@ export default ({ env }) => {
}
}
},
tiptap: {
enabled: true
},
graphql: {
enabled: true,
config: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@strapi/plugin-i18n": "4.14.3",
"@strapi/plugin-users-permissions": "4.14.3",
"@strapi/strapi": "4.14.3",
"@webbio/strapi-plugin-tiptap": "^0.0.8",
"better-sqlite3": "9.0.0",
"mysql": "^2.18.1"
},
Expand Down
12 changes: 12 additions & 0 deletions src/api/page/content-types/page/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@
"type": "relation",
"relation": "oneToOne",
"target": "api::platform.platform"
},
"schwanz": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "customField",
"options": {
"preset": "rich"
},
"customField": "plugin::tiptap.tiptap"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,23 +245,17 @@ const updateSourceEntities = async (uid: Common.UID.ContentType, id: any, saniti
// Update internal links for wysiwyg internal links
const internalLinksFromWysiwyg = await getInternalLinksFromWysiwygFields(sanitizedEntity, uid, id);

console.log(internalLinksFromWysiwyg);

// Delete links
await deleteManyInternalLinksBySource(uid, id, true);
// Insert links
const createdInternalLinksFromWysiwyg = await createManyInternalLinks(uid, id, internalLinksFromWysiwyg, true);

console.log(createdInternalLinksFromWysiwyg);

// Update entity
const updatedEntityWysiwyg = mapInternalLinksWysiwygToEntity(sanitizedEntity, createdInternalLinksFromWysiwyg);

// Update internal links for normal internal links
const internalLinksFromNormal = await getInternalLinksFromCustomFields(sanitizedEntity, uid, id);

console.log(internalLinksFromNormal);

// Delete links
await deleteManyInternalLinksBySource(uid, id, false);
// Insert links
Expand Down Expand Up @@ -318,7 +312,6 @@ const updateInternalLinksFromTargetContentType = async (
const uid = internalLinks[0]?.sourceContentTypeUid;
const id = internalLinks[0]?.sourceContentTypeId;
const entity: any = await getPopulatedEntity(uid, id);
console.log('entity', entity);
const sanitizedEntity = await sanitizeEntity(entity, uid);
const updatedEntity = mapInternalLinksWysiwygToEntity(sanitizedEntity, internalLinks);
await strapi.entityService.update(uid, id, {
Expand Down
12 changes: 12 additions & 0 deletions types/generated/contentTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,18 @@ export interface ApiPagePage extends Schema.CollectionType {
};
}>;
platform: Attribute.Relation<'api::page.page', 'oneToOne', 'api::platform.platform'>;
schwanz: Attribute.RichText &
Attribute.CustomField<
'plugin::tiptap.tiptap',
{
preset: 'rich';
}
> &
Attribute.SetPluginOptions<{
i18n: {
localized: true;
};
}>;
createdAt: Attribute.DateTime;
updatedAt: Attribute.DateTime;
publishedAt: Attribute.DateTime;
Expand Down
Loading

0 comments on commit 1109d14

Please sign in to comment.