Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gaoding/editor-sdk

Package Overview
Dependencies
Maintainers
22
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gaoding/editor-sdk - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

src/utils.ts

102

dist/editor-sdk.cjs.js

@@ -360,3 +360,3 @@ "use strict";

};
function createIframe(url, query, onClose) {
function createIframe(url, query, onClose, hide = false) {
const frame = document.createElement("iframe");

@@ -381,2 +381,5 @@ frame.style.cssText = `

`;
if (hide) {
wrapper.style.visibility = "hidden";
}
const btn = document.createElement("div");

@@ -416,3 +419,4 @@ btn.style.cssText = `

const mask = document.createElement("div");
mask.style.cssText = `
if (!hide) {
mask.style.cssText = `
position: fixed;

@@ -424,8 +428,16 @@ inset: 0px;

`;
}
let isOpen = false;
let overflowValue = "";
function toggleScrollSwitch() {
if (hide)
return;
const dom = document.querySelector(".gaoding-editor-iframe-dialog");
if (!dom)
return;
{
document.documentElement.style.overflow = "";
if (isOpen) {
overflowValue = document.documentElement.style.overflow;
document.documentElement.style.overflow = "hidden";
} else {
document.documentElement.style.overflow = overflowValue;
}

@@ -435,2 +447,3 @@ }

var _a, _b;
isOpen = false;
toggleScrollSwitch();

@@ -443,2 +456,3 @@ if (onClose)

function open() {
isOpen = true;
document.body.appendChild(mask);

@@ -664,4 +678,82 @@ document.body.appendChild(modal);

}
async function koutu(file) {
const { open, close, iframe } = createIframe(`${env.KOUTU_EDITOR_URL}`, { app_id: c.appId, version: c.version || "KE001" }, void 0, true);
iframe.style.display = "none";
const child = connectToChild({
iframe,
methods: {
async onload() {
const service2 = await child.promise;
service2.init({ version: isKE002Config(c) ? c.version : "KE001", appId: c.appId });
},
async getUseRightToken(info) {
try {
const token = isKE002Config(c) ? await c.getUseRightToken(info) : true;
if (token instanceof Error) {
return {
message: token.message
};
}
return token;
} catch (error) {
return { message: error.message };
}
},
async getUserCode() {
return isKE002Config(c) ? c.getUserCode() : false;
}
}
});
open();
const service = await child.promise;
const res = await service.exportFile(file);
close();
child.destroy();
if (res.message) {
throw new Error(res.message);
}
return res;
}
async function openWork(id2) {
return new Promise(async (resolve) => {
const { open, close, iframe } = createIframe(`${env.KOUTU_EDITOR_URL}`, { app_id: c.appId, version: c.version || "KE001" }, () => resolve(false));
const child = connectToChild({
iframe,
methods: {
async onload() {
const service2 = await child.promise;
service2.init({ version: isKE002Config(c) ? c.version : "KE001", appId: c.appId });
},
async getUseRightToken(info) {
try {
const token = isKE002Config(c) ? await c.getUseRightToken(info) : true;
if (token instanceof Error) {
return {
message: token.message
};
}
return token;
} catch (error) {
return { message: error.message };
}
},
async getUserCode() {
return isKE002Config(c) ? c.getUserCode() : false;
},
download(info) {
resolve(info);
close();
child.destroy();
}
}
});
open();
const service = await child.promise;
service.openWork(id2);
});
}
return {
importFile
importFile,
openWork,
koutu
};

@@ -668,0 +760,0 @@ }

@@ -357,3 +357,3 @@ var __defProp = Object.defineProperty;

};
function createIframe(url, query, onClose) {
function createIframe(url, query, onClose, hide = false) {
const frame = document.createElement("iframe");

@@ -378,2 +378,5 @@ frame.style.cssText = `

`;
if (hide) {
wrapper.style.visibility = "hidden";
}
const btn = document.createElement("div");

@@ -413,3 +416,4 @@ btn.style.cssText = `

const mask = document.createElement("div");
mask.style.cssText = `
if (!hide) {
mask.style.cssText = `
position: fixed;

@@ -421,8 +425,16 @@ inset: 0px;

`;
}
let isOpen = false;
let overflowValue = "";
function toggleScrollSwitch() {
if (hide)
return;
const dom = document.querySelector(".gaoding-editor-iframe-dialog");
if (!dom)
return;
{
document.documentElement.style.overflow = "";
if (isOpen) {
overflowValue = document.documentElement.style.overflow;
document.documentElement.style.overflow = "hidden";
} else {
document.documentElement.style.overflow = overflowValue;
}

@@ -432,2 +444,3 @@ }

var _a, _b;
isOpen = false;
toggleScrollSwitch();

@@ -440,2 +453,3 @@ if (onClose)

function open() {
isOpen = true;
document.body.appendChild(mask);

@@ -661,4 +675,82 @@ document.body.appendChild(modal);

}
async function koutu(file) {
const { open, close, iframe } = createIframe(`${env.KOUTU_EDITOR_URL}`, { app_id: c.appId, version: c.version || "KE001" }, void 0, true);
iframe.style.display = "none";
const child = connectToChild({
iframe,
methods: {
async onload() {
const service2 = await child.promise;
service2.init({ version: isKE002Config(c) ? c.version : "KE001", appId: c.appId });
},
async getUseRightToken(info) {
try {
const token = isKE002Config(c) ? await c.getUseRightToken(info) : true;
if (token instanceof Error) {
return {
message: token.message
};
}
return token;
} catch (error) {
return { message: error.message };
}
},
async getUserCode() {
return isKE002Config(c) ? c.getUserCode() : false;
}
}
});
open();
const service = await child.promise;
const res = await service.exportFile(file);
close();
child.destroy();
if (res.message) {
throw new Error(res.message);
}
return res;
}
async function openWork(id2) {
return new Promise(async (resolve) => {
const { open, close, iframe } = createIframe(`${env.KOUTU_EDITOR_URL}`, { app_id: c.appId, version: c.version || "KE001" }, () => resolve(false));
const child = connectToChild({
iframe,
methods: {
async onload() {
const service2 = await child.promise;
service2.init({ version: isKE002Config(c) ? c.version : "KE001", appId: c.appId });
},
async getUseRightToken(info) {
try {
const token = isKE002Config(c) ? await c.getUseRightToken(info) : true;
if (token instanceof Error) {
return {
message: token.message
};
}
return token;
} catch (error) {
return { message: error.message };
}
},
async getUserCode() {
return isKE002Config(c) ? c.getUserCode() : false;
},
download(info) {
resolve(info);
close();
child.destroy();
}
}
});
open();
const service = await child.promise;
service.openWork(id2);
});
}
return {
importFile
importFile,
openWork,
koutu
};

@@ -665,0 +757,0 @@ }

4

package.json
{
"name": "@gaoding/editor-sdk",
"description": "稿定编辑器对外 SDK",
"version": "1.0.0",
"version": "1.0.1",
"scripts": {

@@ -28,3 +28,3 @@ "build": "vite build",

},
"gitHead": "1cb9dcf4ef4fe1c4cbb3f0e63c96e915bb0a1f64"
"gitHead": "76bf62e8c2e1d56897fe7bed3211719c71745d13"
}

@@ -5,5 +5,5 @@ import { createIframe, connectToChild } from './iframe';

import { ImageEditorMethods, ImageEditorService } from './type';
import { transformFile } from './utils';
interface Config {

@@ -42,3 +42,3 @@ // 应用ID, 在控制台应用详情查看

async function importFile(file: (string | Blob)[]) {
async function importFile(file: (File | Blob | string)[]) {
return new Promise<{ files: Blob[]; urls: string[] } | false>(async resolve => {

@@ -74,4 +74,4 @@ const { open, close, iframe } = createIframe(`${env.IMAGE_EDITOR_URL}`, { app_id: c.appId, version: c.version || 'IE001' }, () => resolve(false));

const service = await child.promise;
service.importFile(file);
const data = await Promise.all(file.map(async f => typeof f === 'string' ? f : await transformFile(f)));
service.importFile(data);
});

@@ -78,0 +78,0 @@ }

@@ -5,2 +5,3 @@ import { createIframe, connectToChild } from './iframe';

import { KoutuEditorMethods, KoutuEditorService } from './type';
import { transformFile } from './utils';

@@ -38,3 +39,3 @@

async function importFile(file: string | Blob) {
async function importFile(file: string | Blob | File) {
return new Promise<{ files: Blob[]; urls: string[] } | false>(async resolve => {

@@ -74,3 +75,4 @@ const { open, close, iframe } = createIframe(`${env.KOUTU_EDITOR_URL}`, { app_id: c.appId, version: c.version || 'KE001' }, () => resolve(false));

const service = await child.promise;
service.importFile(file);
const data = typeof file === 'string' ? file : await transformFile(file);
service.importFile(data);
});

@@ -77,0 +79,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc